ipaddress 1.1.0
|
Fixed size string class. More...
#include <fixed-string.hpp>
Public Types | |
using | value_type = char |
Type of character in a string. | |
using | const_pointer = const char* |
Type of constant pointer to the string data. | |
using | const_reference = const char& |
Type of constant reference to a character in the string. | |
using | const_iterator = const_pointer |
Type of constant iterator for traversing the string. | |
using | const_reverse_iterator = std::reverse_iterator<const_iterator> |
Type of constant reverse iterator for traversing the string in reverse. | |
Public Member Functions | |
constexpr inline | fixed_string () noexcept=default |
Default constructor. | |
template<typename T > | |
constexpr inline | fixed_string (const T(&data)[N+1]) noexcept(noexcept(internal::char_reader< T >::has_throw())) |
Constructs a fixed_string from a character array. | |
template<typename T > | |
constexpr inline | fixed_string (const T(&data)[N+1], error_code &code) noexcept |
Constructs a fixed_string from a character array. | |
constexpr inline const_iterator | begin () const noexcept |
Retrieves the begin iterator of the fixed_string. | |
constexpr inline const_iterator | end () const noexcept |
Retrieves the end iterator of the fixed_string. | |
constexpr inline const_reverse_iterator | rbegin () const noexcept |
Retrieves the reverse begin iterator of the fixed_string. | |
constexpr inline const_reverse_iterator | rend () const noexcept |
Retrieves the reverse end iterator of the fixed_string. | |
constexpr inline const_iterator | cbegin () const noexcept |
Retrieves the constant begin iterator of the fixed_string. | |
constexpr inline const_iterator | cend () const noexcept |
Retrieves the constant end iterator of the fixed_string. | |
constexpr inline const_reverse_iterator | crbegin () const noexcept |
Retrieves the constant reverse begin iterator of the fixed_string. | |
constexpr inline const_reverse_iterator | crend () const noexcept |
Retrieves the constant reverse end iterator of the fixed_string. | |
constexpr inline bool | empty () const noexcept |
Checks if the fixed_string is empty. | |
constexpr inline size_t | size () const noexcept |
Retrieves the size of the fixed_string. | |
constexpr inline size_t | capacity () const noexcept |
Retrieves the capacity of the fixed_string. | |
constexpr inline const_reference | operator[] (size_t n) const noexcept |
Accesses the character at the specified location with bounds checking. | |
constexpr inline const_reference | at (size_t n) const noexcept |
Accesses the character at the specified location with bounds checking. | |
constexpr inline const_reference | front () const noexcept |
Accesses the first element. | |
constexpr inline const_reference | back () const noexcept |
Accesses the last element. | |
constexpr inline const_pointer | data () const noexcept |
Provides a pointer to the underlying data. | |
template<size_t N2> | |
constexpr inline int | compare (const fixed_string< N2 > &rhs) const noexcept |
Compares the string with another fixed_string. | |
constexpr inline size_t | hash () const noexcept |
Calculates the hash of the string. | |
constexpr inline void | swap (fixed_string &other) noexcept |
Swaps the contents with another fixed_string. | |
Fixed size string class.
fixed_string is a template class that encapsulates a string of a fixed number of characters. It is designed to be used where strings are needed as non-type template parameters.
N | The maximum number of characters the fixed_string can hold. |
|
defaultnoexcept |
Default constructor.
Constructs a fixed_string with default values, initializing the string with null characters.
|
inlinenoexcept |
Constructs a fixed_string from a character array.
This constructor template initializes a fixed_string with the contents of a given character array.
T | The character type of the input array. |
[in] | data | The character array to initialize the fixed_string with. |
parse_error | Thrown if contains unexpected characters for addresses |
|
inlinenoexcept |
Constructs a fixed_string from a character array.
This constructor template initializes a fixed_string with the contents of a given character array.
T | The character type of the input array. |
[in] | data | The character array to initialize the fixed_string with. |
[out] | code | A reference to an error_code object that will be set if an error occurs during parsing. |
|
inlinenoexcept |
Retrieves the begin iterator of the fixed_string.
Returns an iterator pointing to the first character of the fixed_string. If the fixed_string is empty, the returned iterator will be equal to the one returned by end().
|
inlinenoexcept |
Retrieves the end iterator of the fixed_string.
Returns an iterator pointing to the past-the-end character of the fixed_string. This iterator acts as a placeholder and should not be dereferenced.
|
inlinenoexcept |
Retrieves the reverse begin iterator of the fixed_string.
Returns a reverse iterator pointing to the last character of the fixed_string. If the fixed_string is empty, the returned iterator will be equal to rend().
|
inlinenoexcept |
Retrieves the reverse end iterator of the fixed_string.
Returns a reverse iterator pointing to the position preceding the first character of the fixed_string. This iterator acts as a placeholder and should not be dereferenced.
|
inlinenoexcept |
Retrieves the constant begin iterator of the fixed_string.
Returns a constant iterator pointing to the first character of the fixed_string. If the fixed_string is empty, the returned iterator will be equal to cend().
|
inlinenoexcept |
Retrieves the constant end iterator of the fixed_string.
Returns a constant iterator pointing to the past-the-end character of the fixed_string. This iterator acts as a placeholder and should not be dereferenced.
|
inlinenoexcept |
Retrieves the constant reverse begin iterator of the fixed_string.
Returns a constant reverse iterator pointing to the last character of the fixed_string. If the fixed_string is empty, the returned iterator will be equal to crend().
|
inlinenoexcept |
Retrieves the constant reverse end iterator of the fixed_string.
Returns a reverse iterator pointing to the position preceding the first character of the fixed_string when reversed. This iterator acts as a placeholder and should not be dereferenced.
|
inlinenoexcept |
Checks if the fixed_string is empty.
Evaluates whether the fixed_string contains no characters.
true
if the fixed_string is empty, false
otherwise.
|
inlinenoexcept |
Retrieves the size of the fixed_string.
Returns the number of characters currently stored in the fixed_string.
|
inlinenoexcept |
Retrieves the capacity of the fixed_string.
Returns the total number of characters that the fixed_string can hold.
|
inlinenoexcept |
Accesses the character at the specified location with bounds checking.
Returns a reference to the character at the specified location n. If n is out of bounds, an exception of type std::out_of_range
will be thrown.
[in] | n | The position of the character to return. |
std::out_of_range | When going beyond the bounds of the character array. |
|
inlinenoexcept |
Accesses the character at the specified location with bounds checking.
Returns a reference to the character at the specified location n. If n is out of bounds, an exception of type std::out_of_range
will be thrown.
[in] | n | The position of the character to return. |
std::out_of_range | When going beyond the bounds of the character array. |
|
inlinenoexcept |
Accesses 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.
|
inlinenoexcept |
Accesses 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.
|
inlinenoexcept |
|
inlinenoexcept |
Compares the string with another fixed_string.
Compares the string with another fixed_string lexicographically.
N2 | The size of the other fixed_string. |
[in] | rhs | The other fixed_string to compare with. |
|
inlinenoexcept |
Calculates the hash of the string.
Computes a hash value for the string using a FNV-1a hash function.
|
inlinenoexcept |
Swaps the contents with another fixed_string.
Exchanges the contents of the string with those of another fixed_string.
[in,out] | other | The other fixed_string to swap with. |