Tools.h++ Class Reference

Table Of Contents
RWCString::mbLength() to get the number of characters. Note that the latter is much
slower because it must determine the number of bytes in every character. Hence, if the
string is known to be nothing but SBCS, then RWCString::length() is much to be
preferred.
One or more bytes of a multibyte character can be zero. Hence, MBCS cannot be counted
on being null terminated. In practice, it is a rare MBCS that uses embedded nulls.
Nevertheless, you should be aware of this and program defensively. In any case, class
RWCString can handle embedded nulls.
Parameters of type "const char*" must not be passed a value of zero. This is detected in the
debug version of the library.
The class is implemented using a technique called copy on write. With this technique, the copy
constructor and assignment operators still reference the old object and hence are very fast. An
actual copy is made only when a "write" is performed, that is if the object is about to be changed.
The net result is excellent performance, but with easy-to-understand copy semantics.
A separate class RWCSubString supports substring extraction and modification operations.
Persistence
Simple
Example
#include <rw/re.h>
#include <rw/rstream.h>
main(){
RWCString a("There is no joy in Beantown.");
cout << a << endl << "becomes...." << endl;
RWCRExpr re("[A-Z][a-z]*town"); // Any capitalized "town"
a.replace(re, "Redmond");
cout << a << endl;
}
Program output:
There is no joy in Redmond.
Enumerations
enum RWCString::caseCompare { exact, ignoreCase }
Used to specify whether comparisons, searches, and hashing functions should use case