Lightweight view into a region of a shared Buffer. More...
#include <bufferview.h>

Public Types | |
| using | List = promeki::List< BufferView > |
| List of BufferView values. | |
Public Member Functions | |
| BufferView ()=default | |
| Default constructor. Creates an empty view with no buffer. | |
| BufferView (Buffer::Ptr buf, size_t offset, size_t size) | |
| Constructs a BufferView referencing a region of a shared buffer. | |
| const Buffer::Ptr & | buffer () const |
| Returns the shared backing buffer. | |
| size_t | offset () const |
| Returns the byte offset into the buffer. | |
| size_t | size () const |
| Returns the byte size of this view. | |
| const uint8_t * | data () const |
| Returns a const pointer to this view's data. | |
| uint8_t * | data () |
| Returns a mutable pointer to this view's data. | |
| bool | isNull () const |
| Returns true if no buffer is set. | |
| bool | isValid () const |
| Returns true if a buffer is set. | |
Lightweight view into a region of a shared Buffer.
BufferView is a simple value type that references a contiguous region (offset + size) of a shared Buffer. Multiple BufferViews can reference different regions of the same underlying Buffer::Ptr, avoiding per-view allocation when slicing large buffers into smaller pieces.
Common uses include RTP packet fragmentation, scatter/gather I/O, and any scenario where a large buffer is logically divided into sub-regions without copying data.
|
inline |
Constructs a BufferView referencing a region of a shared buffer.
| buf | The shared backing buffer. |
| offset | Byte offset into the buffer where this view begins. |
| size | Byte size of this view. |
|
inline |
Returns a mutable pointer to this view's data.
Returns a const pointer to this view's data.