|
| | Str () |
| | Construct empty string.
|
| |
| | Str (size_t initialAllocatedLength) |
| | Construct reserving an initial capacity.
|
| |
| | Str (int initialAllocatedLength) |
| | Construct reserving an initial capacity (int overload)
|
| |
| | Str (const char *str) |
| | Construct from C-string (nullptr -> empty)
|
| |
| | Str (const Str &other)=default |
| | Copy-construct.
|
| |
| | Str (Str &&other) noexcept=default |
| | Move-construct.
|
| |
| Str & | operator= (const Str &other)=default |
| | Copy-assign.
|
| |
| Str & | operator= (Str &&other) noexcept=default |
| | Move-assign.
|
| |
| bool | isEmpty () const |
| | True if empty.
|
| |
| int | length () const |
| | Current length (int)
|
| |
| void | copyFrom (const char *source, int len) |
| | Copy from raw buffer with length.
|
| |
| void | substrView (StrView &from, int start, int end) |
| | Assign substring view from StrView [start,end)
|
| |
| void | substrView (const char *from, int start, int end) |
| | Assign substring view from const char* [start,end)
|
| |
| const char * | c_str () const |
| | C-string pointer to internal buffer.
|
| |
| | operator const char * () const |
| | Implicit conversion to const char*.
|
| |
| void | clear () |
| | Clear contents (size -> 0)
|
| |
| void | add (const char *append) |
| | Append C-string (ignored if nullptr)
|
| |
| void | add (const uint8_t *append, int len) |
| | Append raw bytes.
|
| |
| void | add (char c) |
| | Append single character.
|
| |
| void | add (int value) |
| | Append integer as decimal text.
|
| |
| void | add (double value, int precision=2, int=0) |
| | Append floating point as text with precision.
|
| |
| void | set (const char *v) |
| | Assign from C-string (nullptr -> empty)
|
| |
| void | set (int v) |
| | Assign from integer.
|
| |
| void | set (double v, int precision=2, int width=0) |
| | Assign from floating point with precision.
|
| |
| Str & | operator= (const char *v) |
| | Assign from C-string (operator=)
|
| |
| Str & | operator= (char *v) |
| | Assign from char* (operator=)
|
| |
| Str & | operator= (int v) |
| | Assign from integer (operator=)
|
| |
| Str & | operator= (double v) |
| | Assign from double (operator=)
|
| |
| void | reset () |
| | Clear contents (alias of clear)
|
| |
| void | clearAll () |
| | Clear contents (legacy alias)
|
| |
| void | release () |
| | Clear and shrink capacity to fit.
|
| |
| bool | equals (const char *other) const |
| | Exact string equality with C-string.
|
| |
| bool | contains (const char *sub) const |
| | True if substring occurs.
|
| |
| bool | endsWith (const char *suffix) const |
| | True if ends with suffix (case-sensitive)
|
| |
| bool | equalsIgnoreCase (const char *other) const |
| | Case-insensitive equality with C-string.
|
| |
| bool | endsWithIgnoreCase (const char *suffix) const |
| | True if ends with suffix (case-insensitive)
|
| |
| bool | startsWith (const char *prefix) const |
| | True if starts with prefix (case-sensitive)
|
| |
| int | indexOf (const char *substr, int start=0) const |
| | Index of substring from position (or -1)
|
| |
| int | indexOf (char c, int start=0) const |
| | Index of character from position (or -1)
|
| |
| void | remove (int n) |
| | removes the first n characters
|
| |
| void | trim () |
| | Trim spaces on both ends.
|
| |
| void | ltrim () |
| | Trim leading spaces.
|
| |
| void | rtrim () |
| | Trim trailing spaces.
|
| |
| void | setLength (int newLen, bool addZero=true) |
| | Resize logical length (pads with NUL if growing)
|
| |
| void | remove (const char *toRemove) |
| | Remove first occurrence of substring (no-op if not found)
|
| |
| bool | replace (const char *toReplace, const char *replaced, int startPos=0) |
| | Replace first occurrence of toReplace with replaced starting at startPos.
|
| |
| int | replaceAll (const char *toReplace, const char *replaced) |
| | Replace all occurrences of toReplace with replaced; returns count.
|
| |
| Str | substring (int start, int end) const |
| | Return substring [start,end) as a new Str.
|
| |
| int | toInt () const |
| | Convert to int (0 if empty)
|
| |
| long | toLong () const |
| | Convert to long (0 if empty)
|
| |
| double | toDouble () const |
| | Convert to double (0.0 if empty)
|
| |
| float | toFloat () const |
| | Convert to float (0.0f if empty)
|
| |
| void | toLowerCase () |
| | Lowercase in-place.
|
| |
| void | toUpperCase () |
| | Uppercase in-place.
|
| |
| void | setCapacity (size_t newLen) |
| | Reserve capacity.
|
| |
| size_t | capacity () const |
| | Current capacity.
|
| |
| void | operator+= (const char *v) |
| | Append via operator+= (C-string)
|
| |
| void | operator+= (int v) |
| | Append via operator+= (int)
|
| |
| void | operator+= (double v) |
| | Append via operator+= (double)
|
| |
| void | operator+= (const char c) |
| | Append via operator+= (char)
|
| |
| bool | operator== (const char *alt) const |
| | Equality with C-string.
|
| |
| bool | operator!= (const char *alt) const |
| | Inequality with C-string.
|
| |
| char & | operator[] (size_t i) |
| | Element access (mutable)
|
| |
| const char & | operator[] (size_t i) const |
| | Element access (const)
|
| |
| bool | isOnHeap () const |
| | Always true: storage is heap-backed.
|
| |
Heap-backed string utility used throughout tiny_dlna.
This class intentionally uses composition around std::string and forwards a small, controlled subset of operations used by the codebase. It attempts to preserve the historical Str API (length as int, add/set helpers, substring helpers, simple trimming and search utilities) while keeping ownership explicit and avoiding exposure of the entire std::string interface.
Usage notes:
- Most callers treat
Str similarly to the original project string type; it provides an implicit conversion to const char* for convenience when interoperating with legacy StrView APIs.
- The class is intended for embedded-friendly usage where a heap buffer is acceptable;
isOnHeap() returns true for the callers that check allocation semantics.