13#ifndef NROS_CPP_FIXED_STRING_HPP
14#define NROS_CPP_FIXED_STRING_HPP
46 for (; i < N - 1 && s[i] !=
'\0'; ++i) {
59 while (len < N &&
data[len] !=
'\0')
65 static constexpr size_t capacity() {
return N - 1; }
69 if (s ==
nullptr)
return data[0] ==
'\0';
70 return strncmp(
data, s, N) == 0;
73 bool operator!=(
const char* s)
const {
return !(*
this == s); }
Definition fixed_string.hpp:33
FixedString & operator=(const char *s)
Assign from a C string. Truncates if longer than capacity.
Definition fixed_string.hpp:40
const char * c_str() const
Get a pointer to the null-terminated string.
Definition fixed_string.hpp:54
char data[N]
Definition fixed_string.hpp:34
bool operator==(const char *s) const
Compare with a C string.
Definition fixed_string.hpp:68
FixedString()
Default constructor — empty string.
Definition fixed_string.hpp:37
static constexpr size_t capacity()
Maximum number of characters (excluding null terminator).
Definition fixed_string.hpp:65
size_t length() const
Get the length of the string (up to N-1).
Definition fixed_string.hpp:57
bool operator!=(const char *s) const
Definition fixed_string.hpp:73