Arduino DLNA Server
Loading...
Searching...
No Matches
Public Member Functions | List of all members
tiny_dlna::Str Class Reference

Heap-backed string utility used throughout tiny_dlna. More...

#include <Str.h>

Public Member Functions

 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.
 
Stroperator= (const Str &other)=default
 Copy-assign.
 
Stroperator= (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.
 
Stroperator= (const char *v)
 Assign from C-string (operator=)
 
Stroperator= (char *v)
 Assign from char* (operator=)
 
Stroperator= (int v)
 Assign from integer (operator=)
 
Stroperator= (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.
 

Detailed Description

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:

Constructor & Destructor Documentation

◆ Str() [1/6]

tiny_dlna::Str::Str ( )
inline

Construct empty string.

◆ Str() [2/6]

tiny_dlna::Str::Str ( size_t  initialAllocatedLength)
inlineexplicit

Construct reserving an initial capacity.

◆ Str() [3/6]

tiny_dlna::Str::Str ( int  initialAllocatedLength)
inline

Construct reserving an initial capacity (int overload)

◆ Str() [4/6]

tiny_dlna::Str::Str ( const char *  str)
inline

Construct from C-string (nullptr -> empty)

◆ Str() [5/6]

tiny_dlna::Str::Str ( const Str other)
default

Copy-construct.

◆ Str() [6/6]

tiny_dlna::Str::Str ( Str &&  other)
defaultnoexcept

Move-construct.

Member Function Documentation

◆ add() [1/5]

void tiny_dlna::Str::add ( char  c)
inline

Append single character.

◆ add() [2/5]

void tiny_dlna::Str::add ( const char *  append)
inline

Append C-string (ignored if nullptr)

◆ add() [3/5]

void tiny_dlna::Str::add ( const uint8_t *  append,
int  len 
)
inline

Append raw bytes.

◆ add() [4/5]

void tiny_dlna::Str::add ( double  value,
int  precision = 2,
int  = 0 
)
inline

Append floating point as text with precision.

◆ add() [5/5]

void tiny_dlna::Str::add ( int  value)
inline

Append integer as decimal text.

◆ c_str()

const char * tiny_dlna::Str::c_str ( ) const
inline

C-string pointer to internal buffer.

◆ capacity()

size_t tiny_dlna::Str::capacity ( ) const
inline

Current capacity.

◆ clear()

void tiny_dlna::Str::clear ( )
inline

Clear contents (size -> 0)

◆ clearAll()

void tiny_dlna::Str::clearAll ( )
inline

Clear contents (legacy alias)

◆ contains()

bool tiny_dlna::Str::contains ( const char *  sub) const
inline

True if substring occurs.

◆ copyFrom()

void tiny_dlna::Str::copyFrom ( const char *  source,
int  len 
)
inline

Copy from raw buffer with length.

◆ endsWith()

bool tiny_dlna::Str::endsWith ( const char *  suffix) const
inline

True if ends with suffix (case-sensitive)

◆ endsWithIgnoreCase()

bool tiny_dlna::Str::endsWithIgnoreCase ( const char *  suffix) const
inline

True if ends with suffix (case-insensitive)

◆ equals()

bool tiny_dlna::Str::equals ( const char *  other) const
inline

Exact string equality with C-string.

◆ equalsIgnoreCase()

bool tiny_dlna::Str::equalsIgnoreCase ( const char *  other) const
inline

Case-insensitive equality with C-string.

◆ indexOf() [1/2]

int tiny_dlna::Str::indexOf ( char  c,
int  start = 0 
) const
inline

Index of character from position (or -1)

◆ indexOf() [2/2]

int tiny_dlna::Str::indexOf ( const char *  substr,
int  start = 0 
) const
inline

Index of substring from position (or -1)

◆ isEmpty()

bool tiny_dlna::Str::isEmpty ( ) const
inline

True if empty.

◆ isOnHeap()

bool tiny_dlna::Str::isOnHeap ( ) const
inline

Always true: storage is heap-backed.

◆ length()

int tiny_dlna::Str::length ( ) const
inline

Current length (int)

◆ ltrim()

void tiny_dlna::Str::ltrim ( )
inline

Trim leading spaces.

◆ operator const char *()

tiny_dlna::Str::operator const char * ( ) const
inline

Implicit conversion to const char*.

◆ operator!=()

bool tiny_dlna::Str::operator!= ( const char *  alt) const
inline

Inequality with C-string.

◆ operator+=() [1/4]

void tiny_dlna::Str::operator+= ( const char *  v)
inline

Append via operator+= (C-string)

◆ operator+=() [2/4]

void tiny_dlna::Str::operator+= ( const char  c)
inline

Append via operator+= (char)

◆ operator+=() [3/4]

void tiny_dlna::Str::operator+= ( double  v)
inline

Append via operator+= (double)

◆ operator+=() [4/4]

void tiny_dlna::Str::operator+= ( int  v)
inline

Append via operator+= (int)

◆ operator=() [1/6]

Str & tiny_dlna::Str::operator= ( char *  v)
inline

Assign from char* (operator=)

◆ operator=() [2/6]

Str & tiny_dlna::Str::operator= ( const char *  v)
inline

Assign from C-string (operator=)

◆ operator=() [3/6]

Str & tiny_dlna::Str::operator= ( const Str other)
default

Copy-assign.

◆ operator=() [4/6]

Str & tiny_dlna::Str::operator= ( double  v)
inline

Assign from double (operator=)

◆ operator=() [5/6]

Str & tiny_dlna::Str::operator= ( int  v)
inline

Assign from integer (operator=)

◆ operator=() [6/6]

Str & tiny_dlna::Str::operator= ( Str &&  other)
defaultnoexcept

Move-assign.

◆ operator==()

bool tiny_dlna::Str::operator== ( const char *  alt) const
inline

Equality with C-string.

◆ operator[]() [1/2]

char & tiny_dlna::Str::operator[] ( size_t  i)
inline

Element access (mutable)

◆ operator[]() [2/2]

const char & tiny_dlna::Str::operator[] ( size_t  i) const
inline

Element access (const)

◆ release()

void tiny_dlna::Str::release ( )
inline

Clear and shrink capacity to fit.

◆ remove() [1/2]

void tiny_dlna::Str::remove ( const char *  toRemove)
inline

Remove first occurrence of substring (no-op if not found)

◆ remove() [2/2]

void tiny_dlna::Str::remove ( int  n)
inline

removes the first n characters

◆ replace()

bool tiny_dlna::Str::replace ( const char *  toReplace,
const char *  replaced,
int  startPos = 0 
)
inline

Replace first occurrence of toReplace with replaced starting at startPos.

◆ replaceAll()

int tiny_dlna::Str::replaceAll ( const char *  toReplace,
const char *  replaced 
)
inline

Replace all occurrences of toReplace with replaced; returns count.

◆ reset()

void tiny_dlna::Str::reset ( )
inline

Clear contents (alias of clear)

◆ rtrim()

void tiny_dlna::Str::rtrim ( )
inline

Trim trailing spaces.

◆ set() [1/3]

void tiny_dlna::Str::set ( const char *  v)
inline

Assign from C-string (nullptr -> empty)

◆ set() [2/3]

void tiny_dlna::Str::set ( double  v,
int  precision = 2,
int  width = 0 
)
inline

Assign from floating point with precision.

◆ set() [3/3]

void tiny_dlna::Str::set ( int  v)
inline

Assign from integer.

◆ setCapacity()

void tiny_dlna::Str::setCapacity ( size_t  newLen)
inline

Reserve capacity.

◆ setLength()

void tiny_dlna::Str::setLength ( int  newLen,
bool  addZero = true 
)
inline

Resize logical length (pads with NUL if growing)

◆ startsWith()

bool tiny_dlna::Str::startsWith ( const char *  prefix) const
inline

True if starts with prefix (case-sensitive)

◆ substring()

Str tiny_dlna::Str::substring ( int  start,
int  end 
) const
inline

Return substring [start,end) as a new Str.

◆ substrView() [1/2]

void tiny_dlna::Str::substrView ( const char *  from,
int  start,
int  end 
)
inline

Assign substring view from const char* [start,end)

◆ substrView() [2/2]

void tiny_dlna::Str::substrView ( StrView from,
int  start,
int  end 
)
inline

Assign substring view from StrView [start,end)

◆ toDouble()

double tiny_dlna::Str::toDouble ( ) const
inline

Convert to double (0.0 if empty)

◆ toFloat()

float tiny_dlna::Str::toFloat ( ) const
inline

Convert to float (0.0f if empty)

◆ toInt()

int tiny_dlna::Str::toInt ( ) const
inline

Convert to int (0 if empty)

◆ toLong()

long tiny_dlna::Str::toLong ( ) const
inline

Convert to long (0 if empty)

◆ toLowerCase()

void tiny_dlna::Str::toLowerCase ( )
inline

Lowercase in-place.

◆ toUpperCase()

void tiny_dlna::Str::toUpperCase ( )
inline

Uppercase in-place.

◆ trim()

void tiny_dlna::Str::trim ( )
inline

Trim spaces on both ends.


The documentation for this class was generated from the following file: