Go to the documentation of this file.
20 #ifndef FASTCDR_UTILS_FIXED_SIZE_STRING_HPP_
21 #define FASTCDR_UTILS_FIXED_SIZE_STRING_HPP_
27 #define MEMCCPY _memccpy
29 #define MEMCCPY memccpy
30 #endif // ifdef _WIN32
43 template <
size_t MAX_CHARS>
67 size_t n_chars) noexcept
80 size_t n_chars) noexcept
83 (MAX_CHARS < n_chars) ? MAX_CHARS : n_chars;
96 const char* c_string) noexcept
99 set(c_string !=
nullptr ? c_string :
"");
108 const char* c_string) noexcept
110 set(c_string !=
nullptr ? c_string :
"");
119 const std::string& str) noexcept
131 const std::string& str) noexcept
173 const char* rhs)
const noexcept
184 const std::string& rhs)
const noexcept
186 return strncmp(
string_data, rhs.c_str(), MAX_CHARS) == 0;
197 return strncmp(
string_data, rhs.c_str(), MAX_CHARS) == 0;
206 const char* rhs)
const noexcept
208 return !(*
this == rhs);
217 const std::string& rhs)
const noexcept
219 return !(*
this == rhs);
230 return !(*
this == rhs);
261 const std::string& rhs)
const noexcept
272 const std::string& rhs)
const noexcept
280 operator const char* ()
const noexcept {
299 const char* str)
const noexcept
310 const std::string& str)
const noexcept
312 return strncmp(
string_data, str.c_str(), MAX_CHARS);
323 return strncmp(
string_data, str.c_str(), MAX_CHARS);
329 const char* c_string) noexcept
bool operator<(const fixed_string< N > &rhs) const noexcept
Compares relational less than with a fixed_string of any size.
fixed_string(const std::string &str) noexcept
Constructs from a std::string.
char string_data[MAX_CHARS+1]
Holds string data, including ending null character.
const char * c_str() const noexcept
Converts to C string.
size_t size() const noexcept
Returns the size of the string.
bool operator!=(const char *rhs) const noexcept
Compares inequality with a C string.
std::string to_string() const
Converts to std::string.
fixed_string(const char *c_array, size_t n_chars) noexcept
Constructs from a char array.
void set(const char *c_string) noexcept
int compare(const std::string &str) const noexcept
Compares with a std::string.
static constexpr size_t max_size
Maximum number of characters.
fixed_string & assign(const char *c_array, size_t n_chars) noexcept
Assigns from a char array.
size_t string_len
Holds current string length.
bool operator>(const fixed_string< N > &rhs) const noexcept
Compares relational greater than with a fixed_string of any size.
fixed_string() noexcept
Default constructor.
fixed_string(const char *c_string) noexcept
Constructs from a C string.
Template class for non-alloc strings.
fixed_string & operator=(const char *c_string) noexcept
Assigns from a C string.
int compare(const fixed_string< N > &str) const noexcept
Compares with a fixed_string.
int compare(const char *str) const noexcept
Compares with a C string.
bool operator==(const char *rhs) const noexcept
Compares equality with a C string.
plotjuggler
Author(s): Davide Faconti
autogenerated on Mon Nov 11 2024 03:23:44