|
Public Types |
| typedef unsigned | size_type |
Public Member Functions |
| | String () |
| | Construct an empty string.
|
| | String (const String &original) |
| | Copy constructor.
|
| | String (const char *str) |
| | Create a string from a cstring.
|
| | String (const String &str, unsigned offset, unsigned len=npos) |
| | Create a new string from a subset of another string.
|
| | String (unsigned count, const char *str) |
| | Create a string of a known size, and optionally fill with content.
|
| | String (unsigned count, char fill= ' ') |
| | Fill a new string with character data.
|
| virtual | ~String () |
| | Destroy the string...
|
| const char * | getIndex (unsigned index) const |
| | Get a string pointer to string content based on an indexed offset.
|
| char * | getText (void) const |
| | Get the text of a string.
|
| const unsigned | getLength (void) const |
| | Get the assigned length of string.
|
| const unsigned | getSize (void) const |
| | Get the allocation size of the string variable.
|
| bool | isEmpty (void) const |
| | Return true if string is empty.
|
| void | resize (unsigned size) |
| | Re-allocate buffer space for string.
|
| void | clear (void) |
| | Clear the contents of the entire string.
|
| char | at (int offset) const |
| | Return a character at a known offset.
|
| unsigned | count (const String &s, unsigned offset=0) const |
| | Count the number of occurences of a specific string within our string.
|
| unsigned | count (const char *s, unsigned offset=0, unsigned len=0) const |
| | Count the number of occurrences of a specific text pattern within our string.
|
| String | token (const char *delim="\t\n\r", unsigned offset=0) |
| | Extract a new string as a token from the current string.
|
| unsigned | find (const String &s, unsigned offset=0, unsigned instance=1) const |
| | Find the index to the nth instance of a substring in our string.
|
| unsigned | rfind (const String &s, unsigned offset=0) const |
| | Find last occurence of a substring in our string.
|
| unsigned | find (const char *s, unsigned offset=0, unsigned len=0, unsigned count=1) const |
| | Find the index to the nth instance of text in our string.
|
| unsigned | rfind (const char *s, unsigned offset=0, unsigned len=0) const |
| | Find last occurence of a text in our string.
|
| void | trim (const char *cs) |
| | Trim trailing characters from a string.
|
| void | chop (const char *cs) |
| | Chop leading characters from a string.
|
| void | strip (const char *cs) |
| | Strip lead and trailing characters from a string.
|
| void | chop (unsigned count) |
| | Chop n leading characters from a string.
|
| void | trim (unsigned count) |
| | Trim n trailing characters from a string.
|
| void | erase (unsigned start, unsigned len=npos) |
| | Erase a portion of string.
|
| void | insert (unsigned start, const char *text, unsigned len=0) |
| | Insert text into a string.
|
| void | insert (unsigned start, const String &str) |
| | Insert other string into our string.
|
| void | replace (unsigned start, unsigned len, const char *text, unsigned count=0) |
| | Replace text at a specific position in the string with new text.
|
| void | replace (unsigned start, unsigned len, const String &s) |
| | Replace text at a specific position in the string with new string,.
|
| unsigned | find (unsigned instance, const char *text, unsigned offset=0, unsigned len=0) const |
| | A more convenient version of find for nth occurences, by putting the instance first.
|
| unsigned | find (unsigned instance, const String &s, unsigned offset=0) const |
| | A more convenient version of find for nth occurences, by putting the instance first.
|
| String | substr (unsigned start, unsigned len) const |
| | Return a new string that contains a specific substring of the current string.
|
| const char * | index (unsigned idx) const |
| | Return an indexed string based on the index, such as from a find.
|
| void | compact (void) |
| | Reduce the size of the string allocation to the minimum needed based on the current effective length.
|
| char * | c_str (void) const |
| | Old ANSI C++ compatible string pointer extraction.
|
| | operator char * () const |
| | Get our string data through dereference operator.
|
| bool | operator! (void) const |
| | Logical test for string empty.
|
| char * | text (void) const |
| | Alternate get text method.
|
| char * | data (void) const |
| | Alternate get text method.
|
| unsigned | length (void) const |
| | Get length as if null terminated string.
|
| unsigned | size (void) const |
| | Get actual length of string data.
|
| unsigned | capacity (void) const |
| | Get space allocated to hold current string.
|
| bool | empty (void) const |
| | Return true if string is empty.
|
| void | append (const char *str, unsigned count=0) |
| | Append text to the end of the current string.
|
| void | append (const char *str, unsigned offset, unsigned count) |
| | Append text into the current string.
|
| void | add (char c) |
| | Add a character to the end of a string.
|
| void | append (const String &str) |
| | Append string to the end of the current string.
|
| const char | operator[] (unsigned index) const |
| | Extract a character by array indexing.
|
| void | operator= (const String &str) |
| | Assign our string from another string.
|
| const char * | operator= (const char *str) |
| | Assign our string for c string.
|
| String & | operator+= (const String &str) |
| | Append operator.
|
| String & | operator+= (char c) |
| | Append operator.
|
| String & | operator+= (const char *str) |
| | Append operator.
|
| bool | operator< (const String &str) |
| bool | operator< (const char *str) |
| bool | operator> (const String &str) |
| bool | operator> (const char *str) |
| bool | operator<= (const String &str) |
| bool | operator<= (const char *str) |
| bool | operator>= (const String &str) |
| bool | operator>= (const char *str) |
| bool | operator== (const String &str) |
| bool | operator== (const char *str) |
| bool | operator!= (const String &str) |
| bool | operator!= (const char *str) |
| bool | operator *= (const String &str) |
| | Test if string is contained in our string.
|
| bool | operator *= (const char *str) |
| | Test if text is contained in our string.
|
Static Public Attributes |
| const unsigned | npos |
Protected Member Functions |
| bool | isBig (void) const |
| | Determine if string is allocated in local variable or an external reference.
|
| const char * | set (const char *str, unsigned len=0) |
| | Set the content of the string variable to the specified string value, and use smart re-allocation strategies if appropriate to shrink the size of the variable.
|
| void | set (const String &str) |
| | Set the content of the string variable to that of another variable.
|
| void | copy (const String &str) |
| | Impliment the copy constructor, used internally.
|
| void | init (void) |
| | Used to initialize a string object.
|
| char * | getSpace (unsigned size) |
| | Used to fetch memory, if needed, based on the size, from the pager, or the system heap.
|
| unsigned | setSize (unsigned size) |
| | Set the size of allocated space in the string variable (capacity) to a known value.
|
| void | setLength (unsigned len) |
| | Set the length value of the string content.
|
| virtual int | compare (const char *text, unsigned len=0, unsigned index=0) const |
| | A derivable low level comparison operator.
|
| unsigned | search (const char *text, unsigned clen=0, unsigned offset=0) const |
| | An internal method used to search for a substring starting at a known offset.
|
Static Protected Attributes |
| const unsigned | minsize |
| const unsigned | slotsize |
| const unsigned | pagesize |
| const unsigned | slotlimit |
| const unsigned | slots |
Friends |
| class | MemPager |
| __EXPORT String | operator+ (const String &s1, const String &s2) |
| | Add two strings and return a temporary object.
|
| __EXPORT String | operator+ (const String &s1, const char *s2) |
| __EXPORT String | operator+ (const char *s1, const String &s2) |
| __EXPORT String | operator+ (const String &s1, const char c2) |
| __EXPORT String | operator+ (const char c1, const String &s2) |
| __EXPORT std::istream & | getline (std::istream &is, String &str, char delim= '\n', unsigned size=0) |
| | Fetch input from a std::istream into the current string variable until either the string variable is filled (based on current length) or the deliminator is read.
|
| __EXPORT std::ostream & | operator<< (std::ostream &os, const String &str) |
| | Stream the content of our string variable directly to a C++ streaming source.
|
| std::istream & | operator>> (std::istream &is, String &str) |
| | Stream input into our variable.
|
It uses optimized memory allocation strategies to efficiently handle smaller string content by grouping strings into 32 byte aligned slots that can be re-allocated from a free list directly.
While meant to cover the basic functionality of the ANSI C++ string class in form and function, this class offers some important enhancements, including the ability to derive class type specific versions of itself. The latter might be used to derive a unicode string, a string for data and time data types, or to add case insensitive comparisons, for example.