#include <rll/fixed_string.h>
template <std:: size_t N>
fixed_string struct
Fixed size string class.
Template parameters | |
---|---|
N | The maximum number of characters the fixed_ |
fixed_
Public types
-
using const_iterator = const_
pointer - Type of constant iterator for traversing the string.
- using const_pointer = char const *
- Type of constant pointer to the string data.
- using const_reference = char const &
- Type of constant reference to a character in the string.
-
using const_reverse_iterator = std::
reverse_iterator<const_ iterator> - Type of constant reverse iterator for traversing the string in reverse.
- using value_type = char
- Type of character in a string.
Public static variables
- static auto max_length constexpr
Constructors, destructors, conversion operators
- fixed_string() defaulted constexpr noexcept
- Default constructor.
-
template <typename T>fixed_string(T const (&data)[N+1]) constexpr noexcept(…)
- Constructs a fixed_
string from a character array. -
template <typename T>fixed_string(T const (&data)[N+1], bool& error) constexpr noexcept
- Constructs a fixed_
string from a character array.
Public functions
-
auto at(std::
size_t n) const → const_ reference constexpr noexcept - Accesses the character at the specified location with bounds checking.
-
auto back() const → const_
reference constexpr noexcept - Accesses the last element.
-
auto begin() const → const_
iterator constexpr noexcept - Retrieves the begin iterator of the fixed_
string. - auto capacity() const → size_t constexpr noexcept
- Retrieves the capacity of the fixed_
string. -
auto cbegin() const → const_
iterator constexpr noexcept - Retrieves the constant begin iterator of the fixed_
string. -
auto cend() const → const_
iterator constexpr noexcept - Retrieves the constant end iterator of the fixed_
string. -
template <size_t N2>auto compare(fixed_
string<N2> const& rhs) const → int constexpr noexcept - Compares the string with another fixed_
string. -
auto crbegin() const → const_
reverse_ iterator constexpr noexcept - Retrieves the constant reverse begin iterator of the fixed_
string. -
auto crend() const → const_
reverse_ iterator constexpr noexcept - Retrieves the constant reverse end iterator of the fixed_
string. -
auto data() const → const_
pointer constexpr noexcept - Provides a pointer to the underlying data.
- auto empty() const → bool constexpr noexcept
- Checks if the fixed_
string is empty. -
auto end() const → const_
iterator constexpr noexcept - Retrieves the end iterator of the fixed_
string. -
auto front() const → const_
reference constexpr noexcept - Accesses the first element.
-
auto hash() const → std::
size_t constexpr noexcept - Calculates the hash of the string.
-
auto operator[](std::
size_t const n) const → const_ reference constexpr noexcept - Accesses the character at the specified location with bounds checking.
-
auto rbegin() const → const_
reverse_ iterator constexpr noexcept - Retrieves the reverse begin iterator of the fixed_
string. -
auto rend() const → const_
reverse_ iterator constexpr noexcept - Retrieves the reverse end iterator of the fixed_
string. - auto size() const → size_t constexpr noexcept
- Retrieves the size of the fixed_
string. -
void swap(fixed_
string& other) constexpr noexcept - Swaps the contents with another fixed_
string.
Public variables
Function documentation
template <std:: size_t N>
rll::fixed_string::fixed_string() defaulted constexpr noexcept
Default constructor.
Constructs a fixed_
rll::fixed_string::fixed_string(T const (&data)[N+1]) constexpr noexcept(…)
Constructs a fixed_
Template parameters | |
---|---|
T | The character type of the input array. |
Parameters | |
data in | The character array to initialize the fixed_ |
Exceptions | |
parse_error | Thrown if contains unexpected characters for addresses |
This constructor template initializes a fixed_
rll::fixed_string::fixed_string(T const (&data)[N+1], bool& error) constexpr noexcept
Constructs a fixed_
Template parameters | |
---|---|
T | The character type of the input array. |
Parameters | |
data in | The character array to initialize the fixed_ |
error out | A reference to an bool object that will be set to true if an error occurs during parsing. |
This constructor template initializes a fixed_
template <std:: size_t N>
const_ reference rll::fixed_string::at(std:: size_t n) const constexpr noexcept
Accesses the character at the specified location with bounds checking.
Parameters | |
---|---|
n in | The position of the character to return. |
Returns | A reference to the character at the specified location. |
Exceptions | |
std:: |
When going beyond the bounds of the character array. |
Returns a reference to the character at the specified location n. If n is out of bounds, an exception of type std::
will be thrown.
template <std:: size_t N>
const_ reference rll::fixed_string::back() const constexpr noexcept
Accesses the last element.
Returns | Reference to the last element. |
---|
Provides a reference to the last element in the string. Undefined behavior occurs if this function is called on an empty string.
template <std:: size_t N>
const_ iterator rll::fixed_string::begin() const constexpr noexcept
Retrieves the begin iterator of the fixed_
Returns | A constant iterator to the beginning of the fixed_ |
---|
Returns an iterator pointing to the first character of the fixed_
template <std:: size_t N>
size_t rll::fixed_string::capacity() const constexpr noexcept
Retrieves the capacity of the fixed_
Returns | The capacity of the fixed_ |
---|
Returns the total number of characters that the fixed_
template <std:: size_t N>
const_ iterator rll::fixed_string::cbegin() const constexpr noexcept
Retrieves the constant begin iterator of the fixed_
Returns | A constant iterator to the beginning of the fixed_ |
---|
Returns a constant iterator pointing to the first character of the fixed_
template <std:: size_t N>
const_ iterator rll::fixed_string::cend() const constexpr noexcept
Retrieves the constant end iterator of the fixed_
Returns | A constant iterator to the end of the fixed_ |
---|
Returns a constant iterator pointing to the past-the-end character of the fixed_
int rll::fixed_string::compare(fixed_ string<N2> const& rhs) const constexpr noexcept
Compares the string with another fixed_
Template parameters | |
---|---|
N2 | The size of the other fixed_ |
Parameters | |
rhs in | The other fixed_ |
Returns | Negative value if less, zero if equal, positive value if greater. |
template <std:: size_t N>
const_ reverse_ iterator rll::fixed_string::crbegin() const constexpr noexcept
Retrieves the constant reverse begin iterator of the fixed_
Returns | A constant reverse iterator to the beginning of the reversed fixed_ |
---|
Returns a constant reverse iterator pointing to the last character of the fixed_
template <std:: size_t N>
const_ reverse_ iterator rll::fixed_string::crend() const constexpr noexcept
Retrieves the constant reverse end iterator of the fixed_
Returns | A constant reverse iterator to the end of the reversed fixed_ |
---|
Returns a reverse iterator pointing to the position preceding the first character of the fixed_
template <std:: size_t N>
const_ pointer rll::fixed_string::data() const constexpr noexcept
Provides a pointer to the underlying data.
Returns | Pointer to the underlying data storage. |
---|
Returns a pointer to the underlying array serving as the string's storage. The range [data(), data() + size()) is valid even if the string is empty, but the data is not dereferenceable in that case.
template <std:: size_t N>
bool rll::fixed_string::empty() const constexpr noexcept
Checks if the fixed_
Returns | true if the fixed_false otherwise. |
---|
Evaluates whether the fixed_
template <std:: size_t N>
const_ iterator rll::fixed_string::end() const constexpr noexcept
Retrieves the end iterator of the fixed_
Returns | A constant iterator to the element following the last character. |
---|
Returns an iterator pointing to the past-the-end character of the fixed_
template <std:: size_t N>
const_ reference rll::fixed_string::front() const constexpr noexcept
Accesses the first element.
Returns | Reference to the first element. |
---|
Provides a reference to the first element in the string. Undefined behavior occurs if this function is called on an empty string.
template <std:: size_t N>
std:: size_t rll::fixed_string::hash() const constexpr noexcept
Calculates the hash of the string.
Returns | The hash value of the string. |
---|
Computes a hash value for the string using a FNV-1a hash function.
template <std:: size_t N>
const_ reference rll::fixed_string::operator[](std:: size_t const n) const constexpr noexcept
Accesses the character at the specified location with bounds checking.
Parameters | |
---|---|
n in | The position of the character to return. |
Returns | A reference to the character at the specified location. |
Exceptions | |
std:: |
When going beyond the bounds of the character array. |
Returns a reference to the character at the specified location n. If n is out of bounds, an exception of type std::
will be thrown.
template <std:: size_t N>
const_ reverse_ iterator rll::fixed_string::rbegin() const constexpr noexcept
Retrieves the reverse begin iterator of the fixed_
Returns | A constant reverse iterator to the beginning of the reversed fixed_ |
---|
Returns a reverse iterator pointing to the last character of the fixed_
template <std:: size_t N>
const_ reverse_ iterator rll::fixed_string::rend() const constexpr noexcept
Retrieves the reverse end iterator of the fixed_
Returns | A constant reverse iterator to the end of the reversed fixed_ |
---|
Returns a reverse iterator pointing to the position preceding the first character of the fixed_
template <std:: size_t N>
size_t rll::fixed_string::size() const constexpr noexcept
Retrieves the size of the fixed_
Returns | The number of characters in the fixed_ |
---|
Returns the number of characters currently stored in the fixed_
template <std:: size_t N>
void rll::fixed_string::swap(fixed_ string& other) constexpr noexcept
Swaps the contents with another fixed_
Parameters | |
---|---|
other in/out | The other fixed_ |
fixed_ string<N - 1> make_fixed_string(T const(&data)[N]) constexpr noexcept(…)
Creates a fixed-length string from a character array.
Template parameters | |
---|---|
T | The character type of the input array. |
N | The size of the character array plus one for the null terminator. |
Parameters | |
data in | The character array to initialize the fixed_ |
Returns | A fixed_ |
Constructs a fixed_
fixed_ string<N - 1> make_fixed_string(T const(&data)[N],
bool& code) constexpr noexcept
Creates a fixed-length string from a character array.
Template parameters | |
---|---|
T | The character type of the input array. |
N | The size of the character array plus one for the null terminator. |
Parameters | |
data in | The character array to initialize the fixed_ |
code out | A reference to an error_code object that will be set if an error occurs during parsing. |
Returns | A fixed_ |
Constructs a fixed_
bool operator!=(fixed_ string<N1> const& lhs,
fixed_ string<N2> const& rhs) constexpr noexcept
Compares the contents of two fixed strings for inequality.
Template parameters | |
---|---|
N1 | The maximum number of characters of lhs. |
N2 | The maximum number of characters of rhs. |
Parameters | |
lhs in | The fixed string whose contents to compare. |
rhs in | The fixed string whose contents to compare. |
Returns | true if the contents of the strings are not equal, false otherwise. |
Checks if the contents of lhs and rhs are not equal, meaning they do not have the same number of elements or there is at least one position at which the elements in lhs and rhs differ.
bool operator<(fixed_ string<N1> const& lhs,
fixed_ string<N2> const& rhs) constexpr noexcept
Compares the contents of two fixed strings lexicographically.
Template parameters | |
---|---|
N1 | The maximum number of characters of lhs. |
N2 | The maximum number of characters of rhs. |
Parameters | |
lhs in | The fixed string whose contents to compare. |
rhs in | The fixed string whose contents to compare. |
Returns | true if the contents of lhs are lexicographically less than the contents of rhs, false otherwise. |
Checks if the contents of lhs are lexicographically less than the contents of rhs.
bool operator<=(fixed_ string<N1> const& lhs,
fixed_ string<N2> const& rhs) constexpr noexcept
Compares the contents of two fixed strings for less than or equal relation.
Template parameters | |
---|---|
N1 | The maximum number of characters of lhs. |
N2 | The maximum number of characters of rhs. |
Parameters | |
lhs in | The fixed string whose contents to compare. |
rhs in | The fixed string whose contents to compare. |
Returns | true if lhs is lexicographically less than or equal to rhs, false otherwise. |
Determines if the contents of lhs are lexicographically less than or equal to the contents of rhs.
bool operator==(fixed_ string<N1> const& lhs,
fixed_ string<N2> const& rhs) constexpr noexcept
Compares the contents of two fixed strings for equality.
Template parameters | |
---|---|
N1 | The maximum number of characters of lhs. |
N2 | The maximum number of characters of rhs. |
Parameters | |
lhs in | The fixed string whose contents to compare. |
rhs in | The fixed string whose contents to compare. |
Returns | true if the contents of the strings are equal, false otherwise. |
Checks if the contents of lhs and rhs are equal, meaning they have the same number of elements and each element in lhs compares equal with the element in rhs at the same position.
bool operator>(fixed_ string<N1> const& lhs,
fixed_ string<N2> const& rhs) constexpr noexcept
Compares the contents of two fixed strings for greater than relation.
Template parameters | |
---|---|
N1 | The maximum number of characters of lhs. |
N2 | The maximum number of characters of rhs. |
Parameters | |
lhs in | The fixed string whose contents to compare. |
rhs in | The fixed string whose contents to compare. |
Returns | true if lhs is lexicographically greater than rhs, false otherwise. |
Determines if the contents of lhs are lexicographically greater than the contents of rhs.
bool operator>=(fixed_ string<N1> const& lhs,
fixed_ string<N2> const& rhs) constexpr noexcept
Compares the contents of two fixed strings for greater than or equal relation.
Template parameters | |
---|---|
N1 | The maximum number of characters of lhs. |
N2 | The maximum number of characters of rhs. |
Parameters | |
lhs in | The fixed string whose contents to compare. |
rhs in | The fixed string whose contents to compare. |
Returns | true if lhs is lexicographically greater than or equal to rhs, false otherwise. |
Determines if the contents of lhs are lexicographically greater than or equal to the contents of rhs.