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...
 
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...
 
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

◆ back()

const char* CStringArray::back ( ) const

Get last item in array, null if empty.

◆ 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

◆ front()

const char* CStringArray::front ( ) const
inline

Get first value in array, null if empty.

◆ 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

◆ popBack()

String CStringArray::popBack ( )

Pop last item from array.

Return values
Stringnull if array is empty

◆ popFront()

String CStringArray::popFront ( )

Pop first item from array (at index 0)

Return values
Stringnull if array is empty

◆ pushBack()

bool CStringArray::pushBack ( const char *  str)
inline

Add item to end of array.

Parameters
strItem to add
Return values
boolfalse on memory error

◆ pushFront()

bool CStringArray::pushFront ( const char *  str)

Insert item at start of array.

Parameters
strItem to insert
Return values
boolfalse on memory error

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