Rogue Wave banner
Previous fileTop of DocumentContentsIndex pageNext file
Essential Tools Module Reference Guide
Rogue Wave web site:  Home Page  |  Main Documentation Page

RWCString

Module:  Essential Tools Module   Group:  String Processing Classes


Does not inherit

Local Index

Members

Non-Members

Synopsis

#include <rw/cstring.h>
RWCString a;

Description

Class RWCString offers powerful and convenient facilities for manipulating strings.


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

RWCString is based on the std::string from the C++ Standard Library. In builds that do not depend on the C++ Standard Library, RWCString is a typedef for RWClassicCString. Refer to the class reference entry for RWClassicCString when dealing with non-standard library builds.

Applications that perform many RWCString->basic_string conversions may be able to obtain significant speed improvements by using this C++ Standard Library implementation.

Although the class is primarily intended to be used to handle single-byte character sets (SBCS; such as ASCII or ISO Latin-1), with care it can be used to handle multibyte character sets (MBCS). There are two things that must be kept in mind when working with MBCS:

Parameters of type "const char*" must not be passed a value of zero. This is detected in the debug version of the library.

A separate class RWCSubString supports substring extraction and modification operations. RWCConstSubString supports substring extractions on const RWCString instances.

Persistence

Simple

Example

Program output:

Enumerations

enum RWCString::caseCompare { exact, ignoreCase } 
enum RWCString::scopeType { one, all } 

Public Constructors

RWCString();
RWCString(const std::string& a); 
RWCString(const char* cs);
RWCString(const char* cs, size_t N);
RWCString(RWSize_T ic);
RWCString(const RWCString& str);
RWCString(const RWCSubString& ss);
RWCString(const RWCConstSubString& ss);
RWCString(char c);
RWCString(char c, size_t N);

Type Conversion

operator
const char*() const;

Access to the RWCString's data as a null terminated string. This data is owned by the RWCString and may not be deleted or changed. If the RWCString object itself changes or goes out of scope, the pointer value previously returned may (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

RWCString&
operator=(const char* cs);
RWCString&
operator=(const RWCString& str);
RWCString&
operator=(const std::string& str);
RWCString&
operator+=(const char* cs);
RWCString&
operator+=(const RWCString& str);
RWCString&
operator+=(const std::string& str)

Indexing Operators

char&
operator[](size_t i);
char
operator[](size_t i) const;
char&
operator()(size_t i);
char
operator()(size_t i) const;
RWCSubString
operator()(size_t start, size_t len);
RWCConstSubString
operator()(size_t start, size_t len) const;

NOTE -- This function returns an RWCSubString in implementations of the Essential Tools Module built without the C++ Standard Library.
RWCSubString
operator()(const RWCRegexp& re, size_t start=0);
RWCConstSubString
operator()(const RWCRegexp& re, size_t start=0) const;

NOTE -- This function returns an RWCSubString in implementations of the Essential Tools Module built without the C++ Standard Library.

NOTE -- RWCRExpr and RWRegexp are now deprecated in favor of RWTRegex<T>.

Public Member Functions

RWCString&
append(const char* cs);
RWCString&
append(const char* cs, size_t N);
RWCString&
append(char c, size_t N);
RWCString&
append(const RWCString& str);

RWCString&
append(const std::string& str);
RWCString&
append(const RWCString& str, size_t N);

RWCString&
append(const std::string& str, size_t N);
size_t
binaryStoreSize() const;
size_t
capacity() const;
size_t
capacity(size_t capac);
int
collate(const char* str) const;
int
collate(const RWCString& str) const;
int
collate(const std::string& str) const;
int
compareTo(const char* str, caseCompare = RWCString::exact)
          const;
int
compareTo(const RWCString& str, 
          caseCompare = RWCString::exact) const;
int
compareTo(const std::string& str, 
          caseCompare cmp = exact) const;
int
compareTo(const std::string* str, 
          caseCompare cmp = exact) const;
bool
contains(const char* str, caseCompare = RWCString::exact)
         const;
bool
contains(const RWCString& cs, 
         caseCompare = RWCString::exact) const;
bool
contains(const std::string& str, 
         caseCompare cmp = exact) const;
const char*
data() const;
size_t
first(char c) const;
size_t
first(char c, size_t) const;
size_t
first(const char* str) const;
size_t
first(const char* str, size_t N) const;
unsigned
hash(caseCompare = RWCString::exact) const;
size_t
index(const char* pat,size_t i=0, 
      caseCompare = RWCString::exact) const;
size_t
index(const RWCString& pat,size_t i=0, 
      caseCompare = RWCString::exact) const;
size_t
index(const std::string& pat,size_t i=0, 
      caseCompare cmp = exact) const;
size_t
index(const char* pat, size_t patlen,size_t i, 
      caseCompare cmp) const;
size_t
index(const RWCString& pat, size_t patlen,size_t i,
      caseCompare cmp) const;
size_t
index(const std::string& pat, size_t patlen,size_t i,
      caseCompare cmp) const;
size_t
index(const RWCRExpr& re, size_t i=0) const;
size_t
index(const RWCRegexp& re, size_t i=0) const;
size_t
index(const RWCRExpr& re,size_t* ext,size_t i=0) const;
size_t
index(const RWCRegexp& re,size_t* ext,size_t i=0) const;
RWCString&
insert(size_t pos, const char* cs);
RWCString&
insert(size_t pos, const char* cs, size_t N);
RWCString&
insert(size_t pos, const RWCString& str);
RWCString&
insert(size_t pos, const std::string& str);
RWCString&
insert(size_t pos, const RWCString& str, size_t N);
RWCString&
insert(size_t pos, const std::string& str, size_t N);
bool
isAscii() const;
bool
isNull() const;
size_t
last(char c) const;
size_t
last(char c, size_t N) const;
size_t
length() const;
RWCSubString
match(const RWCRExpr& re, size_t start=0);
RWCConstSubString
match(const RWCRExpr& re, size_t start=0) const;
size_t
mbLength() const;
RWCString&
prepend(const char* cs);
RWCString&
prepend(const char* cs, size_t N);
RWCString&
prepend(char c, size_t N);
RWCString&
prepend(const RWCString& str);
RWCString&
prepend(const std::string& str);
RWCString&
prepend(const RWCString& cstr, size_t N);
RWCString&
prepend(const std::string& str, size_t N);
istream&
readFile(istream& s);
istream&
readLine(istream& s, bool skipWhite = true);
istream&
readString(istream& s);
istream&
readToDelim(istream& s, char delim='\n');
istream&
readToken(istream& s);
RWCString&
remove(size_t pos);
RWCString&
remove(size_t pos, size_t N);
RWCString&
replace(size_t pos, size_t N, const char* cs);
RWCString&
replace(size_t pos, size_t N1,const char* cs, size_t N2);
RWCString&
replace(size_t pos, size_t N, const RWCString& str);
RWCString&
replace(size_t pos, size_t N, const std::string& str);
RWCString&
replace(size_t pos, size_t N1,const RWCString& str, 
        size_t N2);
RWCString&
replace(size_t pos, size_t N1,const std::string& str, 
        size_t N2);
replace(const RWCRExpr& pattern, const char* replacement, 
        scopeType scope=one);
replace(const RWCRExpr& pattern, 
        const RWCString& replacement,scopeType scope=one);
void
resize(size_t n);

NOTE -- Member function rindex appears only when building on top of the C++ Standard Library.
size_t 
rindex(const char* pat, caseCompare cmp) const;
size_t
rindex(const char pat,size_t i=RW_NPOS, 
       caseCompare cmp = RWCString::exact) const;
size_t
rindex(const char* pat,size_t i=RW_NPOS, 
       caseCompare cmp = RWCString::exact) const;
size_t
rindex(const RWCString& pat,size_t i=RW_NPOS, 
       caseCompare cmp = RWCString::exact) const;
size_t
rindex(const std::string& pat,size_t i=RW_NPOS, 
       caseCompare cmp = RWCString::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::string& pat, size_t patlen,
       size_t i,caseCompare cmp) const;
std::string&
std();
const std::string&
std() const;
RWCSubString
strip(stripType s = RWCString::trailing, char c = ' ');
RWCConstSubString
strip(stripType s = RWCString::trailing, char c = ' ') 
const;
RWCSubString
subString(const char* cs, size_t start=0,
          caseCompare = RWCString::exact);
RWCConstSubString
subString(const char* cs, size_t start=0,
          caseCompare = RWCString::exact) const;
RWCString
toAscii() const; 
void
toLower();
void
toUpper();

Static Public Member Functions

static size_t
byteCount(const char *str, size_t nChars = RW_NPOS);
static unsigned
hash(const RWCString& str);
static size_t
initialCapacity(size_t ic = 15);
static size_t
mbLength(const char* str, size_t nBytes = RW_NPOS);
static size_t
maxWaste(size_t mw = 15);
static size_t
resizeIncrement(size_t ri = 16);

Related Global Operators

bool
operator==(const RWCString&, const char*);
bool
operator==(const char*, const RWCString&);
bool
operator==(const RWCString&, const RWCString&);
bool
operator!=(const RWCString&, const char*);
bool
operator!=(const char*, const RWCString&);
bool
operator!=(const RWCString&, const RWCString&);
bool
operator< (const RWCString&, const char*);
bool
operator< (const char*, const RWCString&);
bool
operator< (const RWCString&, const RWCString&);
bool
operator> (const RWCString&, const char*);
bool
operator> (const char*, const RWCString&);
bool
operator> (const RWCString&, const RWCString&);
bool
operator<=(const RWCString&, const char*);
bool
operator<=(const char*, const RWCString&);
bool
operator<=(const RWCString&, const RWCString&);
bool
operator>=(const RWCString&, const char*);
bool
operator>=(const char*, const RWCString&);
bool
operator>=(const RWCString&, const RWCString&);
RWCString
operator+(const RWCString&, const RWCString&);
RWCString
operator+(const char*, const RWCString&);
RWCString
operator+(const RWCString&, const char*);
ostream&
operator<<(ostream& s, const RWCString&);
istream&
operator>>(istream& s, RWCString& str);
RWvostream&
operator<<(RWvostream&, const RWCString& str);
RWFile&
operator<<(RWFile&,     const RWCString& str);
RWvistream&
operator>>(RWvistream&, RWCString& str);
RWFile&
operator>>(RWFile&,     RWCString& str);

Related Global Functions

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

Global Logical Operators

bool
operator==(const RWCString&, const RWCSubString&);
bool
operator==(const RWCSubString&, const RWCString&);
bool
operator==(const RWCString& str, char c);
bool
operator==(char c, const RWCString& str);
bool
operator!=(const RWCString&, const RWCString&);
bool
operator!=(const RWCString&, const RWCSubString&);
bool
operator!=(const RWCSubString&, const RWCString&);
bool
operator!=(const char*, const RWCString&);
bool
operator!=(const RWCString&, const char*);
bool
operator!=(const RWCString& str, char c);
bool
operator!=(char c, const RWCString& str);
bool
operator< (const RWCString& str, char c);
bool
operator< (char c, const RWCString& str);
bool
operator<=(const RWCString& str, char c);
bool
operator<=(char c, const RWCString& str);
bool
operator> (const RWCString& str, char c);
bool
operator> (char c, const RWCString& str);
bool
operator>=(const RWCString& str, char c);
bool
operator>=(char c, const RWCString& str);


Previous fileTop of DocumentContentsIndex pageNext file

© Copyright Rogue Wave Software, Inc. All Rights Reserved.
Rogue Wave and SourcePro are registered trademarks of Rogue Wave Software, 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.