1#ifndef SERIALIZABLE_HPP
2#define SERIALIZABLE_HPP
22 class SerializeBufferBase;
28#if FW_SERIALIZABLE_TO_STRING || FW_ENABLE_TEXT_LOGGING || BUILD_UT
33 friend std::ostream& operator<<(std::ostream& os,
const Serializable& val);
int8_t I8
8-bit signed integer
float F32
32-bit floating point
uint8_t U8
8-bit unsigned integer
PlatformUIntType NATIVE_UINT_TYPE
C++-compatible configuration header for fprime configuration.
NATIVE_UINT_TYPE getBuffCapacity() const
returns capacity, not current size, of buffer
U8 * getBuffAddr()
gets buffer address for data filling
void setExtBuffer(U8 *buffPtr, NATIVE_UINT_TYPE size)
Set the external buffer.
void clear()
clear external buffer
ExternalSerializeBuffer()
default constructor
Serializable()
Default constructor.
virtual ~Serializable()
destructor
virtual SerializeStatus deserialize(SerializeBufferBase &buffer)=0
deserialize to contents
virtual SerializeStatus serialize(SerializeBufferBase &buffer) const =0
serialize contents
NATIVE_UINT_TYPE getBuffLeft() const
returns how much deserialization buffer is left
void resetDeser()
reset deserialization to beginning
SerializeStatus setBuffLen(NATIVE_UINT_TYPE length)
sets buffer length manually after filling with data
const U8 * getBuffAddrLeft() const
gets address of remaining non-deserialized data.
void resetSer()
reset to beginning of buffer to reuse for serialization
SerializeBufferBase()
default constructor
SerializeStatus setBuff(const U8 *src, NATIVE_UINT_TYPE length)
sets buffer contents and size
SerializeStatus deserializeSkip(NATIVE_UINT_TYPE numBytesToSkip)
Skips the number of specified bytes for deserialization.
SerializeBufferBase & operator=(const SerializeBufferBase &src)
equal operator
virtual const U8 * getBuffAddr() const =0
gets buffer address for data reading, const version
virtual NATIVE_UINT_TYPE getBuffCapacity() const =0
returns capacity, not current size, of buffer
SerializeStatus deserialize(U8 &val)
deserialize 8-bit unsigned int
virtual ~SerializeBufferBase()
destructor
U8 * getBuffAddrSer()
gets address of end of serialization. DANGEROUS! Need to know max buffer size and adjust when done
SerializeStatus serialize(U8 val)
serialize 8-bit unsigned int
SerializeStatus copyRawOffset(SerializeBufferBase &dest, NATIVE_UINT_TYPE size)
directly copies buffer without looking for a size in the stream.
SerializeStatus copyRaw(SerializeBufferBase &dest, NATIVE_UINT_TYPE size)
directly copies buffer without looking for a size in the stream.
virtual U8 * getBuffAddr()=0
gets buffer address for data filling
NATIVE_UINT_TYPE getBuffLength() const
returns current buffer size
SerializeStatus
forward declaration for string
@ FW_DESERIALIZE_FORMAT_ERROR
Deserialization data had incorrect values (unexpected data types)
@ FW_DESERIALIZE_BUFFER_EMPTY
Deserialization buffer was empty when trying to read more data.
@ FW_SERIALIZE_OK
Serialization/Deserialization operation was successful.
@ FW_SERIALIZE_FORMAT_ERROR
Data was the wrong format (e.g. wrong packet type)
@ FW_DESERIALIZE_TYPE_MISMATCH
Deserialized type ID didn't match.
@ FW_DESERIALIZE_SIZE_MISMATCH
Data was left in the buffer, but not enough to deserialize.
@ FW_SERIALIZE_NO_ROOM_LEFT
No room left in the buffer to serialize data.