CkStringArray C++ Class Reference (Visual C++)
CkStringArray
* This is a freeware class/component/library.
Component for managing and manipulating collections of strings.
Properties
long get_Count();
The number of strings in the array.
bool get_Crlf(); void put_Crlf(bool newVal);
If true, strings are always automatically converted to use CRLF line endings. If false, strings are automatically converted to use bare LF line endings.
bool get_Trim(); void put_Trim(bool newVal);
If true, whitespace, including carriage-returns and linefeeds, are automatically removed from the beginning and end of a string when added to the array.
bool get_Unique(); void put_Unique(bool newVal);
If true, the array does not allow duplicates. When an attempt is made to insert a string that already exists in the array, the insertion simply doesn't happen and no error is returned.
bool get_Utf8(void) const; void put_Utf8(bool b);
When set to true, all "const char *" arguments are expected to be utf-8 strings. If set to false, the "const char *" arguments are expected to be ANSI strings.
Methods
void Append(const char * str);
Appends a string to the end of the array.
bool AppendSerialized(const char * encodedStr);
Appends multiple strings to the end of the array. The encodedStrings argument is what is returned from the Serialize method (see below).
void Clear();
Remove all strings from the array.
bool Contains(const char * str);
Returns true if the string is present in the array. The string comparisons are case sensitive.
long Find(const char * str, long firstIndex);
Finds the index of the first string equal to the string passed. The search begins at beginIndex. If the string is not found, -1 is returned. The first string in the array is at index 0.
int FindFirstMatch(const char * str, int firstIndex);
To be documented soon...
bool GetString(long index, CkString & str);
Returns the string at a location in the array. The first string is at index 0. Returns true for success, false for failure.
const char * GetString(long index);
Returns the string at a location in the array. The first string is at index 0.
int GetStringLen(int index);
Returns Nth's string length, in characters. The first string is at index 0.
void InsertAt(long index, const char * str);
Insert a string into the array at a particular index. Using index 0 will insert at the beginning.
bool LastString(CkString & str);
Returns the last string in the array. Returns true for success, false for failure.
bool LoadFromFile(const char * filename);
Adds strings from a file (one per line) into the string array. Returns true for success, false for failure.
void LoadFromText(const char * str);
Adds strings from an in-memory string (one per line) into the string array.
bool Pop(CkString & str);
Returns the last string and removes it from the array. Returns true for success, false for failure.
void Prepend(const char * str);
Adds a string to the beginning of the array.
void Remove(const char * str);
Removes all strings equal to the string argument from the array.
bool RemoveAt(long index);
Removes the string at a particular index.
bool SaveNthToFile(int index, const char * filename);
Saves the Nth string in the StringArray object to a file. Returns true for success, false for failure.
bool SaveToFile(const char * filename);
Saves the array of strings to a file, one string per line. Returns true for success, false for failure.
void SaveToText(CkString & outStr);
Saves the array of strings to a single string, one string per line (separated by CRLF line endings).
void Serialize(CkString & encodedStr);
Returns an string which is an encoded representation of all the strings in the array. The StringArray can be re-created by calling the AppendSerialized method. One reason this method exists is to make it easy to pass entire string arrays as a form parameter in a Web page. Returns true for success, false for failure.
void Sort(bool ascending);
Sorts the string array in ascending or descending order.
void SplitAndAppend(const char * str, const char * boundary);
Splits a string at a character or substring boundary and adds each resulting string to the StringArray object.
void Union(CkStringArray & array);
Performs the union set-operator. The caller will contain the union of two string arrays.
const char * getString(long index);
Returns the string at a location in the array. The first string is at index 0.
const char * lastStr();
To be documented soon...
const char * pop();
Returns the last string and removes it from the array.
const char * saveToText();
Saves the array of strings to a single string, one string per line (separated by CRLF line endings).
const char * serialize();
Returns an string which is an encoded representation of all the strings in the array. The StringArray can be re-created by calling the AppendSerialized method. One reason this method exists is to make it easy to pass entire string arrays as a form parameter in a Web page.
const char * strAt(long index);
To be documented soon...
|