#include <MAUtil/String.h>
Each String references an instance of StringData, and these instances are shared between strings as much as possible by using the copy-on-write idiom.
Public Types | |
enum | { npos = -1 } |
Public Member Functions | |
String () | |
String (int capacity) | |
String (const char *text) | |
String (const char *text, int len) | |
String (const String &s) | |
const char * | c_str () const |
String & | operator= (const String &other) |
char & | operator[] (int index) |
const char & | operator[] (int index) const |
bool | operator== (const String &other) const |
bool | operator!= (const String &other) const |
bool | operator< (const String &other) const |
bool | operator> (const String &other) const |
bool | operator<= (const String &other) const |
bool | operator>= (const String &other) const |
String | operator+ (const String &other) const |
String & | operator+= (const String &other) |
String | operator+ (char c) const |
String & | operator+= (char c) |
int | find (const String &s, unsigned int offset=0) const |
int | findLastOf (const char findThis) const |
int | findFirstOf (const char findThis, int position=0) const |
int | findFirstNotOf (const char findNotThis, int position=0) const |
void | insert (int position, const String &other) |
void | insert (int position, char c) |
void | remove (int position, int number) |
String | substr (int startIndex, int length=npos) const |
int | size () const |
int | capacity () const |
int | length () const |
void | resize (int newSize) |
void | reserve (int newSize) |
void | clear () |
void | append (const char *other, int len) |
void | setData (StringData *data) |
char * | pointer () |
~String () | |
Protected Member Functions | |
void | allocStringData (const char *text, int len) |
Protected Attributes | |
StringData * | sd |
|
|
|
Initializes the new string with shared empty data. |
|
Initializes the string with empty data and the given capacity. |
|
Copies the specified C string into the new string. |
|
Copies len bytes of the C string text into the new string. |
|
Makes the new string share the data of s. |
|
|
|
Returns a pointer to the null-terminated character data. This pointer becomes invalid as soon as non-const medthod of this class is called. |
|
Makes this string share the other string's data. |
|
Returns a reference to the character at position index. |
|
Returns a const reference to the character at position index. |
|
Returns true if the strings are equal, false otherwise. |
|
Returns false if the strings are equal, true otherwise. |
|
Returns true if this is lexiographically less than other, false otherwise. |
|
Returns true if this is lexiographically greater than other, false otherwise. |
|
Returns true if this is lexiographically less than or equal to other, false otherwise. |
|
Returns true if this is lexiographically greater than or equal to other, false otherwise. |
|
Returns a copy of this string concatenated with the other. |
|
Concatenates a string in-place with other and returns a reference to itself. |
|
Returns a copy of this string concatenated with the c. |
|
Concatenates a string in-place with c and returns a reference to itself. |
|
Returns the index of the first instance of the given string inside this string, starting at the given position. Returns npos if not found. |
|
Returns the last index of the given character. Returns npos if not found. |
|
Returns the first index of the given character starting at the given position. Returns npos if not found. |
|
Returns the first index _not_ matching the given character, starting at the given position. Returns npos if not found. |
|
Inserts the given string at the given position. |
|
Inserts the given character at the given position. |
|
Removes the given number of characters starting at the given position. |
|
Returns a new string that is a copy of the specified portion of this string. |
|
Returns the number of characters in the string. |
|
Returns the size of the reserved space in the string data object. |
|
Returns the number of characters in the string. |
|
Resizes the string. Any new characters are undefined. |
|
Reserves space in the string data object. |
|
Resizes the string to zero. |
|
Appends a string at the end of the string. |
|
Replaces this string's data object. |
|
Returns a pointer to the string data. The pointer becomes invalidated by any non-const method of this class. |
|
|
|
A pointer to the string data object shared by this string. |