Class to manage a double null-terminated list of strings, such as "one\0two\0three\0". More...
#include <CStringArray.h>
Classes | |
class | Iterator |
Public Member Functions | |
CStringArray & | operator= (const char *cstr) |
bool | add (const char *str, int length=-1) |
Append a new string (or array of strings) to the end of the array. More... | |
bool | add (const String &str) |
Append a new string (or array of strings) to the end of the array. More... | |
int | indexOf (const char *str, bool ignoreCase=true) const |
Find the given string and return its index. More... | |
int | indexOf (const String &str, bool ignoreCase=true) const |
Find the given string and return its index. More... | |
bool | contains (const char *str, bool ignoreCase=true) const |
Check if array contains a string. More... | |
bool | contains (const String &str, bool ignoreCase=true) const |
Check if array contains a string. More... | |
const char * | getValue (unsigned index) const |
Get string at the given position. More... | |
const char * | operator[] (unsigned index) const |
Get string at the given position. More... | |
const char * | front () const |
Get first value in array, null if empty. More... | |
bool | pushFront (const char *str) |
Insert item at start of array. More... | |
String | popFront () |
Pop first item from array (at index 0) More... | |
const char * | back () const |
Get last item in array, null if empty. More... | |
bool | pushBack (const char *str) |
Add item to end of array. More... | |
String | popBack () |
Pop last item from array. More... | |
void | clear () |
Empty the array. More... | |
unsigned | count () const |
Get quantity of strings in array. More... | |
String | join (const String &separator=",") const |
Get contents of array as delimited string. More... | |
int | compareTo (const char *cstr, size_t length) const |
int | compareTo (const String &s) const |
bool | equals (const String &s) const |
bool | equals (const char *cstr) const |
bool | equals (const char *cstr, size_t length) const |
bool | equals (const FlashString &fstr) const |
bool | reserve (size_t size) |
Pre-allocate String memory. More... | |
bool | operator== (const String &rhs) const |
bool | operator== (const char *cstr) const |
bool | operator== (const FlashString &fstr) const |
bool | operator!= (const String &rhs) const |
bool | operator!= (const char *cstr) const |
bool | operator< (const String &rhs) const |
bool | operator> (const String &rhs) const |
bool | operator<= (const String &rhs) const |
bool | operator>= (const String &rhs) const |
const char * | c_str () const |
Get a constant (un-modifiable) pointer to String content. More... | |
bool | endsWith (char suffix) const |
Compare the end of a String. More... | |
bool | endsWith (const String &suffix) const |
Compare the end of a String. More... | |
bool | equalsIgnoreCase (const char *cstr) const |
bool | equalsIgnoreCase (const char *cstr, size_t length) const |
bool | equalsIgnoreCase (const String &s2) const |
bool | equalsIgnoreCase (const FlashString &fstr) const |
size_t | getBytes (unsigned char *buf, size_t bufsize, size_t index=0) const |
Read contents of a String into a buffer. More... | |
size_t | length (void) const |
Obtain the String length in characters, excluding NUL terminator. More... | |
bool | startsWith (const String &prefix) const |
Compare the start of a String Comparison is case-sensitive, must match exactly. More... | |
bool | startsWith (const String &prefix, size_t offset) const |
Compare a string portion. More... | |
void | toCharArray (char *buf, size_t bufsize, size_t index=0) const |
Read contents of String into a buffer. More... | |
void | toLowerCase (void) |
Convert the entire String content to lower case. More... | |
void | toUpperCase (void) |
Convert the entire String content to upper case. More... | |
Constructors | |
CStringArray (const String &str) | |
CStringArray (const char *cstr=nullptr) | |
CStringArray (const char *cstr, unsigned int length) | |
CStringArray (flash_string_t pstr, int length=-1) | |
CStringArray (const FlashString &fstr) | |
Concatenation operators | |
CStringArray & | operator+= (const String &str) |
CStringArray & | operator+= (const char *cstr) |
template<typename T > | |
CStringArray & | operator+= (T value) |
Append numbers, etc. to the array. More... | |
Iterator support (forward only) | |
Iterator | begin () const |
Iterator | end () const |
Detailed Description
Class to manage a double null-terminated list of strings, such as "one\0two\0three\0".
Constructor & Destructor Documentation
◆ CStringArray() [1/5]
|
inline |
◆ CStringArray() [2/5]
|
inline |
◆ CStringArray() [3/5]
|
inline |
◆ CStringArray() [4/5]
|
inlineexplicit |
◆ CStringArray() [5/5]
|
inline |
Member Function Documentation
◆ add() [1/2]
bool CStringArray::add | ( | const char * | str, |
int | length = -1 |
||
) |
Append a new string (or array of strings) to the end of the array.
- Parameters
-
str length Length of new string in array (default is length of str)
- Return values
-
bool false on memory allocation error
- Note
- If str contains any NUL characters it will be handled as an array
◆ add() [2/2]
|
inline |
Append a new string (or array of strings) to the end of the array.
- Parameters
-
str
- Return values
-
bool false on memory allocation error
- Note
- If str contains any NUL characters it will be handled as an array
◆ back()
const char* CStringArray::back | ( | ) | const |
Get last item in array, null if empty.
◆ begin()
|
inline |
◆ c_str()
|
inline |
Get a constant (un-modifiable) pointer to String content.
- Return values
-
const char* Always valid, even for a null string
◆ clear()
|
inline |
Empty the array.
◆ compareTo() [1/2]
int String::compareTo |
◆ compareTo() [2/2]
|
inline |
◆ contains() [1/2]
|
inline |
Check if array contains a string.
- Parameters
-
str String to search for ignoreCase Whether search is case-sensitive or not
- Return values
-
bool True if string exists in array
- Note
- Search is not case-sensitive
◆ contains() [2/2]
|
inline |
Check if array contains a string.
- Parameters
-
str String to search for ignoreCase Whether search is case-sensitive or not
- Return values
-
bool True if string exists in array
- Note
- Search is not case-sensitive
◆ count()
unsigned CStringArray::count | ( | ) | const |
Get quantity of strings in array.
- Return values
-
unsigned Quantity of strings
◆ end()
|
inline |
◆ endsWith() [1/2]
bool String::endsWith |
◆ endsWith() [2/2]
bool String::endsWith |
◆ equals() [1/4]
bool String::equals |
◆ equals() [2/4]
bool String::equals |
◆ equals() [3/4]
|
inline |
◆ equals() [4/4]
|
inline |
◆ equalsIgnoreCase() [1/4]
bool String::equalsIgnoreCase |
◆ equalsIgnoreCase() [2/4]
bool String::equalsIgnoreCase |
◆ equalsIgnoreCase() [3/4]
|
inline |
◆ equalsIgnoreCase() [4/4]
|
inline |
◆ front()
|
inline |
Get first value in array, null if empty.
◆ getBytes()
size_t String::getBytes |
Read contents of a String into a buffer.
- Parameters
-
buf buffer to write data bufsize size of buffer in bytes index offset to start
- Return values
-
unsigned number of bytes copied, excluding nul terminator
- Note
- Returned data always nul terminated so buffer size needs to take this into account
◆ getValue()
const char* CStringArray::getValue | ( | unsigned | index | ) | const |
Get string at the given position.
- Parameters
-
index 0-based index of string to obtain
- Return values
-
const char* nullptr if index is not valid
◆ indexOf() [1/2]
int CStringArray::indexOf | ( | const char * | str, |
bool | ignoreCase = true |
||
) | const |
Find the given string and return its index.
- Parameters
-
str String to find ignoreCase Whether search is case-sensitive or not
- Return values
-
int index of given string, -1 if not found
- Note
- Comparison is not case-sensitive
◆ indexOf() [2/2]
|
inline |
Find the given string and return its index.
- Parameters
-
str String to find ignoreCase Whether search is case-sensitive or not
- Return values
-
int index of given string, -1 if not found
- Note
- Comparison is not case-sensitive
◆ join()
Get contents of array as delimited string.
- Parameters
-
separator What to join elements with
- Return values
-
String e.g. CStringArray(F("a\0b\0c")).join() returns "a,b,c"
◆ length()
|
inline |
Obtain the String length in characters, excluding NUL terminator.
◆ operator!=() [1/2]
|
inline |
◆ operator!=() [2/2]
|
inline |
◆ operator+=() [1/3]
|
inline |
◆ operator+=() [2/3]
|
inline |
◆ operator+=() [3/3]
|
inline |
Append numbers, etc. to the array.
- Parameters
-
value char, int, float, etc. as supported by String
◆ operator<()
|
inline |
◆ operator<=()
|
inline |
◆ operator=()
|
inline |
◆ operator==() [1/3]
|
inline |
◆ operator==() [2/3]
|
inline |
◆ operator==() [3/3]
|
inline |
◆ operator>()
|
inline |
◆ operator>=()
|
inline |
◆ operator[]()
|
inline |
Get string at the given position.
- Parameters
-
index 0-based index of string to obtain
- Return values
-
const char* nullptr if index is not valid
◆ popBack()
String CStringArray::popBack | ( | ) |
Pop last item from array.
- Return values
-
String null if array is empty
◆ popFront()
String CStringArray::popFront | ( | ) |
Pop first item from array (at index 0)
- Return values
-
String null if array is empty
◆ pushBack()
|
inline |
Add item to end of array.
- Parameters
-
str Item to add
- Return values
-
bool false on memory error
◆ pushFront()
bool CStringArray::pushFront | ( | const char * | str | ) |
Insert item at start of array.
- Parameters
-
str Item to insert
- Return values
-
bool false on memory error
◆ reserve()
bool String::reserve |
◆ startsWith() [1/2]
|
inline |
Compare the start of a String Comparison is case-sensitive, must match exactly.
- Parameters
-
prefix
- Return values
-
bool true on match
◆ startsWith() [2/2]
bool String::startsWith |
Compare a string portion.
- Parameters
-
prefix offset Index to start comparison at
- Return values
-
bool true on match
- Note
- Comparison is case-sensitive, must match exactly
mis-named as does not necessarily compare from start
◆ toCharArray()
|
inline |
Read contents of String into a buffer.
- See also
- See
getBytes()
◆ toLowerCase()
void String::toLowerCase | ( | void | ) |
Convert the entire String content to lower case.
◆ toUpperCase()
void String::toUpperCase | ( | void | ) |
Convert the entire String content to upper case.
The documentation for this class was generated from the following file: