Class Hierarchy Compound List File List Header Files Compound Members File Members
String Class Reference
Strings are represented as possibly shared segment lists.
More...
List of all members.
Public Members
- String ()
- Construct an empty string.
- String (const char *text)
- Construct a string from text.
- String (const char *text,int len)
- Construct a string from the first len characters of text.
- String (int size,int expand)
- Construct an empty string with a buffer of given size. More...
- String (const String &x,const String &y)
- Construct a concatenation of the two strings.
- String (const String &x, char ch)
- Construct a concatenation of the string and a character.
- String (const String &x)
- Copy constructor (very fast - no text copying required).
- String (int i)
- Construct a string as base 10 representation of an int.
- String (bool b)
- Construct a string from a bool (true or false).
- String (long l)
- Construct a string as base 10 representation of a long.
- String (double d)
- Construct a string as base 10 representation of double.
- String (const LString &x)
- Construct a String from an LString.
- String& operator= (const String &x)
- Assignment and concatenate and assign operators.
- String& operator= (const char *x)
- String& operator+= (const String &x)
- String& operator+= (const char *x)
- String& operator+= (char x)
- String& operator+= (const LString &x)
- char& operator[] (int i)
- Index into string
-
Warning:
-
does no bounds checking.
- void append (const String &x)
- append a String or char *. More...
- void append (const char *x)
- void push (char x)
- Push a character onto a string. More...
- String operator+ (const String &x) const
- Add a String or a single char.
- String operator+ (const char *x) const
- String operator+ (const LString &x) const
- String operator+ (char x) const
- void set_value (const char *text,int len)
- set the value of a string to the left most len characters of a char *. More...
- ~String ()
- int compare (const String &x) const
- compare a string. More...
- bool operator== (const String &x) const
- The usual comparison operators.
- bool operator!= (const String &x) const
- bool operator< (const String &x) const
- bool operator<= (const String &x) const
- bool operator> (const String &x) const
- bool operator>= (const String &x) const
- operator const char * () const
- Access the string as a const char *. More...
- const char* c_str () const
- bool truncate_to_last (char marker)
- Truncate the string the the last instance of the character the matching character is removed. More...
- bool trim_to_first (char marker)
- Trim the prefix finishing with the first instance of the characeter The character is trimmed.
- bool truncate_at_pos (int pos)
- Truncate to a given position The new length will be equal to the parameter value.
- bool is_empty () const
- int size () const
- int length () const
- String Left (int len) const
- Basic like string functions Left(len) - get String of left "len" chars Right(len) - get String of right "len" characters Mid(left_pos,len) - extract middle part of string NOTE: for Left and Right, the length can be negative, in which case, the length of the string is added to the parameter - in other words, it is the number of characters to chop off.
- String Right (int len) const
- String Mid (int left_pos,int len) const
- String substr (int left_pos,int len) const
- bool ends_in (const String &s) const
- Does the string end in or start with the comparison string?
- bool starts_with (const String &s) const
- int find (const String &x) const
- Find a substring. More...
- void make_empty ()
- Clear a string.
Detailed Description
Strings are represented as possibly shared segment lists.
Member Function Documentation
String::String ()
Construct an empty string.
String::String (const char * text)
Construct a string from text.
String::String (const char * text, int len)
Construct a string from the first len characters of text.
String::String (int size, int expand)
Construct an empty string with a buffer of given size.
-
Parameters:
-
size - in bytes (rounded up to modulo 8)
-
ignored - . Must be present or what you will get is a string containing size as text
String::String (const String & x, const String & y)
Construct a concatenation of the two strings.
String::String (const String & x, char ch)
Construct a concatenation of the string and a character.
String::String (const String & x)
Copy constructor (very fast - no text copying required).
String::String (int i)
Construct a string as base 10 representation of an int.
String::String (bool b)
Construct a string from a bool (true or false).
String::String (long l)
Construct a string as base 10 representation of a long.
String::String (double d)
Construct a string as base 10 representation of double.
String::String (const LString & x)
Construct a String from an LString.
String & String::operator= (const String & x)
Assignment and concatenate and assign operators.
String & String::operator= (const char * x)
String & String::operator+= (const String & x)
String & String::operator+= (const char * x)
String & String::operator+= (char x)
String & String::operator+= (const LString & x)
char & String::operator[] (int i)
Index into string
-
Warning:
-
does no bounds checking.
void String::append (const String & x)
append a String or char *.
Equivalent to +=
void String::append (const char * x)
void String::push (char x)
Push a character onto a string.
Present for hysterical reasons. Use += operator by preference
String String::operator+ (const String & x) const
Add a String or a single char.
String String::operator+ (const char * x) const
String String::operator+ (const LString & x) const
String String::operator+ (char x) const
void String::set_value (const char * text, int len)
set the value of a string to the left most len characters of a char *.
-
Parameters:
-
text - to set
-
no - of characters to take
String::~String ()
int String::compare (const String & x) const
compare a string.
-
Parameters:
-
string - to compare
-
Returns:
-
- -ve if "this" < param string, 0 if equal, +ve if greater Very strcmp like.
bool String::operator== (const String & x) const
The usual comparison operators.
bool String::operator!= (const String & x) const
bool String::operator< (const String & x) const
bool String::operator<= (const String & x) const
bool String::operator> (const String & x) const
bool String::operator>= (const String & x) const
String::operator const char * () const
Access the string as a const char *.
Two forms, as a cast and as a function
const char * String::c_str () const
bool String::truncate_to_last (char marker)
Truncate the string the the last instance of the character the matching character is removed.
Hence, fullpathname.truncate_to_last('/') will give you the directory name.
bool String::trim_to_first (char marker)
Trim the prefix finishing with the first instance of the characeter The character is trimmed.
bool String::truncate_at_pos (int pos)
Truncate to a given position The new length will be equal to the parameter value.
bool String::is_empty () const
int String::size () const
int String::length () const
String String::Left (int len) const
Basic like string functions Left(len) - get String of left "len" chars Right(len) - get String of right "len" characters Mid(left_pos,len) - extract middle part of string NOTE: for Left and Right, the length can be negative, in which case, the length of the string is added to the parameter - in other words, it is the number of characters to chop off.
String String::Right (int len) const
String String::Mid (int left_pos, int len) const
String String::substr (int left_pos, int len) const
bool String::ends_in (const String & s) const
Does the string end in or start with the comparison string?
bool String::starts_with (const String & s) const
int String::find (const String & x) const
Find a substring.
Returns index of first character of substring, or -1 if not found
void String::make_empty ()
The documentation for this class was generated from the following file:
Generated at Mon Nov 22 19:43:46 1999 for NCI SUIF by
written by Dimitri van Heesch, © 1997-1999