Immutable Unicode string storage wrapping compile-time decoded data. More...
#include <stringdata.h>


Public Member Functions | |
| StringUnicodeLiteralData (const char32_t *codepoints, size_t charCount, const char *bytes, size_t byteLen, uint64_t precomputedHash=0) | |
| Constructs from pre-decoded codepoints and original UTF-8 bytes. | |
| StringData * | _promeki_clone () const override |
| Creates a deep copy of this storage backend. | |
| 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, Char) override |
| Sets the character at the given index. | |
| bool | isLatin1 () const override |
| Returns true if the storage uses Latin1 encoding (one byte per character). | |
| bool | isLiteral () const override |
| Returns true if the storage wraps an immutable literal. | |
| 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 &) override |
| Appends another string's data to this storage. | |
| void | append (Char) override |
| Appends a single character. | |
| void | insert (size_t, const StringData &) override |
| Inserts a string at the given position. | |
| void | erase (size_t, size_t) override |
| Erases characters from the string. | |
| void | clear () override |
| Removes all characters from the string. | |
| void | resize (size_t, 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 () |
| Virtual destructor. | |
| bool | isEmpty () const |
| Returns true if the string has zero length. | |
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". | |
Immutable Unicode string storage wrapping compile-time decoded data.
Wraps pointers to a pre-decoded char32_t codepoint array and the original UTF-8 bytes — both live in CompiledString's constexpr static storage. The refcount is immortal so the object is never deleted. COW always clones to a StringUnicodeData before mutation.
|
inline |
Constructs from pre-decoded codepoints and original UTF-8 bytes.
| codepoints | Pointer to decoded char32_t array (must remain valid for the lifetime of this object). |
| charCount | Number of codepoints. |
| bytes | Pointer to original UTF-8 bytes (must remain valid for the lifetime of this object). |
| byteLen | Length of the UTF-8 data in bytes. |
| precomputedHash | Optional pre-computed FNV-1a hash (0 = compute on construction). |
|
overridevirtual |
Creates a deep copy of this storage backend.
Implements StringData.
|
inlineoverridevirtual |
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.
|
inlineoverridevirtual |
Returns the byte count of the encoded string data.
Implements StringData.
Returns the character at the given index.
Implements StringData.
|
inlineoverridevirtual |
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.
|
inlineoverridevirtual |
Returns a 64-bit hash of the string data.
Implements StringData.
|
inlineoverridevirtual |
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 true if the storage wraps an immutable literal.
Reimplemented from 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.
|
inlineoverridevirtual |
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.