Class OsfBuffer
Defined in File buffer.h
Class Documentation
-
class OsfBuffer
Buffer class for storing and accessing OSF binary data including header, metadata, message.
It supports memory-mapped or internal (owned) data, with interfaces to load, access, and reset buffer contents.
Public Functions
-
OsfBuffer()
-
~OsfBuffer()
-
void reset()
Clears the buffer and resets internal state.
For owned data, the memory is released. For memory-mapped data, the pointer is cleared but memory is not unmapped or freed.
-
OsfBuffer(const OsfBuffer &other)
Copy constructor.
- Parameters:
other[in] – The buffer to copy from.
-
void load_data(const uint8_t *data, uint64_t size)
Load buffer using externally managed data (memory-mapped).
This does not take ownership of the data and assumes the lifetime of the provided memory is externally managed.
- Parameters:
data[in] – Pointer to external data buffer.
size[in] – Size of the data in bytes.
- Throws:
std::logic_error – if data is null.
-
void load_data(std::vector<uint8_t> &&data)
Load buffer by moving from a provided vector.
Takes ownership of the provided vector contents.
- Parameters:
data[in] – Rvalue reference to a vector of bytes.
- Throws:
std::logic_error – if data is empty.
-
void load_data(const std::vector<uint8_t> &data)
Load buffer by copying from a provided vector.
Copies the provided vector contents.
- Parameters:
data[in] – Rvalue reference to a vector of bytes.
- Throws:
std::logic_error – if data is empty.
-
void load_data(const class OsfBuffer &base_buffer, uint64_t offset, uint64_t size)
Load buffer by referencing a provided base buffer.
- Parameters:
base_buffer[in] – The base OsfBuffer to use as the source.
offset[in] – The offset within the base buffer to start.
size[in] – The number of bytes.
-
const uint8_t *data() const
Get a pointer to the underlying data.
If the buffer was loaded using memory-mapped data, that pointer is returned. Otherwise, the internal owned memory is returned.
- Returns:
Pointer to the data, or nullptr if uninitialized.
-
const uint8_t *cbegin() const
Returns a const iterator to the beginning of the buffer.
- Returns:
A const iterator pointing to the first byte.
-
const uint8_t *cend() const
Returns a const iterator to the end of the buffer.
- Returns:
A const iterator pointing past the last byte.
-
uint64_t size() const
Get the size of the buffer in bytes.
- Returns:
Size of the buffer content.
-
bool has_value() const
Check if the buffer contains valid data.
- Returns:
True if the buffer has been initialized with valid data.
-
OsfBuffer()