General purpose character string.
General purpose character string. Each instance of class GString represents a character string. Overloaded operators provide a value semantic to GString objects. Conversion operators and constructors transparently convert between GString objects and const char* pointers.Functions taking strings as arguments should declare their arguments as "const char*". Such functions will work equally well with GString objects since there is a fast conversion operator from GString to "const char*". Functions returning strings should return GString objects because the class will automatically manage the necessary memory.
Characters in the string can be identified by their position. The first character of a string is numbered zero. Negative positions represent characters relative to the end of the string (i.e. position -1 accesses the last character of the string, position -2 represents the second last character, etc.)
GString(const GString &gs)
GString(const char *dat)
GString(const char *dat, unsigned int len)
GString(const GString &gs, int from, unsigned int len)
GString(const int number)
GString(const double number)
GString& operator= (const GString &gs)
GString& operator= (const char *str)
operator const char* () const
unsigned int length() const
int operator! () const
if (! str) { ... }
while (!! str) { ... } -- Note the double operator!
Class GString does not to support syntax "
the required conversion operator introduces dangerous ambiguities with
certain compilers.
char operator[] (int n) const
void setat(int n, char ch)
GString substr(int from, unsigned int len=1) const
GString upcase() const
GString downcase() const
void empty()
char* getbuf(int n = -1)
void format(const char *fmt, ... )
int search(char c, int from=0) const
int search(const char *str, int from=0) const
int rsearch(char c, int from=-1) const
int rsearch(const char *str, int from=-1) const
GString& operator+= (char ch)
GString& operator+= (const char *str)
friend GString operator+(const GString &s1, const GString &s2)
friend int operator==(const GString &s1, const GString &s2)
friend int operator!=(const GString &s1, const GString &s2)
friend int operator>=(const GString &s1, const GString &s2)
friend int operator> (const GString &s1, const GString &s2)
friend int operator<=(const GString &s1, const GString &s2)
friend int operator< (const GString &s1, const GString &s2)
friend unsigned int hash(const GString &ref)
Alphabetic index HTML hierarchy of classes or Java