Return to Index
String
The string class provides a flexible alternative
to standard C-style strings. It is fully operator
overloaded to simplify programming, and is used
throughout the runtime library. It provides
a convenient printf(...) method to generate
nicely formatted text using the standard stdio printf
syntax. The class also has searching capabilities, as
well as the standard substring manipulationg methods.
The internal storage is simply a standard C-style
character array, and can be accessed directly with the
cStr() and getBuffer() methods. However,
direct manipulation of the underlying storage is not
recommended, as it may leave the string class in a volatile
state. If a large C-style buffer must be pre-allocated and
filled externally, use the getWriteBuffer() and
ungetWriteBuffer() methods.
The following
operators are also overridden for strings:
   ==, !=, , =, , =, +
String::String |
String::String();
Creates an empty string. |
String::String |
String::String(const char* s);
Creates a copy of the supplied string. |
Parameters: |
const char* | s | The NULL-terminated string to copy. |
|
String::String |
String::String(const String& s);
Creates a copy of the supplied string. |
Parameters: |
const String& | s | The string to copy. |
|
const String& String::operator= |
const String& String::operator=(const String& s);
The standard string assignment operator. Note that this copies the string memory. |
Parameters: |
const String& | s | The string to assign. |
|
const String& String::operator= |
const String& String::operator=(const char* s);
The standard string assignment operator. Note that this copies the string memory. |
Parameters: |
const char* | s | The string to assign. |
|
const String& String::operator= |
const String& String::operator=(char ch);
The standard character assignment operator. |
Parameters: |
char | ch | The character to assign. |
|
const char* String::cStr |
const char* String::cStr();
Returns a const pointer to the internal buffer. Use when calling printf(...) and other functions that require C-strings. |
int String::length |
int String::length();
Returns the length of the string. |
char String::operator[] |
char String::operator[](int i);
Indexing operator to return characters in the string.    char ch = str[2]; |
Parameters: |
int | i | Specifies which character to return. |
|
String& String::operator[] |
String& String::operator[](int i);
Indexing operator to allow for assignment into the string.    str[2] = 'c'; |
Parameters: |
int | i | Specifies the index of the character to return a reference to. |
|
const String& String::operator+= |
const String& String::operator+=(const String& s);
The string concatenation operator. |
Parameters: |
const String& | s | The string to concatenate. |
|
const String& String::operator+= |
const String& String::operator+=(char ch);
The character concatenation operator. |
Parameters: |
char | ch | The character to concatenate. |
|
bool String::printf |
bool String::printf(const char* format, ... .);
A convenient string formatting function. It provides the functionality of sprintf. Note that the maximum buffer length is 2048. |
Parameters: |
const char* | format | The standard printf formatting string. |
... | . | The variable argument list. |
|
char* String::getBuffer |
char* String::getBuffer();
Returns the internal buffer directly. |
char* String::getWriteBuffer |
char* String::getWriteBuffer();
Allocates a new buffer and returns it. Note that any preexisting string is lost. |
void String::ungetWriteBuffer |
void String::ungetWriteBuffer();
Restores the string class after a getWriteBuffer operation. |
double String::toDouble |
double String::toDouble(bool* (=NULL) success);
Attempts to convert the string to a double value. |
Parameters: |
bool* (=NULL) | success | If not NULL, this parameter indicates whether or not the conversion was successful. |
|
long String::toLong |
long String::toLong(bool* (=NULL) success, int (=10) base);
Attempts to convert the string to a long integer value. |
Parameters: |
bool* (=NULL) | success | If not NULL, this parameter indicates whether or not the conversion was successful. |
int (=10) | base | The base of the conversion. Defaults to 10. |
|
int String::toInt |
int String::toInt(bool* (=NULL) success);
Attempts to convert the string to a normal base 10 integer value. |
Parameters: |
bool* (=NULL) | success | If not NULL, this parameter indicates whether or not the conversion was successful. |
|
unsigned int String::toUnsignedInt |
unsigned int String::toUnsignedInt(bool* (=NULL) success);
Attempts to convert the string to a normal base 10 unsigned integer value. |
Parameters: |
bool* (=NULL) | success | If not NULL, this parameter indicates whether or not the conversion was successful. |
|
void String::toUpper |
void String::toUpper();
Converts the string to all uppercase characters. |
void String::toLower |
void String::toLower();
Converts the string to all lowercase characters. |
int String::find |
int String::find(const String& s);
Searches for the first occurrence of the given string.
Returns: Returns the starting position of the found string, or -1 for failure. |
Parameters: |
const String& | s | The string to search for. |
|
int String::find |
int String::find(char ch);
Searches for the first occurrence of a character.
Returns: Returns the position of the first occurrence, or -1 for failure. |
Parameters: |
char | ch | The character to search for. |
|
String String::subStr |
String String::subStr(int pos, int len);
Returns a substring. |
Parameters: |
int | pos | The starting position. |
int | len | The length of the substring. A length less than 0 returns the rest of the string. |
|
String String::left |
String String::left(int n);
Returns the first n characters of the string. |
Parameters: |
int | n | The number of characters. |
|
String String::right |
String String::right(int n);
Returns the last n characters of the string. |
Parameters: |
int | n | The number of characters. |
|
void String::truncate |
void String::truncate(int len);
Truncates the string to the specified length. |
Parameters: |
int | len | The length of the string. |
|
Generated automatically by docgen 0.0.1
© 2003 Aron Dobos