String implementation which keeps the data on the heap. We grow the allocated memory only if the copy source is not fitting.
More...
|
| Str ()=default |
|
| Str (int initialAllocatedLength) |
|
| Str (const char *str) |
|
| Str (StrView &source) |
| Convert StrView to Str. More...
|
|
| Str (Str &source) |
| Copy constructor. More...
|
|
| Str (Str &&obj) |
| Move constructor. More...
|
|
| ~Str () |
| Destructor. More...
|
|
Str & | operator= (Str &&obj) |
| Move assignment. More...
|
|
Str & | operator= (Str &obj) |
| Copy assingment. More...
|
|
bool | isOnHeap () override |
| checks if the string is on the heap More...
|
|
bool | isConst () override |
| checks if the string is a constant that must not be changed More...
|
|
void | operator= (const char *str) override |
| we can assign a const char* More...
|
|
void | operator= (char *str) override |
| we can assign a char* More...
|
|
void | operator= (int v) override |
| we can assign an int More...
|
|
void | operator= (double v) override |
| we can assign a double More...
|
|
size_t | capacity () |
|
void | setCapacity (size_t newLen) |
|
void | allocate (int len=-1) |
|
void | copyFrom (const char *source, int len, int maxlen=0) |
| assigns a memory buffer More...
|
|
void | setChars (char c, int len) |
| Fills the string with len chars. More...
|
|
void | urlEncode () |
| url encode the string More...
|
|
void | urlDecode () |
| decodes a url encoded string More...
|
|
void | clear () override |
| clears the string by setting the terminating 0 at the beginning More...
|
|
void | resize (int size) |
|
void | swap (Str &other) |
|
const char * | c_str () |
| provides the string value as const char* More...
|
|
void | reset () |
|
| StrView ()=default |
|
| StrView (const char *chars) |
| Creates a StrView for string constant. More...
|
|
| StrView (char chars[], int maxlen, int len=0) |
| Creates a StrView with the indicated buffer. More...
|
|
| StrView (const StrView &)=default |
|
| StrView (StrView &&)=default |
|
StrView & | operator= (const StrView &)=default |
|
StrView & | operator= (StrView &&)=default |
|
virtual void | set (const char *alt) |
| assigs a value More...
|
|
virtual void | set (const StrView &alt) |
| assigs from another StrView value More...
|
|
virtual void | set (const char c) |
|
virtual void | set (int value) |
|
virtual void | set (double value, int precision=2, int withd=0) |
|
virtual void | swap (StrView &str) |
|
virtual void | set (char chars[], int maxlen, int len=0, bool isConst=false) |
| assigns a memory buffer More...
|
|
virtual void | add (int value) |
| adds a int value More...
|
|
virtual void | add (double value, int precision=2, int withd=0) |
| adds a double value More...
|
|
virtual void | add (const char *append) |
| adds a string More...
|
|
virtual void | add (const char c) |
| adds a character More...
|
|
virtual bool | equals (const char *str) |
| checks if the string equals indicated parameter string More...
|
|
virtual bool | startsWith (const char *str) |
| checks if the string starts with the indicated substring More...
|
|
virtual bool | endsWith (const char *str) |
| checks if the string ends with the indicated substring More...
|
|
virtual bool | endsWithIgnoreCase (const char *str) |
| checks if the string ends with the indicated substring More...
|
|
virtual bool | matches (const char *pattern) |
|
virtual int | indexOf (const char c, int start=0) |
|
virtual bool | contains (const char *str) |
| checks if the string contains a substring More...
|
|
virtual int | indexOf (const char *cont, int start=0) |
|
virtual int | lastIndexOf (const char *cont) |
| provides the position of the last occurrence of the indicated substring More...
|
|
virtual void | operator= (char c) |
| we can assign a char More...
|
|
virtual void | operator<< (int n) |
| shift characters to the right -> we just move the pointer More...
|
|
virtual char | operator[] (int index) |
|
virtual void | operator+= (const char *str) |
| adds a substring at the end of the string More...
|
|
virtual void | operator+= (int value) |
| adds a int at the end of the string More...
|
|
virtual void | operator+= (double value) |
| adds a double at the end of the string More...
|
|
virtual void | operator+= (const char value) |
| adds a character More...
|
|
virtual bool | operator== (const StrView &alt) const |
| checks if the indicated string is equal to the current string More...
|
|
virtual bool | operator== (const char *alt) const |
| checks if the indicated string is equal to the current string More...
|
|
virtual bool | operator!= (const StrView &alt) const |
| checks if the indicated string is different from the current string More...
|
|
virtual bool | operator!= (const char *alt) const |
| checks if the indicated string is different from the current string More...
|
|
virtual int | length () |
|
virtual bool | isEmpty () |
| checks if the string is empty More...
|
|
virtual bool | isNewLine () |
|
virtual int | maxLength () |
| provides the maximum length of the string More...
|
|
virtual bool | replace (const char *toReplace, const int replaced) |
| Replaces the first instance of toReplace with replaced. More...
|
|
virtual bool | replace (const char *toReplace, const float replaced) |
|
virtual bool | replace (const char *toReplace, const char *replaced) |
| Replaces the first instance of toReplace with replaced. More...
|
|
virtual bool | replaceAll (const char *toReplace, const char *replaced) |
| Replaces all instances of toReplace with replaced. More...
|
|
virtual void | remove (const char *toRemove) |
| removes the indicated substring from the string More...
|
|
virtual void | removeAll (const char *toRemove) |
| removes the indicated substring from the string More...
|
|
virtual void | setLength (int len, bool addZero=true) |
| limits the length of the string (by adding a delimiting 0) More...
|
|
virtual void | setLengthUndo () |
| undo the last setLength call More...
|
|
virtual void | substring (StrView &from, int start, int end) |
| copies a substring into the current string More...
|
|
virtual void | substring (const char *from, int start, int end) |
| copies a substring into the current string More...
|
|
virtual void | trim () |
| remove leading and traling spaces More...
|
|
virtual int | count (char c, int startPos) |
| count number of indicated characters as position More...
|
|
virtual void | ltrim () |
| remove leading spaces More...
|
|
virtual void | rtrim () |
| remove trailing spaces More...
|
|
virtual void | clearAll () |
|
virtual void | insert (int pos, const char *str) |
| inserts a substring into the string More...
|
|
virtual bool | equalsIgnoreCase (const char *alt) |
| Compares the string ignoring the case. More...
|
|
int | toInt () |
| Converts the string to an int. More...
|
|
long | toLong () |
| Converts the string to an long. More...
|
|
double | toDouble () |
| Converts the string to a double. More...
|
|
float | toFloat () |
| Converts the string to a double. More...
|
|
void | toLowerCase () |
| Converts the string to lowercase letters. More...
|
|
void | toUpperCase () |
| Converts the string to uppercase letters. More...
|
|
bool | containsNumber () |
|
bool | isInteger () |
| Returns true if the string is an integer. More...
|
|
int | numberOfDecimals () |
| Determines the number of decimals in the number string. More...
|
|
bool | isNumber () |
|
const char * | buildPath (const char *start, const char *p1=nullptr, const char *p2=nullptr) |
|
String implementation which keeps the data on the heap. We grow the allocated memory only if the copy source is not fitting.
While it should be avoided to use a lot of heap allocatioins in embedded devices it is sometimes more convinent to allocate a string once on the heap and have the insurance that it might grow if we need to process an unexpected size.
We also need to use this if we want to manage a vecor of strings.
- Author
- Phil Schatzmann
- Copyright
- GPLv3