|
Open Model Railroad Network (OpenMRN)
|
Holds a reference to a raw buffer, with the start and size information. More...
#include <ByteBuffer.hxx>
Public Member Functions | |
| size_t | size () const |
| void | advance (size_t num_bytes) |
| Moves forward the data beginning pointer by a given number of bytes. | |
| void | set_from (RawBufferPtr buf, size_t len, size_t ofs=0) |
| Overwrites this chunk from a raw buffer. | |
| void | set_from (const string *data) |
| Overwrites this chunk from a string. | |
| void | set_from (const void *data, size_t len) |
| Overwrites this chunk from an externally owned memory area. | |
| size_t | append (const void *data, size_t len) |
| Adds more data to the end of the buffer. | |
| uint8_t * | append_ptr () |
| void | append_complete (size_t len) |
| Notifies that a certain number of bytes have been appended, i.e., written into append_ptr(). | |
| size_t | free_space () |
Public Attributes | |
| RawBufferPtr | ownedData_ |
| Owns a ref for a RawData buffer. | |
| uint8_t * | data_ {nullptr} |
| Points to the first byte of the useful data. | |
| size_t | size_ {0} |
| How many bytes from data_ does this chunk represent. | |
Holds a reference to a raw buffer, with the start and size information.
Definition at line 64 of file ByteBuffer.hxx.
|
inline |
Moves forward the data beginning pointer by a given number of bytes.
Represents that some number of bytes were consumed by the sink.
| num_bytes | how much data was consumed. Must be <= size(). |
Definition at line 85 of file ByteBuffer.hxx.
|
inline |
Adds more data to the end of the buffer.
Requirement: this chunk must be a data source, and there has to be an ownedData_ set.
| data | payload to copy |
| len | how many bytes to add |
Definition at line 134 of file ByteBuffer.hxx.
|
inline |
Notifies that a certain number of bytes have been appended, i.e., written into append_ptr().
Requirement: this chunk must be a data source, and there has to be an ownedData_ set.
Definition at line 163 of file ByteBuffer.hxx.
|
inline |
Definition at line 152 of file ByteBuffer.hxx.
|
inline |
Definition at line 172 of file ByteBuffer.hxx.
|
inline |
Overwrites this chunk from a string.
WARNING: the ownership of the string is not transferred; the caller must make sure the string remains alive as long as this Chunk is ever in use (including all copies).
Definition at line 109 of file ByteBuffer.hxx.
|
inline |
Overwrites this chunk from an externally owned memory area.
The caller must make sure the memory area remains alive as long as this Chunk is ever in use (including all copies).
| data | payload to set into this buffer. Must stay alive. |
| len | number of bytes to use from that source. |
Definition at line 121 of file ByteBuffer.hxx.
|
inline |
Overwrites this chunk from a raw buffer.
| buf | An owned share of a RawBuffer. |
| len | How many bytes to take from this buffer. |
| ofs | From which offset we should take these bytes (default 0, may be omitted). |
Definition at line 99 of file ByteBuffer.hxx.
|
inline |
Definition at line 77 of file ByteBuffer.hxx.
| uint8_t* ByteChunk::data_ {nullptr} |
Points to the first byte of the useful data.
Definition at line 71 of file ByteBuffer.hxx.
| RawBufferPtr ByteChunk::ownedData_ |
Owns a ref for a RawData buffer.
If this is nullptr, then the data references by this chunk is externally owned.
Definition at line 68 of file ByteBuffer.hxx.
| size_t ByteChunk::size_ {0} |
How many bytes from data_ does this chunk represent.
Definition at line 74 of file ByteBuffer.hxx.