22 : m_store(nullptr), m_store_size(0), m_head_idx(0), m_allocated_size(0), m_high_water_mark(0) {}
25 : m_store(nullptr), m_store_size(0), m_head_idx(0), m_allocated_size(0), m_high_water_mark(0) {
32 FW_ASSERT(m_store ==
nullptr && m_store_size == 0);
39 m_high_water_mark = 0;
43 return m_allocated_size;
47 FW_ASSERT(m_store !=
nullptr && m_store_size != 0);
48 FW_ASSERT(m_allocated_size <= m_store_size, static_cast<FwAssertArgType>(m_allocated_size));
49 return m_store_size - m_allocated_size;
53 FW_ASSERT(idx < m_store_size, static_cast<FwAssertArgType>(idx));
54 return (idx + amount) % m_store_size;
58 FW_ASSERT(m_store !=
nullptr && m_store_size != 0);
65 FwSizeType idx = advance_idx(m_head_idx, m_allocated_size);
67 FW_ASSERT(idx < m_store_size, static_cast<FwAssertArgType>(idx));
68 m_store[idx] = buffer[i];
69 idx = advance_idx(idx);
71 m_allocated_size += size;
73 m_high_water_mark = (m_high_water_mark > m_allocated_size) ? m_high_water_mark : m_allocated_size;
79 FW_ASSERT(m_store !=
nullptr && m_store_size != 0);
84 const FwSizeType idx = advance_idx(m_head_idx, m_allocated_size);
86 if ((idx + size) > m_store_size) {
87 FW_ASSERT(size <= STAGING_BUFFER_SIZE, static_cast<FwAssertArgType>(size),
88 static_cast<FwAssertArgType>(STAGING_BUFFER_SIZE));
89 U8 staging[STAGING_BUFFER_SIZE > 0 ? STAGING_BUFFER_SIZE : 1] = {};
103 m_allocated_size += size;
105 m_high_water_mark = (m_high_water_mark > m_allocated_size) ? m_high_water_mark : m_allocated_size;
110 return this->serialize_impl(serializable, size);
114 return this->serialize_impl(buffer, size);
118 FW_ASSERT(m_store !=
nullptr && m_store_size != 0);
119 return peek(reinterpret_cast<U8&>(value), offset);
123 FW_ASSERT(m_store !=
nullptr && m_store_size != 0);
125 if ((
sizeof(
U8) + offset) > m_allocated_size) {
128 const FwSizeType idx = advance_idx(m_head_idx, offset);
129 FW_ASSERT(idx < m_store_size, static_cast<FwAssertArgType>(idx));
130 value = m_store[idx];
135 FW_ASSERT(m_store !=
nullptr && m_store_size != 0);
137 if ((
sizeof(U32) + offset) > m_allocated_size) {
141 FwSizeType idx = advance_idx(m_head_idx, offset);
144 for (
FwSizeType i = 0; i <
sizeof(U32); i++) {
145 FW_ASSERT(idx < m_store_size, static_cast<FwAssertArgType>(idx));
146 value = (value << 8) | static_cast<U32>(m_store[idx]);
147 idx = advance_idx(idx);
153 FW_ASSERT(m_store !=
nullptr && m_store_size != 0);
156 if ((size + offset) > m_allocated_size) {
159 FwSizeType idx = advance_idx(m_head_idx, offset);
162 FW_ASSERT(idx < m_store_size, static_cast<FwAssertArgType>(idx));
163 buffer[i] = m_store[idx];
164 idx = advance_idx(idx);
169 template <
typename T>
171 FW_ASSERT(m_store !=
nullptr && m_store_size != 0);
173 if ((size + offset) > m_allocated_size) {
176 const FwSizeType idx = advance_idx(m_head_idx, offset);
178 if ((idx + size) > m_store_size) {
179 FW_ASSERT(size <= STAGING_BUFFER_SIZE, static_cast<FwAssertArgType>(size),
180 static_cast<FwAssertArgType>(STAGING_BUFFER_SIZE));
181 U8 staging[STAGING_BUFFER_SIZE > 0 ? STAGING_BUFFER_SIZE : 1];
189 return stagingBuffer.deserializeTo(serializable);
195 return slot.deserializeTo(serializable);
199 return this->peek_impl(serializable, size, offset);
203 return this->peek_impl(buffer, size, offset);
207 FW_ASSERT(m_store !=
nullptr && m_store_size != 0);
209 if (amount > m_allocated_size) {
212 m_head_idx = advance_idx(m_head_idx, amount);
213 m_allocated_size -= amount;
218 FW_ASSERT(m_store !=
nullptr && m_store_size != 0);
220 if (amount > m_allocated_size) {
224 m_allocated_size -= amount;
229 FW_ASSERT(m_store !=
nullptr && m_store_size != 0);
234 return m_high_water_mark;
238 m_high_water_mark = 0;
Serialization/Deserialization operation was successful.
Deserialization buffer was empty when trying to read more data.
PlatformSizeType FwSizeType
No room left in the buffer to serialize data.
SerializeStatus
forward declaration for string
FwSizeType get_high_water_mark() const
Fw::SerializeStatus serialize(const U8 *const buffer, const FwSizeType size)
External serialize buffer with no copy semantics.
void clear_high_water_mark()
Fw::SerializeStatus rotate(FwSizeType amount)
FwSizeType get_allocated_size() const
uint8_t U8
8-bit unsigned integer
FwSizeType get_capacity() const
Fw::SerializeStatus peek(char &value, FwSizeType offset=0) const
void setup(U8 *const buffer, const FwSizeType size)
FwSizeType get_free_size() const
Fw::SerializeStatus trim(FwSizeType amount)