string

## class string

> infinite length string class.

### Public Fields

  static const string | EMPTY the empty string

### Public Methods

  | string () create empty string.
  | string (const string &s) copy constructor. usage: string x = string
  | string (const char* s) copy constructor. usage: string x = "abc"
  | string (char c) copy constructor. usage: string x = 'a'
  | string (int n) copy constructor (decimals). usage: string x = 12;
  | string (unsigned n) copy constructor (decimals). usage: string x = 12;
  | string (double d) copy constructor (doubles). usage: string x = 1.2;
  virtual | ~string () delete string.
  string& | operator= (const string &s) copy operator a la strcpy.
  string& | operator= (const char* s) copy operator a la strcpy.
  string& | operator= (char c) copy operator a la strcpy.
  string& | operator= (int n) copy operator a la strcpy. s = n in decimal notation.
  string& | operator= (unsigned n) copy operator a la strcpy. s = n in decimal notation.
  string& | operator= (double d) copy operator a la strcpy. s = d in floating point notation.
  string& | operator+= (const string &s) concat operator a la strcat.
  string& | operator+= (const char* s) concat operator a la strcat.
  string& | operator+= (int n) concat. n in decimal notation is added.
  string& | operator+= (unsigned n) concat. n in decimal notation is added.
  string& | operator+= (double d) concat. d in floating point notation is added.
  string& | operator+= (char c) concat operator a la strcat.
  friend string | operator+ (const char* s1, const string &s2) constructive concat operator.
  friend string | operator+ (const string &s1, const char* s2) constructive concat operator.
  string | operator+ (const string &s) constructive concat operator.
  string | operator+ (const char* s) constructive concat operator.
  void | add (char c) add c at end of string.
  void | insert (char c, int pos) add character at n-th position of string.
  int | contains (const string &s) const return 1 if target is in string. 0 for failure.
  int | contains (const char* s) const return 1 if target is in string. 0 for failure.
  int | contains (char c) const return 1 if target is in string. 0 for failure.
  int | startsWith (const string &s) const return 1 if string starts with target, 0 for failure.
  int | startsWith (const char* s) const return 1 if string starts with target, 0 for failure.
  int | endsWith (const string &s) const return 1 if string ends with target, 0 for failure.
  int | endsWith (const char* s) const return 1 if string ends with target, 0 for failure.
  int | setSuffix (const string &s, char delim = '.') adds suffix s. return 1 when suffix is changed, 0 when only added.
  int | getSuffix (string &s, char delim = '.') const puts suffix in s. when there is no suffix returns 0, 1 otherwise.
  char& | operator[] (int i) selection of char by index a la array.
  const char& | operator[] (int i) const selection of char by index a la array.
  void | remove () remove last character of string.
  void | remove (int pos) remove pos-th character of string.
  int | replace (char old, char nw) replace each occurence of old char by nw char .
  int | replace (const string &pat, const string &repl, int casesens=1) global substitution.
  int | replaceFirst (const string &pat, const string &repl, int casesens=1) first occurrence substitution.
  void | addPlural () add to word an english plural ending, like horse->horses, sky->skies.
  friend string | upcase (const string &s) move all chars to upper case
  friend string | downcase (const string &s) move all chars to lower case
  friend string | stripblanks (const string &s) strip all spurious blank chars.
  void | upcase () in-place version of the above.
  void | downcase ()
  void | stripblanks ()
  unsigned long | toulong () const
  long | tolong () const
  double | todouble () const
  int | toint () const
  unsigned | length () const number of characters in string.
  unsigned | lines () const the number of lines in string when printed: newlines+1.
  unsigned | width () const return nr. of chars of line with most chars in string.
  int | whichline (int i, int &pos) const return which line has i-th char. pos becomes position in line.
  int | nthInline (int line, int n) const return position of n-th char in line-th line.
  unsigned | letters () const return number of letters (a-z,A-Z) in string.
  void | setPrecision (unsigned p) set precision when string is interpreted as double.
  friend ostream& | operator<< (ostream &o, const string &s) write string to output stream.
  friend istream& | operator>> (istream &i, string &s) read string from input stream.
  friend int | operator== (const string &x, const char* s) comparison operator returns 1 if equal
  friend int | operator== (const string &x, const string &y) comparison operator returns 1 if equal.
  friend int | operator%= (const string &x, const char* s) comparison operator that ignores case
  friend int | operator%= (const string &x, const string &y) comparison operator that ignores case
  friend int | operator!= (const string &x, const char* s) comparison operator a la !equal.
  friend int | operator!= (const string &x, const string &y) comparison operator a la !equal.
  friend int | compare (const string &x, const char* s) comparison operator a la strcmp
  friend int | compare (const string &x, const string &y) comparison operator a la strcmp
  const char* | getstr () const return a const pointer to the data to do dirty stuff.

### Protected Methods

  int | doReplace (const string &pat, const string &repl, int global, int casesens=1)

## Documentation

> infinite length string class.

`static const string EMPTY`
  the empty string

`string()`
  create empty string.

`string(const string &s)`
  copy constructor. usage: string x = string

`string(const char* s)`
  copy constructor. usage: string x = "abc"

`string(char c)`
  copy constructor. usage: string x = 'a'

`string(int n)`
  copy constructor (decimals). usage: string x = 12;

`string(unsigned n)`
  copy constructor (decimals). usage: string x = 12;

`string(double d)`
  copy constructor (doubles). usage: string x = 1.2;

`virtual ~string()`
  delete string.

`string& operator=(const string &s)`
  copy operator a la strcpy.

`string& operator=(const char* s)`
  copy operator a la strcpy.

`string& operator=(char c)`
  copy operator a la strcpy.

`string& operator=(int n)`
  copy operator a la strcpy. s = n in decimal notation.

`string& operator=(unsigned n)`
  copy operator a la strcpy. s = n in decimal notation.

`string& operator=(double d)`
  copy operator a la strcpy. s = d in floating point notation.

`string& operator+=(const string &s)`
  concat operator a la strcat.

`string& operator+=(const char* s)`
  concat operator a la strcat.

`string& operator+=(int n)`
  concat. n in decimal notation is added.

`string& operator+=(unsigned n)`
  concat. n in decimal notation is added.

`string& operator+=(double d)`
  concat. d in floating point notation is added.

`string& operator+=(char c)`
  concat operator a la strcat.

`friend string operator+(const char* s1, const string &s2)`
  constructive concat operator.

`friend string operator+(const string &s1, const char* s2)`
  constructive concat operator.

`string operator+(const string &s)`
  constructive concat operator.

`string operator+(const char* s)`
  constructive concat operator.

`void add(char c)`
  add c at end of string.

`void insert(char c, int pos)`
  add character at n-th position of string.

`int contains(const string &s) const`
  return 1 if target is in string. 0 for failure.

`int contains(const char* s) const`
  return 1 if target is in string. 0 for failure.

`int contains(char c) const`
  return 1 if target is in string. 0 for failure.

`int startsWith(const string &s) const`
  return 1 if string starts with target, 0 for failure.

`int startsWith(const char* s) const`
  return 1 if string starts with target, 0 for failure.

`int endsWith(const string &s) const`
  return 1 if string ends with target, 0 for failure.

`int endsWith(const char* s) const`
  return 1 if string ends with target, 0 for failure.

`int setSuffix(const string &s, char delim = '.')`
  adds suffix s. return 1 when suffix is changed, 0 when only added.

`int getSuffix(string &s, char delim = '.') const`
  puts suffix in s. when there is no suffix returns 0, 1 otherwise.

`char& operator[](int i)`
  selection of char by index a la array.

`const char& operator[](int i) const`
  selection of char by index a la array.

`void remove()`
  remove last character of string.

`void remove(int pos)`
  remove pos-th character of string.

`int replace(char old, char nw)`
  replace each occurence of old char by nw char .

`int replace(const string &pat, const string &repl, int casesens=1)`
  global substitution.

`int replaceFirst(const string &pat, const string &repl, int casesens=1)`
  first occurrence substitution.

`void addPlural()`
  add to word an english plural ending, like horse->horses, sky->skies.

`friend string upcase(const string &s)`
  move all chars to upper case

`friend string downcase(const string &s)`
  move all chars to lower case

`friend string stripblanks(const string &s)`
  strip all spurious blank chars.

`void upcase()`
  in-place version of the above.

`void downcase()`

`void stripblanks()`

`unsigned long toulong() const`

`long tolong() const`

`double todouble() const`

`int toint() const`

`unsigned length() const`
  number of characters in string.

`unsigned lines() const`
  the number of lines in string when printed: newlines+1.

`unsigned width() const`
  return nr. of chars of line with most chars in string.

`int whichline(int i, int &pos) const`
  return which line has i-th char. pos becomes position in line.

`int nthInline(int line, int n) const`
  return position of n-th char in line-th line.

`unsigned letters() const`
  return number of letters (a-z,A-Z) in string.

`void setPrecision(unsigned p)`
  set precision when string is interpreted as double.

`friend ostream& operator<<(ostream &o, const string &s)`
  write string to output stream.

`friend istream& operator>>(istream &i, string &s)`
  read string from input stream.

`friend int operator==(const string &x, const char* s)`
  comparison operator returns 1 if equal

`friend int operator==(const string &x, const string &y)`
  comparison operator returns 1 if equal.

`friend int operator%=(const string &x, const char* s)`
  comparison operator that ignores case

`friend int operator%=(const string &x, const string &y)`
  comparison operator that ignores case

`friend int operator!=(const string &x, const char* s)`
  comparison operator a la !equal.

`friend int operator!=(const string &x, const string &y)`
  comparison operator a la !equal.

`friend int compare(const string &x, const char* s)`
  comparison operator a la strcmp

`friend int compare(const string &x, const string &y)`
  comparison operator a la strcmp

`const char* getstr() const`
  return a const pointer to the data to do dirty stuff.

`int doReplace(const string &pat, const string &repl, int global, int casesens=1)`

This class has no child classes.

alphabetic index hierarchy of classes

this page has been generated automatically by doc++

(c)opyright by Malte Zöckler, Roland Wunderling
contact: doc++@zib.de