roo_collections
API Documentation for roo_collections
Loading...
Searching...
No Matches
roo_collections::SmallString< N > Class Template Reference

Fixed-capacity string stored inline (no heap allocation). More...

#include <small_string.h>

Public Member Functions

 SmallString ()
 Creates an empty string.
 
 SmallString (const char *str)
 Constructs from a C string.
 
 SmallString (const std::string &str)
 Constructs from std::string.
 
 SmallString (const roo::string_view &str)
 Constructs from roo::string_view.
 
 SmallString (const SmallString &other)
 Copy constructor.
 
SmallStringoperator= (const SmallString &other)
 Copy assignment.
 
SmallStringoperator= (const char *other)
 Assigns from C string.
 
SmallStringoperator= (roo::string_view other)
 Assigns from roo::string_view.
 
size_t length () const
 Returns the string length.
 
const charc_str () const
 Returns pointer to null-terminated character data.
 
bool empty () const
 Checks whether the string is empty.
 
bool operator== (const SmallString &other) const
 Equality comparison.
 
bool operator!= (const SmallString &other) const
 Inequality comparison.
 
 operator roo::string_view () const
 Implicit conversion to roo::string_view.
 

Static Public Attributes

static constexpr size_t kCapacity = N
 Maximum storage capacity (including the trailing '\0').
 

Detailed Description

template<size_t N>
class roo_collections::SmallString< N >

Fixed-capacity string stored inline (no heap allocation).

Intended for short, bounded identifiers and other small keys/values where a constant memory footprint is preferred over unbounded growth.

Template Parameters
NCapacity of the internal storage buffer, in bytes.

Definition at line 26 of file small_string.h.

Constructor & Destructor Documentation

◆ SmallString() [1/5]

template<size_t N>
roo_collections::SmallString< N >::SmallString ( )
inline

Creates an empty string.

Definition at line 32 of file small_string.h.

◆ SmallString() [2/5]

template<size_t N>
roo_collections::SmallString< N >::SmallString ( const char str)
inline

Constructs from a C string.

Parameters
strNull-terminated source string.

Definition at line 36 of file small_string.h.

◆ SmallString() [3/5]

template<size_t N>
roo_collections::SmallString< N >::SmallString ( const std::string &  str)
inline

Constructs from std::string.

Parameters
strSource string.

Definition at line 40 of file small_string.h.

◆ SmallString() [4/5]

template<size_t N>
roo_collections::SmallString< N >::SmallString ( const roo::string_view &  str)
inline

Constructs from roo::string_view.

Parameters
strSource view.

Definition at line 44 of file small_string.h.

◆ SmallString() [5/5]

template<size_t N>
roo_collections::SmallString< N >::SmallString ( const SmallString< N > &  other)
inline

Copy constructor.

Definition at line 49 of file small_string.h.

Member Function Documentation

◆ c_str()

template<size_t N>
const char * roo_collections::SmallString< N >::c_str ( ) const
inline

Returns pointer to null-terminated character data.

Definition at line 74 of file small_string.h.

◆ empty()

template<size_t N>
bool roo_collections::SmallString< N >::empty ( ) const
inline

Checks whether the string is empty.

Returns
true when empty.

Definition at line 78 of file small_string.h.

◆ length()

template<size_t N>
size_t roo_collections::SmallString< N >::length ( ) const
inline

Returns the string length.

Returns
Length in characters.

Definition at line 71 of file small_string.h.

Referenced by roo_collections::SmallString< N >::operator roo::string_view().

◆ operator roo::string_view()

template<size_t N>
roo_collections::SmallString< N >::operator roo::string_view ( ) const
inline

Implicit conversion to roo::string_view.

Definition at line 89 of file small_string.h.

References roo_collections::SmallString< N >::length().

◆ operator!=()

template<size_t N>
bool roo_collections::SmallString< N >::operator!= ( const SmallString< N > &  other) const
inline

Inequality comparison.

Definition at line 86 of file small_string.h.

References roo_collections::SmallString< N >::operator==().

◆ operator=() [1/3]

template<size_t N>
SmallString & roo_collections::SmallString< N >::operator= ( const char other)
inline

Assigns from C string.

Definition at line 58 of file small_string.h.

◆ operator=() [2/3]

template<size_t N>
SmallString & roo_collections::SmallString< N >::operator= ( const SmallString< N > &  other)
inline

Copy assignment.

Definition at line 52 of file small_string.h.

◆ operator=() [3/3]

template<size_t N>
SmallString & roo_collections::SmallString< N >::operator= ( roo::string_view  other)
inline

Assigns from roo::string_view.

Definition at line 64 of file small_string.h.

◆ operator==()

template<size_t N>
bool roo_collections::SmallString< N >::operator== ( const SmallString< N > &  other) const
inline

Equality comparison.

Definition at line 81 of file small_string.h.

Referenced by roo_collections::SmallString< N >::operator!=().

Field Documentation

◆ kCapacity

template<size_t N>
constexpr size_t roo_collections::SmallString< N >::kCapacity = N
staticconstexpr

Maximum storage capacity (including the trailing '\0').

Definition at line 29 of file small_string.h.


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