#include <rtstring.h>
Inheritance diagram for lrt::String:

Public Types | |
| enum | SplitFlags { NONE = 0, CREATE_EMPTY = 1 } |
| Flags for split(). More... | |
Public Methods | |
| String () | |
| Creates an empty string. | |
| String (const char *cStr) | |
| Creates a string from an C-style character pointer. More... | |
| String (const char chr, int length) | |
Creates a string consisting of length equal characters, namely chr. More... | |
| String (int num, int radix=10, int length=0) | |
| Creates a string representing a given integer number. More... | |
| String (double num, int minLength=13) | |
| Creates a string representing a given floating-point number. More... | |
| String (const String &str) | |
| Creates a copy of String str. | |
| String & | operator+= (const char) |
| Appends a single character (or character literal) to this string. More... | |
| String & | operator+= (const int) |
| Appends the numerical (decimal) representation of a number to this string. More... | |
| String & | operator+= (const String &) |
| Appends another String to this String. More... | |
| String & | operator= (const String &) |
| Clears this String, then copies the given String's contents over to this one. More... | |
| String | trim () const |
| Returns a new string like this one, but with any whitespace from the beginning and end of the string removed. More... | |
| String | substring (int start, int end=Math::MAX_INT) const |
| Returns a new string which represents a part of this string. More... | |
| String | lowerCase () const |
| Returns a new string which is the lowercase equivalent of this string. | |
| String | upperCase () const |
| Returns a new string which is the uppercase equivalent of this string. | |
| int | indexOf (char ch, int fromIndex=0) const |
| Finds the first occurence of a given character in this string. More... | |
| int | indexOf (const String &str, int fromIndex=0) const |
| Finds the first occurence of a given substring in this string. More... | |
| int | lastIndexOf (char ch, int fromIndex=Math::MAX_INT) const |
| Finds the first occurence of a given character in this string, searching backwards from the end of this string. More... | |
| int | lastIndexOf (const String &str, int fromIndex=Math::MAX_INT) const |
| Finds the first occurence of a given substring in this string, searching backwards from the end of this string. More... | |
| bool | operator== (const String &) const |
Returns true if all characters of this string are exactly equal to the given string. | |
| bool | operator!= (const String &) const |
Returns true if any character, or the length, of this string differ from the given string. | |
| bool | operator< (const String &) const |
Returns true if this string should be ordered before the given string. More... | |
| int | compare (const String &str) const |
| Returns a negative, zero, or a positive number as this is less, equal, or greater than str. More... | |
| int | compareIgnoreCase (const String &str) const |
| Returns a negative, zero, or a positive number as this is less, equal, or greater than str. More... | |
| bool | startsWith (const String &str) const |
Returns true if this string starts with the given substring str. | |
| bool | endsWith (const String &str) const |
Returns true if this string ends with the given substring str. | |
| String | replace (char oldCh, char newCh) const |
Returns a new string, in which all occurencies of oldCh are replaced by newCh. | |
| String | replace (const String &oldStr, const String &newStr) const |
Returns a new string, in which all occurencies of oldStr have been replaced by newStr. | |
| Array< String > | split (const String &separators=",", const String &combiners="\"\'", int maxParts=-1, SplitFlags flags=NONE) const |
| Splits this string into parts. More... | |
| const char * | cStr () const |
| Returns a constant pointer to this string's data. More... | |
| int | intValue (int def, int radix=10) const |
| Parses this String as an integer. More... | |
| double | doubleValue (double def) const |
| Parses this String as a floating-point value. More... | |
| virtual | ~String () |
Static Public Methods | |
| int | compare (const String &str1, const String &str2) |
| Compares two strings. More... | |
| int | compareIgnoreCase (const String &str1, const String &str2) |
| Compares two strings, ignoring case. More... | |
| String | join (const Array< String > &arr, const String &joiner=",", const int upTo=Math::MAX_INT) |
Joins an array of Strings together. More... | |
The String class of libRT implements many methods for comfortable handling of strings, including conversion from and to numbers, case conversions, substrings, searches, comparisons, etc.
|
|
Flags for split().
|
|
|
Creates a string from an C-style character pointer. This constructor is also used to implicitely convert all string literals to libRT Strings. |
|
||||||||||||
|
Creates a string consisting of Example: String('a', 7) becomes "aaaaaaa" |
|
||||||||||||||||
|
Creates a string representing a given integer number.
|
|
||||||||||||
|
Creates a string representing a given floating-point number.
|
|
||||||||||||
|
Compares two strings. This method is case sensitive, and will not work well for non-English text.
|
|
|
Returns a negative, zero, or a positive number as this is less, equal, or greater than str. This method is case sensitive, and will not work well for non-English text.
|
|
||||||||||||
|
Compares two strings, ignoring case. This method is case insensitive, and will not work well for non-English text.
|
|
|
Returns a negative, zero, or a positive number as this is less, equal, or greater than str. This method is case insensitive, and will not work well for non-English text.
|
|
|
Returns a constant pointer to this string's data.
This string is zero-terminated before returning the pointer, but any subsequent String modifications (through the String methods, as you cannot modify the string using the returned pointer) will probably make the pointer useless. |
|
|
Parses this String as a floating-point value. As many numbers as possible are parsed from the beginning of this String. If there are no valid numbers at the beginning of this String, the given default value is instead returned.
|
|
||||||||||||
|
Finds the first occurence of a given substring in this string.
|
|
||||||||||||
|
Finds the first occurence of a given character in this string.
|
|
||||||||||||
|
Parses this String as an integer.
As many numbers as possible are parsed from the beginning of this String. If there are no valid numbers at the beginning of this String (considering the given
|
|
||||||||||||||||
|
Joins an array of
|
|
||||||||||||
|
Finds the first occurence of a given substring in this string, searching backwards from the end of this string.
|
|
||||||||||||
|
Finds the first occurence of a given character in this string, searching backwards from the end of this string.
|
|
|
Appends another String to this String.
|
|
|
Appends the numerical (decimal) representation of a number to this string.
|
|
|
Appends a single character (or character literal) to this string.
|
|
|
Returns This operator is case sensitive, and will not work well for non-English text. |
|
|
Clears this String, then copies the given String's contents over to this one.
|
|
||||||||||||||||||||
|
Splits this string into parts.
The string is split into portions wherever one of the
Example: The string "
|
|
||||||||||||
|
Returns a new string which represents a part of this string.
|
|
|
Returns a new string like this one, but with any whitespace from the beginning and end of the string removed. For a definition of whitespace,
|