|
|
| ByteBuffer () noexcept |
| | Constructs a ByteBuffer with default capacity using SBO if enabled.
|
| | ByteBuffer (std::size_t capacity) noexcept |
| | Constructs a ByteBuffer with the specified capacity.
|
|
std::uint8_t | readUint8 () const |
| | Reads a single byte from the buffer at the current read cursor position and advances the cursor.
|
|
std::uint16_t | readUInt16 () const |
| | Reads a 16-bit unsigned integer from the buffer at the current read cursor position and advances the cursor by 2 bytes.
|
|
std::uint32_t | readUInt32 () const |
| | Reads a 32-bit unsigned integer from the buffer at the current read cursor position and advances the cursor by 4 bytes.
|
|
void | incrementReadCursor (std::size_t shiftVal) const noexcept |
| | Increments the read cursor by the specified value.
|
|
void | resetReadCursor () const noexcept |
| | Resets the read cursor to the beginning of the buffer.
|
| ByteBuffer & | append (std::uint16_t bytes) |
| | Appends a 2 bytes to the end of the buffer.
|
| ByteBuffer & | append (std::uint32_t bytes) |
| | Appends 4 bytes to the end of the buffer.
|
| ByteBuffer & | append (const std::uint8_t *bytes, std::size_t size) |
| | Appends a sequence of bytes to the end of the buffer.
|
| ByteBuffer & | append (const ByteBuffer &byteBuffer) |
| | Appends the contents of another ByteBuffer to this buffer.
|
| void | removeFromBeginning (std::size_t count) |
| | Removes the specified number of bytes from the beginning of the buffer.
|
|
std::size_t | size () const noexcept |
| | Get the size of the buffer (number of bytes currently stored).
|
|
std::size_t | capacity () const noexcept |
| | Get the capacity of the buffer (maximum number of bytes it can hold).
|
|
std::size_t | headroom () const noexcept |
| | Get the headroom of the buffer (remaining space available for writing).
|
|
const std::uint8_t * | bytes () const noexcept |
| | Get a pointer to the underlying byte array.
|
|
std::size_t | readCursor () const noexcept |
| | Get the current read cursor position.
|
|
std::size_t | readHeadroom () const noexcept |
| | Get the remaining bytes available to read from the current read cursor position.
|
|
std::string | toString () const noexcept |
| | Converts the buffer contents to a string of bits for debugging.
|
A fixed-capacity byte buffer with optional small buffer optimization (SBO).
ByteBuffer provides a contiguous memory area for storing bytes, with a capacity defined at construction time. The buffer is not resizable after construction. If SBO is enabled and the requested capacity is small enough, the buffer uses stack memory; otherwise, it allocates on the heap.
Provides methods for appending and reading bytes and multi-byte values, as well as cursor management for sequential reading.
The buffer's capacity is fixed after construction and cannot be changed.
SBO (Small Buffer Optimization) is enabled if ENABLE_BYTEBUFFER_SBO is defined.