Template class for non-alloc strings. More...
#include <fixed_size_string.hpp>
Public Member Functions | |
fixed_string & | assign (const char *c_array, size_t n_chars) noexcept |
Assigns from a char array. More... | |
const char * | c_str () const noexcept |
Converts to C string. More... | |
int | compare (const char *str) const noexcept |
Compares with a C string. More... | |
template<size_t N> | |
int | compare (const fixed_string< N > &str) const noexcept |
Compares with a fixed_string. More... | |
int | compare (const std::string &str) const noexcept |
Compares with a std::string. More... | |
fixed_string () noexcept | |
Default constructor. More... | |
fixed_string (const char *c_array, size_t n_chars) noexcept | |
Constructs from a char array. More... | |
fixed_string (const char *c_string) noexcept | |
Constructs from a C string. More... | |
fixed_string (const std::string &str) noexcept | |
Constructs from a std::string. More... | |
operator const char * () const noexcept | |
Casts to a C string. More... | |
bool | operator!= (const char *rhs) const noexcept |
Compares inequality with a C string. More... | |
template<size_t N> | |
bool | operator!= (const fixed_string< N > &rhs) const noexcept |
Compares inequality with a fixed_string of any size. More... | |
bool | operator!= (const std::string &rhs) const noexcept |
Compares inequality with a std::string. More... | |
template<size_t N> | |
bool | operator< (const fixed_string< N > &rhs) const noexcept |
Compares relational less than with a fixed_string of any size. More... | |
bool | operator< (const std::string &rhs) const noexcept |
Compares relational less than with a std::string of any size. More... | |
fixed_string & | operator= (const char *c_string) noexcept |
Assigns from a C string. More... | |
template<size_t N> | |
fixed_string & | operator= (const fixed_string< N > &rhs) noexcept |
Assigns from a fixed_string of any size. More... | |
fixed_string & | operator= (const std::string &str) noexcept |
Assigns from a std::string. More... | |
bool | operator== (const char *rhs) const noexcept |
Compares equality with a C string. More... | |
template<size_t N> | |
bool | operator== (const fixed_string< N > &rhs) const noexcept |
Compares equality with a fixed_string of any size. More... | |
bool | operator== (const std::string &rhs) const noexcept |
Compares equality with a std::string. More... | |
template<size_t N> | |
bool | operator> (const fixed_string< N > &rhs) const noexcept |
Compares relational greater than with a fixed_string of any size. More... | |
bool | operator> (const std::string &rhs) const noexcept |
Compares relational greater than with a std::string of any size. More... | |
size_t | size () const noexcept |
Returns the size of the string. More... | |
std::string | to_string () const |
Converts to std::string. More... | |
Static Public Attributes | |
static constexpr size_t | max_size = MAX_CHARS |
Maximum number of characters. More... | |
Private Member Functions | |
void | set (const char *c_string) noexcept |
Private Attributes | |
char | string_data [MAX_CHARS+1] |
Holds string data, including ending null character. More... | |
size_t | string_len |
Holds current string length. More... | |
Template class for non-alloc strings.
Will be truncated when assigned from a longer string.
MAX_CHARS | Maximum number of characters is specified as the template parameter. Space for an additional null terminator will be reserved. |
Definition at line 44 of file fixed_size_string.hpp.
|
inlinenoexcept |
Default constructor.
Definition at line 52 of file fixed_size_string.hpp.
|
inlinenoexcept |
Constructs from a char array.
[in] | c_array | Char array to be constructed from. |
[in] | n_chars | Number of characters of the Char array |
Definition at line 65 of file fixed_size_string.hpp.
|
inlinenoexcept |
Constructs from a C string.
[in] | c_string | Pointer to the C string. |
Definition at line 95 of file fixed_size_string.hpp.
|
inlinenoexcept |
Constructs from a std::string.
[in] | str | Reference to the std::string. |
Definition at line 118 of file fixed_size_string.hpp.
|
inlinenoexcept |
Assigns from a char array.
[in] | c_array | Char array to be assigned from. |
[in] | n_chars | Number of characters of the Char array. |
Definition at line 78 of file fixed_size_string.hpp.
|
inlinenoexcept |
Converts to C string.
Definition at line 153 of file fixed_size_string.hpp.
|
inlinenoexcept |
Compares with a C string.
[in] | str | C string to be compared with. |
std::string::compare()
. Definition at line 298 of file fixed_size_string.hpp.
|
inlinenoexcept |
Compares with a fixed_string.
[in] | str | fixed_string to be compared with. |
std::string::compare()
. Definition at line 320 of file fixed_size_string.hpp.
|
inlinenoexcept |
Compares with a std::string.
[in] | str | std::string to be compared with. |
std::string::compare()
. Definition at line 309 of file fixed_size_string.hpp.
|
inlinenoexcept |
Casts to a C string.
Definition at line 280 of file fixed_size_string.hpp.
|
inlinenoexcept |
Compares inequality with a C string.
[in] | rhs | C string to be compared with. |
true
if strings are not equal. false
otherwise. Definition at line 205 of file fixed_size_string.hpp.
|
inlinenoexcept |
Compares inequality with a fixed_string of any size.
[in] | rhs | fixed_string to be compared with. |
true
if strings are not equal. false
otherwise. Definition at line 227 of file fixed_size_string.hpp.
|
inlinenoexcept |
Compares inequality with a std::string.
[in] | rhs | std::string to be compared with. |
true
if strings are not equal. false
otherwise. Definition at line 216 of file fixed_size_string.hpp.
|
inlinenoexcept |
Compares relational less than with a fixed_string of any size.
[in] | rhs | fixed_string to be compared with. |
true
if this string is less than the provided one. false
otherwise. Definition at line 238 of file fixed_size_string.hpp.
|
inlinenoexcept |
Compares relational less than with a std::string of any size.
[in] | rhs | std::string to be compared with. |
true
if this string is less than the provided one. false
otherwise. Definition at line 260 of file fixed_size_string.hpp.
|
inlinenoexcept |
Assigns from a C string.
[in] | c_string | Pointer to the C string. |
Definition at line 107 of file fixed_size_string.hpp.
|
inlinenoexcept |
Assigns from a fixed_string of any size.
[in] | rhs | Reference to the fixed_string. return Reference of this instance. |
Definition at line 142 of file fixed_size_string.hpp.
|
inlinenoexcept |
Assigns from a std::string.
[in] | str | Reference to the std::string. return Reference of this instance. |
Definition at line 130 of file fixed_size_string.hpp.
|
inlinenoexcept |
Compares equality with a C string.
[in] | rhs | C string to be compared with. |
true
if strings are equal. false
otherwise. Definition at line 172 of file fixed_size_string.hpp.
|
inlinenoexcept |
Compares equality with a fixed_string of any size.
[in] | rhs | fixed_string to be compared with. |
true
if strings are equal. false
otherwise. Definition at line 194 of file fixed_size_string.hpp.
|
inlinenoexcept |
Compares equality with a std::string.
[in] | rhs | std::string to be compared with. |
true
if strings are equal. false
otherwise. Definition at line 183 of file fixed_size_string.hpp.
|
inlinenoexcept |
Compares relational greater than with a fixed_string of any size.
[in] | rhs | fixed_string to be compared with. |
true
if this string is greater than the provided one. false
otherwise. Definition at line 249 of file fixed_size_string.hpp.
|
inlinenoexcept |
Compares relational greater than with a std::string of any size.
[in] | rhs | std::string to be compared with. |
true
if this string is greater than the provided one. false
otherwise. Definition at line 271 of file fixed_size_string.hpp.
|
inlineprivatenoexcept |
Definition at line 328 of file fixed_size_string.hpp.
|
inlinenoexcept |
Returns the size of the string.
Definition at line 288 of file fixed_size_string.hpp.
|
inline |
Converts to std::string.
Definition at line 162 of file fixed_size_string.hpp.
|
staticconstexpr |
Maximum number of characters.
Definition at line 49 of file fixed_size_string.hpp.
|
private |
Holds string data, including ending null character.
Definition at line 335 of file fixed_size_string.hpp.
|
private |
Holds current string length.
Definition at line 336 of file fixed_size_string.hpp.