Class hierarchy Compound list Compound Members
String Class Reference
A String (an array of char) with dynamic allocation. More...
List of all members.
Public Members
- String (void)
- Construct an empty string.
- String (const String& S)
- Copy constructor.
- String (const char* pBuf)
- Construct a string from a characters buffer.
- String (const int Val)
- Construct a string with a number.
- String (const char Val, const int len)
- Construct a string filled with the same character.
- char& operator[] (const int index)
- Return a character in the string.
- const char& operator[] (const int index) const
- Return a character in the string.
- const char* getString () const
- Return the internal char* representation.
- operator const char* () const
- Automatic conversion to c style constant string.
- String& operator= (const String& S)
- Copy a string.
- String operator+ (const String& aString) const
- Concatenate with the string and return the new created string.
- String& operator+= (const String& S)
- Append the string with another.
- unsigned size () const
- Returns the number of characters in the string.
- unsigned length () const
- Returns the number of characters in the string.
- float asFloat () const
- Returns the float value represented by the string.
- double asDouble () const
- Returns the double value represented by the string.
- long asInt () const
- Returns the int value represented by the string.
- long asIntHex () const
- Returns the int value represented by the string, assuming the string is in base 16.
- unsigned long asUnsigned () const
- Returns the unsigned int value represented by the string.
- String& untabify (const int TabSize)
- Converts tabs to spaces.
- int isDigits () const
- Returns true is string consists only of digits.
- int indexOf (const char c) const
- Finds the first appearance of a character.
- int lastIndexOf (const char c) const
- Finds the last appearance of a character.
- int indexOf (const String& S, const int CaseSense=1) const
- Finds a Sub String, returns -1 if not found.
- int occurrencesOf (const char c) const
- Counts number of occurrences of a character.
- String& substring (const int start, const int end)
- Cuts the string into a substring (in place) from start (inclusive) to end (non-inclusive).
- String& substring (const int start)
- Cuts the string into a substring (in place) from start (inclusive) to the end of the string.
- String& replace (const char c1, const char c2)
- Replace all occurrences of c1 by c2.
- String& trim ()
- Removes all leading and trailing spaces and tabs.
- String& toUpperCase ()
- Converts all characters to upper case.
- String& toLowerCase ()
- Converts all characters to lower case.
- String& packSpaces ()
- Removes all spaces and tabs from the string.
- int beginsWith (const String& s) const
- Returns non zero if this string begins with the parameter string (Case sensitive).
- int endsWith (const String& s) const
- Returns non zero if this string ends with the parameter string (Case sensitive).
- int equals (const String& s) const
- Returns non zero if this string is exactly the same as the parameter string (Case sensitive).
- unsigned crcValue () const
- Returns the string's crc value (used for hash values).
Static Public Members
- String readLine (istream& is)
- Reads a line of input up to \n or 1024 chars.
Detailed Description
A String (an array of char) with dynamic allocation.
Provides plenty of utility methods, and operators.
Note: Caution must be taken when constructing a string with integral
parameters, since compilers tend to convert them to int.
example: String S('A'); will lead to S=="65"; ('A' ascii value)
Member Function Documentation
String::String(void)
Construct an empty string.
String::String(const String& S)
String::String(const char* pBuf)
Construct a string from a characters buffer.
String::String(const int Val)
Construct a string with a number.
Example: String(123) == "123"
String::String(const char Val, const int len)
Construct a string filled with the same character.
Example: String('a',5) == "aaaaa"
char& String::operator[](const int index)
Return a character in the string.
Characters must not be changed
to or from a null character.
char& String::operator[](const int index)
Return a character in the string.
Characters must not be changed
to or from a null character.
const char* String::getString() const
Return the internal char* representation.
This is only for reading,
to maintain the String's internal data structures.
String::operator const char*() const
Automatic conversion to c style constant string.
String& String::operator=(const String& S)
String String::operator+(const String& aString) const
Concatenate with the string and return the new created string.
String& String::operator+=(const String& S)
Append the string with another.
unsigned String::size() const
Returns the number of characters in the string.
unsigned String::length() const
Returns the number of characters in the string.
float String::asFloat() const
Returns the float value represented by the string.
double String::asDouble() const
Returns the double value represented by the string.
long String::asInt() const
Returns the int value represented by the string.
long String::asIntHex() const
Returns the int value represented by the string, assuming the string is in base 16.
unsigned long String::asUnsigned() const
Returns the unsigned int value represented by the string.
String& String::untabify(const int TabSize)
Converts tabs to spaces.
'TabSize' spaces per tab
int String::isDigits() const
Returns true is string consists only of digits.
int String::indexOf(const char c) const
Finds the first appearance of a character.
returns -1 if not found.
int String::lastIndexOf(const char c) const
Finds the last appearance of a character.
returns -1 if not found.
int String::indexOf(const String& S, const int CaseSense=1) const
Finds a Sub String, returns -1 if not found.
int String::occurrencesOf(const char c) const
Counts number of occurrences of a character.
String& String::substring(const int start, const int end)
Cuts the string into a substring (in place) from start (inclusive) to end (non-inclusive).
String& String::substring(const int start)
Cuts the string into a substring (in place) from start (inclusive) to the end of the string.
String& String::replace(const char c1, const char c2)
Replace all occurrences of c1 by c2.
String& String::trim()
Removes all leading and trailing spaces and tabs.
String& String::toUpperCase()
Converts all characters to upper case.
String& String::toLowerCase()
Converts all characters to lower case.
String& String::packSpaces()
Removes all spaces and tabs from the string.
int String::beginsWith(const String& s) const
Returns non zero if this string begins with the parameter string (Case sensitive).
int String::endsWith(const String& s) const
Returns non zero if this string ends with the parameter string (Case sensitive).
int String::equals(const String& s) const
Returns non zero if this string is exactly the same as the parameter string (Case sensitive).
unsigned String::crcValue() const
Returns the string's crc value (used for hash values).
String String::readLine(istream& is) [static]
Reads a line of input up to \n or 1024 chars.
The documentation for this class was generated from the following file: