20 #if FW_SERIALIZABLE_TO_STRING || FW_ENABLE_TEXT_LOGGING || BUILD_UT 22 void Serializable::toString(
StringBase& text)
const {
29 std::ostream& operator<<(std::ostream& os,
const Serializable& val) {
86 #if FW_HAS_16_BIT == 1 113 #if FW_HAS_32_BIT == 1 145 #if FW_HAS_64_BIT == 1 188 (void)memcpy(&u64Val, &val,
sizeof(val));
195 (void)memcpy(&u32Val, &val,
sizeof(val));
221 return this->
serialize(reinterpret_cast<PlatformPointerCastType>(val));
229 return this->
serialize(buff, static_cast<FwSizeType>(length),
237 stat = this->
serialize(static_cast<FwSizeStoreType>(length));
289 status = this->
serialize(static_cast<FwSizeStoreType>(size));
324 #if FW_HAS_16_BIT == 1 357 #if FW_HAS_32_BIT == 1 395 #if FW_HAS_64_BIT == 1 451 (void)memcpy(&val, &tempVal,
sizeof(val));
479 PlatformPointerCastType pointerCastVal = 0;
482 val =
reinterpret_cast<void*
>(pointerCastVal);
494 (void)memcpy(&val, &tempVal,
sizeof(val));
527 if ((storedLength > this->
getBuffLeft()) or (storedLength > length)) {
533 length =
static_cast<FwSizeType>(storedLength);
651 (void)memcpy(this->
getBuffAddr(), src,
static_cast<size_t>(length));
670 static_cast<FwAssertArgType>(this->
m_deserLoc));
729 if (us[byte] != them[byte]) {
737 std::ostream& operator<<(std::ostream& os,
const SerializeBufferBase& buff) {
738 const U8* us = buff.getBuffAddr();
743 os <<
"[" << std::setw(2) << std::hex << std::setfill(
'0') << us[byte] <<
"]" << std::dec;
Serialization/Deserialization operation was successful.
void clear()
clear external buffer
SerializeBufferBase()
default constructor
Deserialization buffer was empty when trying to read more data.
PlatformSizeType FwSizeType
void resetSer()
reset to beginning of buffer to reuse for serialization
SerializeStatus copyRaw(SerializeBufferBase &dest, Serializable::SizeType size)
directly copies buffer without looking for a size in the stream.
SerializeStatus serialize(U8 val)
serialize 8-bit unsigned int
int8_t I8
8-bit signed integer
No room left in the buffer to serialize data.
#define FW_SERIALIZE_FALSE_VALUE
Value encoded during serialization for boolean false.
Serializable::SizeType m_buffSize
size of external buffer
virtual ~SerializeBufferBase()
destructor
Deserialization data had incorrect values (unexpected data types)
Serializable::SizeType m_serLoc
current offset in buffer of serialized data
const U8 * getBuffAddrLeft() const
gets address of remaining non-deserialized data.
ExternalSerializeBuffer()
default constructor
SerializeStatus
forward declaration for string
float F32
32-bit floating point
U16 FwSizeStoreType
The type used to serialize a size value.
Serializable::SizeType getBuffLength() const
returns current buffer size
Serializable::SizeType getBuffLeft() const
returns how much deserialization buffer is left
Include length as first token in serialization.
Data was the wrong format (e.g. wrong packet type)
virtual SerializeStatus serialize(SerializeBufferBase &buffer) const =0
serialize contents
U8 * m_buff
pointer to external buffer
#define FW_SERIALIZE_TRUE_VALUE
Value encoded during serialization for boolean true.
SerializeStatus serializeSize(const FwSizeType size)
serialize a size value
Data was left in the buffer, but not enough to deserialize.
SerializeStatus deserializeSize(FwSizeType &size)
deserialize a size value
Serializable()
Default constructor.
void resetDeser()
reset deserialization to beginning
SerializeStatus copyRawOffset(SerializeBufferBase &dest, Serializable::SizeType size)
directly copies buffer without looking for a size in the stream.
SerializeStatus moveDeserToOffset(FwSizeType offset)
Moves deserialization to the specified offset.
virtual SerializeStatus deserialize(SerializeBufferBase &buffer)=0
deserialize to contents
SerializeStatus moveSerToOffset(FwSizeType offset)
Moves serialization to the specified offset.
uint8_t U8
8-bit unsigned integer
virtual Serializable::SizeType getBuffCapacity() const =0
returns capacity, not current size, of buffer
SerializeStatus deserializeSkip(FwSizeType numBytesToSkip)
Skips the number of specified bytes for deserialization.
static U32 min(const U32 a, const U32 b)
void setExtBuffer(U8 *buffPtr, Serializable::SizeType size)
Omit length from serialization.
virtual ~Serializable()
destructor
Serializable::SizeType m_deserLoc
current offset for deserialization
SerializeStatus deserialize(U8 &val)
deserialize 8-bit unsigned int
double F64
64-bit floating point (double). Required for compiler-supplied double promotion.
SerializeBufferBase & operator=(const SerializeBufferBase &src)
copy assignment operator
SerializeStatus setBuff(const U8 *src, Serializable::SizeType length)
sets buffer contents and size
Serializable::SizeType getBuffCapacity() const
returns capacity, not current size, of buffer
virtual U8 * getBuffAddr()=0
gets buffer address for data filling
SerializeStatus serializeSkip(FwSizeType numBytesToSkip)
Skips the number of specified bytes for serialization.
PlatformAssertArgType FwAssertArgType
The type of arguments to assert functions.
U8 * getBuffAddr()
gets buffer address for data filling
SerializeStatus setBuffLen(Serializable::SizeType length)
sets buffer length manually after filling with data