Roc Toolkit internal modules
Roc Toolkit: real-time audio streaming
Loading...
Searching...
No Matches
roc::core::StringBuffer< EmbeddedCapacity > Class Template Reference

String buffer. More...

#include <string_buffer.h>

Inheritance diagram for roc::core::StringBuffer< EmbeddedCapacity >:
roc::core::NonCopyable< T >

Public Member Functions

 StringBuffer (IAllocator &allocator)
 Initialize empty buffer.
 
bool is_empty () const
 Check if buffer is empty.
 
size_t len () const
 Get string length, excluding terminating zero.
 
const char * c_str () const
 Get zero-terminated string.
 
void clear ()
 Set buffer to empty string.
 
bool assign (const char *str)
 Copy given string into buffer. str should be zero-terminated.
 
bool assign (const char *str_begin, const char *str_end)
 Copy given range into buffer. Buffer will be automatically zero-terminated.
 
char * extend (size_t n_chars)
 Extend buffer by requested number of characters.
 
bool grow (size_t desired_len)
 Grow capacity to be able to hold desired number of characters. Capacity is increased linearly.
 
bool grow_exp (size_t desired_len)
 Grow capacity to be able to hold desired number of characters. Capacity is increased exponentionally.
 

Detailed Description

template<size_t EmbeddedCapacity = 0>
class roc::core::StringBuffer< EmbeddedCapacity >

String buffer.

Dynamic array storing zero-terminated string. Works on top of Array, but guarantees that the string is always zero-terminated.

Template Parameters
EmbeddedCapacityis the same as for Array.

Definition at line 29 of file string_buffer.h.

Constructor & Destructor Documentation

◆ StringBuffer()

template<size_t EmbeddedCapacity = 0>
roc::core::StringBuffer< EmbeddedCapacity >::StringBuffer ( IAllocator allocator)
inlineexplicit

Initialize empty buffer.

Definition at line 32 of file string_buffer.h.

Member Function Documentation

◆ assign() [1/2]

template<size_t EmbeddedCapacity = 0>
bool roc::core::StringBuffer< EmbeddedCapacity >::assign ( const char *  str)
inline

Copy given string into buffer. str should be zero-terminated.

Definition at line 60 of file string_buffer.h.

◆ assign() [2/2]

template<size_t EmbeddedCapacity = 0>
bool roc::core::StringBuffer< EmbeddedCapacity >::assign ( const char *  str_begin,
const char *  str_end 
)
inline

Copy given range into buffer. Buffer will be automatically zero-terminated.

Definition at line 68 of file string_buffer.h.

◆ c_str()

template<size_t EmbeddedCapacity = 0>
const char * roc::core::StringBuffer< EmbeddedCapacity >::c_str ( ) const
inline

Get zero-terminated string.

Definition at line 48 of file string_buffer.h.

◆ clear()

template<size_t EmbeddedCapacity = 0>
void roc::core::StringBuffer< EmbeddedCapacity >::clear ( )
inline

Set buffer to empty string.

Definition at line 53 of file string_buffer.h.

◆ extend()

template<size_t EmbeddedCapacity = 0>
char * roc::core::StringBuffer< EmbeddedCapacity >::extend ( size_t  n_chars)
inline

Extend buffer by requested number of characters.

Remarks
Characters are appended to the buffer and filled with zeros. It's the caller responsibility to fill them.

Definition at line 91 of file string_buffer.h.

◆ grow()

template<size_t EmbeddedCapacity = 0>
bool roc::core::StringBuffer< EmbeddedCapacity >::grow ( size_t  desired_len)
inline

Grow capacity to be able to hold desired number of characters. Capacity is increased linearly.

Definition at line 106 of file string_buffer.h.

◆ grow_exp()

template<size_t EmbeddedCapacity = 0>
bool roc::core::StringBuffer< EmbeddedCapacity >::grow_exp ( size_t  desired_len)
inline

Grow capacity to be able to hold desired number of characters. Capacity is increased exponentionally.

Definition at line 112 of file string_buffer.h.

◆ is_empty()

template<size_t EmbeddedCapacity = 0>
bool roc::core::StringBuffer< EmbeddedCapacity >::is_empty ( ) const
inline

Check if buffer is empty.

Definition at line 38 of file string_buffer.h.

◆ len()

template<size_t EmbeddedCapacity = 0>
size_t roc::core::StringBuffer< EmbeddedCapacity >::len ( ) const
inline

Get string length, excluding terminating zero.

Definition at line 43 of file string_buffer.h.


The documentation for this class was generated from the following file: