Rogue Wave banner
Previous fileTop of documentContentsIndexNext file

RWWString

Data Type and Member Function Indexes
(exclusive of constructors and destructors)

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 fundamental 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.

RWWStrings tolerate 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.

Persistence

Simple

Example

#include <rw/rstream.h>
#include <rw/wstring.h>

main(){
 RWWString a(L"There is no joy in Beantown");
 a.subString(L"Beantown") = L"Redmond";
 cout << a << endl;
 return 0;
}

Program output:

There is no joy in Redmond.

Enumerations

enum RWWString::caseCompare { exact, ignoreCase };
enum RWWString::multiByte_ { multiByte };
enum RWWString::ascii_ {ascii };

Public Constructors

RWWString();
RWWString(const wchar_t* cs);
RWWString(const wchar_t* cs, size_t N);
RWWString(RWSize_T ic);
RWWString(const RWWString& str); 
RWWString(const RWWSubString& ss);
RWWString(char c);
RWWString(char c, size_t N);
RWWString(const char* mbcs, multiByte_ mb);
RWWString(const char* acs, ascii_ asc);
RWWString(const char* cs, size_t N, multiByte_ mb);
RWWString(const char* cs, size_t N, ascii__ asc);

Type Conversion

operator
const wchar_t*() const; 

Assignment Operators

RWWString&
operator=(const char* cs); 
RWWString&
operator=(const RWWString& str);
RWWString&
operator=(const RWWSubString& sub);
RWWString&
operator+=(const wchar_t* cs); 
RWWString&
operator+=(const RWWString& str);

Indexing Operators

wchar_t&
operator[](size_t i); 
wchar_t
operator[](size_t i) const;
wchar_t&
operator()(size_t i); 
wchar_t
operator()(size_t i) const;
RWWSubString
operator()(size_t start, size_t len); 
const RWWSubString
operator()(size_t start, size_t len) const;

Public Member Functions

RWWString&
append(const wchar_t* cs); 
RWWString&
append(const wchar_t* cs, size_t N,);
RWWString&
append(const RWWString& cstr);
RWWString&
append(const RWWString& cstr, size_t N);
size_t
binaryStoreSize() const; 
size_t
capacity() const; 
size_t
capacity(size_t capac); 
int
collate(const RWWString& str) const; 
int
collate(const wchar_t*   str) const;
int
compareTo(const RWWString& str, 
          caseCompare = RWWString::exact) const;
int
compareTo(const wchar_t*   str, 
          caseCompare = RWWString::exact) const;
RWBoolean
contains(const RWWString& cs, 
         caseCompare = RWWString::exact) const;
RWBoolean
contains(const wchar_t* str, 
         caseCompare = RWWString::exact) const;
const wchar_t*
data() const; 
size_t
first(wchar_t c) const; 
size_t
first(wchar_t c, size_t) const;
size_t
first(const wchar_t* str) const;
size_t
first(const wchar_t* str, size_t N) const;
unsigned
hash(caseCompare = RWWString::exact) const; 
size_t
index(const wchar_t* pat,size_t i=0, 
      caseCompare = RWWString::exact) const;
size_t
index(const RWWString& pat,size_t i=0, 
      caseCompare = RWWString::exact) const;
size_t
index(const wchar_t* pat, size_t patlen,size_t i, 
      caseCompare) const;
size_t
index(const RWWString& pat, size_t patlen,size_t i, 
      caseCompare) const;
RWWString&
insert(size_t pos, const wchar_t* cs); 
RWWString&
insert(size_t pos, const wchar_t* cs, size_t N);
RWWString&
insert(size_t pos, const RWWString& str);
RWWString&
insert(size_t pos, const RWWString& str, size_t N);
RWBoolean
isAscii() const; 
RWBoolean
isNull() const; 
size_t
last(wchar_t c) const; 
size_t
length() const; 
RWWString&
prepend(const wchar_t* cs); 
RWWString&
prepend(const wchar_t* cs, size_t N,);
RWWString&
prepend(const RWWString& str);
RWWString&
prepend(const RWWString& cstr, size_t N);
istream&
readFile(istream& s); 
istream&
readLine(istream& s, RWBoolean skipWhite = TRUE); 
istream&
readString(istream& s); 
istream&
readToDelim(istream&, wchar_t delim=(wchar_t)'\n'); 
istream&
readToken(istream& s); 
RWWString&
remove(size_t pos); 
RWWString&
remove(size_t pos, size_t N); 
RWWString&
replace(size_t pos, size_t N, const wchar_t* cs); 
RWWString&
replace(size_t pos, size_t N1,const wchar_t* cs, size_t N2);
RWWString&
replace(size_t pos, size_t N, const RWWString& str);
RWWString&
replace(size_t pos, size_t N1,
        const RWWString& str, size_t N2);
void
resize(size_t n); 
RWWSubString
strip(stripType s = RWWString::trailing, wchar_t c = L' '); const RWWSubString
strip(stripType s = RWWString::trailing, wchar_t c = L' ') 
      const;
RWWSubString
subString(const wchar_t* cs, size_t start=0, 
          caseCompare = RWWString::exact);
const RWWSubString
subString(const wchar_t* cs, size_t start=0,
          caseCompare = RWWString::exact) const;
RWCString
toAscii() const; 
RWCString
toMultiByte() const; 
void
toLower();
void
toUpper();

Static Public Member Functions

static unsigned
hash(const RWWString& wstr); 
static size_t
initialCapacity(size_t ic = 15); 
static size_t
maxWaste(size_t mw = 15); 
static size_t
resizeIncrement(size_t ri = 16); 

Related Global Operators

RWBoolean
operator==(const RWWString&, const wchar_t*  ); 
RWBoolean
operator==(const wchar_t*,   const RWWString&);
RWBoolean
operator==(const RWWString&, const RWWString&);
RWBoolean
operator!=(const RWWString&, const wchar_t*  );
RWBoolean
operator!=(const wchar_t*,   const RWWString&);
RWBoolean
operator!=(const RWWString&, const RWWString&);
RWBoolean
operator< (const RWWString&, const wchar_t*  ); 
RWBoolean
operator< (const wchar_t*,   const RWWString&);
RWBoolean
operator< (const RWWString&, const RWWString&);
RWBoolean
operator> (const RWWString&, const wchar_t*  ); 
RWBoolean
operator> (const wchar_t*,   const RWWString&);
RWBoolean
operator> (const RWWString&, const RWWString&);
RWBoolean
operator<=(const RWWString&, const wchar_t*  ); 
RWBoolean
operator<=(const wchar_t*,   const RWWString&);
RWBoolean
operator<=(const RWWString&, const RWWString&);
RWBoolean
operator>=(const RWWString&, const wchar_t*  );
RWBoolean
operator>=(const wchar_t*,   const RWWString&);
RWBoolean
operator>=(const RWWString&, const RWWString&);
RWWString
operator+(const RWWString&, const RWWString&);
RWWString
operator+(const wchar_t*,   const RWWString&);
RWWString
operator+(const RWWString&, const wchar_t*  );
ostream&
operator<<(ostream& s, const RWWString& str); 
istream&
operator>>(istream& s, RWWString& str); 
RWvostream&
operator<<(RWvostream&, const RWWString& str);
RWFile&
operator<<(RWFile&,     const RWWString& str);
RWvistream&
operator>>(RWvistream&, RWWString& str);
RWFile&
operator>>(RWFile&,     RWWString& str);

Related Global Functions

RWWString
strXForm(const RWWString&);
RWWString
toLower(const RWWString& str); 
RWWString
toUpper(const RWWString& str); 


Previous fileTop of documentContentsIndexNext file
©Copyright 1999, Rogue Wave Software, Inc.
Send mail to report errors or comment on the documentation.