Roc Toolkit internal modules
Roc Toolkit: real-time audio streaming
|
String buffer. More...
#include <string_buffer.h>
Public Member Functions | |
StringBuffer (IArena &arena) | |
Initialize empty buffer. More... | |
bool | is_empty () const |
Check if buffer is empty. More... | |
size_t | len () const |
Get string length, excluding terminating zero. More... | |
const char * | c_str () const |
Get zero-terminated string. More... | |
void | clear () |
Set buffer to empty string. More... | |
ROC_ATTR_NODISCARD bool | assign (const char *str) |
Copy given string into buffer. str should be zero-terminated. More... | |
ROC_ATTR_NODISCARD bool | assign (const char *str_begin, const char *str_end) |
Copy given range into buffer. Buffer will be automatically zero-terminated. More... | |
ROC_ATTR_NODISCARD char * | extend (size_t n_chars) |
Extend buffer by requested number of characters. More... | |
ROC_ATTR_NODISCARD bool | grow (size_t desired_len) |
Grow capacity to be able to hold desired number of characters. Capacity is increased linearly. More... | |
ROC_ATTR_NODISCARD bool | grow_exp (size_t desired_len) |
Grow capacity to be able to hold desired number of characters. Capacity is increased exponentially. More... | |
String buffer.
Dynamic array storing zero-terminated string. Works on top of Array, but guarantees that the string is always zero-terminated.
EmbeddedCapacity | is the same as for Array. |
Definition at line 30 of file string_buffer.h.
|
explicit |
Initialize empty buffer.
ROC_ATTR_NODISCARD bool roc::core::StringBuffer::assign | ( | const char * | str | ) |
Copy given string into buffer. str
should be zero-terminated.
ROC_ATTR_NODISCARD bool roc::core::StringBuffer::assign | ( | const char * | str_begin, |
const char * | str_end | ||
) |
Copy given range into buffer. Buffer will be automatically zero-terminated.
const char* roc::core::StringBuffer::c_str | ( | ) | const |
Get zero-terminated string.
void roc::core::StringBuffer::clear | ( | ) |
Set buffer to empty string.
ROC_ATTR_NODISCARD char* roc::core::StringBuffer::extend | ( | size_t | n_chars | ) |
Extend buffer by requested number of characters.
ROC_ATTR_NODISCARD bool roc::core::StringBuffer::grow | ( | size_t | desired_len | ) |
Grow capacity to be able to hold desired number of characters. Capacity is increased linearly.
ROC_ATTR_NODISCARD bool roc::core::StringBuffer::grow_exp | ( | size_t | desired_len | ) |
Grow capacity to be able to hold desired number of characters. Capacity is increased exponentially.
bool roc::core::StringBuffer::is_empty | ( | ) | const |
Check if buffer is empty.
size_t roc::core::StringBuffer::len | ( | ) | const |
Get string length, excluding terminating zero.