#include <ustl.h>
Inheritance diagram for ustl::string:
Public Types | |
typedef char | value_type |
typedef value_type * | pointer |
typedef const value_type * | const_pointer |
typedef pointer | iterator |
typedef const_pointer | const_iterator |
typedef value_type & | reference |
typedef value_type | const_reference |
typedef ::ustl::reverse_iterator< iterator > | reverse_iterator |
typedef ::ustl::reverse_iterator< const_iterator > | const_reverse_iterator |
Public Member Functions | |
string (void) | |
Creates an empty string. | |
string (const string &s) | |
Assigns itself the value of string s . | |
string (const cmemlink &l) | |
Assigns itself the value of string s . | |
string (const_pointer s) | |
Links to s . | |
string (const_pointer s, size_type len) | |
Copies the value of s of length len into itself. | |
string (const_pointer s1, const_pointer s2) | |
Copies into itself the string data between s1 and s2 . | |
string (size_type n, value_type c=c_Terminator) | |
Creates a string of length n filled with character c . | |
size_type | length (void) const |
const_iterator | ichar (uoff_t c) const |
Returns an iterator to the character position c . | |
iterator | ichar (uoff_t c) |
Returns an iterator to the character position c . | |
pointer | data (void) |
Returns a modifiable pointer to the block. | |
const_pointer | c_str (void) const |
size_type | max_size (void) const |
Returns the maximum possible size of the block. | |
size_type | capacity (void) const |
Returns the number of bytes allocated. | |
void | resize (size_type n) |
Resize the string to n characters. New space contents is undefined. | |
const_iterator | begin (void) const |
Returns a const pointer to the block. | |
iterator | begin (void) |
Returns a modifiable pointer to the block. | |
const_iterator | end (void) const |
Returns a const pointer to the end of the block. | |
iterator | end (void) |
Returns a modifiable pointer to the end of the block. | |
const_reverse_iterator | rbegin (void) const |
reverse_iterator | rbegin (void) |
const_reverse_iterator | rend (void) const |
reverse_iterator | rend (void) |
const_reference | at (uoff_t pos) const |
Returns the const reference to the pos character. | |
reference | at (uoff_t pos) |
Returns the reference to the pos character. | |
wchar_t | char_at (uoff_t pos) const |
Returns the character at position pos . | |
operator const value_type * (void) const | |
Returns the pointer to the first character. | |
operator value_type * (void) | |
Returns the pointer to the first character. | |
const string & | operator= (const string &s) |
Assigns itself the value of string s . | |
const string & | operator= (const_reference c) |
Assigns itself the value of character c . | |
const string & | operator= (const_pointer s) |
Assigns itself the value of 0-terminated string s . | |
const string & | operator+= (const string &s) |
Appends string s . | |
const string & | operator+= (const_reference c) |
Appends character c . | |
const string & | operator+= (const_pointer s) |
Appends itself the value of 0-terminated string s . | |
const string & | operator+= (wchar_t c) |
Appends character c . | |
string | operator+ (const string &s) const |
Concatenates itself with s . | |
bool | operator== (const string &s) const |
Returns true if this string is equal to string s . | |
bool | operator== (const_pointer s) const |
Returns true if this string is equal to string s . | |
bool | operator== (const_reference c) const |
Returns true if this string is equal to character c . | |
bool | operator!= (const_pointer s) const |
Returns true if this string is not equal to string s . | |
bool | operator< (const string &s) const |
Returns true if this string is less than to string s . | |
bool | operator< (const_pointer s) const |
Returns true if this string is less than to string s . | |
bool | operator< (const_reference c) const |
Returns true if this string is less than to character c . | |
bool | operator> (const_pointer s) const |
Returns true if this string is less than to string s . | |
void | assign (const_iterator i1, const_iterator i2) |
Assigns itself the value of the range [i1 , i2 ]. | |
void | assign (const_pointer s, size_type len) |
Assigns itself the value of string s of length len . | |
void | assign (const_pointer s) |
Assigns itself the value of string s . | |
void | append (const_iterator i1, const_iterator i2) |
Appends to itself the value of the range [i1 , i2 ]. | |
void | append (const_pointer s, size_type len) |
Appends to itself the value of string s of length len . | |
void | append (const_pointer s) |
Appends to itself the value of string s of length len . | |
void | append (size_type n, const_reference c) |
void | append (size_type n, wchar_t c) |
Appends to itself n characters of value c . | |
size_type | copyto (pointer p, size_type n, const_iterator start) const |
Copies into itself at offset start , the value of string p of length n . | |
int | compare (const string &s) const |
Returns comparison value regarding string s . | |
int | compare (const_pointer s) const |
Returns comparison value regarding string s . | |
int | compare (const_iterator first1, const_iterator last1, const_iterator first2, const_iterator last2) const |
void | insert (const uoff_t ip, wchar_t c, size_type n=1) |
void | insert (const uoff_t ip, const wchar_t *first, const wchar_t *last, const size_type n=1) |
Inserts sequence of wide characters at ip . | |
void | insert (iterator start, const_reference c, size_type n=1) |
Inserts character c into this string at start . | |
void | insert (iterator start, const_pointer s, size_type n=1) |
Inserts count instances of string s at offset start . | |
void | insert (iterator start, const_pointer first, const_iterator last, size_type n=1) |
iterator | erase (iterator start, size_type size=1) |
Erases size bytes at start . | |
void | erase (uoff_t start, size_type size=1) |
iterator | erase (iterator first, const_iterator last) |
void | push_back (const_reference c) |
Inserts c at the end of the string. | |
void | push_back (wchar_t c) |
Inserts c at the end of the string. | |
void | pop_back (void) |
Erases one element at the end of the string. | |
void | clear (void) |
Removes all characters from the string. | |
void | replace (iterator first, iterator last, const_reference c, size_type n=1) |
Replaces range [start , start + len ] with character c . | |
void | replace (iterator first, iterator last, const_pointer s, size_type n=1) |
Replaces range [start , start + len ] with string s . | |
void | replace (iterator first, iterator last, const_pointer i1, const_pointer i2, size_type n=1) |
Replaces range [start , start + len ] with count instances of string s . | |
const_iterator | find (const_reference c, const_iterator pos=NULL) const |
Returns the offset of the first occurence of c after pos . | |
const_iterator | find (const string &s, const_iterator pos=NULL) const |
Returns the offset of the first occurence of substring s of length n after pos . | |
const_iterator | rfind (const_reference c, const_iterator pos=NULL) const |
Returns the offset of the last occurence of character c after pos . | |
const_iterator | rfind (const string &s, const_iterator pos=NULL) const |
Returns the offset of the last occurence of substring s of size n after pos . | |
const_iterator | find_first_of (const string &s, const_iterator pos=NULL) const |
Returns the offset of the first occurence of one of characters in s of size n after pos . | |
const_iterator | find_first_not_of (const string &s, const_iterator pos=NULL) const |
Returns the offset of the first occurence of one of characters not in s of size n after pos . | |
const_iterator | find_last_of (const string &s, const_iterator pos=NULL) const |
Returns the offset of the last occurence of one of characters in s of size n after pos . | |
const_iterator | find_last_not_of (const string &s, const_iterator pos=NULL) const |
Returns the offset of the last occurence of one of characters not in s of size n after pos . | |
int | vformat (const char *fmt, va_list args) |
Equivalent to a vsprintf on the string. | |
int | format (const char *fmt,...) __attribute__((__format__(__printf__ |
Equivalent to a sprintf on the string. | |
void | read (istream &) |
Reads the object from stream os . | |
void | write (ostream &os) const |
Writes the object to stream os . | |
size_t | stream_size (void) const |
Returns the number of bytes required to write this object to a stream. | |
Static Public Member Functions | |
hashvalue_t | hash (const char *f1, const char *l1) |
Returns a hash value for [first, last). | |
Static Public Attributes | |
const uoff_t | npos = static_cast<uoff_t>(-1) |
Value that means the end of string. | |
const value_type | c_Terminator = 0 |
String terminator. | |
const size_type | size_Terminator = sizeof(c_Terminator) |
Most systems terminate strings with '\0'. | |
const char | empty_string [size_Terminator] = "" |
An empty string. | |
Protected Member Functions | |
virtual size_type | minimumFreeCapacity (void) const |
Do not use or override this! It exists only for implementing string. |
An STL container for string manipulation. Differences from C++ standard: string is a class, not a template. Wide characters are assumed to be encoded with utf8 at all times except when rendering or editing. all functions work with iterators instead of indexes. This makes for a cleaner syntax in most cases, and, of course, a cleaner implementation. The exception to expression clarity is the code that changes the string based on fixed offsets. You can bite it and use begin() offsets, but a better solution is to simply not do it. Code written in that manner is too inflexible. Search for separators, or use the replace call. format member function - strstreams on the string are possible, but are in many cases inconvenient because they hardcode not only the locations of substitutions, but also the constant text in between. Such behaviour makes string localization all but impossible. Another constant gripe is the requirement for space precomputation for strings. string::format will reallocate the string, if needed, to hold the entire output. (That's only for glibc > 2.0.6. See code for comments) Also, take care not to pass in untrusted format strings lest they contain a n, which causes a nasty security hole. const char* cast operator. It is much clearer to use this than having to type .c_str() every time. A side effect of this is that const operator[] is no longer needed (gcc will warn about an ambiguous overload) length() returns the number of _characters_, not bytes. This function is O(N), since the character count is not stored, so use wisely.
|
Returns comparison value regarding string
|
|
Returns comparison value regarding string
|
|
Returns comparison value regarding string
|
|
Erases |
|
Inserts wide character
|
|
Returns the length of the string in characters. This may be different from the value returned by size() if you have non-ascii characters (UTF-8) in the string. |