|
HooverChessUtils_PgnReader 0.9.0
|
A Pascal-style length-prefixed string with the specified maximum length. More...
#include <pgnreader-string-utils.h>
Public Member Functions | |
| constexpr | MiniString () noexcept |
| Initializing constructor. Sets the length of the contained string to 0. | |
| constexpr | MiniString (MiniString_Uninitialized) noexcept |
| Non-initializing constructor. The state of the object is undefined. | |
| MiniString (const MiniString &)=default | |
| Copy constructor (default) | |
| MiniString (MiniString &&)=default | |
| Move constructor (default) | |
| MiniString & | operator= (const MiniString &) &=default |
| Copy assignment (default) | |
| MiniString & | operator= (MiniString &&) &=default |
| Move assignment (default) | |
| ~MiniString ()=default | |
| Destructor (default) | |
| constexpr void | setLength (std::uint8_t length) noexcept |
| Sets the length of the contained string without resetting the contents. | |
| constexpr void | assign (const char *str) noexcept |
| Assigns a C-string. | |
| constexpr void | assign (const char *str, std::size_t strLen) noexcept |
| Assigns a string with length. In case the string is longer than the maximum capacity, the contained string is truncated. | |
| constexpr char | operator[] (std::size_t index) const noexcept |
| Returns a character at a specified offset. This function does not perform an index bounds check. | |
| constexpr char & | operator[] (std::size_t index) noexcept |
| Returns a reference to the character at a specified offset. This function does not perform an index bounds check. | |
| constexpr char * | data () noexcept |
Returns a pointer to the string data. The string may be non-terminated by ('\0'). | |
| constexpr const char * | data () const noexcept |
Returns a const pointer to the string data. The string may be non-terminated by ('\0'). | |
| constexpr std::size_t | size () const noexcept |
| Returns the size of the string. | |
| constexpr std::string_view | getStringView () const |
| Returns a string view to the string. | |
Static Public Member Functions | |
| static constexpr std::size_t | capacity () noexcept |
| Returns the capacity (maximum size) of a string to hold. | |
Private Attributes | |
| std::uint8_t | m_length |
| std::array< char, t_maxLen > | m_storage |
A Pascal-style length-prefixed string with the specified maximum length.
| t_maxLen | Maximum length of the contained string. Range: [1, 255] |
This object is intended as a fast, low-level container for small strings. The implementation foregoes many common API usage correctness checks to improve runtime performance.
MiniString is not a '\0'-terminated string. A MiniString can contain the character '\0'.
|
inlineconstexprnoexcept |
Initializing constructor. Sets the length of the contained string to 0.
|
inlineconstexprnoexcept |
Non-initializing constructor. The state of the object is undefined.
|
default |
Copy constructor (default)
|
default |
Move constructor (default)
|
default |
Destructor (default)
|
inlineconstexprnoexcept |
Assigns a C-string.
| [in] | str | C-string |
Assigns a C-string by copying up to t_maxLen characters and setting the length. The terminator ('\0') is not included.
|
inlineconstexprnoexcept |
Assigns a string with length. In case the string is longer than the maximum capacity, the contained string is truncated.
| [in] | str | Pointer to string |
| [in] | strLen | Input string length |
|
inlinestaticconstexprnoexcept |
Returns the capacity (maximum size) of a string to hold.
t_maxLen template parameter.
|
inlineconstexprnoexcept |
Returns a const pointer to the string data. The string may be non-terminated by ('\0').
|
inlineconstexprnoexcept |
Returns a pointer to the string data. The string may be non-terminated by ('\0').
|
inlineconstexpr |
Returns a string view to the string.
|
default |
Copy assignment (default)
|
default |
Move assignment (default)
|
inlineconstexprnoexcept |
Returns a character at a specified offset. This function does not perform an index bounds check.
| [in] | index | String offset |
|
inlineconstexprnoexcept |
Returns a reference to the character at a specified offset. This function does not perform an index bounds check.
| [in] | index | String offset |
Example
|
inlineconstexprnoexcept |
Sets the length of the contained string without resetting the contents.
| [in] | length | New string length. Range: [0, t_maxLen] |
length-1] is fully initialized.
|
inlineconstexprnoexcept |
Returns the size of the string.
|
private |
|
private |