Latin1 string storage. One byte = one character. More...
#include <stringdata.h>


Public Member Functions | |
| StringLatin1Data ()=default | |
| Default constructor. Creates empty Latin1 storage. | |
| StringLatin1Data (const std::string &s) | |
| Constructs from a std::string (copy). | |
| StringLatin1Data (std::string &&s) | |
| Constructs from a std::string (move). | |
| StringLatin1Data (const char *s) | |
| Constructs from a C string. | |
| StringLatin1Data (const char *s, size_t len) | |
| Constructs from a buffer with explicit length. | |
| StringLatin1Data (size_t ct, char c) | |
| Constructs a string of repeated characters. | |
| 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. | |
| std::string & | rawStr () |
| Direct access to the underlying std::string. | |
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. | |
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". | |
Latin1 string storage. One byte = one character.
All character positions and byte positions are identical. This is the fast path for ASCII / Latin1 strings.
|
inline |
Constructs from a std::string (copy).
| s | The source string. |
|
inline |
Constructs from a std::string (move).
| s | The source string to move from. |
Constructs from a C string.
| s | The null-terminated string (null treated as empty). |
Constructs from a buffer with explicit length.
| s | Pointer to character data. |
| len | Number of bytes. |
Constructs a string of repeated characters.
| ct | Number of characters. |
| c | Character to repeat. |
|
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.
|
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.
|
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.
|
inlineoverridevirtual |
Returns a const reference to the internal std::string representation.
Implements StringData.