In file ../include/EST_String.h:

## class EST_String

> A non-copyleft implementation of a string class to use with compilers that aren't GNU C++.

## Inheritance:

### Public Fields

  static const char* | version Global version string
  static const EST_String | Empty Constant empty string
  | Split a string into parts.
  int | max

### Public Methods

  | EST_String (void) Construct an empty string
  | EST_String (const char* s) Construct from char *
  | EST_String (const char* s, int start_or_fill, int len) Construct from part of char * or fill with given character
  | EST_String (const char* s, int s_size, int start, int len) Construct from C string
  | EST_String (const EST_String &s) Copy constructor We have to declare our own copy constructor to lie to the compier about the constness of the RHS
  | EST_String (const char c) Construct from single char.
  | ~EST_String () Destructor
  int | length (void) const Length of string (not length of underlying chunk)
  int | space (void) const Size of underlying chunk
  const char* | str (void) const Get a const-pointer to the actual memory
  char* | updatable_str (void) Get a writable pointer to the actual memory
  static EST_String | FromChar (const char c) Build string from a single character
  static EST_String | Number (int i, int base=10) Build string from an integer
  static EST_String | Number (long i, int base=10) Build string from a long integer
  static EST_String | Number (double d) Build string from a double
  static EST_String | Number (float f) Build string from a float
  int | Int (bool &ok) const Convert to an integer
  long | Long (bool &ok) const Convert to a long
  float | Float (bool &ok) const Convert to a float
  double | Double (bool &ok) const Convert to a double
  | Before
  EST_String | before (int pos, int len=0) const Part before position
  EST_String | before (const char* s, int pos=0) const Part before first matching substring after pos
  EST_String | before (const EST_String &s, int pos=0) const Part before first matching substring after pos
  EST_String | before (EST_Regex &e, int pos=0) const Part before first match of regexp after pos
  | At
  EST_String | at (int from, int len=0) const Return part at position
  EST_String | at (const char* s, int pos=0) const Return part where substring found (not useful, included for completeness)
  EST_String | at (const EST_String &s, int pos=0) const Return part where substring found (not useful, included for completeness)
  EST_String | at (EST_Regex &e, int pos=0) const Return part matching regexp
  | After
  EST_String | after (int pos, int len=1) const Part after pos+len
  EST_String | after (const char* s, int pos=0) const Part after substring
  EST_String | after (const EST_String &s, int pos=0) const Part after substring
  EST_String | after (EST_Regex &e, int pos=0) const Part after match of regular expression
  | Search for something
  int | search (const char* s, int len, int &mlen, int pos=0) const Find a substring
  int | search (const EST_String s, int &mlen, int pos=0) const Find a substring
  int | search (EST_Regex &re, int &mlen, int pos=0, int* starts=NULL, int* ends=NULL) const Find a match of the regular expression
  | Get position of something
  int | index (const char* s, int pos=0) const Position of substring (starting at pos)
  int | index (const EST_String &s, int pos=0) const Position of substring (starting at pos)
  int | index (EST_Regex &ex, int pos=0) const Position of match of regexp (starting at pos)
  | Does string contain something?
  int | contains (const char* s, int pos=-1) const Does it contain this substring?
  int | contains (const EST_String &s, int pos=-1) const Does it contain this substring?
  int | contains (const char c, int pos=-1) const Does it contain this character?
  int | contains (EST_Regex &ex, int pos=-1) const Does it contain a match for this regular expression?
  | Does string exactly match?
  int | matches (const char* e, int pos=0) const Exatly match this string?
  int | matches (const EST_String &e, int pos=0) const Exatly match this string?
  int | matches (EST_Regex &e, int pos=0, int* starts=NULL, int* ends=NULL) const Exactly matches this regular expression, can return ends of sub-expressions
  | Global replacement
  int | gsub (const char* os, const EST_String &s) Substitute one string for another
  int | gsub (const char* os, const char* s) Substitute one string for another
  int | gsub (const EST_String &os, const EST_String &s) Substitute one string for another
  int | gsub (const EST_String &os, const char* s) Substitute one string for another
  int | gsub (EST_Regex &ex, const EST_String &s) Substitute string for matches of regular expression
  int | gsub (EST_Regex &ex, const char* s) Substitute string for matches of regular expression
  int | gsub (EST_Regex &ex, int bracket_num) Substitute string for matches of regular expression
  int | subst (EST_String source, int (&starts)[EST_Regex_max_subexpressions], int (&ends)[EST_Regex_max_subexpressions]) Substitute the result of a match into a string
  | Frequency counts
  int | freq (const char* s) const Number of occurances of substring
  int | freq (const EST_String &s) const Number of occurances of substring
  int | freq (EST_Regex &s) const Number of matches of regular expression
  | Quoting
  EST_String | quote (const char quotec) const Return the string in quotes with internal quotes protected
  EST_String | quote_if_needed (const char quotec) const Return in quotes if there is something to protect (eg.
  EST_String | unquote (const char quotec) const Remove quotes and unprotect internal quotes
  EST_String | unquote_if_needed (const char quotec) const Remove quotes if any
  | Operators
  const char | operator () (int i) const Function style access to constant strings
  char& | operator [] (int i) Array style access to writable strings
  | operator const char* () const Cast to const char * by simply giving access to pointer
  | operator char* () Cast to char *, may involve copying
  | Add to end of string.
  EST_String& | operator += (const char* b) Add C string to end of EST_String
  EST_String& | operator += (const EST_String b) Add EST_String to end of EST_String
  | Asignment
  EST_String& | operator = (const char* str) Assign C string to EST_String
  EST_String& | operator = (const char c) Assign single character to EST_String
  EST_String& | operator = (const EST_String &s) Assign EST_String to EST_String
  | Concatenation
  | relational operators
  return | b
  | return (a==b)
  return | compare (a, b)
  | String comparison.
  return | compare (b, a)
  | Case folded comparison.
  const EST_String& table return | fcompare (a, b, (const unsigned char* )(const char* )table)
  static EST_String | cat (const EST_String s1, const EST_String s2 = Empty, const EST_String s3 = Empty, const EST_String s4 = Empty, const EST_String s5 = Empty, const EST_String s6 = Empty, const EST_String s7 = Empty, const EST_String s8 = Empty, const EST_String s9 = Empty ) Concatenate a number of strings.

### Public

  typedef int | EST_string_size Type of string size field
  #define | MAX_STRING_SIZE (INT_MAX) Maximum string size

## Documentation

> A non-copyleft implementation of a string class to use with compilers that aren't GNU C++.

> Strings are reference-counted and reasonably efficiant (eg you can pass them around, into and out of functions and so on without worrying too much about the cost).

> The associated class EST_Regex can be used to represent regular expressions.

`static const char* version`
  Global version string

`static const EST_String Empty`
  Constant empty string

`typedef int EST_string_size`
  Type of string size field

`#define MAX_STRING_SIZE(INT_MAX)`
  Maximum string size

  `int locate(const char* it, int len, int from, int &start, int &end) const`
    Find substring

  `int locate(const EST_String &s, int from, int &start, int &end) const`
    Find substring

  `int locate(EST_Regex &ex, int from, int &start, int &end, int* starts=NULL, int* ends=NULL) const`
    Find match for regexp

  `EST_String chop_internal(const char* s, int length, int pos, EST_chop_direction directionult) const`
    Locate subsring and chop

  `EST_String chop_internal(int pos, int length, EST_chop_direction directionult) const`
    Chop at given position

  `EST_String chop_internal(EST_Regex &ex, int pos, EST_chop_direction directionult) const`
    Locate match for expression and chop

  `int gsub_internal(const char* os, int olength, const char* s, int length)`
    Substitute for string

  `int gsub_internal(EST_Regex &ex, const char* s, int length)`
    Substitute for matches of regexp

`EST_String(void)`
  Construct an empty string

`EST_String(const char* s)`
  Construct from char *

`EST_String(const char* s, int start_or_fill, int len)`
  Construct from part of char * or fill with given character

`EST_String(const char* s, int s_size, int start, int len)`
  Construct from C string

`EST_String(const EST_String &s)`
  Copy constructor We have to declare our own copy constructor to lie to the compier about the constness of the RHS

`EST_String(const char c)`
  Construct from single char. This constructor is not usually included as it can mask errors.
  See Also:
    __FSF_COMPATABILITY__

`~EST_String()`
  Destructor

`int length(void) const`
  Length of string (not length of underlying chunk)

`int space(void) const`
  Size of underlying chunk

`const char* str(void) const`
  Get a const-pointer to the actual memory

`char* updatable_str(void)`
  Get a writable pointer to the actual memory

`static EST_String FromChar(const char c)`
  Build string from a single character

`static EST_String Number(int i, int base=10)`
  Build string from an integer

`static EST_String Number(long i, int base=10)`
  Build string from a long integer

`static EST_String Number(double d)`
  Build string from a double

`static EST_String Number(float f)`
  Build string from a float

`int Int(bool &ok) const`
  Convert to an integer

`long Long(bool &ok) const`
  Convert to a long

`float Float(bool &ok) const`
  Convert to a float

`double Double(bool &ok) const`
  Convert to a double

`Before`

`EST_String before(int pos, int len=0) const`
  Part before position

`EST_String before(const char* s, int pos=0) const`
  Part before first matching substring after pos

`EST_String before(const EST_String &s, int pos=0) const`
  Part before first matching substring after pos

`EST_String before(EST_Regex &e, int pos=0) const`
  Part before first match of regexp after pos

`At`

`EST_String at(int from, int len=0) const`
  Return part at position

`EST_String at(const char* s, int pos=0) const`
  Return part where substring found (not useful, included for completeness)

`EST_String at(const EST_String &s, int pos=0) const`
  Return part where substring found (not useful, included for completeness)

`EST_String at(EST_Regex &e, int pos=0) const`
  Return part matching regexp

`After`

`EST_String after(int pos, int len=1) const`
  Part after pos+len

`EST_String after(const char* s, int pos=0) const`
  Part after substring

`EST_String after(const EST_String &s, int pos=0) const`
  Part after substring

`EST_String after(EST_Regex &e, int pos=0) const`
  Part after match of regular expression

`Search for something`

`int search(const char* s, int len, int &mlen, int pos=0) const`
  Find a substring

`int search(const EST_String s, int &mlen, int pos=0) const`
  Find a substring

`int search(EST_Regex &re, int &mlen, int pos=0, int* starts=NULL, int* ends=NULL) const`
  Find a match of the regular expression

`Get position of something`

`int index(const char* s, int pos=0) const`
  Position of substring (starting at pos)

`int index(const EST_String &s, int pos=0) const`
  Position of substring (starting at pos)

`int index(EST_Regex &ex, int pos=0) const`
  Position of match of regexp (starting at pos)

`Does string contain something?`

`int contains(const char* s, int pos=-1) const`
  Does it contain this substring?

`int contains(const EST_String &s, int pos=-1) const`
  Does it contain this substring?

`int contains(const char c, int pos=-1) const`
  Does it contain this character?

`int contains(EST_Regex &ex, int pos=-1) const`
  Does it contain a match for this regular expression?

`Does string exactly match?`

`int matches(const char* e, int pos=0) const`
  Exatly match this string?

`int matches(const EST_String &e, int pos=0) const`
  Exatly match this string?

`int matches(EST_Regex &e, int pos=0, int* starts=NULL, int* ends=NULL) const`
  Exactly matches this regular expression, can return ends of sub-expressions

`Global replacement`

`int gsub(const char* os, const EST_String &s)`
  Substitute one string for another

`int gsub(const char* os, const char* s)`
  Substitute one string for another

`int gsub(const EST_String &os, const EST_String &s)`
  Substitute one string for another

`int gsub(const EST_String &os, const char* s)`
  Substitute one string for another

`int gsub(EST_Regex &ex, const EST_String &s)`
  Substitute string for matches of regular expression

`int gsub(EST_Regex &ex, const char* s)`
  Substitute string for matches of regular expression

`int gsub(EST_Regex &ex, int bracket_num)`
  Substitute string for matches of regular expression

`int subst(EST_String source, int (&starts)[EST_Regex_max_subexpressions], int (&ends)[EST_Regex_max_subexpressions])`
  Substitute the result of a match into a string

`Frequency counts`

`int freq(const char* s) const`
  Number of occurances of substring

`int freq(const EST_String &s) const`
  Number of occurances of substring

`int freq(EST_Regex &s) const`
  Number of matches of regular expression

`Quoting`

`EST_String quote(const char quotec) const`
  Return the string in quotes with internal quotes protected

`EST_String quote_if_needed(const char quotec) const`
  Return in quotes if there is something to protect (eg. spaces)

`EST_String unquote(const char quotec) const`
  Remove quotes and unprotect internal quotes

`EST_String unquote_if_needed(const char quotec) const`
  Remove quotes if any

`Operators`

Friends:
  EST_String operator * (const EST_String &s, int n)

`const char operator () (int i) const`
  Function style access to constant strings

`char& operator [] (int i)`
  Array style access to writable strings

`operator const char*() const`
  Cast to const char * by simply giving access to pointer

`operator char*()`
  Cast to char *, may involve copying

`Add to end of string.`

`EST_String& operator += (const char* b)`
  Add C string to end of EST_String

`EST_String& operator += (const EST_String b)`
  Add EST_String to end of EST_String

`Asignment`

`EST_String& operator = (const char* str)`
  Assign C string to EST_String

`EST_String& operator = (const char c)`
  Assign single character to EST_String

`EST_String& operator = (const EST_String &s)`
  Assign EST_String to EST_String

`Concatenation`

Friends:
  EST_String operator + (const EST_String &a, const EST_String &b)
  EST_String operator + (const char *a, const EST_String &b)
  EST_String operator + (const EST_String &a, const char *b)

`relational operators`

Friends:
  int operator == (const char *a, const EST_String &b)
  int operator == (const EST_String &a, const char *b)
  int operator == (const EST_String &a, const EST_String &b)
  int operator != (const char *a, const EST_String &b)
  int operator != (const EST_String &a, const char *b)
  int operator != (const EST_String &a, const EST_String &b)
  inline int operator < (const char *a, const EST_String &b)
  inline int operator < (const EST_String &a, const char *b)
  inline int operator < (const EST_String &a, const EST_String &b)
  inline int operator > (const char *a, const EST_String &b)
  inline int operator > (const EST_String &a, const char *b)
  inline int operator > (const EST_String &a, const EST_String &b)
  inline int operator <= (const char *a, const EST_String &b)
  inline int operator <= (const EST_String &a, const char *b)
  inline int operator <= (const EST_String &a, const EST_String &b)
  inline int operator >= (const char *a, const EST_String &b)
  inline int operator >= (const EST_String &a, const char *b)
  inline int operator >= (const EST_String &a, const EST_String &b)

`return b`

`return(a==b)`

`return compare(a, b)`

`String comparison.`
  All these operators return -1, 0 or 1 to indicate the sort order of the strings.
  Friends:
    int compare(const EST_String &a, const EST_String &b)
    int compare(const EST_String &a, const char *b)
    inline int compare(const char *a, const EST_String &b)

  `return compare(b, a)`

  `Case folded comparison.`
    Case folded comparison.

    The table argument can defined how upper and lower case characters correspond. The default works for ASCII.

    Friends:
      int fcompare(const EST_String &a, const EST_String &b,
      int fcompare(const EST_String &a, const char *b,
      inline int fcompare(const EST_String &a, const EST_String &b,

    `const EST_String& table return fcompare(a, b, (const unsigned char* )(const char* )table)`

`Split a string into parts.`
  These functions divide up a string producing an array of substrings.
  Friends:
    int split(const EST_String & s, EST_String result[],

  `int max`

`static EST_String cat(const EST_String s1, const EST_String s2 = Empty, const EST_String s3 = Empty, const EST_String s4 = Empty, const EST_String s5 = Empty, const EST_String s6 = Empty, const EST_String s7 = Empty, const EST_String s8 = Empty, const EST_String s9 = Empty )`
  Concatenate a number of strings. This is more efficiant than multiple uses of + or +=

Direct child classes:
  EST_Pathname
  EST_Regex

Friends:
  EST_String upcase(const EST_String &s)
  EST_String downcase(const EST_String &s)
  ostream &operator << (ostream &s, const EST_String &str)
  class EST_Regex
Author:
  Alan W Black <awb@cstr.ed.ac.uk> Richard Caley <rjc@cstr.ed.ac.uk>
Version:
See Also:
  EST_Chunk
  EST_Regex
  string_example

Alphabetic index HTML hierarchy of classes or Java

This page is part of the Edinburgh Speech Tools Library documentation
Copyright University of Edinburgh 1997
Contact: speech_tools@cstr.ed.ac.uk