Tools.h++ Manual
104011 Tandem Computers Incorporated 21-205
21
RWWString
Synopsis
#include <rw/wstring.h>
RWWString a;
Description Class
RWWString
offers very powerful and convenient facilities for
manipulating wide character strings.
This string class manipulates wide characters of the Standard C type
wchar_t
.
These characters are generally two or four bytes, and can be used to encode
richer code sets than the classic
"char"
type. Because
wchar_t
characters are
all the same size, indexing is fast.
Conversion to and from multibyte and ASCII forms are provided by the
RWWString
constructors, and by the
RWWString
member functions
isAscii(), toAscii(), and toMultiByte()
.
Stream operations implicitly translate to and from the multibyte stream
representation. That is, on output, wide character strings are converted into
multibyte strings, while on input they are converted back into wide character
strings. Hence, the external representation of wide character strings is usually
as multibyte character strings, saving storage space and making interfaces with
devices (which usually expect multibyte strings) easier.
Class
RWWString
tolerates embedded nulls.
Parameters of type "
const wchar_t*
" 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
RWWSubString
class supports substring extraction and
modification operations.