|
|
int String::match(const String&) const;
s.match(t) returns the length of the initial
common substring of
s and t; returns
the length if the Strings do not differ.
The String argument can also be a character
pointer.
String::firstdiff(const String&) const;
s.firstdiff(t) returns the first position
at which
s differs from t;
returns -1 if the Strings do not differ or if s
is an initial substring of t. The String argument
can also be a character pointer.
int
String::index(const String&,int pos=0) const;
int
String::index(char,int pos=0) const;
If t is a substring of s,
s.index(t,pos) returns the first position (which
is >=
pos) at which they coincide; it returns -1 otherwise.
If c is an element of s,
s.index(c,pos) returns the first position (which
is >= pos) at which c
appears in
s; it returns -1 otherwise.
String String::upper() const;
s.upper() returns a new String constructed
from
s as follows: for each character
c of
s, if c is lowercase,
the result is the uppercase version of c; otherwise
the result is
c.
String String::lower() const;
s.lower() returns a new String constructed
from
s as follows: for each character
c of
s, if c is uppercase,
the result is the lowercase version of c; otherwise
the result is
c.
char* String::dump(char *) const;
s.dump(p) fills the buffer pointed to by character
pointer
p with the characters of String
s, followed by a null character, and returns the
character pointer.
It is up to the programmer to be sure the buffer is large enough.
This function is an ``escape hatch'' to old-style C strings.
int String::hashval() const;
s.hashval() returns a non-negative integer
derived
from String
s to be used in hash tables, etc.
The algorithm involves a sequence of
xors and shifts.
(But see also
Symbol(C++)
for more on using strings as keys.)