22 #if FW_SERIALIZABLE_TO_STRING || BUILD_UT
24 void Serializable::toString(
StringBase& text)
const {
31 std::ostream& operator<<(std::ostream& os,
const Serializable& val) {
42 m_serLoc(0), m_deserLoc(0) {
49 this->m_serLoc = src.m_serLoc;
50 this->m_deserLoc = src.m_deserLoc;
73 this->m_serLoc +=
sizeof(val);
84 this->
getBuffAddr()[this->m_serLoc + 0] =
static_cast<U8>(val);
85 this->m_serLoc +=
sizeof(val);
97 this->
getBuffAddr()[this->m_serLoc + 0] =
static_cast<U8>(val >> 8);
98 this->
getBuffAddr()[this->m_serLoc + 1] =
static_cast<U8>(val);
99 this->m_serLoc +=
sizeof(val);
100 this->m_deserLoc = 0;
110 this->
getBuffAddr()[this->m_serLoc + 0] =
static_cast<U8>(val >> 8);
111 this->
getBuffAddr()[this->m_serLoc + 1] =
static_cast<U8>(val);
112 this->m_serLoc +=
sizeof(val);
113 this->m_deserLoc = 0;
124 this->
getBuffAddr()[this->m_serLoc + 0] =
static_cast<U8>(val >> 24);
125 this->
getBuffAddr()[this->m_serLoc + 1] =
static_cast<U8>(val >> 16);
126 this->
getBuffAddr()[this->m_serLoc + 2] =
static_cast<U8>(val >> 8);
127 this->
getBuffAddr()[this->m_serLoc + 3] =
static_cast<U8>(val);
128 this->m_serLoc +=
sizeof(val);
129 this->m_deserLoc = 0;
139 this->
getBuffAddr()[this->m_serLoc + 0] =
static_cast<U8>(val >> 24);
140 this->
getBuffAddr()[this->m_serLoc + 1] =
static_cast<U8>(val >> 16);
141 this->
getBuffAddr()[this->m_serLoc + 2] =
static_cast<U8>(val >> 8);
142 this->
getBuffAddr()[this->m_serLoc + 3] =
static_cast<U8>(val);
143 this->m_serLoc +=
sizeof(val);
144 this->m_deserLoc = 0;
156 this->
getBuffAddr()[this->m_serLoc + 0] =
static_cast<U8>(val >> 56);
157 this->
getBuffAddr()[this->m_serLoc + 1] =
static_cast<U8>(val >> 48);
158 this->
getBuffAddr()[this->m_serLoc + 2] =
static_cast<U8>(val >> 40);
159 this->
getBuffAddr()[this->m_serLoc + 3] =
static_cast<U8>(val >> 32);
160 this->
getBuffAddr()[this->m_serLoc + 4] =
static_cast<U8>(val >> 24);
161 this->
getBuffAddr()[this->m_serLoc + 5] =
static_cast<U8>(val >> 16);
162 this->
getBuffAddr()[this->m_serLoc + 6] =
static_cast<U8>(val >> 8);
163 this->
getBuffAddr()[this->m_serLoc + 7] =
static_cast<U8>(val);
164 this->m_serLoc +=
sizeof(val);
165 this->m_deserLoc = 0;
175 this->
getBuffAddr()[this->m_serLoc + 0] =
static_cast<U8>(val >> 56);
176 this->
getBuffAddr()[this->m_serLoc + 1] =
static_cast<U8>(val >> 48);
177 this->
getBuffAddr()[this->m_serLoc + 2] =
static_cast<U8>(val >> 40);
178 this->
getBuffAddr()[this->m_serLoc + 3] =
static_cast<U8>(val >> 32);
179 this->
getBuffAddr()[this->m_serLoc + 4] =
static_cast<U8>(val >> 24);
180 this->
getBuffAddr()[this->m_serLoc + 5] =
static_cast<U8>(val >> 16);
181 this->
getBuffAddr()[this->m_serLoc + 6] =
static_cast<U8>(val >> 8);
182 this->
getBuffAddr()[this->m_serLoc + 7] =
static_cast<U8>(val);
183 this->m_serLoc +=
sizeof(val);
184 this->m_deserLoc = 0;
194 (void) memcpy(&u64Val, &val,
sizeof(val));
205 (void) memcpy(&u32Val, &val,
sizeof(val));
222 this->m_serLoc +=
sizeof(
U8);
223 this->m_deserLoc = 0;
233 return this->
serialize((POINTER_CAST) val);
253 (void) memcpy(&this->
getBuffAddr()[this->m_serLoc], buff, length);
254 this->m_serLoc += length;
255 this->m_deserLoc = 0;
282 this->m_serLoc += size;
283 this->m_deserLoc = 0;
300 this->m_deserLoc +=
sizeof(val);
314 this->m_deserLoc +=
sizeof(val);
329 val = (U16) (this->
getBuffAddr()[this->m_deserLoc + 1] << 0)
330 | (U16) (this->
getBuffAddr()[this->m_deserLoc + 0] << 8);
331 this->m_deserLoc +=
sizeof(val);
345 val = (I16) (this->
getBuffAddr()[this->m_deserLoc + 1] << 0)
346 | (I16) (this->
getBuffAddr()[this->m_deserLoc + 0] << 8);
347 this->m_deserLoc +=
sizeof(val);
362 val = ((U32) this->
getBuffAddr()[this->m_deserLoc + 3] << 0)
363 | ((U32) this->
getBuffAddr()[this->m_deserLoc + 2] << 8)
364 | ((U32) this->
getBuffAddr()[this->m_deserLoc + 1] << 16)
365 | ((U32) this->
getBuffAddr()[this->m_deserLoc + 0] << 24);
366 this->m_deserLoc +=
sizeof(val);
380 val = ((U32) this->
getBuffAddr()[this->m_deserLoc + 3] << 0)
381 | ((U32) this->
getBuffAddr()[this->m_deserLoc + 2] << 8)
382 | ((U32) this->
getBuffAddr()[this->m_deserLoc + 1] << 16)
383 | ((U32) this->
getBuffAddr()[this->m_deserLoc + 0] << 24);
384 this->m_deserLoc +=
sizeof(val);
410 this->m_deserLoc +=
sizeof(val);
424 val = ((I64) this->
getBuffAddr()[this->m_deserLoc + 7] << 0)
425 | ((I64) this->
getBuffAddr()[this->m_deserLoc + 6] << 8)
426 | ((I64) this->
getBuffAddr()[this->m_deserLoc + 5] << 16)
427 | ((I64) this->
getBuffAddr()[this->m_deserLoc + 4] << 24)
428 | ((I64) this->
getBuffAddr()[this->m_deserLoc + 3] << 32)
429 | ((I64) this->
getBuffAddr()[this->m_deserLoc + 2] << 40)
430 | ((I64) this->
getBuffAddr()[this->m_deserLoc + 1] << 48)
431 | ((I64) this->
getBuffAddr()[this->m_deserLoc + 0] << 56);
432 this->m_deserLoc +=
sizeof(val);
472 this->m_deserLoc +=
sizeof(
U8);
487 (void) memcpy(&val, &tempVal,
sizeof(val));
506 if ((storedLength > this->
getBuffLeft()) or (storedLength > length)) {
510 (void) memcpy(buff, &this->
getBuffAddr()[this->m_deserLoc], storedLength);
520 (void) memcpy(buff, &this->
getBuffAddr()[this->m_deserLoc], length);
523 this->m_deserLoc += length;
560 this->m_deserLoc += storedLength;
566 this->m_deserLoc = 0;
571 this->m_deserLoc = 0;
579 }
else if (this->
getBuffLength() - this->m_deserLoc < numBytesToSkip) {
583 this->m_deserLoc += numBytesToSkip;
588 return this->m_serLoc;
598 this->m_serLoc = length;
599 this->m_deserLoc = 0;
608 this->m_serLoc = length;
609 this->m_deserLoc = 0;
615 return this->m_serLoc - this->m_deserLoc;
626 this->m_deserLoc += size;
645 this->m_deserLoc += size;
675 if (us[
byte] != them[
byte]) {
683 std::ostream& operator<<(std::ostream& os,
const SerializeBufferBase& buff) {
685 const U8* us = buff.getBuffAddr();
690 os <<
"[" << std::setw(2) << std::hex << std::setfill(
'0') << (
NATIVE_UINT_TYPE)us[
byte] <<
"]" << std::dec;
707 this->m_buff = buffPtr;
708 this->m_buffSize = size;
713 this->m_buffSize = 0;
717 return this->m_buffSize;