Fast CDR  Version 2.2.5
Fast CDR
Loading...
Searching...
No Matches
fixed_string< MAX_CHARS > Struct Template Reference

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_stringassign (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_stringoperator= (const char *c_string) noexcept
 Assigns from a C string.
 
 fixed_string (const std::string &str) noexcept
 Constructs from a std::string.
 
fixed_stringoperator= (const std::string &str) noexcept
 Assigns from a std::string.
 
template<size_t N>
fixed_stringoperator= (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.
 

Detailed Description

template<size_t MAX_CHARS>
struct eprosima::fastcdr::fixed_string< MAX_CHARS >

Template class for non-alloc strings.

Will be truncated when assigned from a longer string.

Template Parameters
MAX_CHARSMaximum number of characters is specified as the template parameter. Space for an additional null terminator will be reserved.

Constructor & Destructor Documentation

◆ fixed_string() [1/4]

template<size_t MAX_CHARS>
fixed_string ( )
inlinenoexcept

Default constructor.

◆ fixed_string() [2/4]

template<size_t MAX_CHARS>
fixed_string ( const char *  c_array,
size_t  n_chars 
)
inlinenoexcept

Constructs from a char array.

Parameters
[in]c_arrayChar array to be constructed from.
[in]n_charsNumber of characters of the Char array

◆ fixed_string() [3/4]

template<size_t MAX_CHARS>
fixed_string ( const char *  c_string)
inlinenoexcept

Constructs from a C string.

Parameters
[in]c_stringPointer to the C string.

◆ fixed_string() [4/4]

template<size_t MAX_CHARS>
fixed_string ( const std::string &  str)
inlinenoexcept

Constructs from a std::string.

Parameters
[in]strReference to the std::string.

Member Function Documentation

◆ assign()

template<size_t MAX_CHARS>
fixed_string & assign ( const char *  c_array,
size_t  n_chars 
)
inlinenoexcept

Assigns from a char array.

Parameters
[in]c_arrayChar array to be assigned from.
[in]n_charsNumber of characters of the Char array.
Returns
Reference of this instance.

◆ c_str()

template<size_t MAX_CHARS>
const char * c_str ( ) const
inlinenoexcept

Converts to C string.

Returns
Pointer to the C string.

◆ compare() [1/3]

template<size_t MAX_CHARS>
int compare ( const char *  str) const
inlinenoexcept

Compares with a C string.

Parameters
[in]strC string to be compared with.
Returns
Integer value with the result of the comparison as described in std::string::compare().

◆ compare() [2/3]

template<size_t MAX_CHARS>
template<size_t N>
int compare ( const fixed_string< N > &  str) const
inlinenoexcept

Compares with a fixed_string.

Parameters
[in]strfixed_string to be compared with.
Returns
Integer value with the result of the comparison as described in std::string::compare().

◆ compare() [3/3]

template<size_t MAX_CHARS>
int compare ( const std::string &  str) const
inlinenoexcept

Compares with a std::string.

Parameters
[in]strstd::string to be compared with.
Returns
Integer value with the result of the comparison as described in std::string::compare().

◆ operator const char *()

template<size_t MAX_CHARS>
operator const char * ( ) const
inlinenoexcept

Casts to a C string.

◆ operator!=() [1/3]

template<size_t MAX_CHARS>
bool operator!= ( const char *  rhs) const
inlinenoexcept

Compares inequality with a C string.

Parameters
[in]rhsC string to be compared with.
Returns
true if strings are not equal. false otherwise.

◆ operator!=() [2/3]

template<size_t MAX_CHARS>
template<size_t N>
bool operator!= ( const fixed_string< N > &  rhs) const
inlinenoexcept

Compares inequality with a fixed_string of any size.

Parameters
[in]rhsfixed_string to be compared with.
Returns
true if strings are not equal. false otherwise.

◆ operator!=() [3/3]

template<size_t MAX_CHARS>
bool operator!= ( const std::string &  rhs) const
inlinenoexcept

Compares inequality with a std::string.

Parameters
[in]rhsstd::string to be compared with.
Returns
true if strings are not equal. false otherwise.

◆ operator<() [1/2]

template<size_t MAX_CHARS>
template<size_t N>
bool operator< ( const fixed_string< N > &  rhs) const
inlinenoexcept

Compares relational less than with a fixed_string of any size.

Parameters
[in]rhsfixed_string to be compared with.
Returns
true if this string is less than the provided one. false otherwise.

◆ operator<() [2/2]

template<size_t MAX_CHARS>
bool operator< ( const std::string &  rhs) const
inlinenoexcept

Compares relational less than with a std::string of any size.

Parameters
[in]rhsstd::string to be compared with.
Returns
true if this string is less than the provided one. false otherwise.

◆ operator=() [1/3]

template<size_t MAX_CHARS>
fixed_string & operator= ( const char *  c_string)
inlinenoexcept

Assigns from a C string.

Parameters
[in]c_stringPointer to the C string.
Returns
Reference of this instance.

◆ operator=() [2/3]

template<size_t MAX_CHARS>
template<size_t N>
fixed_string & operator= ( const fixed_string< N > &  rhs)
inlinenoexcept

Assigns from a fixed_string of any size.

Parameters
[in]rhsReference to the fixed_string. return Reference of this instance.

◆ operator=() [3/3]

template<size_t MAX_CHARS>
fixed_string & operator= ( const std::string &  str)
inlinenoexcept

Assigns from a std::string.

Parameters
[in]strReference to the std::string. return Reference of this instance.

◆ operator==() [1/3]

template<size_t MAX_CHARS>
bool operator== ( const char *  rhs) const
inlinenoexcept

Compares equality with a C string.

Parameters
[in]rhsC string to be compared with.
Returns
true if strings are equal. false otherwise.

◆ operator==() [2/3]

template<size_t MAX_CHARS>
template<size_t N>
bool operator== ( const fixed_string< N > &  rhs) const
inlinenoexcept

Compares equality with a fixed_string of any size.

Parameters
[in]rhsfixed_string to be compared with.
Returns
true if strings are equal. false otherwise.

◆ operator==() [3/3]

template<size_t MAX_CHARS>
bool operator== ( const std::string &  rhs) const
inlinenoexcept

Compares equality with a std::string.

Parameters
[in]rhsstd::string to be compared with.
Returns
true if strings are equal. false otherwise.

◆ operator>() [1/2]

template<size_t MAX_CHARS>
template<size_t N>
bool operator> ( const fixed_string< N > &  rhs) const
inlinenoexcept

Compares relational greater than with a fixed_string of any size.

Parameters
[in]rhsfixed_string to be compared with.
Returns
true if this string is greater than the provided one. false otherwise.

◆ operator>() [2/2]

template<size_t MAX_CHARS>
bool operator> ( const std::string &  rhs) const
inlinenoexcept

Compares relational greater than with a std::string of any size.

Parameters
[in]rhsstd::string to be compared with.
Returns
true if this string is greater than the provided one. false otherwise.

◆ size()

template<size_t MAX_CHARS>
size_t size ( ) const
inlinenoexcept

Returns the size of the string.

Returns
Length of the string.

◆ to_string()

template<size_t MAX_CHARS>
std::string to_string ( ) const
inline

Converts to std::string.

Returns
Reference to the std::string.

Member Data Documentation

◆ max_size

template<size_t MAX_CHARS>
constexpr size_t max_size = MAX_CHARS
staticconstexpr

Maximum number of characters.


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