| Fast CDR Version 2.3.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_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.

## 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_CHARS | Maximum 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 | ( |  | ) |

inline noexcept

Default constructor.

## ◆ fixed_string() [2/4]

template<size_t MAX_CHARS>

fixed_string | ( | const char * | c_array,
|  | size_t | n_chars )

inline noexcept

Constructs from a char array.

Parameters

  [in] | c_array | Char array to be constructed from.
  [in] | n_chars | Number of characters of the Char array

## ◆ fixed_string() [3/4]

template<size_t MAX_CHARS>

fixed_string | ( | const char * | c_string | ) |

inline noexcept

Constructs from a C string.

Parameters

  [in] | c_string | Pointer to the C string.

## ◆ fixed_string() [4/4]

template<size_t MAX_CHARS>

fixed_string | ( | const std::string & | str | ) |

inline noexcept

Constructs from a std::string.

Parameters

  [in] | str | Reference to the std::string.

## Member Function Documentation

## ◆ assign()

template<size_t MAX_CHARS>

fixed_string & assign | ( | const char * | c_array,
|  | size_t | n_chars )

inline noexcept

Assigns from a char array.

Parameters

  [in] | c_array | Char array to be assigned from.
  [in] | n_chars | Number of characters of the Char array.

Returns
  Reference of this instance.

## ◆ c_str()

template<size_t MAX_CHARS>

const char * c_str | ( |  | ) | const

inline noexcept

Converts to C string.

Returns
  Pointer to the C string.

## ◆ compare() [1/3]

template<size_t MAX_CHARS>

int compare | ( | const char * | str | ) | const

inline noexcept

Compares with a C string.

Parameters

  [in] | str | C 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

inline noexcept

Compares with a fixed_string.

Parameters

  [in] | str | fixed_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

inline noexcept

Compares with a std::string.

Parameters

  [in] | str | std::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

inline noexcept

Casts to a C string.

## ◆ operator!=() [1/3]

template<size_t MAX_CHARS>

bool operator!= | ( | const char * | rhs | ) | const

inline noexcept

Compares inequality with a C string.

Parameters

  [in] | rhs | C 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

inline noexcept

Compares inequality with a fixed_string of any size.

Parameters

  [in] | rhs | fixed_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

inline noexcept

Compares inequality with a std::string.

Parameters

  [in] | rhs | std::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

inline noexcept

Compares relational less than with a fixed_string of any size.

Parameters

  [in] | rhs | fixed_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

inline noexcept

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

Parameters

  [in] | rhs | std::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 | ) |

inline noexcept

Assigns from a C string.

Parameters

  [in] | c_string | Pointer 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 | ) |

inline noexcept

Assigns from a fixed_string of any size.

Parameters

  [in] | rhs | Reference to the fixed_string. return Reference of this instance.

## ◆ operator=() [3/3]

template<size_t MAX_CHARS>

fixed_string & operator= | ( | const std::string & | str | ) |

inline noexcept

Assigns from a std::string.

Parameters

  [in] | str | Reference to the std::string. return Reference of this instance.

## ◆ operator==() [1/3]

template<size_t MAX_CHARS>

bool operator== | ( | const char * | rhs | ) | const

inline noexcept

Compares equality with a C string.

Parameters

  [in] | rhs | C 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

inline noexcept

Compares equality with a fixed_string of any size.

Parameters

  [in] | rhs | fixed_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

inline noexcept

Compares equality with a std::string.

Parameters

  [in] | rhs | std::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

inline noexcept

Compares relational greater than with a fixed_string of any size.

Parameters

  [in] | rhs | fixed_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

inline noexcept

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

Parameters

  [in] | rhs | std::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

inline noexcept

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>

size_t max_size = MAX_CHARS

static constexpr

Maximum number of characters.

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

- include/fastcdr/cdr/fixed_size_string.hpp