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);
66 for (U32 i = 0; i < size; i++) {
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;
78 FW_ASSERT(m_store !=
nullptr && m_store_size != 0);
79 return peek(reinterpret_cast<U8&>(value), offset);
83 FW_ASSERT(m_store !=
nullptr && m_store_size != 0);
85 if ((
sizeof(
U8) + offset) > m_allocated_size) {
88 const FwSizeType idx = advance_idx(m_head_idx, offset);
89 FW_ASSERT(idx < m_store_size, static_cast<FwAssertArgType>(idx));
95 FW_ASSERT(m_store !=
nullptr && m_store_size != 0);
97 if ((
sizeof(U32) + offset) > m_allocated_size) {
101 FwSizeType idx = advance_idx(m_head_idx, offset);
104 for (
FwSizeType i = 0; i <
sizeof(U32); i++) {
105 FW_ASSERT(idx < m_store_size, static_cast<FwAssertArgType>(idx));
106 value = (value << 8) | static_cast<U32>(m_store[idx]);
107 idx = advance_idx(idx);
113 FW_ASSERT(m_store !=
nullptr && m_store_size != 0);
116 if ((size + offset) > m_allocated_size) {
119 FwSizeType idx = advance_idx(m_head_idx, offset);
122 FW_ASSERT(idx < m_store_size, static_cast<FwAssertArgType>(idx));
123 buffer[i] = m_store[idx];
124 idx = advance_idx(idx);
130 FW_ASSERT(m_store !=
nullptr && m_store_size != 0);
132 if (amount > m_allocated_size) {
135 m_head_idx = advance_idx(m_head_idx, amount);
136 m_allocated_size -= amount;
141 FW_ASSERT(m_store !=
nullptr && m_store_size != 0);
146 return m_high_water_mark;
150 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)
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