Public Member Functions | Static Public Attributes | Private Member Functions | Private Attributes | List of all members
eprosima::fastcdr::fixed_string< MAX_CHARS > Struct Template Reference

Template class for non-alloc strings. More...

#include <fixed_size_string.hpp>

Public Member Functions

fixed_stringassign (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_stringoperator= (const char *c_string) noexcept
 Assigns from a C string. More...
 
template<size_t N>
fixed_stringoperator= (const fixed_string< N > &rhs) noexcept
 Assigns from a fixed_string of any size. More...
 
fixed_stringoperator= (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...
 

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.

Definition at line 44 of file fixed_size_string.hpp.

Constructor & Destructor Documentation

◆ fixed_string() [1/4]

template<size_t MAX_CHARS>
eprosima::fastcdr::fixed_string< MAX_CHARS >::fixed_string ( )
inlinenoexcept

Default constructor.

Definition at line 52 of file fixed_size_string.hpp.

◆ fixed_string() [2/4]

template<size_t MAX_CHARS>
eprosima::fastcdr::fixed_string< 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

Definition at line 65 of file fixed_size_string.hpp.

◆ fixed_string() [3/4]

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

Constructs from a C string.

Parameters
[in]c_stringPointer to the C string.

Definition at line 95 of file fixed_size_string.hpp.

◆ fixed_string() [4/4]

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

Constructs from a std::string.

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

Definition at line 118 of file fixed_size_string.hpp.

Member Function Documentation

◆ assign()

template<size_t MAX_CHARS>
fixed_string& eprosima::fastcdr::fixed_string< MAX_CHARS >::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.

Definition at line 78 of file fixed_size_string.hpp.

◆ c_str()

template<size_t MAX_CHARS>
const char* eprosima::fastcdr::fixed_string< MAX_CHARS >::c_str ( ) const
inlinenoexcept

Converts to C string.

Returns
Pointer to the C string.

Definition at line 153 of file fixed_size_string.hpp.

◆ compare() [1/3]

template<size_t MAX_CHARS>
int eprosima::fastcdr::fixed_string< MAX_CHARS >::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().

Definition at line 298 of file fixed_size_string.hpp.

◆ compare() [2/3]

template<size_t MAX_CHARS>
template<size_t N>
int eprosima::fastcdr::fixed_string< MAX_CHARS >::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().

Definition at line 320 of file fixed_size_string.hpp.

◆ compare() [3/3]

template<size_t MAX_CHARS>
int eprosima::fastcdr::fixed_string< MAX_CHARS >::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().

Definition at line 309 of file fixed_size_string.hpp.

◆ operator const char *()

template<size_t MAX_CHARS>
eprosima::fastcdr::fixed_string< MAX_CHARS >::operator const char * ( ) const
inlinenoexcept

Casts to a C string.

Definition at line 280 of file fixed_size_string.hpp.

◆ operator!=() [1/3]

template<size_t MAX_CHARS>
bool eprosima::fastcdr::fixed_string< MAX_CHARS >::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.

Definition at line 205 of file fixed_size_string.hpp.

◆ operator!=() [2/3]

template<size_t MAX_CHARS>
template<size_t N>
bool eprosima::fastcdr::fixed_string< MAX_CHARS >::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.

Definition at line 227 of file fixed_size_string.hpp.

◆ operator!=() [3/3]

template<size_t MAX_CHARS>
bool eprosima::fastcdr::fixed_string< MAX_CHARS >::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.

Definition at line 216 of file fixed_size_string.hpp.

◆ operator<() [1/2]

template<size_t MAX_CHARS>
template<size_t N>
bool eprosima::fastcdr::fixed_string< MAX_CHARS >::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.

Definition at line 238 of file fixed_size_string.hpp.

◆ operator<() [2/2]

template<size_t MAX_CHARS>
bool eprosima::fastcdr::fixed_string< MAX_CHARS >::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.

Definition at line 260 of file fixed_size_string.hpp.

◆ operator=() [1/3]

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

Assigns from a C string.

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

Definition at line 107 of file fixed_size_string.hpp.

◆ operator=() [2/3]

template<size_t MAX_CHARS>
template<size_t N>
fixed_string& eprosima::fastcdr::fixed_string< MAX_CHARS >::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.

Definition at line 142 of file fixed_size_string.hpp.

◆ operator=() [3/3]

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

Assigns from a std::string.

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

Definition at line 130 of file fixed_size_string.hpp.

◆ operator==() [1/3]

template<size_t MAX_CHARS>
bool eprosima::fastcdr::fixed_string< MAX_CHARS >::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.

Definition at line 172 of file fixed_size_string.hpp.

◆ operator==() [2/3]

template<size_t MAX_CHARS>
template<size_t N>
bool eprosima::fastcdr::fixed_string< MAX_CHARS >::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.

Definition at line 194 of file fixed_size_string.hpp.

◆ operator==() [3/3]

template<size_t MAX_CHARS>
bool eprosima::fastcdr::fixed_string< MAX_CHARS >::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.

Definition at line 183 of file fixed_size_string.hpp.

◆ operator>() [1/2]

template<size_t MAX_CHARS>
template<size_t N>
bool eprosima::fastcdr::fixed_string< MAX_CHARS >::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.

Definition at line 249 of file fixed_size_string.hpp.

◆ operator>() [2/2]

template<size_t MAX_CHARS>
bool eprosima::fastcdr::fixed_string< MAX_CHARS >::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.

Definition at line 271 of file fixed_size_string.hpp.

◆ set()

template<size_t MAX_CHARS>
void eprosima::fastcdr::fixed_string< MAX_CHARS >::set ( const char *  c_string)
inlineprivatenoexcept

Definition at line 328 of file fixed_size_string.hpp.

◆ size()

template<size_t MAX_CHARS>
size_t eprosima::fastcdr::fixed_string< MAX_CHARS >::size ( ) const
inlinenoexcept

Returns the size of the string.

Returns
Length of the string.

Definition at line 288 of file fixed_size_string.hpp.

◆ to_string()

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

Converts to std::string.

Returns
Reference to the std::string.

Definition at line 162 of file fixed_size_string.hpp.

Member Data Documentation

◆ max_size

template<size_t MAX_CHARS>
constexpr size_t eprosima::fastcdr::fixed_string< MAX_CHARS >::max_size = MAX_CHARS
staticconstexpr

Maximum number of characters.

Definition at line 49 of file fixed_size_string.hpp.

◆ string_data

template<size_t MAX_CHARS>
char eprosima::fastcdr::fixed_string< MAX_CHARS >::string_data[MAX_CHARS+1]
private

Holds string data, including ending null character.

Definition at line 335 of file fixed_size_string.hpp.

◆ string_len

template<size_t MAX_CHARS>
size_t eprosima::fastcdr::fixed_string< MAX_CHARS >::string_len
private

Holds current string length.

Definition at line 336 of file fixed_size_string.hpp.


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


plotjuggler
Author(s): Davide Faconti
autogenerated on Mon Nov 11 2024 03:23:52