|
|
Donner
C++20 SVG rendering library
|
ChunkedString is a small helper to accumulate multiple RcStringOrRef pieces, either as small appended fragments or single codepoints. More...
#include "donner/base/ChunkedString.h"
Public Member Functions | |
| ChunkedString ()=default | |
| Default constructor. | |
| ChunkedString (std::string_view sv) | |
| Constructor from a string_view. | |
| ChunkedString (const RcString &str) | |
| Constructor from an RcString. | |
| ChunkedString (const RcStringOrRef &str) | |
| Constructor from an RcStringOrRef. | |
| ChunkedString (const char *str) | |
| Constructor from a C-style string. | |
| ChunkedString (const ChunkedString &other) | |
| Copy constructor from another ChunkedString. | |
| ChunkedString & | operator= (const ChunkedString &other) |
| Assignment operator. | |
| void | append (std::string_view sv) |
| Appends a string_view as a piece reference. | |
| void | appendLiteral (const char *str) |
| Helper method to append a C-style string literal. | |
| void | append (const RcStringOrRef &piece) |
| Appends an RcStringOrRef by-value (moves in the reference). | |
| void | append (const RcString &piece) |
| Appends an RcString. | |
| void | append (const ChunkedString &other) |
| Append another ChunkedString. | |
| void | prepend (std::string_view sv) |
| Prepends a string_view at the beginning of the chunks. | |
| void | prependLiteral (const char *str) |
| Helper method to prepend a C-style string literal. | |
| void | prepend (const RcStringOrRef &piece) |
| Prepends an RcStringOrRef by-value at the beginning of the chunks. | |
| void | prepend (const RcString &piece) |
| Prepends an RcString at the beginning of the chunks. | |
| void | prepend (const ChunkedString &other) |
| Prepends another ChunkedString at the beginning of the chunks. | |
| RcString | toSingleRcString () const |
| Flattens all the pieces into one single RcStringOrRef. | |
| std::string_view | firstChunk () const |
| Return the first chunk as a string_view. | |
| size_t | size () const |
| Return the total length of the string. | |
| size_t | numChunks () const |
| Return the number of chunks in the string. | |
| bool | empty () const |
| Checks if the string is empty. | |
| char | operator[] (size_t pos) const |
| Access the character at the specified position. | |
| ChunkedString | substr (size_t pos, size_t count=std::string_view::npos) const |
| Returns a substring of this string. | |
| void | remove_prefix (size_t n) |
| Removes the first n characters from the string. | |
| bool | starts_with (std::string_view prefix) const |
| Checks if the string starts with the given prefix. | |
| bool | operator== (const ChunkedString &other) const |
| Equality operator to compare with another ChunkedString. | |
| bool | operator== (std::string_view sv) const |
| Equality operator to compare with a string_view. | |
| bool | operator== (const RcString &str) const |
| Equality operator to compare with an RcString. | |
| bool | operator== (const RcStringOrRef &str) const |
| Equality operator to compare with an RcStringOrRef. | |
| bool | operator== (const char *str) const |
| Equality operator to compare with a C-style string. | |
| bool | ends_with (std::string_view suffix) const |
| Checks if the string ends with the given suffix. | |
| size_t | find (std::string_view s, size_t pos=0) const |
| Finds the first occurrence of a substring. | |
Friends | |
| bool | operator== (std::string_view sv, const ChunkedString &cs) |
| Friend functions to allow reversed equality syntax. | |
| bool | operator== (const RcString &str, const ChunkedString &cs) |
| bool | operator== (const RcStringOrRef &str, const ChunkedString &cs) |
| bool | operator== (const char *str, const ChunkedString &cs) |
| std::ostream & | operator<< (std::ostream &os, const ChunkedString &cs) |
| Stream insertion operator. | |
ChunkedString is a small helper to accumulate multiple RcStringOrRef pieces, either as small appended fragments or single codepoints.
It can optionally flatten them all into a single RcString if needed.
|
inlineexplicit |
Constructor from a string_view.
This is a zero-copy operation, referencing the underlying memory (if still alive).
| sv | The string_view to initialize with. |
|
inlineexplicit |
|
inlineexplicit |
Constructor from an RcStringOrRef.
| str | The RcStringOrRef to initialize with. |
|
inlineexplicit |
Constructor from a C-style string.
| str | The C-style string to initialize with. |
|
inline |
Copy constructor from another ChunkedString.
| other | The ChunkedString to copy from. |
|
inline |
Appends a string_view as a piece reference.
This is a zero-copy operation, referencing the underlying memory (if still alive).
|
inline |
Helper method to append a C-style string literal.
This resolves the ambiguity between the string_view, RcString, and RcStringOrRef overloads when passing string literals.
| str | The string literal to append. |
|
inline |
Checks if the string is empty.
|
inline |
Checks if the string ends with the given suffix.
| suffix | The suffix to check for. |
|
inline |
Finds the first occurrence of a substring.
| s | The substring to find. |
| pos | The position to start searching from. |
|
inline |
Assignment operator.
| other | The ChunkedString to assign from. |
|
inline |
Equality operator to compare with a C-style string.
| str | The C-style string to compare with. |
|
inline |
Equality operator to compare with another ChunkedString.
| other | The ChunkedString to compare with. |
|
inline |
|
inline |
Equality operator to compare with an RcStringOrRef.
| str | The RcStringOrRef to compare with. |
|
inline |
Equality operator to compare with a string_view.
| sv | The string_view to compare with. |
|
inline |
Access the character at the specified position.
Note: This operation may be slow for large strings with many chunks, as it needs to find the chunk containing the specified position.
| pos | Position of the character to access. |
|
inline |
Prepends a string_view at the beginning of the chunks.
This is a zero-copy operation, referencing the underlying memory (if still alive).
|
inline |
Helper method to prepend a C-style string literal.
This resolves the ambiguity between the string_view, RcString, and RcStringOrRef overloads when passing string literals.
| str | The string literal to prepend. |
|
inline |
Removes the first n characters from the string.
| n | Number of characters to remove. |
|
inline |
Checks if the string starts with the given prefix.
| prefix | The prefix to check for. |
|
inline |
Returns a substring of this string.
| pos | Position of the first character to include. |
| count | Number of characters to include. |
|
inline |
Flattens all the pieces into one single RcStringOrRef.
If there's only one piece, returns it directly; if empty, returns an empty piece. Otherwise, merges them into a newly allocated RcString and returns that.
|
friend |
Stream insertion operator.
| os | The output stream. |
| cs | The ChunkedString to output. |