GCpp general purpose C++ library
version 1.0
|
#include <GString.hh>
Public Member Functions | |
template<class Q > | |
bool | IsInstanceOf () const |
template<class Q > | |
bool | IsInstanceOf () |
virtual GString * | Clone () const |
virtual const char * | ClassName () const |
GString () | |
GString (const string &s) | |
GString (const char *s) | |
GString (const GString &s) | |
GString & | operator= (const GString &s) |
GString & | operator= (const string &s) |
GString & | operator= (const char *s) |
virtual | ~GString () |
virtual GString | ToLower () const |
virtual GString | ToUpper () const |
virtual GString | NoAccent () const |
virtual GString | NoPunct (const string &punct=",;:.!?", const char rep= ' ') const |
virtual GString | NoSpace (const string &spc=" \n\t\r") const |
virtual GString | NoEndSpace (const string &spc=" \n\t\r") const |
virtual GString | Fill (size_t len, const char c= ' ', bool trunc=false) const |
size_t | FindFirstOf (const string &s, size_t index=0) |
GString & | ReplaceChar (char c, char r, u_int n=0) |
GString & | ReplaceAll (const GString &s, const GString &r) |
virtual int | Compare (const GString &str) const |
virtual int | CompareDict (const GString &str) const |
virtual int | ReadInt (int default_val=0) const |
virtual float | ReadFloat (float default_val=0.) const |
virtual double | ReadDouble (double default_val=0.) const |
virtual int | ReadSubInt (size_t &ifirst, size_t &ilast, size_t index=0, int default_val=0, const string &separ=" \n\t\r") const |
virtual float | ReadSubFloat (size_t &ifirst, size_t &ilast, const size_t index=0, const float default_val=0., const string &separ=" \n\t\r") const |
virtual double | ReadSubDouble (size_t &ifirst, size_t &ilast, const size_t index=0, const double default_val=0., const string &separ=" \n\t\r") const |
virtual GString | GetSubstring (char first, char last, size_t &ifirst, size_t &ilast, size_t index=0, bool keep=true) const |
virtual GString | GetSubstring (char first, char last, size_t index=0, bool keep=true) const |
virtual GString | GetWord (size_t &ifirst, size_t &ilast, size_t index=0, const string &separ=" ,;:.!?'[]{}()=+-*&%$#\n\t\r") const |
virtual GString | GetWord (size_t index=0, const string &separ=" ,;:.!?'[]{}()=+-*&%$#\n\t\r") const |
virtual u_int | CountWords (const string &separ=" ,;:.!?'[]{}()=+-*&%$#\n\t\r") const |
virtual u_int | GetWords (string *table, const string &separ=" ,;:.!?'[]{}()=+-*&%$#\n\t\r") const |
virtual string * | CreateWordsTable (u_int &nw, const string &separ=" ,;:.!?'[]{}()=+-*&%$#\n\t\r") const |
virtual size_t | FindFormat (const char fmtc, size_t &fmtlen, size_t &len) |
virtual size_t | FindFormat (const char fmtc, size_t &fmtlen) |
virtual GString | ReplaceFormat (const char fmtc, const int val, const char spc= '0') |
Static Public Member Functions | |
static const char * | StaticClassName () |
Class deriving from the standard C++ string class, defining new functions.
|
inline |
Default constructor: empty string.
|
inline |
Copy constructor of a std::string object.
s | string to copy |
|
inline |
Copy constructor of a C (char *) string.
s | string to copy |
|
inline |
Copy constructor of a GString object.
s | string to copy |
|
inlinevirtual |
Destructor.
|
virtual |
Comparison function: it returns -1, 0 or 1 depending if the object name is lower, equal or bigger than the argument string.
str | string to compare with |
Referenced by GNamedListT< T >::Compare().
|
virtual |
Alphabetical comparison function, with no distinction between upper and lower case, with no accents. Only if words are identical, the accents first, then upper/lower cases are tested.
str | string to compare with |
References NoAccent(), NoPunct(), and ToLower().
Referenced by GNamedListT< T >::Compare().
|
virtual |
Function returning the number of words in a string, and store them in an array of strings.
separ | list of space characters |
References GetWords().
Referenced by CreateWordsTable().
|
virtual |
Function allocating an array of strings containing the words of the current string. It returns the pointer to the array, or NULL if there's no word. The array must be freed after use. The argument nw receives the number of words (which is the array size).
nw | number of words found (as function output) |
separ | list of space characters |
References CountWords(), and GetWords().
|
virtual |
Fill the string with a character until it's size reach the required length. If the string length is already greater or equal to the required length, the returned string is the current string (truncated to this length according to truncation argument).
len | required length |
c | fill character |
trunc | indicates if the returned string should be truncated to len |
|
inline |
Returns the position of the first character from the argument string.
s | list of characters to look for |
index | start search position |
|
virtual |
The function searches in the string for a format identifier. It should look like "%X" or "%nX", where n is an integer indicating the format size, and X is the identification character. The function returns the position where the format indication is found, or string::npos if the format is not present.
fmtc | letter (character) for the format |
fmtlen | length of the format (as function output) |
len | length of the format indication (as function output) |
References ReadInt().
Referenced by FindFormat(), and ReplaceFormat().
|
inlinevirtual |
The function searches in the string for a format identifier. It should look like "%X" or "%nX", where n is an integer indicating the format size, and X is the identification character. The function returns the position where the format indication is found, or string::npos if the format is not present.
fmtc | letter (character) for the format |
fmtlen | length of the format (as function output) |
References FindFormat().
|
virtual |
Extract a sub-string, limited by given start and stop characters. A charater '\0' as start or stop means any character: for start, the first character is accepted, and for stop, the extraction goes to the end of the string. According to argument keep, the start/stop characters are included in the result string.
first | start (beginning) character |
last | stop (end) character |
ifirst | position of start character (as function output) |
ilast | position of stop character (as function output) |
index | start search position |
keep | indicates if the result contains the start/stop characters |
Referenced by GIntervalList::Add(), GetSubstring(), GInterval::GInterval(), and GIntervalList::Remove().
|
virtual |
Extract a sub-string, limited by given start and stop characters. A charater '\0' as start or stop means any character: for start, the first character is accepted, and for stop, the extraction goes to the end of the string. According to argument keep, the start/stop characters are included in the result string.
first | start (beginning) character |
last | stop (end) character |
index | start search position |
keep | indicates if the result contains the start/stop characters |
References GetSubstring().
|
virtual |
Extract a word, limited by space characters.
ifirst | position of 1st character of the word (as function output) |
ilast | position of last character of the word (as function output) |
index | start search position |
separ | list of space characters |
Referenced by GetWord(), GStringList::GStringList(), ReadSubDouble(), ReadSubFloat(), and ReadSubInt().
|
virtual |
Extract a word, limited by space characters.
index | start search position |
separ | list of space characters |
References GetWord().
|
virtual |
Function returning the number of words in a string, and store them in an array of strings. The array size is not checked. Use function CreateWordsTable to allocate an array with the exact size. If the pointertable is NULL, the words are not copied, only counted.
table | words arry (output) |
separ | list of space characters |
Referenced by CountWords(), and CreateWordsTable().
|
inline |
Macro from GCpp library that defines the following functions:
|
virtual |
Return a copy of the string where all accents have been removed.
References GSTRING_ACCENT_LIST, and GSTRING_NO_ACCENT_LIST.
Referenced by CompareDict().
|
virtual |
Return a copy of the string where space characters have been suppressed at the beginning and the end of the string.
spc | list of space characters |
Referenced by GInterval::GInterval().
|
virtual |
Return a copy of the string where punctuation characters have been replaced by a character (default is space).
punct | list of characters to replace |
rep | replacement character ('\0' to suppress instead of replace) |
Referenced by CompareDict().
|
virtual |
Return a copy of the string where space characters have been suppressed.
spc | list of space characters |
Affectation operator.
s | string to be affected to current object |
|
inline |
Affectation operator.
s | string to be affected to current object |
s | chaîne à affecter |
|
inline |
Affectation operator.
s | string to be affected to current object |
|
virtual |
Read a real number (double) from the string.
default_val | returned value in case of problem |
Referenced by GOptionString::CheckOption(), GOptionString::ExtractOption(), and ReadSubDouble().
|
virtual |
Read a real number (float) from the string.
default_val | returned value in case of problem |
Referenced by ReadSubFloat().
|
virtual |
Read an integer (int) from the string.
default_val | returned value in case of problem |
Referenced by GOptionString::CheckOption(), GOptionString::ExtractOption(), FindFormat(), GInterval::GInterval(), and ReadSubInt().
|
virtual |
Read real number (double) from the string.
ifirst | found position of the 1st character (as function output) |
ilast | found position of the last character (as function output) |
index | start search position |
default_val | returned value in case of problem |
separ | list of separator characters |
References GetWord(), and ReadDouble().
|
virtual |
Read real number (float) from the string.
ifirst | found position of the 1st character (as function output) |
ilast | found position of the last character (as function output) |
index | start search position |
default_val | returned value in case of problem |
separ | list of separator characters |
References GetWord(), and ReadFloat().
|
virtual |
Read an integer (int) from the string.
ifirst | found position of the 1st character (as function output) |
ilast | found position of the last character (as function output) |
index | start search position |
default_val | returned value in case of problem |
separ | list of separator characters |
Replace all occurences of the sub-string s by the string r.
s | string to replace |
r | replacement string |
Replace character c by character r. If n is not 0, it is the maximum number of occurences that are replaced (else, they are all replaced).
c | character to replace |
r | replacement character |
n | maximum number of replacements |
|
virtual |
Replace a format indication (like "%X" or "%nX") with an integer value.
fmtc | letter (character) for the format |
val | integer value to fill the format |
spc | character to fill spaces (if format length is included) |
References FindFormat(), and GGetString().
|
virtual |
Return a lower case copy of the string.
References GSTRING_ACCENT_LOWER, and GSTRING_ACCENT_UPPER.
Referenced by CompareDict().
|
virtual |
Return a upper case copy of the string.
References GSTRING_ACCENT_LOWER, and GSTRING_ACCENT_UPPER.
Referenced by GOptionString::OptPosition().