String Class Reference#include <str.h>
Inheritance diagram for String:
[legend]List of all members.
Detailed Description
The String class represents a 0-terminated array of characters.
|
Public Types |
| typedef U32 | SizeType |
| typedef StringChar | ValueType |
| | Case = 0 |
| | Case sensitive.
|
| | NoCase = 1 |
| | Case insensitive.
|
| | Left = 0 |
| | Start at left end of string.
|
| | Right = 2 |
| | Start at right end of string.
|
| enum | Mode {
Case = 0,
NoCase = 1,
Left = 0,
Right = 2
} |
| | Default mode is case sensitive starting from the left. More...
|
Public Member Functions |
| | String () |
| | String (const String &str) |
| | String (const StringChar *str) |
| | String (const StringChar *str, SizeType size) |
| | String (const UTF16 *str) |
| | ~String () |
| const UTF8 * | c_str () const |
| | Return the string as a native type.
|
| const UTF16 * | utf16 () const |
| SizeType | length () const |
| | Returns the length of the string.
|
| SizeType | size () const |
| | Returns the length of the string including the NULL terminator.
|
| bool | isEmpty () const |
| | Is this an empty string [""]?
|
| bool | isNotEmpty () const |
| | Is this not an empty string [""]?
|
| bool | isShared () const |
| | Is this string's reference count greater than 1?
|
| U32 | getHashCaseSensitive () const |
| | Get the case-sensitive hash of the string [only calculates the hash as necessary].
|
| U32 | getHashCaseInsensitive () const |
| | Get the case-insensitive hash of the string [only calculates the hash as necessary].
|
| String & | operator= (StringChar) |
| String & | operator+= (StringChar) |
| String & | operator= (const StringChar *) |
| String & | operator+= (const StringChar *) |
| String & | operator= (const String &) |
| String & | operator+= (const String &) |
| StringChar | operator[] (SizeType) const |
| int | compare (const StringChar *str, SizeType len=0, int mode=Case|Left) const |
| | Compare this string with another.
|
| int | compare (const String &str, SizeType len=0, int mode=Case|Left) const |
| bool | equal (const String &str, int mode=Case) const |
| | Compare two strings for equality.
|
| SizeType | find (StringChar c, SizeType pos=0, int mode=Case|Left) const |
| SizeType | find (const StringChar *str, SizeType pos=0, int mode=Case|Left) const |
| SizeType | find (const String &str, SizeType pos=0, int mode=Case|Left) const |
| String & | insert (SizeType pos, const StringChar c) |
| String & | insert (SizeType pos, const StringChar *str) |
| String & | insert (SizeType pos, const String &str) |
| String & | insert (SizeType pos, const StringChar *str, SizeType len) |
| String & | erase (SizeType pos, SizeType len) |
| String & | replace (SizeType pos, SizeType len, const StringChar *str) |
| String & | replace (SizeType pos, SizeType len, const String &str) |
| String & | replace (StringChar c1, StringChar c2) |
| | Replace all occurrences of character 'c1' with 'c2'.
|
| String | substr (SizeType pos, SizeType len) const |
| | operator const char * () const |
| bool | operator== (const String &str) const |
| bool | operator!= (const String &str) const |
| bool | operator< (const String &str) const |
| bool | operator> (const String &str) const |
| bool | operator<= (const String &str) const |
| bool | operator>= (const String &str) const |
Static Public Member Functions |
|
| static String | ToString (const char *format,...) |
| static String | ToString (U32 v) |
| static String | ToString (S32 v) |
| static String | ToString (F32 v) |
| static String | SpanToString (const char *start, const char *end) |
| static String | ToLower (const String &string) |
| static String | ToUpper (const String &string) |
|
| static void | BeginString () |
| static S32 | AppendChar (char ch) |
| static S32 | AppendString (const char *str) |
| static S32 | AppendString (const char *str, S32 len) |
| static S32 | AppendFormat (const char *format,...) |
| static String | EndString () |
Static Public Attributes |
| static const SizeType | NPos |
| | Indicates 'not found' when using find() functions.
|
Private Member Functions |
| | String (SubString *str) |
| | operator const bool () const |
| bool | operator== (const StringChar *str) const |
| bool | operator!= (const StringChar *str) const |
| bool | operator< (const StringChar *str) const |
| bool | operator> (const StringChar *str) const |
| bool | operator<= (const StringChar *str) const |
| bool | operator>= (const StringChar *str) const |
| void | setSubString (SubString *sub) |
| void | decrement () |
Static Private Member Functions |
| static void | copy (StringChar *dst, const StringChar *src, U32 size) |
| static SubString & | GetEmptyString () |
Private Attributes |
| SubString * | _string |
Friends |
| String | operator+ (const String &a, StringChar c) |
| String | operator+ (StringChar c, const String &a) |
| String | operator+ (const String &a, const StringChar *b) |
| String | operator+ (const String &a, const String &b) |
| String | operator+ (const StringChar *a, const String &b) |
Member Typedef Documentation
Member Enumeration Documentation
Default mode is case sensitive starting from the left.
- Enumerator:
-
| Case |
Case sensitive. |
| NoCase |
Case insensitive. |
| Left |
Start at left end of string. |
| Right |
Start at right end of string. |
Constructor & Destructor Documentation
| String::String |
( |
const String & |
str |
) |
|
| String::String |
( |
const UTF16 * |
str |
) |
|
| String::String |
( |
SubString * |
str |
) |
[inline, private] |
Member Function Documentation
| const UTF8* String::c_str |
( |
|
) |
const |
Return the string as a native type.
| const UTF16* String::utf16 |
( |
|
) |
const |
Returns the length of the string.
Returns the length of the string including the NULL terminator.
| bool String::isEmpty |
( |
|
) |
const |
Is this an empty string [""]?
| bool String::isNotEmpty |
( |
|
) |
const [inline] |
Is this not an empty string [""]?
| bool String::isShared |
( |
|
) |
const |
Is this string's reference count greater than 1?
| U32 String::getHashCaseSensitive |
( |
|
) |
const |
Get the case-sensitive hash of the string [only calculates the hash as necessary].
| U32 String::getHashCaseInsensitive |
( |
|
) |
const |
Get the case-insensitive hash of the string [only calculates the hash as necessary].
| int String::compare |
( |
const StringChar * |
str, |
|
|
SizeType |
len = 0, |
|
|
int |
mode = Case|Left | |
|
) |
| | const |
Compare this string with another.
- Parameters:
-
| str | The string to compare against. |
| len | If len is non-zero, then at most len characters are compared. |
| mode | Comparison mode. |
- Returns:
- Difference between the first two characters that don't match.
| int String::compare |
( |
const String & |
str, |
|
|
SizeType |
len = 0, |
|
|
int |
mode = Case|Left | |
|
) |
| | const |
| bool String::equal |
( |
const String & |
str, |
|
|
int |
mode = Case | |
|
) |
| | const |
Compare two strings for equality.
It will use the string hashes to determine inequality. - Parameters:
-
| str | The string to compare against. |
| mode | Comparison mode - case sensitive or not. |
Replace all occurrences of character 'c1' with 'c2'.
| String::operator const char * |
( |
|
) |
const [inline] |
| bool String::operator== |
( |
const String & |
str |
) |
const |
| bool String::operator!= |
( |
const String & |
str |
) |
const [inline] |
| bool String::operator< |
( |
const String & |
str |
) |
const |
| bool String::operator> |
( |
const String & |
str |
) |
const |
| bool String::operator<= |
( |
const String & |
str |
) |
const |
| bool String::operator>= |
( |
const String & |
str |
) |
const |
| static String String::ToString |
( |
const char * |
format, |
|
|
|
... | |
|
) |
| | [static] |
| static String String::ToString |
( |
U32 |
v |
) |
[inline, static] |
| static String String::ToString |
( |
S32 |
v |
) |
[inline, static] |
| static String String::ToString |
( |
F32 |
v |
) |
[inline, static] |
| static String String::SpanToString |
( |
const char * |
start, |
|
|
const char * |
end | |
|
) |
| | [static] |
| static String String::ToLower |
( |
const String & |
string |
) |
[static] |
| static String String::ToUpper |
( |
const String & |
string |
) |
[static] |
| static void String::BeginString |
( |
|
) |
[static] |
| static S32 String::AppendChar |
( |
char |
ch |
) |
[static] |
| static S32 String::AppendString |
( |
const char * |
str |
) |
[static] |
| static S32 String::AppendString |
( |
const char * |
str, |
|
|
S32 |
len | |
|
) |
| | [static] |
| static S32 String::AppendFormat |
( |
const char * |
format, |
|
|
|
... | |
|
) |
| | [static] |
| static String String::EndString |
( |
|
) |
[static] |
| String::operator const bool |
( |
|
) |
const [inline, private] |
| bool String::operator== |
( |
const StringChar * |
str |
) |
const [inline, private] |
| bool String::operator!= |
( |
const StringChar * |
str |
) |
const [inline, private] |
| bool String::operator< |
( |
const StringChar * |
str |
) |
const [inline, private] |
| bool String::operator> |
( |
const StringChar * |
str |
) |
const [inline, private] |
| bool String::operator<= |
( |
const StringChar * |
str |
) |
const [inline, private] |
| bool String::operator>= |
( |
const StringChar * |
str |
) |
const [inline, private] |
| static SubString& String::GetEmptyString |
( |
|
) |
[static, private] |
| void String::setSubString |
( |
SubString * |
sub |
) |
[private] |
| void String::decrement |
( |
|
) |
[private] |
Friends And Related Function Documentation
Member Data Documentation
Indicates 'not found' when using find() functions.
|