This is a general purpose string class, which supports many useful string operations. It has methods for numeric conversions, character and string search, formating, editing, and file operations.
|
Public Member Functions |
|
|
| cyString () |
| | Default constructor.
|
|
| cyString (const cyString &src) |
| | Copy constructor.
|
|
| cyString (const char *src) |
| | Sets the string using the given array.
|
|
| cyString (char src) |
| | Sets the string using the given number.
|
|
| cyString (int src) |
| | Default constructor.
|
|
| cyString (long src) |
| | Default constructor.
|
|
| cyString (float src) |
| | Default constructor.
|
|
| cyString (double src) |
| | Default constructor.
|
|
| cyString (const char *src, unsigned int count) |
| | Sets the string using the first 'count' characters of the given array.
|
|
| cyString (double src, int digits, int precisition) |
| | Sets the string as the given double number 'src' using given number of digits and precision.
|
| | cyString (int size, const char *format,...) |
| | Sets the string using the given format and predicted string size.
|
|
virtual | ~cyString () |
| | Destructor.
|
|
|
cyString & | Set (const cyString &str) |
| | Sets the string using the given string. Returns the string.
|
|
cyString & | Set (const char *src) |
| | Sets the string using the given array. Returns the string.
|
|
cyString & | Set (char src) |
| | Sets the string as the given character. Returns the string.
|
|
cyString & | Set (int src) |
| | Sets the string using the given number. Returns the string.
|
|
cyString & | Set (long src) |
| | Sets the string using the given number. Returns the string.
|
|
cyString & | Set (float src) |
| | Sets the string using the given number. Returns the string.
|
|
cyString & | Set (double src) |
| | Sets the string using the given number. Returns the string.
|
|
cyString & | Set (const char *src, unsigned int count) |
| | Sets the string using the first 'count' characters of the given array. Return this string.
|
| cyString & | Set (double src, int digits, int precision) |
| | Sets the string as the given double number 'src' using given number of digits and precision.
|
| cyString & | Set (int size, const char *format,...) |
| | Sets the string using the given format and predicted string size.
|
|
|
cyString & | operator= (const cyString &src) |
|
cyString & | operator= (const char *src) |
|
cyString & | operator= (char src) |
|
cyString & | operator= (int src) |
|
cyString & | operator= (long src) |
|
cyString & | operator= (float src) |
|
cyString & | operator= (double src) |
|
|
void | EmptyString () |
| | Converts to empty string.
|
| int | SetLength (int newLength) |
| | Changes the length of the array by keeping the values in the string.
|
|
void | SetCharString (char chr, int count) |
| | Creates a string of length 'count' with the given character 'chr'.
|
| void | Delete (int start, int count) |
| | Deletes 'count' number of characters from the array, starting from 'start'.
|
|
void | Insert (const cyString &str, int index) |
| | Inserts the given string to the given index.
|
| int | DeleteCarriageReturns () |
| | Deletes all carriage return characters.
|
| int | InsertCarriageReturns () |
| | Insert a carriage return character after every new line character if it doesn't already exits.
|
| int | DeleteChar (char c) |
| | Deletes all the characters in the string that are equal to the given character 'c'.
|
| int | DeleteChars (const cyString &set) |
| | Deletes all the characters in the string that exits in the given set.
|
|
void | Reverse () |
| | Reverses the string.
|
|
void | SwapChars (int index1, int index2, int count=1) |
| | Swap 'count' number of characters starting from 'index1' and 'index2'.
|
| cyString & | Format (int size, const char *format,...) |
| | Sets the string using the given format and predicted string size.
|
|
char & | operator[] (const int index) |
| | Returns the character of the string at the specified index.
|
|
|
int | Length () const |
| | Returns the length of the string.
|
|
const char * | GetString () const |
| | Returns the char array that keep the string data.
|
|
int | IsEmpty () const |
| | Checks if the string is empty (length is zero).
|
| char * | LastChar () const |
| | Returns a pointer to the last character before the first null character.
|
| int | SearchCharInSet (int index, const cyString &set) const |
| | If the character at the given index exists in the given set, returns the index of the character.
|
| int | SearchSet (const cyString &set) const |
| | Searches the string starting from the beginning for a character that exists in the given set.
|
| int | ReverseSearchSet (const cyString &set) const |
| | Searches the string starting from the end for a character that exists in the given set.
|
| int | SearchNextSet (int start, const cyString &set) const |
| | Searches the string starting from the beginning for a character that exists in the given set.
|
| int | GetPosition (char c) const |
| | Returns the first position of the character.
|
| int | GetPosition (const cyString &str) const |
| | Returns the first position of the given string.
|
| int | GetLastPosition (char c) const |
| | Returns the last position of the character.
|
| int | GetLastPosition (const cyString &str) const |
| | Returns the last position of the given string.
|
| int | GetNextPosition (int start, char c) const |
| | Returns the next position of the character.
|
| int | GetNextPosition (int start, const cyString &str) const |
| | Returns the next position of the given string.
|
|
int | GetLineNumber (int pos) const |
| | Returns the line number of the given position in the string.
|
|
int | GetNumLines () const |
| | Returns the number of lines in the string.
|
|
int | CountChar (char c) const |
| | Returns the number of characters in the string that are equal to the given character 'c'.
|
|
int | CountChar (char c, int start, int end) const |
| | Returns the number of characters in the string that are equal to the given character 'c'.between start and end.
|
|
int | CountChars (const cyString &set) const |
| | Returns the number of characters in the string that exists in the given character set.
|
|
char | operator[] (const int index) const |
| | Returns the character of the string at the specified index.
|
|
|
int | operator== (const cyString &str) const |
| | Checks if this string is the same as 'str'.
|
|
int | operator!= (const cyString &str) const |
| | Checks if this string is not the same as 'str'.
|
|
int | operator< (const cyString &str) const |
| | Checks if this string is smaller than 'str'.
|
|
int | operator<= (const cyString &str) const |
| | Checks if this string is smaller than or equal to 'str'.
|
|
int | operator> (const cyString &str) const |
| | Checks if this string is greater than 'str'.
|
|
int | operator>= (const cyString &str) const |
| | Checks if this string is greater than or equal to 'str'.
|
| int | Compare (const cyString &str) const |
| | Compares this string to 'str' (case sensitive).
|
| int | Compare (const cyString &str, int count) const |
| | Compares this string to 'str' (case sensitive) limited to the first 'count' characters.
|
| int | CompareIC (const cyString &str) const |
| | Compares this string to 'str' (case insensitive).
|
| int | CompareIC (const cyString &str, int count) const |
| | Compares this string to 'str' (case insensitive) limited to the first 'count' characters.
|
|
int | IsCapitalChar (int pos) const |
| | Returns if the char in the given position is a capital letter.
|
|
int | IsLowerCaseChar (int pos) const |
| | Returns if the char in the given position is a lower case letter.
|
|
int | IsNumericChar (int pos) const |
| | Returns if the char in the given position is a numeric character.
|
|
int | IsAlphaChar (int pos) const |
| | Returns if the char in the given position is a lower case or capital letter.
|
|
int | IsAlphaNumericChar (int pos) const |
| | Returns if the char in the given position is a lower case or capital letter or a numeric character.
|
|
int | IsNameChar (int pos) const |
| | Returns if the char in the given position is a lower case or capital letter, a numeric character or '_'.
|
|
int | IsSpaceChar (int pos) const |
| | Returns if the char in the given position is a space character.
|
|
int | IsControlChar (int pos) const |
| | Returns if the char in the given position is a control char (including new line etc.).
|
|
|
void | Append (const cyString &str) |
| | Appends to the end of the string.
|
|
cyString & | operator+= (const cyString &str) |
| | Appends to the end of the string and returns this string.
|
|
cyString | operator+ (const cyString &right) |
| | Appends two strings and returns the result.
|
| void | SubString (int start, int count) |
| | Converts the string to its sub-string starting from 'start' with length of 'count'.
|
| cyString | GetSubString (int start, int count) const |
| | Returns the sub-string from 'start' with the length of 'count'.
|
|
|
int | ToInt () const |
| | Converts the string to int.
|
|
long | ToLong () const |
| | Converts the string to long.
|
|
float | ToFloat () const |
| | Converts the string to float.
|
|
double | ToDouble () const |
| | Converts the string to double.
|
|
void | ToIntArray (int n, int *v) const |
| | Converts the string (ex: "23,43,14") to int array.
|
|
void | ToLongArray (int n, long *v) const |
| | Converts the string to long.
|
|
void | ToFloatArray (int n, float *v) const |
| | Converts the string (ex: "23,43,14") to float array.
|
|
void | ToDoubleArray (int n, double *v) const |
| | Converts the string (ex: "23,43,14") to double array.
|
|
|
void | Trim () |
| | Deletes empty characters from the beginning and end of the string.
|
|
void | TrimLeft () |
| | Deletes empty characters from the beginning of the string.
|
|
void | TrimRight () |
| | Deletes empty characters from the end of the string.
|
|
void | Shrink () |
| | Deletes the rest of the string after the first null character.
|
|
|
void | LowerCase () |
| | Coverts the string to lower case.
|
|
void | UpperCase () |
| | Coverts the string to upper case.
|
|
void | SwapCase () |
| | Coverts the string to swapped case.
|
|
void | TitleCase () |
| | Coverts the string to title case.
|
|
cyString | GetLowerCase () const |
| | Returns the lower case version of the string.
|
|
cyString | GetUpperCase () const |
| | Returns the upper case version of the string.
|
|
cyString | GetSwapCase () const |
| | Returns the swapped case version of the string.
|
|
cyString | GetTitleCase () const |
| | Returns the title case version of the string.
|
|
|
void | DecodeFileName (cyString &path, cyString &filename) |
| | Parses the string as file name string and returns path, filename.
|
|
void | DecodeFileName (cyString &path, cyString &filename, cyString &extention) |
| | Parses the string as file name string and returns path, filename and extension.
|
| int | LoadFromStream (FILE *stream, unsigned int count) |
| | Reads 'count' number of characters from the given file stream onto the string.
|
|
int | LoadFromFile (const cyString &filename) |
| | Loads the string from the file. Returns final length of the string.
|
|
int | SaveToStream (FILE *stream) const |
| | Writes string data to the given file stream. Returns the number of bytes written.
|
|
int | SaveToFile (const cyString &filename) const |
| | Saves the string to the text file. Returns the number of bytes written.
|
Friends |
|
std::ostream & | operator<< (std::ostream &os, const cyString &str) |
| | Overloaded stream operator. It only works if you include iostream before this file.
|