16 #if FW_SERIALIZABLE_TO_STRING 26 m_bufferData(nullptr),
30 m_context(0xFFFFFFFF) {}
35 m_bufferData(src.m_bufferData),
36 m_offset(src.m_offset),
38 m_capacity(src.m_capacity),
39 m_context(src.m_context) {
40 if (src.m_bufferData !=
nullptr) {
41 this->m_serialize_repr.
setExtBuffer(this->m_bufferData + this->m_offset, this->m_size);
53 if (m_bufferData !=
nullptr) {
54 this->m_serialize_repr.
setExtBuffer(this->m_bufferData, this->m_size);
61 this->m_bufferData = src.m_bufferData;
62 this->m_offset = src.m_offset;
63 this->m_size = src.m_size;
64 this->m_capacity = src.m_capacity;
65 this->m_context = src.m_context;
66 if (this->m_bufferData !=
nullptr) {
67 this->m_serialize_repr.
setExtBuffer(this->m_bufferData + this->m_offset, this->m_size);
74 return (this->m_bufferData == src.m_bufferData) && (this->m_offset == src.m_offset) &&
75 (this->m_size == src.m_size) && (this->m_capacity == src.m_capacity) && (this->m_context == src.m_context);
79 return (this->m_bufferData !=
nullptr) && (this->m_size > 0);
83 return (this->m_bufferData ==
nullptr) ? nullptr : (this->m_bufferData + this->m_offset);
87 return this->m_bufferData;
95 return this->m_capacity;
99 return this->m_offset;
103 return this->m_context;
107 FW_ASSERT(this->m_bufferData !=
nullptr);
110 FW_ASSERT(this->m_offset >= static_cast<FwSizeType>(-amount), static_cast<FwAssertArgType>(this->m_offset),
111 static_cast<FwAssertArgType>(amount));
114 FW_ASSERT(static_cast<FwSizeType>(amount) <= this->m_size, static_cast<FwAssertArgType>(this->m_size),
115 static_cast<FwAssertArgType>(amount));
120 FW_ASSERT(this->m_offset + this->m_size <= this->m_capacity, static_cast<FwAssertArgType>(this->m_offset),
121 static_cast<FwAssertArgType>(this->m_size), static_cast<FwAssertArgType>(this->m_capacity));
122 this->m_serialize_repr.
setExtBuffer(this->m_bufferData + this->m_offset, this->m_size);
126 FW_ASSERT(this->m_bufferData !=
nullptr);
127 FW_ASSERT(data >= this->m_bufferData && data <= &this->m_bufferData[this->m_capacity]);
128 this->
advance(static_cast<FwSignedSizeType>(data - (this->m_bufferData + this->m_offset)));
132 FW_ASSERT(this->m_offset + size <= this->m_capacity, static_cast<FwAssertArgType>(this->m_offset),
133 static_cast<FwAssertArgType>(size), static_cast<FwAssertArgType>(this->m_capacity));
135 if (m_bufferData !=
nullptr) {
136 this->m_serialize_repr.
setExtBuffer(this->m_bufferData + this->m_offset, this->m_size);
141 this->m_context = context;
145 this->m_bufferData = data;
148 this->m_capacity = size;
149 if (m_bufferData !=
nullptr) {
150 this->m_serialize_repr.
setExtBuffer(this->m_bufferData, this->m_size);
152 this->m_context = context;
178 stat = buffer.
serializeFrom(reinterpret_cast<PlatformPointerCastType>(this->m_bufferData), mode);
203 PlatformPointerCastType pointer;
208 this->m_bufferData =
reinterpret_cast<U8*
>(pointer);
227 if (this->m_bufferData !=
nullptr) {
228 this->m_serialize_repr.
setExtBuffer(this->m_bufferData + this->m_offset, this->m_size);
233 #if FW_SERIALIZABLE_TO_STRING 235 static const char* formatString =
"(data = %p, size = %u, context = %u, offset = %u, capacity = %u)";
236 (void)text.
format(formatString, this->m_bufferData, this->m_size, this->m_context, this->m_offset,
242 std::ostream& operator<<(std::ostream& os,
const Buffer& obj) {
Serialization/Deserialization operation was successful.
void set(U8 *data, FwSizeType size, U32 context=NO_CONTEXT)
PlatformSizeType FwSizeType
void setContext(U32 context)
void setSize(FwSizeType size)
void advance(FwSignedSizeType amount)
bool operator==(const Buffer &src) const
PlatformSignedSizeType FwSignedSizeType
Fw::SerializeStatus deserializeFrom(Fw::SerialBufferBase &buffer, Fw::Endianness mode=Fw::Endianness::BIG)
Fw::SerializeStatus serializeTo(Fw::SerialBufferBase &serialBuffer, Fw::Endianness mode=Fw::Endianness::BIG) const
FwSizeType getCapacity() const
virtual SerializeStatus serializeFrom(U8 val, Endianness mode=Endianness::BIG)=0
Serialize an 8-bit unsigned integer value.
SerializeStatus
forward declaration for string
virtual SerializeStatus deserializeTo(U8 &val, Endianness mode=Endianness::BIG)=0
Deserialize an 8-bit unsigned integer value.
ExternalSerializeBufferWithMemberCopy getDeserializer()
FwSizeType getOffset() const
void resetSer() override
Reset serialization pointer to beginning of buffer.
const char * toChar() const
Convert to a C-style char*.
FormatStatus format(const CHAR *formatString,...)
write formatted string to buffer
uint8_t U8
8-bit unsigned integer
SerializeStatus setBuffLen(Serializable::SizeType length) override
Set buffer length manually.
FwSizeType getSize() const
void setExtBuffer(U8 *buffPtr, Serializable::SizeType size)
Set the external buffer.
External serialize buffer with member copy semantics.
Implementation of malloc based allocator.
ExternalSerializeBufferWithMemberCopy getSerializer()
Buffer & operator=(const Buffer &src)
U8 * getOriginalData() const