12 #ifndef ROC_CORE_STRING_BUFFER_H_
13 #define ROC_CORE_STRING_BUFFER_H_
#define ROC_ATTR_NODISCARD
Emit warning if function result is not checked.
Base class for non-copyable objects.
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.
size_t len() const
Get string length, excluding terminating zero.
ROC_ATTR_NODISCARD bool assign(const char *str)
Copy given string into buffer. str should be zero-terminated.
void clear()
Set buffer to empty string.
bool is_empty() const
Check if buffer is empty.
ROC_ATTR_NODISCARD bool grow(size_t desired_len)
Grow capacity to be able to hold desired number of characters. Capacity is increased linearly.
ROC_ATTR_NODISCARD bool assign(const char *str_begin, const char *str_end)
Copy given range into buffer. Buffer will be automatically zero-terminated.
StringBuffer(IArena &arena)
Initialize empty buffer.
const char * c_str() const
Get zero-terminated string.
ROC_ATTR_NODISCARD char * extend(size_t n_chars)
Extend buffer by requested number of characters.