Template class for non-alloc strings. More...
#include <fixed_size_string.hpp>
Public Member Functions | |
fixed_string () noexcept | |
Default constructor. | |
fixed_string (const char *c_array, size_t n_chars) noexcept | |
Constructs from a char array. | |
fixed_string & | assign (const char *c_array, size_t n_chars) noexcept |
Assigns from a char array. | |
fixed_string (const char *c_string) noexcept | |
Constructs from a C string. | |
fixed_string & | operator= (const char *c_string) noexcept |
Assigns from a C string. | |
fixed_string (const std::string &str) noexcept | |
Constructs from a std::string. | |
fixed_string & | operator= (const std::string &str) noexcept |
Assigns from a std::string. | |
template<size_t N> | |
fixed_string & | operator= (const fixed_string< N > &rhs) noexcept |
Assigns from a fixed_string of any size. | |
const char * | c_str () const noexcept |
Converts to C string. | |
std::string | to_string () const |
Converts to std::string. | |
bool | operator== (const char *rhs) const noexcept |
Compares equality with a C string. | |
bool | operator== (const std::string &rhs) const noexcept |
Compares equality with a std::string. | |
template<size_t N> | |
bool | operator== (const fixed_string< N > &rhs) const noexcept |
Compares equality with a fixed_string of any size. | |
bool | operator!= (const char *rhs) const noexcept |
Compares inequality with a C string. | |
bool | operator!= (const std::string &rhs) const noexcept |
Compares inequality with a std::string. | |
template<size_t N> | |
bool | operator!= (const fixed_string< N > &rhs) const noexcept |
Compares inequality with a fixed_string of any size. | |
template<size_t N> | |
bool | operator< (const fixed_string< N > &rhs) const noexcept |
Compares relational less than with a fixed_string of any size. | |
template<size_t N> | |
bool | operator> (const fixed_string< N > &rhs) const noexcept |
Compares relational greater than with a fixed_string of any size. | |
bool | operator< (const std::string &rhs) const noexcept |
Compares relational less than with a std::string of any size. | |
bool | operator> (const std::string &rhs) const noexcept |
Compares relational greater than with a std::string of any size. | |
operator const char * () const noexcept | |
Casts to a C string. | |
size_t | size () const noexcept |
Returns the size of the string. | |
int | compare (const char *str) const noexcept |
Compares with a C string. | |
int | compare (const std::string &str) const noexcept |
Compares with a std::string. | |
template<size_t N> | |
int | compare (const fixed_string< N > &str) const noexcept |
Compares with a fixed_string. | |
Static Public Attributes | |
static constexpr size_t | max_size = MAX_CHARS |
Maximum number of characters. | |
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. |
|
inlinenoexcept |
Default constructor.
|
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 |
|
inlinenoexcept |
Constructs from a C string.
[in] | c_string | Pointer to the C string. |
|
inlinenoexcept |
Constructs from a std::string.
[in] | str | Reference to the std::string. |
|
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. |
|
inlinenoexcept |
Converts to C string.
|
inlinenoexcept |
Compares with a C string.
[in] | str | C string to be compared with. |
std::string::compare()
.
|
inlinenoexcept |
Compares with a fixed_string.
[in] | str | fixed_string to be compared with. |
std::string::compare()
.
|
inlinenoexcept |
Compares with a std::string.
[in] | str | std::string to be compared with. |
std::string::compare()
.
|
inlinenoexcept |
Casts to a C string.
|
inlinenoexcept |
Compares inequality with a C string.
[in] | rhs | C string to be compared with. |
true
if strings are not equal. false
otherwise.
|
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.
|
inlinenoexcept |
Compares inequality with a std::string.
[in] | rhs | std::string to be compared with. |
true
if strings are not equal. false
otherwise.
|
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.
|
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.
|
inlinenoexcept |
Assigns from a C string.
[in] | c_string | Pointer to the C string. |
|
inlinenoexcept |
Assigns from a fixed_string of any size.
[in] | rhs | Reference to the fixed_string. return Reference of this instance. |
|
inlinenoexcept |
Assigns from a std::string.
[in] | str | Reference to the std::string. return Reference of this instance. |
|
inlinenoexcept |
Compares equality with a C string.
[in] | rhs | C string to be compared with. |
true
if strings are equal. false
otherwise.
|
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.
|
inlinenoexcept |
Compares equality with a std::string.
[in] | rhs | std::string to be compared with. |
true
if strings are equal. false
otherwise.
|
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.
|
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.
|
inlinenoexcept |
Returns the size of the string.
|
inline |
Converts to std::string.
|
staticconstexpr |
Maximum number of characters.