Unicode string storage. Decoded codepoints in a List<Char>. More...
#include <stringdata.h>


Public Member Functions | |
| StringUnicodeData () | |
| Default constructor. Creates empty Unicode storage. | |
| StringUnicodeData (const List< Char > &chars) | |
| Constructs from a list of codepoints (copy). | |
| StringUnicodeData (List< Char > &&chars) | |
| Constructs from a list of codepoints (move). | |
| size_t | length () const override |
| Returns the number of characters in the string. | |
| Char | charAt (size_t idx) const override |
| Returns the character at the given index. | |
| void | setCharAt (size_t idx, Char ch) override |
| Sets the character at the given index. | |
| bool | isLatin1 () const override |
| Returns true if the storage uses Latin1 encoding (one byte per character). | |
| size_t | find (Char ch, size_t from=0) const override |
Finds the first occurrence of a character starting from from. | |
| size_t | find (const StringData &s, size_t from=0) const override |
Finds the first occurrence of a substring starting from from. | |
| size_t | rfind (Char ch, size_t from=npos) const override |
Finds the last occurrence of a character at or before from. | |
| size_t | rfind (const StringData &s, size_t from=npos) const override |
Finds the last occurrence of a substring at or before from. | |
| StringData * | createSubstr (size_t pos, size_t len) const override |
| Creates a new StringData containing a substring. | |
| void | reverseInPlace () override |
| Reverses the characters in place. | |
| size_t | count (const StringData &substr) const override |
| Counts non-overlapping occurrences of a substring. | |
| void | append (const StringData &other) override |
| Appends another string's data to this storage. | |
| void | append (Char ch) override |
| Appends a single character. | |
| void | insert (size_t pos, const StringData &s) override |
| Inserts a string at the given position. | |
| void | erase (size_t pos, size_t count) override |
| Erases characters from the string. | |
| void | clear () override |
| Removes all characters from the string. | |
| void | resize (size_t len, Char fill=Char()) override |
Resizes the string to len characters. | |
| size_t | byteCount () const override |
| Returns the byte count of the encoded string data. | |
| uint8_t | byteAt (size_t idx) const override |
| Returns the byte at the given index. | |
| const char * | cstr () const override |
| Returns a null-terminated C string pointer. | |
| const std::string & | str () const override |
| Returns a const reference to the internal std::string representation. | |
| uint64_t | hash () const override |
| Returns a 64-bit hash of the string data. | |
Public Member Functions inherited from StringData | |
| virtual StringData * | _promeki_clone () const =0 |
| Creates a deep copy of this storage backend. | |
| virtual | ~StringData () |
| Virtual destructor. | |
| bool | isEmpty () const |
| Returns true if the string has zero length. | |
| virtual bool | isLiteral () const |
| Returns true if the storage wraps an immutable literal. | |
Static Public Member Functions | |
| static StringUnicodeData * | fromUtf8 (const char *data, size_t len) |
| Creates a StringUnicodeData by decoding UTF-8 bytes. | |
| static StringUnicodeData * | fromLatin1 (const std::string &s) |
| Creates a StringUnicodeData by promoting Latin1 bytes. | |
Additional Inherited Members | |
Public Attributes inherited from StringData | |
| RefCount | _promeki_refct |
| Manual reference count (PROMEKI_SHARED cannot be used on abstract classes). | |
Static Public Attributes inherited from StringData | |
| static constexpr size_t | npos = static_cast<size_t>(-1) |
| Sentinel value indicating "not found". | |
Unicode string storage. Decoded codepoints in a List<Char>.
All character positions are O(1) since codepoints are stored as fixed-width char32_t values. A UTF-8 encoded std::string is lazily cached for byte-level output.
Constructs from a list of codepoints (copy).
| chars | The decoded codepoints. |
Constructs from a list of codepoints (move).
| chars | The decoded codepoints to move from. |
|
overridevirtual |
Appends another string's data to this storage.
| other | The data to append. |
Implements StringData.
Returns the byte at the given index.
| idx | Zero-based byte index. |
Implements StringData.
|
overridevirtual |
Returns the byte count of the encoded string data.
Implements StringData.
Returns the character at the given index.
Implements StringData.
|
overridevirtual |
Removes all characters from the string.
Implements StringData.
|
overridevirtual |
Counts non-overlapping occurrences of a substring.
| substr | The substring to count. |
Implements StringData.
|
overridevirtual |
Creates a new StringData containing a substring.
| pos | Starting character index. |
| len | Number of characters. |
Implements StringData.
Returns a null-terminated C string pointer.
Implements StringData.
Erases characters from the string.
| pos | Starting character index. |
| count | Number of characters to erase. |
Implements StringData.
Finds the first occurrence of a character starting from from.
| ch | The character to search for. |
| from | Starting character index. |
Implements StringData.
|
overridevirtual |
Finds the first occurrence of a substring starting from from.
| s | The substring data to search for. |
| from | Starting character index. |
Implements StringData.
|
static |
Creates a StringUnicodeData by promoting Latin1 bytes.
| s | The Latin1 string (each byte becomes a Char). |
|
static |
Creates a StringUnicodeData by decoding UTF-8 bytes.
| data | Pointer to UTF-8 encoded bytes. |
| len | Number of bytes. |
|
overridevirtual |
Returns a 64-bit hash of the string data.
Implements StringData.
|
overridevirtual |
Inserts a string at the given position.
| pos | Character index at which to insert. |
| s | The data to insert. |
Implements StringData.
|
inlineoverridevirtual |
Returns true if the storage uses Latin1 encoding (one byte per character).
Implements StringData.
|
inlineoverridevirtual |
Returns the number of characters in the string.
Implements StringData.
Resizes the string to len characters.
| len | New character count. |
| fill | Character used to pad if growing. |
Implements StringData.
|
overridevirtual |
Reverses the characters in place.
Implements StringData.
Finds the last occurrence of a character at or before from.
| ch | The character to search for. |
| from | Maximum character index to consider (npos = end). |
Implements StringData.
|
overridevirtual |
Finds the last occurrence of a substring at or before from.
| s | The substring data to search for. |
| from | Maximum character index to consider (npos = end). |
Implements StringData.
Sets the character at the given index.
| idx | Zero-based character index. |
| ch | The replacement character. |
Implements StringData.
|
overridevirtual |
Returns a const reference to the internal std::string representation.
Implements StringData.