Writes variable-length data buffers to a RingBufferData
, delimited by Base128 varint-encoded length delimiters.
More...
#include "client/length_delimited_ring_buffer.h"
Public Member Functions | |
constexpr | LengthDelimitedRingBufferWriter (RingBufferDataType &ring_buffer) |
Constructs a writer which holds a reference to ring_buffer . | |
LengthDelimitedRingBufferWriter (const LengthDelimitedRingBufferWriter &)=delete | |
LengthDelimitedRingBufferWriter & | operator= (const LengthDelimitedRingBufferWriter &)=delete |
bool | Push (const void *const buffer, typename RingBufferDataType::SizeType buffer_length) |
Writes data to the ring buffer. | |
void | ResetForTesting () |
Resets the state of the ring buffer and writer (e.g., for testing). | |
Writes variable-length data buffers to a RingBufferData
, delimited by Base128 varint-encoded length delimiters.
Holds a reference to a RingBufferData
with the capacity to hold RingBufferDataType::size()
bytes of variable-length buffers each preceded by its length (encoded as a Base128 length varint).
Provides writing capabilities via Push()
.
|
inlineexplicitconstexpr |
Constructs a writer which holds a reference to ring_buffer
.
[in] | ring_buffer | The ring buffer into which data will be written. This object must outlive the lifetime of ring_buffer . |
|
inline |
Writes data to the ring buffer.
If there is not enough room remaining in the ring buffer to store the new data, old data will be removed from the ring buffer in FIFO order until there is room for the new data.
[in] | buffer | The data to be written. |
[in] | buffer_length | The lengh of buffer , in bytes. |
true
, updates ring_buffer.data_range
to reflect the remaining data available to read, and updates ring_buffer_write_offset_
to reflec the current write positionl. Otherwise, returns false
.