Owned UTF-8 text composed of StormByte::CString. More...
#include <StormByte/string/string.hxx>
Public Types | |
| using | value_type = char |
| Byte type. | |
| using | const_iterator = const char * |
| Contiguous observer. | |
| using | const_reverse_iterator = std::reverse_iterator< const_iterator > |
| Reverse observer. | |
Public Member Functions | |
| void | swap (String &other) noexcept |
Swaps buffers with other. | |
Life | |
| String () noexcept | |
| Null text. | |
| String (const char *str) noexcept | |
| Copies a C string. | |
| String (std::string_view str) noexcept | |
| Copies a view into an owned NUL-terminated buffer. | |
| String (CString text) noexcept | |
| Takes an owned buffer. | |
| String (const WString &other) noexcept | |
| UTF-8 from wide text. | |
| String (const String &other) noexcept | |
| Copy constructor. | |
| String (String &&other) noexcept | |
| Move constructor. | |
| ~String () noexcept=default | |
| Releases the buffer. | |
| String & | operator= (const String &other) noexcept |
| Copy assignment. | |
| String & | operator= (String &&other) noexcept |
| Move assignment. | |
Range | |
| const_iterator | begin () const noexcept |
| First character, or null. | |
| const_iterator | end () const noexcept |
| One past the last character, or null. | |
| const_iterator | cbegin () const noexcept |
| First character, or null. | |
| const_iterator | cend () const noexcept |
| One past the last character, or null. | |
| const_reverse_iterator | rbegin () const noexcept |
| Reverse begin. | |
| const_reverse_iterator | rend () const noexcept |
| Reverse end. | |
| const_reverse_iterator | crbegin () const noexcept |
| Reverse begin. | |
| const_reverse_iterator | crend () const noexcept |
| Reverse end. | |
| const char * | data () const noexcept |
| Contiguous pointer; null when the buffer is null. | |
| std::size_t | size () const noexcept |
Byte count; 0 when null or empty. | |
| std::size_t | length () const noexcept |
| Same as size. | |
| bool | empty () const noexcept |
| Whether size is zero. | |
| char | operator[] (std::size_t index) const noexcept |
Byte at index. | |
| operator bool () const noexcept | |
| Whether a buffer is held. | |
Conversions | |
| operator std::string_view () const noexcept | |
| Non-owning view of the text. | |
| operator std::string () const | |
| Copy of the text in the caller’s heap. | |
| operator const char * () const noexcept | |
| View of the owned buffer. | |
| operator WString () const noexcept | |
| Wide text (UTF-8 decoded in the module). | |
| const CString & | Bytes () const noexcept |
| Owned bytes. | |
Comparison | |
| bool | operator== (const String &other) const noexcept |
| Content equality. | |
| bool | operator!= (const String &other) const noexcept |
| Content inequality. | |
| bool | operator== (const char *str) const noexcept |
| Content equality with a C string. | |
| bool | operator!= (const char *str) const noexcept |
| Content inequality with a C string. | |
| std::strong_ordering | operator<=> (const String &other) const noexcept |
| Content order. | |
| std::strong_ordering | operator<=> (const char *str) const noexcept |
| Content order against a C string. | |
Helpers | |
| String | ToLower () const noexcept |
| ASCII-letter lower case of this text. | |
| String | ToUpper () const noexcept |
| ASCII-letter upper case of this text. | |
| String | SanitizeNewlines () const noexcept |
| CR LF to LF on this text. | |
| String | RemoveWhitespace () const noexcept |
Drops isspace bytes from this text. | |
| bool | IsInteger () const noexcept |
| Whether this text is an integer token. | |
| std::vector< String > | Split () const noexcept |
| Whitespace-separated tokens. | |
| std::queue< String > | Explode (char delimiter) const noexcept |
Tokens on delimiter. | |
| static String | ToLower (std::string_view str) noexcept |
| ASCII-letter lower case; UTF-8 otherwise copied. | |
| static String | ToUpper (std::string_view str) noexcept |
| ASCII-letter upper case; UTF-8 otherwise copied. | |
| static String | SanitizeNewlines (std::string_view str) noexcept |
| Turns CR LF into LF. | |
| static String | RemoveWhitespace (std::string_view str) noexcept |
Drops isspace bytes. | |
| static bool | IsInteger (std::string_view str) noexcept |
| Optional sign plus ASCII digits. | |
| static void | Split (std::string_view str, std::vector< String > &out) noexcept |
| Whitespace-separated tokens. | |
| static void | Explode (std::string_view str, char delimiter, std::queue< String > &out) noexcept |
Tokens on delimiter. | |
Owned UTF-8 text composed of StormByte::CString.
UTF-8 counterpart of WString.
Not a std::string. Iterators are constant and contiguous so algorithms that read a range of char work. In-place mutating algorithms do not: helpers return a new String.
operator std::string_view is implicit and inline. operator std::string is explicit and inline (caller heap).
Conversion to WString is explicit and runs in the module (UTF-8 → wide). Conversion from WString copies UTF-8 in the module.
ToUpper / ToLower map only ASCII A–Z / a–z. Other well-formed UTF-8 code points are copied. Ill-formed bytes are copied one-by-one so a sequence is never split in the middle of a valid character.
Defined in string.hxx.
| using StormByte::String::String::const_iterator = const char* |
Contiguous observer.
| using StormByte::String::String::const_reverse_iterator = std::reverse_iterator<const_iterator> |
Reverse observer.
| using StormByte::String::String::value_type = char |
Byte type.
|
noexcept |
Null text.
|
explicitnoexcept |
Copies a C string.
| str | Source; may be null. |
|
explicitnoexcept |
Copies a view into an owned NUL-terminated buffer.
| str | Source. |
|
explicitnoexcept |
Takes an owned buffer.
| text | Buffer. |
|
explicitnoexcept |
UTF-8 from wide text.
| other | Wide source. |
|
noexcept |
Copy constructor.
| other | Text to copy. |
|
noexcept |
Move constructor.
| other | Text to take. other becomes null. |
|
defaultnoexcept |
Releases the buffer.
|
inlinenoexcept |
First character, or null.
|
inlinenoexcept |
Owned bytes.
|
inlinenoexcept |
First character, or null.
|
inlinenoexcept |
One past the last character, or null.
|
inlinenoexcept |
Reverse begin.
|
inlinenoexcept |
Reverse end.
|
inlinenoexcept |
Contiguous pointer; null when the buffer is null.
|
inlinenoexcept |
Whether size is zero.
|
inlinenoexcept |
One past the last character, or null.
|
inlinenoexcept |
Tokens on delimiter.
The queue is built in the caller.
| delimiter | Separator. |
|
staticnoexcept |
Tokens on delimiter.
out is the caller’s container.
| str | Source. | |
| delimiter | Separator. | |
| [out] | out | Tokens, including empty ones. |
|
inlinenoexcept |
Whether this text is an integer token.
|
staticnoexcept |
Optional sign plus ASCII digits.
| str | Source. |
str is an integer token.
|
inlinenoexcept |
Same as size.
|
inlineexplicitnoexcept |
Whether a buffer is held.
false only for a null CString. "" is valid and empty.
|
inlineexplicitnoexcept |
View of the owned buffer.
std::string::c_str().
|
inlineexplicit |
Copy of the text in the caller’s heap.
|
inlinenoexcept |
Non-owning view of the text.
std::string::c_str().
|
explicitnoexcept |
Wide text (UTF-8 decoded in the module).
|
inlinenoexcept |
Content inequality with a C string.
| str | May be null. |
|
inlinenoexcept |
Content inequality.
| other | Other text. |
|
inlinenoexcept |
Content order against a C string.
| str | May be null. |
|
inlinenoexcept |
Content order.
Null is less than any text.
| other | Other text. |
Copy assignment.
| other | Text to copy. |
Move assignment.
| other | Text to take. other becomes null. |
|
inlinenoexcept |
Content equality with a C string.
| str | May be null. |
|
inlinenoexcept |
Content equality.
| other | Other text. |
|
inlinenoexcept |
|
inlinenoexcept |
Reverse begin.
|
inlinenoexcept |
Drops isspace bytes from this text.
|
staticnoexcept |
Drops isspace bytes.
| str | Source. |
|
inlinenoexcept |
Reverse end.
|
inlinenoexcept |
CR LF to LF on this text.
|
staticnoexcept |
Turns CR LF into LF.
| str | Source. |
|
inlinenoexcept |
Byte count; 0 when null or empty.
|
inlinenoexcept |
Whitespace-separated tokens.
The vector is built in the caller.
|
staticnoexcept |
Whitespace-separated tokens.
out is the caller’s container.
| str | Source. | |
| [out] | out | Tokens. |
|
noexcept |
Swaps buffers with other.
| other | Other text. |
|
inlinenoexcept |
ASCII-letter lower case of this text.
|
staticnoexcept |
ASCII-letter lower case; UTF-8 otherwise copied.
| str | Source. |
|
inlinenoexcept |
ASCII-letter upper case of this text.
|
staticnoexcept |
ASCII-letter upper case; UTF-8 otherwise copied.
| str | Source. |