Rogue Wave banner
Previous fileTop of DocumentContentsIndex pageNext file
Essential Tools Module Reference Guide

RWWString

Module:  Essential Tools Module   Group:  String Processing


Does not inherit

Local Index

Members

Non-Members

Synopsis

#include <rw/wstring.h>
RWWString a;

Description

Class RWWString offers very powerful and convenient facilities for manipulating wide character strings.


NOTE -- RWWString is designed for use with wide character strings. To manipulate multibyte character sequences, use RWCString.

When building on top of the standard library, RWWString uses an alternate implementation that is a thin wrapper on top of std::wstring. The RWWString interface remains the same, with the addition of one method for easy conversion: std::wstring std();. For applications doing many RWWString->std::wstring conversions, significant speed improvements might be obtained by using the standard library implementation.


NOTE -- Member function overloads with std::wstring or RWWConstSubString only appear when building on top of the Standard C++ Library.

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.

A separate RWWSubString class supports substring extraction and modification operations.

Persistence

Simple

Example

Program output:

Enumerations

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

Public Constructors

RWWString();
RWWString(const std::wstring& a);
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(const RWWConstSubString& ss); 
RWWString(char c);
RWWString(char c, size_t N);
RWWString(const char* mbcs, multiByte_ mb);
RWWString(const RWCString& s, multiByte_);
RWWString(const RWCString&, multiByte_ mb);
RWWString(const char* acs, ascii_ asc);
RWWString(const RWCString& s, ascii_ );
RWWString(const RWCString&, ascii_ asc);
RWWString(const char* cs, size_t N, multiByte_ mb);
RWWString(const char* cs, size_t N, ascii__ asc);

Type Conversion

Access to the RWWString's data as a null terminated wide string. This datum is owned by the RWWString and may not be deleted or changed. If the RWWString object itself changes or goes out of scope, the pointer value previously returned will become invalid. While the string is null-terminated, note that its length is still given by the member function length(). That is, it may contain embedded nulls.

Assignment Operators

RWWString&
operator=(const RWWString& str);
RWWString&
operator=(const RWWSubString& sub);
RWWString&
operator=(const std::wstring& sub);
RWWString&
operator+=(const wchar_t* cs); 
RWWString&
operator+=(const RWWString& str);
RWWString&
operator+=(const std::wstring& 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& str);
RWWString&
append(const std::wstring& str);
RWWString&
append(const RWWString& str, size_t N);
RWWString&
append(const std::wstring& str, size_t N);
size_t
binaryStoreSize() const; 
size_t
capacity() const; 
size_t
capacity(size_t capac); 
int
collate(const wchar_t*   str) const;
int
collate(const RWWString& str) const; 
int
collate(const std::wstring& str) const;
int
compareTo(const wchar_t*   str, 
          caseCompare = RWWString::exact) const;
int
compareTo(const RWWString& str, 
          caseCompare = RWWString::exact) const;
int
compareTo(const std::wstring& str, 
          caseCompare cmp = exact) const;
int
compareTo(const std::wstring* str, 
          caseCompare cmp = exact) const;
RWBoolean
contains(const wchar_t* str, 
         caseCompare = RWWString::exact) const;
RWBoolean
contains(const RWWString& cs, 
         caseCompare = RWWString::exact) const;
RWBoolean
contains(const std::wstring& str, 
         caseCompare cmp = 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 std::wstring& pat,size_t i=0, 
      caseCompare cmp = 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;
size_t
index(const std::wstring& pat, size_t patlen,size_t i,
      caseCompare cmp) 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 std::wstring& str);
RWWString&
insert(size_t pos, const RWWString& str, size_t N);
RWWString&
insert(size_t pos, const std::wstring& 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 std::wstring& str);
RWWString&
prepend(const RWWString& str, size_t N);
RWWString&
prepend(const std::wstring& str, 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 N, const std::wstring& str);
RWWString&
replace(size_t pos, size_t N1,
        const RWWString& str, size_t N2);
RWWString&
replace(size_t pos, size_t N1,const std::wstring& str, 
        size_t N2);
void
resize(size_t n); 
size_t 
rindex(const char* pat, caseCompare cmp) const;
size_t
rindex(const char pat,size_t i=RW_NPOS, 
       caseCompare cmp = RWWString::exact) const;
size_t
rindex(const char* pat,size_t i=RW_NPOS, 
       caseCompare cmp = RWWString::exact) const;
size_t
rindex(const RWCString& pat,size_t i=RW_NPOS, 
       caseCompare cmp = RWWString::exact) const;
size_t
rindex(const std::wstring& pat,size_t i=RW_NPOS, 
       caseCompare cmp = RWWString::exact) const;
size_t
rindex(const char* pat, size_t patlen,size_t i, 
       caseCompare cmp) const;
size_t
rindex(const RWCString& pat, size_t patlen,
       size_t i,caseCompare cmp) const;
size_t
rindex(const std::wstring& pat, size_t patlen,
       size_t i,caseCompare cmp) const;
std::wstring&
std();
const std::wstring&
std() const;
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); 
static RWWString
fromAscii(const RWCString& str);
static RWWString
fromMultiByte(const RWCString& str);

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 DocumentContentsIndex pageNext file

©2004 Copyright Quovadx, Inc. All Rights Reserved.
Rogue Wave and SourcePro are registered trademarks of Quovadx, Inc. in the United States and other countries. All other trademarks are the property of their respective owners.
Contact Rogue Wave about documentation or support issues.