CStringArray Class Reference

Class to manage a double null-terminated list of strings, such as "one\0two\0three\0". More...

#include <CStringArray.h>

Inheritance diagram for CStringArray:
[legend]
Collaboration diagram for CStringArray:
[legend]

Classes

class  Iterator
 

Public Member Functions

CStringArrayoperator= (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...
 
void clear ()
 Empty the array. More...
 
unsigned count () const
 Get quantity of strings in array. 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
CStringArrayoperator+= (const String &str)
 
CStringArrayoperator+= (const char *cstr)
 
template<typename T >
CStringArrayoperator+= (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]

CStringArray::CStringArray ( const String str)
inline

◆ CStringArray() [2/5]

CStringArray::CStringArray ( const char *  cstr = nullptr)
inline

◆ CStringArray() [3/5]

CStringArray::CStringArray ( const char *  cstr,
unsigned int  length 
)
inline

◆ CStringArray() [4/5]

CStringArray::CStringArray ( flash_string_t  pstr,
int  length = -1 
)
inlineexplicit

◆ CStringArray() [5/5]

CStringArray::CStringArray ( const FlashString fstr)
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
lengthLength of new string in array (default is length of str)
Return values
boolfalse on memory allocation error
Note
If str contains any NUL characters it will be handled as an array

◆ add() [2/2]

bool CStringArray::add ( const String str)
inline

Append a new string (or array of strings) to the end of the array.

Parameters
str
Return values
boolfalse on memory allocation error
Note
If str contains any NUL characters it will be handled as an array

◆ begin()

Iterator CStringArray::begin ( ) const
inline

◆ clear()

void CStringArray::clear ( )
inline

Empty the array.

◆ contains() [1/2]

bool CStringArray::contains ( const char *  str,
bool  ignoreCase = true 
) const
inline

Check if array contains a string.

Parameters
strString to search for
ignoreCaseWhether search is case-sensitive or not
Return values
boolTrue if string exists in array
Note
Search is not case-sensitive

◆ contains() [2/2]

bool CStringArray::contains ( const String str,
bool  ignoreCase = true 
) const
inline

Check if array contains a string.

Parameters
strString to search for
ignoreCaseWhether search is case-sensitive or not
Return values
boolTrue if string exists in array
Note
Search is not case-sensitive

◆ count()

unsigned CStringArray::count ( ) const

Get quantity of strings in array.

Return values
unsignedQuantity of strings

◆ end()

Iterator CStringArray::end ( ) const
inline

◆ getValue()

const char* CStringArray::getValue ( unsigned  index) const

Get string at the given position.

Parameters
index0-based index of string to obtain
Return values
constchar* 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
strString to find
ignoreCaseWhether search is case-sensitive or not
Return values
intindex of given string, -1 if not found
Note
Comparison is not case-sensitive

◆ indexOf() [2/2]

int CStringArray::indexOf ( const String str,
bool  ignoreCase = true 
) const
inline

Find the given string and return its index.

Parameters
strString to find
ignoreCaseWhether search is case-sensitive or not
Return values
intindex of given string, -1 if not found
Note
Comparison is not case-sensitive

◆ operator+=() [1/3]

CStringArray& CStringArray::operator+= ( const String str)
inline

◆ operator+=() [2/3]

CStringArray& CStringArray::operator+= ( const char *  cstr)
inline

◆ operator+=() [3/3]

template<typename T >
CStringArray& CStringArray::operator+= ( value)
inline

Append numbers, etc. to the array.

Parameters
valuechar, int, float, etc. as supported by String

◆ operator=()

CStringArray& CStringArray::operator= ( const char *  cstr)
inline

◆ operator[]()

const char* CStringArray::operator[] ( unsigned  index) const
inline

Get string at the given position.

Parameters
index0-based index of string to obtain
Return values
constchar* nullptr if index is not valid

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