#include <mcllib/MCString.h>
Inheritance diagram for MCString:
Public Types | |
typedef IMPLTYPE | const_iterator |
const iterator type. | |
enum | EStripWsWhere { MCWSHEAD, MCWSTAIL, MCWSBOTH } |
Enum describing where to strip white space from string. More... | |
typedef const char * | IMPLTYPE |
Character type. | |
typedef unsigned long | size_t |
Size type. | |
Public Member Functions | |
const_iterator | begin () const |
Obtain an interator to the beginning of the string. | |
IMPLTYPE | c_str () const |
Obtain a pointer to the beginning of the string (as a C-style null terminated string). | |
int | cmp (const MCString &mcs, bool ignoreCase=false) const |
Compare this string with another string. | |
const_iterator | end () const |
Obtain an interator to the end of the string. | |
void | erase () |
Erase the contents of the string. | |
int | find (char c, int start=0) const |
Find the first occurence of a character in a string. | |
unsigned long | getCount () const |
debug for getting ref count | |
size_t | length () const |
Obtain the length of the string. | |
MCString (IMPLTYPE pStr, size_t length) | |
Construct a string from a character pointer and a length. | |
MCString (IMPLTYPE pStr) | |
Construct a string from a character pointer. | |
MCString () | |
Construct an empty string. | |
operator IMPLTYPE () const | |
Obtain a pointer to the beginning of the string (as a C-style null terminated string). | |
bool | operator!= (const MCString &mcs) const |
Test two strings for inequality. | |
bool | operator< (const MCString &mcs) const |
Test if this string is less than another string. | |
bool | operator== (const MCString &mcs) const |
Test two strings for equality. | |
int | rfind (char c, int start=0) const |
Find the last occurence of a character in a string. | |
size_t | size () const |
Obtain the length of the string. | |
void | stripws (EStripWsWhere where=MCWSBOTH) |
Strip white space from one or both ends of a string. | |
MCString | substr (int start, int length=0) const |
Obtain a substring of the string. | |
~MCString () | |
Destroy string. |
This string type forms the basis for all contained string data (e.g. in exceptions), where leak-free reference counting is needed. It is null terminated to make c_str, begin/end etc. easier to use. It uses reference counting internally so can potentially reduce memory allocation. Additionally, it handles empty strings without allocating any memory on the heap (only the stack memory used for the MCString object).
|
const iterator type. Note that only constant iterators are provided because the string data must not be changed via the iterator. |
|
Enum describing where to strip white space from string.
|
|
Construct an empty string. No (extra) memory is allocated. |
|
Destroy string. This reduces the reference count on the contained data by one, freeing it if no references remain. |
|
Construct a string from a character pointer.
|
|
Construct a string from a character pointer and a length.
|
|
Obtain an interator to the beginning of the string.
|
|
Obtain a pointer to the beginning of the string (as a C-style null terminated string). If the string was constructed using the MCString(str, len) the returned pointer may include a null terminator before the end of the string specified by len. Convenience function for compatibility with std::string
|
|
Compare this string with another string. Operates like strcmp().
|
|
Obtain an interator to the end of the string.
|
|
Erase the contents of the string. Any other references to the same contained string are unaffected. This effectively reduces the reference count on the contained data by one, freeing it if no references remain. |
|
Find the first occurence of a character in a string.
|
|
Obtain the length of the string.
|
|
Obtain a pointer to the beginning of the string (as a C-style null terminated string). If the string was constructed using the MCString(str, len) the returned pointer may include a null terminator before the end of the string specified by len.
|
|
Test two strings for inequality.
|
|
Test if this string is less than another string. This is useful for sorting and to allow strings to be used in STL containers.
|
|
Test two strings for equality.
|
|
Find the last occurence of a character in a string.
|
|
Obtain the length of the string. This is provided for std::string compatibility
|
|
Strip white space from one or both ends of a string. If the string has no white space (according to the value of where) then the string is unaffected. If the string has no non-white space characters, the effect is the same as calling erase() on the string (the string is erased). If the string is modified or erased, any references to the original string are unaffected and this MCString is the only reference to the new string.
|
|
Obtain a substring of the string.
|