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

Public Member Functions | |
| String (const char *str=NULL, uint32 maxLen=MUSCLE_NO_LIMIT) | |
| Constructor. | |
| String (const String &str) | |
| Copy Constructor. | |
| String (const String &str, uint32 beginIndex, uint32 endIndex=MUSCLE_NO_LIMIT) | |
| This constructor sets this String to be a substring of the specified String. | |
| virtual | ~String () |
| Destructor. | |
| String & | operator= (char val) |
| Assignment Operator. | |
| String & | operator= (const char *val) |
| Assignment Operator. | |
| String & | operator= (const String &rhs) |
| Assignment Operator. | |
| String & | operator+= (const String &rhs) |
| Append Operator. | |
| String & | operator+= (const char *rhs) |
| Append Operator. | |
| String & | operator+= (char ch) |
| Append Operator. | |
| String & | operator-= (const String &rhs) |
| Remove Operator. | |
| String & | operator-= (const char ch) |
| Remove Operator. | |
| String & | operator<< (const String &rhs) |
| Append 'Stream' Operator. | |
| String & | operator<< (const char *rhs) |
| Append 'Stream' Operator. | |
| String & | operator<< (int rhs) |
| Append 'Stream' Operator. | |
| String & | operator<< (float rhs) |
| Append 'Stream' Operator. | |
| String & | operator<< (bool rhs) |
| Append 'Stream' Operator. | |
| bool | operator== (const String &rhs) const |
| Comparison Operator. | |
| bool | operator== (const char *rhs) const |
| Comparison Operator. | |
| bool | operator!= (const String &rhs) const |
| Comparison Operator. | |
| bool | operator!= (const char *rhs) const |
| Comparison Operator. | |
| bool | operator< (const String &rhs) const |
| Comparison Operator. | |
| bool | operator< (const char *rhs) const |
| Comparison Operator. | |
| bool | operator> (const String &rhs) const |
| Comparison Operator. | |
| bool | operator> (const char *rhs) const |
| Comparison Operator. | |
| bool | operator<= (const String &rhs) const |
| Comparison Operator. | |
| bool | operator<= (const char *rhs) const |
| Comparison Operator. | |
| bool | operator>= (const String &rhs) const |
| Comparison Operator. | |
| bool | operator>= (const char *rhs) const |
| Comparison Operator. | |
| char | operator[] (uint32 index) const |
| Array Operator. | |
| char & | operator[] (uint32 index) |
| Array Operator. | |
| char | CharAt (uint32 index) const |
| Returns the character at the (index)'th position in the string. | |
| int | CompareTo (const String &rhs) const |
| Compares this string to another string using strcmp(). | |
| int | CompareTo (const char *rhs) const |
| Compares this string to a C string using strcmp(). | |
| const char * | Cstr () const |
| Returns a read-only C-style pointer to our held character string. | |
| const char * | operator() () const |
| Convenience synonym for Cstr(). | |
| void | Clear () |
| Clears this string so that it contains no characters. | |
| status_t | SetCstr (const char *str, uint32 maxLen=MUSCLE_NO_LIMIT) |
| Sets our state from the given C-style string. | |
| status_t | SetFromString (const String &str, uint32 beginIndex=0, uint32 endIndex=MUSCLE_NO_LIMIT) |
| Sets our state from the given String. | |
| bool | IsEmpty () const |
| Returns true iff this string is a zero-length string. | |
| bool | HasChars () const |
| Returns true iff this string is not a zero-length string. | |
| bool | EndsWith (char c) const |
| Returns true iff this string starts with (prefix). | |
| bool | EndsWith (const String &suffix) const |
| Returns true iff this string ends with (suffix). | |
| bool | EndsWith (const char *suffix) const |
| Returns true iff this string ends with (suffix). | |
| bool | Equals (const String &str) const |
| Returns true iff this string is equal to (string), as determined by strcmp(). | |
| bool | Equals (const char *str) const |
| Returns true iff this string is equal to (str), as determined by strcmp(). | |
| bool | Equals (char c) const |
| Returns true iff this string contains a single character (c). | |
| int | IndexOf (char ch, uint32 fromIndex=0) const |
| Returns the first index of (ch) in this string starting at or after (fromIndex), or -1 if not found. | |
| int | IndexOf (const String &str, uint32 fromIndex=0) const |
| Returns the first index of substring (str) in this string starting at or after (fromIndex), or -1 if not found. | |
| int | IndexOf (const char *str, uint32 fromIndex=0) const |
| Returns the first index of substring (str) in this string starting at or after (fromIndex), or -1 if not found. | |
| int | LastIndexOf (char ch, uint32 fromIndex=0) const |
| Returns the last index of (ch) in this string starting at or after (fromIndex), or -1 if not found. | |
| int | LastIndexOf (const String &str) const |
| Returns the last index of substring (str) in this string. | |
| int | LastIndexOf (const char *str) const |
| Returns the last index of substring (str) in this string. | |
| int | LastIndexOf (const String &str, uint32 fromIndex) const |
| Returns the last index of substring (str) in this string starting at or after (fromIndex), or -1 if not found. | |
| int | LastIndexOf (const char *str, uint32 fromIndex) const |
| Returns the last index of substring (str) in this string starting at or after (fromIndex), or -1 if not found. | |
| uint32 | Length () const |
| Returns the number of characters in the string (not including the terminating NUL byte). | |
| uint32 | GetNumInstancesOf (char ch) const |
| Returns the number of instances of (c) in this string. | |
| uint32 | GetNumInstancesOf (const String &substring) const |
| Returns the number of instances of (substring) in this string. | |
| uint32 | GetNumInstancesOf (const char *substring) const |
| Returns the number of instances of (substring) in this string. | |
| bool | StartsWith (char c) const |
| Returns true iff this string starts with (c). | |
| bool | StartsWith (const String &prefix) const |
| Returns true iff this string starts with (prefix). | |
| bool | StartsWith (const char *prefix) const |
| Returns true iff this string starts with (prefix). | |
| bool | StartsWith (const String &prefix, uint32 offset) const |
| Returns true iff this string starts with the first (offset) characters of (prefix). | |
| bool | StartsWith (const char *prefix, uint32 offset) const |
| Returns true iff this string starts with the first (offset) characters of (prefix). | |
| String | Prepend (const String &str, uint32 count=1) const |
| Returns a string that consists of (count) copies of (str), followed by this string. | |
| String | Prepend (const char *str, uint32 count=1) const |
| Returns a string that consists of (count) copies of (str), followed by this string. | |
| String | Append (const String &str, uint32 count=1) const |
| Returns a string that consists of this string followed by (count) copies of (str). | |
| String | Append (const char *str, uint32 count=1) const |
| Returns a string that consists of this string followed by (count) copies of (str). | |
| String | Pad (uint32 minLength, bool padOnRight=false, char padChar= ' ') const |
| Returns a string that is like this string, but padded out to the specified minimum length with (padChar). | |
| String | Substring (uint32 beginIndex) const |
| Returns a string that consists of only the last part of this string, starting with index (beginIndex). | |
| String | Substring (uint32 beginIndex, uint32 endIndex) const |
| Returns a string that consists of only the characters in this string from range (beginIndex) to (endIndex-1). | |
| String | Substring (const String &markerString) const |
| Returns a string that consists of only the last part of this string, starting with the first character after the last instance of (markerString). | |
| String | Substring (const char *markerString) const |
| See the Substring(const String &) documentation for details. | |
| String | Substring (uint32 beginIndex, const String &markerString) const |
| Returns a string that consists of only the characters in the string from range (beginIndex) until the character just before the first character in (markerString). | |
| String | Substring (uint32 beginIndex, const char *markerString) const |
| See the Substring(uint32, const String &) documentation for details. | |
| String | ToLowerCase () const |
| Returns an all lower-case version of this string. | |
| String | ToUpperCase () const |
| Returns an all upper-case version of this string. | |
| String | Trim () const |
| Returns an version of this string that has all leading and trailing whitespace removed. | |
| void | SwapContents (String &swapWithMe) |
| Swaps the state of this string with (swapWithMe). | |
| int | CompareToIgnoreCase (const String &s) const |
| Like CompareTo(), but case insensitive. | |
| bool | EndsWithIgnoreCase (char c) const |
| Like EndsWith(), but case insensitive. | |
| bool | EndsWithIgnoreCase (const String &s) const |
| Like EndsWith(), but case insensitive. | |
| bool | EqualsIgnoreCase (const String &s) const |
| Like Equals(), but case insensitive. | |
| bool | EqualsIgnoreCase (char c) const |
| Like Equals(), but case insensitive. | |
| int | IndexOfIgnoreCase (const String &s) const |
| Like IndexOf(), but case insensitive. | |
| int | IndexOfIgnoreCase (const String &s, uint32 f) const |
| Like IndexOf(), but case insensitive. | |
| int | IndexOfIgnoreCase (char ch) const |
| Like IndexOf(), but case insensitive. | |
| int | IndexOfIgnoreCase (char ch, uint32 f) const |
| Like IndexOf(), but case insensitive. | |
| int | LastIndexOfIgnoreCase (const String &s) const |
| Like LastIndexOf(), but case insensitive. | |
| int | LastIndexOfIgnoreCase (const String &s, uint32 f) const |
| Like LastIndexOf(), but case insensitive. | |
| int | LastIndexOfIgnoreCase (char ch) const |
| Like LastIndexOf(), but case insensitive. | |
| int | LastIndexOfIgnoreCase (char ch, uint32 f) const |
| Like LastIndexOf(), but case insensitive. | |
| bool | StartsWithIgnoreCase (char c) const |
| Like EndsWith(), but case insensitive. | |
| bool | StartsWithIgnoreCase (const String &s) const |
| Like StartsWith(), but case insensitive. | |
| bool | StartsWithIgnoreCase (const String &s, uint32 o) const |
| Like StartsWith(), but case insensitive. | |
| uint32 | HashCode () const |
| Returns a hash code for this string. | |
| uint32 | Replace (char replaceMe, char withMe) |
| Replaces all instances of (oldChar) in this string with (newChar). | |
| int32 | Replace (const String &replaceMe, const String &withMe) |
| Replaces all instances of (replaceMe) in this string with (withMe). | |
| void | Reverse () |
| Reverses the order of all characters in the string, so that e.g. | |
| virtual bool | IsFixedSize () const |
| Part of the Flattenable interface. | |
| virtual uint32 | TypeCode () const |
| Part of the Flattenable interface. | |
| virtual uint32 | FlattenedSize () const |
| Part of the Flattenable interface. | |
| virtual void | Flatten (uint8 *buffer) const |
| Part of the Flattenable interface. | |
| virtual status_t | Unflatten (const uint8 *buf, uint32 size) |
| Unflattens a String from (buf). | |
| status_t | Prealloc (uint32 numChars) |
| Makes sure that we have pre-allocated enough space for a NUL-terminated string at least (numChars) bytes long (not including the NUL byte). | |
| String | Arg (int8 value, const char *fmt="%i") const |
| Returns a string like this string, but with the appropriate %# tokens replaced with a textual representation of the values passed in as (value). | |
| String | Arg (uint8 value, const char *fmt="%u") const |
| As above, but for uint8 values. | |
| String | Arg (int16 value, const char *fmt="%i") const |
| As above, but for int16 values. | |
| String | Arg (uint16 value, const char *fmt="%u") const |
| As above, but for uint16 values. | |
| String | Arg (int32 value, const char *fmt=INT32_FORMAT_SPEC) const |
| As above, but for int32 values. | |
| String | Arg (uint32 value, const char *fmt=UINT32_FORMAT_SPEC) const |
| As above, but for uint32 values. | |
| String | Arg (int64 value, const char *fmt=INT64_FORMAT_SPEC) const |
| As above, but for int64 values. | |
| String | Arg (uint64 value, const char *fmt=UINT64_FORMAT_SPEC) const |
| As above, but for uint64 values. | |
| String | Arg (double value, const char *fmt="%f") const |
| As above, but for double values. | |
| String | Arg (const String &value) const |
| As above, but for string values. | |
| String | Arg (const char *value) const |
| As above, but for C string values. | |
| uint32 | CalculateChecksum () const |
| Returns a 32-bit checksum corresponding to this String's contents. | |
| virtual bool | AllowsTypeCode (uint32 code) const |
| Should return true iff a buffer with uint32 (code) can be used to reconstruct this object's state. | |
| status_t | CopyTo (Flattenable ©To) const |
| Causes (copyTo)'s state to set from this Flattenable, if possible. | |
| status_t | CopyFrom (const Flattenable ©From) |
| Causes our state to be set from (copyFrom)'s state, if possible. | |
| status_t | FlattenToByteBuffer (ByteBuffer &outBuf) const |
| Convenience method. | |
| Ref< ByteBuffer > | FlattenToByteBuffer () const |
| Convenience method. | |
| status_t | UnflattenFromByteBuffer (const ByteBuffer &buf) |
| Convenience method. | |
| status_t | FlattenToDataIO (DataIO &outputStream, bool addSizeHeader) const |
| Convenience method. | |
| status_t | UnflattenFromDataIO (DataIO &inputStream, int32 optReadSize, uint32 optMaxReadSize=MUSCLE_NO_LIMIT) |
| Convenience method. | |
Static Public Member Functions | |
| static void | WriteData (uint8 *outBuf, uint32 *writeOffset, const void *copyFrom, uint32 blockSize) |
| Convenience method for writing data into a byte buffer. | |
| static status_t | ReadData (const uint8 *inBuf, uint32 inputBufferBytes, uint32 *readOffset, void *copyTo, uint32 blockSize) |
| Convenience method for safely reading bytes from a byte buffer. | |
Protected Member Functions | |
| virtual status_t | CopyFromImplementation (const Flattenable ©From) |
| Called by CopyFrom() and CopyTo(). | |
Represents a dynamically resizable NUL-terminated string.
Definition at line 29 of file String.h.
| String::String | ( | const char * | str = NULL, |
|
| uint32 | maxLen = MUSCLE_NO_LIMIT | |||
| ) | [inline] |
Constructor.
| str | If non-NULL, the initial value for this String. | |
| maxLen | The maximum number of characters to place into this String (not including the NUL terminator byte). Default is unlimited (i.e. scan the entire string no matter how long it is) |
Definition at line 38 of file String.h.
References SetCstr().
Referenced by Substring().
| String::String | ( | const String & | str | ) | [inline] |
Copy Constructor.
| str | String to become a copy of. |
Definition at line 43 of file String.h.
References SetFromString().
| String::String | ( | const String & | str, | |
| uint32 | beginIndex, | |||
| uint32 | endIndex = MUSCLE_NO_LIMIT | |||
| ) | [inline] |
This constructor sets this String to be a substring of the specified String.
| str | String to become a copy of. | |
| beginIndex | Index of the first character in (str) to include. | |
| endIndex | Index after the last character in (str) to include. Defaults to a very large number, so that by default the entire remainder of the string is included. |
Definition at line 51 of file String.h.
References SetFromString().
| String& String::operator= | ( | char | val | ) | [inline] |
| String& String::operator= | ( | const char * | val | ) | [inline] |
Assignment Operator.
| rhs | String to become a copy of. |
Definition at line 69 of file String.h.
References SetFromString().
Append Operator.
| rhs | A string to append to this string. |
| String& String::operator+= | ( | const char * | rhs | ) |
Append Operator.
| rhs | A string to append to this string. If NULL, this operation is a no-op. |
| String& String::operator+= | ( | char | ch | ) | [inline] |
Remove Operator.
| rhs | A substring to remove from this string; the last instance of the substring will be cut out. If (rhs) is not found, there is no effect. |
| String& String::operator-= | ( | const char | ch | ) |
Remove Operator.
| ch | A character to remove from this string; the last instance of this char will be cut out. If (ch) is not found, there is no effect. |
| String& String::operator<< | ( | const char * | rhs | ) | [inline] |
| String& String::operator<< | ( | int | rhs | ) |
Append 'Stream' Operator.
| rhs | An int to append to this string. |
| String& String::operator<< | ( | float | rhs | ) |
Append 'Stream' Operator.
| rhs | A float to append to this string. Formatting is set at 2 decimals of precision. |
| String& String::operator<< | ( | bool | rhs | ) |
Append 'Stream' Operator.
| rhs | A bool to append to this string. Converts to 'true' and 'false' strings appropriately. |
| bool String::operator== | ( | const String & | rhs | ) | const [inline] |
| bool String::operator== | ( | const char * | rhs | ) | const [inline] |
| bool String::operator!= | ( | const String & | rhs | ) | const [inline] |
| bool String::operator!= | ( | const char * | rhs | ) | const [inline] |
| bool String::operator< | ( | const String & | rhs | ) | const [inline] |
| bool String::operator< | ( | const char * | rhs | ) | const [inline] |
| bool String::operator> | ( | const String & | rhs | ) | const [inline] |
| bool String::operator> | ( | const char * | rhs | ) | const [inline] |
| bool String::operator<= | ( | const String & | rhs | ) | const [inline] |
| bool String::operator<= | ( | const char * | rhs | ) | const [inline] |
| bool String::operator>= | ( | const String & | rhs | ) | const [inline] |
| bool String::operator>= | ( | const char * | rhs | ) | const [inline] |
| char String::operator[] | ( | uint32 | index | ) | const [inline] |
| char& String::operator[] | ( | uint32 | index | ) | [inline] |
| char String::CharAt | ( | uint32 | index | ) | const [inline] |
Returns the character at the (index)'th position in the string.
| index | A value between 0 and (Length()-1), inclusive. |
Definition at line 212 of file String.h.
References operator[]().
| int String::CompareTo | ( | const String & | rhs | ) | const [inline] |
Compares this string to another string using strcmp().
| rhs | A string to compare ourself with |
Definition at line 217 of file String.h.
References Cstr().
Referenced by CompareToIgnoreCase().
| int String::CompareTo | ( | const char * | rhs | ) | const [inline] |
| void String::Clear | ( | ) | [inline] |
| status_t String::SetCstr | ( | const char * | str, | |
| uint32 | maxLen = MUSCLE_NO_LIMIT | |||
| ) |
Sets our state from the given C-style string.
| str | The new string to copy from. If maxLen is negative, this may be NULL. | |
| maxLen | If set, the number of characters to copy (not including the NUL terminator byte). By default, the number of characters is determined automatically by scanning the string. |
Referenced by operator=(), and String().
| status_t String::SetFromString | ( | const String & | str, | |
| uint32 | beginIndex = 0, |
|||
| uint32 | endIndex = MUSCLE_NO_LIMIT | |||
| ) |
Sets our state from the given String.
This is similar to the copy constructor, except that it allows you to optionally specify a maximum length, and it allows you to detect out-of-memory errors.
| str | The new string to copy from. | |
| beginIndex | Index of the first character in (str) to include. Defaults to zero, so that by default the entire string is included. | |
| endIndex | Index after the last character in (str) to include. Defaults to a very large number, so that by default the entire remainder of the string is included. |
Referenced by operator=(), and String().
| bool String::EndsWith | ( | char | c | ) | const [inline] |
Returns true iff this string starts with (prefix).
| c | a character to check for at the end of this String. |
Definition at line 262 of file String.h.
Referenced by EndsWithIgnoreCase().
| bool String::EndsWith | ( | const String & | suffix | ) | const [inline] |
| bool String::EndsWith | ( | const char * | suffix | ) | const [inline] |
| bool String::Equals | ( | const String & | str | ) | const [inline] |
Returns true iff this string is equal to (string), as determined by strcmp().
Definition at line 282 of file String.h.
Referenced by EqualsIgnoreCase().
| bool String::Equals | ( | const char * | str | ) | const [inline] |
| bool String::Equals | ( | char | c | ) | const [inline] |
| int String::IndexOf | ( | char | ch, | |
| uint32 | fromIndex = 0 | |||
| ) | const [inline] |
Returns the first index of (ch) in this string starting at or after (fromIndex), or -1 if not found.
| ch | A character to look for in this string. | |
| fromIndex | Index of the first character to start searching at in this String. Defaults to zero (i.e. start from the first character) |
Definition at line 298 of file String.h.
References Cstr(), and Length().
Referenced by IndexOfIgnoreCase(), and Substring().
| int String::IndexOf | ( | const String & | str, | |
| uint32 | fromIndex = 0 | |||
| ) | const [inline] |
Returns the first index of substring (str) in this string starting at or after (fromIndex), or -1 if not found.
| str | A String to look for in this string. | |
| fromIndex | Index of the first character to start searching at in this String. Defaults to zero (i.e. start from the first character) |
| int String::IndexOf | ( | const char * | str, | |
| uint32 | fromIndex = 0 | |||
| ) | const [inline] |
Returns the first index of substring (str) in this string starting at or after (fromIndex), or -1 if not found.
| str | Pointer to a C string to compare to. NULL pointers are considered a synonym for "". | |
| fromIndex | Index of the first character to start searching at in this String. Defaults to zero (i.e. start from the first character) |
| int String::LastIndexOf | ( | char | ch, | |
| uint32 | fromIndex = 0 | |||
| ) | const [inline] |
Returns the last index of (ch) in this string starting at or after (fromIndex), or -1 if not found.
| ch | A character to look for in this string. | |
| fromIndex | Index of the first character to start searching at in this String. Defaults to zero (i.e. start from the first character) |
Definition at line 328 of file String.h.
References Cstr(), and Length().
Referenced by LastIndexOf(), LastIndexOfIgnoreCase(), and Substring().