RNBO: RNBO::DataBuffer Class Reference
#include <RNBO_DataBuffer.h>
Public Member Functions | |
DataBuffer (size_t size) | |
Initialize a DataBuffer with zeros. More... | |
DataBuffer (const char *dataToCopy, size_t sizeOfDataToCopy) | |
Initialize a DataBuffer with a block of memory. More... | |
DataBuffer (const char *stringToCopy) | |
Initialize a DataBuffer with a null-terminated string. More... | |
void | resize (size_t size) |
Resize the DataBuffer, attempting to preserve contents. More... | |
size_t | size () const |
Get the current buffer size. More... | |
char * | data () |
Get a pointer to the raw data. More... | |
const char * | data () const |
Get a const pointer to the raw data. More... | |
Detailed Description
DataBuffer holds an arbitrary block of data.
It is designed to be owned and used from one thread at a time and has no protections/locks on any of its methods. It is also designed to minimize memory allocation, so shrinking the buffer size will not cause reallocations.
Constructor & Destructor Documentation
◆ DataBuffer() [1/3]
RNBO::DataBuffer::DataBuffer | ( | size_t | size | ) |
Initialize a DataBuffer with zeros.
- Parameters
-
size the buffer size in bytes
◆ DataBuffer() [2/3]
RNBO::DataBuffer::DataBuffer | ( | const char * | dataToCopy, |
size_t | sizeOfDataToCopy | ||
) |
Initialize a DataBuffer with a block of memory.
- Parameters
-
dataToCopy source data to copy sizeOfDataToCopy the number of bytes to copy from the source data
◆ DataBuffer() [3/3]
RNBO::DataBuffer::DataBuffer | ( | const char * | stringToCopy | ) |
Initialize a DataBuffer with a null-terminated string.
The string's contents are copied to a newly allocated block of memory.
- Parameters
-
stringToCopy the null-terminated string to initialize the DataBuffer with
Member Function Documentation
◆ data() [1/2]
|
inline |
Get a pointer to the raw data.
This can be used to modify the data in the buffer
- Returns
- a pointer to the first byte of raw data in the DataBuffer
◆ data() [2/2]
|
inline |
Get a const pointer to the raw data.
- Returns
- a const pointer to the first byte of raw data in the DataBuffer
◆ resize()
void RNBO::DataBuffer::resize | ( | size_t | size | ) |
Resize the DataBuffer, attempting to preserve contents.
When expanding, the extra space is filled with zeros.
- Parameters
-
size the new size of the DataBuffer
◆ size()
|
inline |
Get the current buffer size.
- Returns
- the size of the DataBuffer in bytes
The documentation for this class was generated from the following file: