![]() |
Public API Reference |
![]() |
An array of strings. More...
#include <csutil/stringarray.h>
Public Types | |
enum | ConsecutiveDelimiterMode { delimSplitEach, delimIgnore, delimIgnoreDifferent } |
Mode how SplitString() treats consecutive occurance of delimiters. More... | |
Public Member Functions | |
size_t | Contains (const char *str, bool case_sensitive=true) const |
Alias for Find() and FindCaseInsensitive(). | |
bool | Delete (const char *item) |
Delete the given element from the array. | |
size_t | Find (const char *str) const |
Find a string, case-sensitive. | |
size_t | FindCaseInsensitive (const char *str) const |
Find a string, case-insensitive. | |
size_t | FindSortedKey (csArrayCmp< char const *, char const * > comparekey, size_t *candidate=0) const |
Find an element based on some key, using a comparison function. | |
size_t | FindSortedKey (char const *key, bool case_sensitive=true, size_t *candidate=0) const |
Find an element. | |
size_t | InsertSorted (const char *item, bool case_sensitive=true, size_t *equal_index=0) |
Insert an element at a sorted position. | |
char * | Pop () |
Pop an element from tail end of array. | |
void | Sort (int(*compare)(char const *const &, char const *const &)) |
Sort array based on comparison function. | |
void | Sort (bool case_sensitive=true) |
Sort array. | |
size_t | SplitString (const char *str, const char *delimiters, ConsecutiveDelimiterMode delimMode=delimSplitEach) |
Add a number of strings to this array by splitting str at characters from delimiters. | |
StringArray (size_t limit=0, const CapacityHandler &ch=CapacityHandler()) | |
Initialize object to hold initially limit elements, and increase storage by threshold each time the upper bound is exceeded. | |
StringArray (const char *str, const char *delimiters, ConsecutiveDelimiterMode delimMode=delimSplitEach, size_t limit=0, const CapacityHandler &ch=CapacityHandler()) | |
Initialize object to hold initially limit elements, and increase storage by threshold each time the upper bound is exceeded. | |
Static Public Member Functions | |
static int | CaseInsensitiveCompare (const char *const &item1, const char *const &item2) |
Case-insensitive comparision function for strings. | |
static int | CaseSensitiveCompare (const char *const &item1, const char *const &item2) |
Case-sensitive comparision function for strings. |
An array of strings.
This array will properly make copies of the strings and later delete those copies via delete[].
Definition at line 63 of file stringarray.h.
enum CS::Utility::StringArray::ConsecutiveDelimiterMode |
Mode how SplitString() treats consecutive occurance of delimiters.
Definition at line 229 of file stringarray.h.
CS::Utility::StringArray< Allocator, CapacityHandler >::StringArray | ( | size_t | limit = 0 , |
const CapacityHandler & | ch = CapacityHandler() |
||
) | [inline] |
Initialize object to hold initially limit
elements, and increase storage by threshold
each time the upper bound is exceeded.
Definition at line 76 of file stringarray.h.
CS::Utility::StringArray< Allocator, CapacityHandler >::StringArray | ( | const char * | str, |
const char * | delimiters, | ||
ConsecutiveDelimiterMode | delimMode = delimSplitEach , |
||
size_t | limit = 0 , |
||
const CapacityHandler & | ch = CapacityHandler() |
||
) | [inline] |
Initialize object to hold initially limit
elements, and increase storage by threshold
each time the upper bound is exceeded.
Additionally load in this array the splitted string provided.
str | The string to split and place in this array. |
delimiters | The delimiters to use to split the string. |
delimMode | The way to split this array |
Definition at line 253 of file stringarray.h.
static int CS::Utility::StringArray< Allocator, CapacityHandler >::CaseInsensitiveCompare | ( | const char *const & | item1, |
const char *const & | item2 | ||
) | [inline, static] |
Case-insensitive comparision function for strings.
Definition at line 89 of file stringarray.h.
static int CS::Utility::StringArray< Allocator, CapacityHandler >::CaseSensitiveCompare | ( | const char *const & | item1, |
const char *const & | item2 | ||
) | [inline, static] |
Case-sensitive comparision function for strings.
Definition at line 82 of file stringarray.h.
size_t CS::Utility::StringArray< Allocator, CapacityHandler >::Contains | ( | const char * | str, |
bool | case_sensitive = true |
||
) | const [inline] |
Alias for Find() and FindCaseInsensitive().
str | String to look for in array. |
case_sensitive | If true, consider case when performing comparison. (default: yes) |
Definition at line 221 of file stringarray.h.
bool CS::Utility::StringArray< Allocator, CapacityHandler >::Delete | ( | const char * | item | ) | [inline] |
Delete the given element from the array.
item
, thus it may be slow for large arrays. Definition at line 188 of file stringarray.h.
size_t CS::Utility::StringArray< Allocator, CapacityHandler >::Find | ( | const char * | str | ) | const [inline] |
Find a string, case-sensitive.
Definition at line 174 of file stringarray.h.
size_t CS::Utility::StringArray< Allocator, CapacityHandler >::FindCaseInsensitive | ( | const char * | str | ) | const [inline] |
Find a string, case-insensitive.
Definition at line 202 of file stringarray.h.
size_t CS::Utility::StringArray< Allocator, CapacityHandler >::FindSortedKey | ( | csArrayCmp< char const *, char const * > | comparekey, |
size_t * | candidate = 0 |
||
) | const [inline] |
Find an element based on some key, using a comparison function.
Definition at line 121 of file stringarray.h.
size_t CS::Utility::StringArray< Allocator, CapacityHandler >::FindSortedKey | ( | char const * | key, |
bool | case_sensitive = true , |
||
size_t * | candidate = 0 |
||
) | const [inline] |
Find an element.
Definition at line 132 of file stringarray.h.
size_t CS::Utility::StringArray< Allocator, CapacityHandler >::InsertSorted | ( | const char * | item, |
bool | case_sensitive = true , |
||
size_t * | equal_index = 0 |
||
) | [inline] |
Insert an element at a sorted position.
Definition at line 145 of file stringarray.h.
char* CS::Utility::StringArray< Allocator, CapacityHandler >::Pop | ( | ) | [inline] |
Pop an element from tail end of array.
Reimplemented from csArray< const char *, csStringArrayElementHandler, Allocator, CapacityHandler >.
Definition at line 158 of file stringarray.h.
void CS::Utility::StringArray< Allocator, CapacityHandler >::Sort | ( | int(*)(char const *const &, char const *const &) | compare | ) | [inline] |
Sort array based on comparison function.
Reimplemented from csArray< const char *, csStringArrayElementHandler, Allocator, CapacityHandler >.
Definition at line 98 of file stringarray.h.
void CS::Utility::StringArray< Allocator, CapacityHandler >::Sort | ( | bool | case_sensitive = true | ) | [inline] |
Sort array.
case_sensitive | If true, consider case when performing comparison. (default: yes) |
Definition at line 108 of file stringarray.h.
size_t CS::Utility::StringArray< Allocator, CapacityHandler >::SplitString | ( | const char * | str, |
const char * | delimiters, | ||
ConsecutiveDelimiterMode | delimMode = delimSplitEach |
||
) | [inline] |
Add a number of strings to this array by splitting str at characters from delimiters.
It will start from the first char and won't ignore delimiters before the first word (in other words even with delimIgnore you'll get at least an empty string if the string starts with delimiters).
Definition at line 267 of file stringarray.h.