rwlogo
SourcePro 11.1

SourcePro® C++ API Reference Guide



   SourcePro C++
Documentation Home

RWClassicCString Class Reference
[String Processing]

Alternate implementation of RWCString that does not depend on the C++ Standard Library. More...

#include <rw/tools/nostl/cstring.h>

List of all members.

Public Types

enum  stripType { leading, trailing, both }
enum  caseCompare { exact, ignoreCase, ignoreCaseStrict }
enum  scopeType { one, all }

Public Member Functions

 RWClassicCString ()
 RWClassicCString (RWSize_T ic)
 RWClassicCString (const RWClassicCString &str)
 RWClassicCString (const char *a)
 RWClassicCString (const char *a, size_t N)
 RWClassicCString (char c)
 RWClassicCString (char c, size_t N)
 RWClassicCString (const RWClassicCSubString &ss)
 operator const char * () const
RWClassicCStringoperator= (const char *cs)
RWClassicCStringoperator= (const RWClassicCString &str)
RWClassicCStringoperator+= (const char *cs)
RWClassicCStringoperator+= (const RWClassicCString &str)
char & operator[] (short i)
char & operator[] (int i)
char & operator[] (long i)
char & operator[] (unsigned short i)
char & operator[] (unsigned int i)
char & operator[] (unsigned long i)
char & operator[] (long long i)
char & operator[] (unsigned long long i)
char operator[] (short i) const
char operator[] (int i) const
char operator[] (long i) const
char operator[] (unsigned short i) const
char operator[] (unsigned int i) const
char operator[] (unsigned long i) const
char operator[] (long long i) const
char operator[] (unsigned long long i) const
char & operator() (size_t i)
char operator() (size_t i) const
RWClassicCSubString operator() (size_t start, size_t len)
RWClassicCSubString operator() (size_t start, size_t len) const
RWClassicCSubString operator() (const RWCRegexp &re)
RWClassicCSubString operator() (const RWCRegexp &re, size_t start)
RWClassicCSubString operator() (const RWCRegexp &re) const
RWClassicCSubString operator() (const RWCRegexp &re, size_t start) const
RWClassicCSubString match (const RWCRExpr &re)
RWClassicCSubString match (const RWCRExpr &re, size_t start) const
RWClassicCSubString subString (const char *cs, size_t start=0, caseCompare cmp=exact)
RWClassicCSubString subString (const char *cs, size_t start=0, caseCompare cmp=exact) const
RWClassicCStringappend (const char *cs)
RWClassicCStringappend (const char *cs, size_t N)
RWClassicCStringappend (const RWClassicCString &cs)
RWClassicCStringappend (const RWClassicCString &cs, size_t N)
RWClassicCStringappend (char c, size_t rep=1)
RWspace binaryStoreSize () const
size_t capacity () const
size_t capacity (size_t N)
int collate (const char *str) const
int collate (const RWClassicCString &str) const
int compareTo (const RWClassicCString &str, caseCompare cmp=exact) const
int compareTo (const char *str, caseCompare cmp=exact) const
bool contains (const char *str, caseCompare cmp=exact) const
bool contains (const RWClassicCString &str, caseCompare cmp=exact) const
const char * data () const
size_t first (char c) const
size_t first (char c, size_t i) const
size_t first (const char *str) const
size_t first (const char *str, size_t N) const
unsigned hash (caseCompare cmp=exact) const
size_t index (const char *pat, size_t i=0, caseCompare cmp=exact) const
size_t index (const RWClassicCString &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 RWClassicCString &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
RWClassicCStringinsert (size_t pos, const char *cs)
RWClassicCStringinsert (size_t pos, const char *cs, size_t N)
RWClassicCStringinsert (size_t pos, const RWClassicCString &str)
RWClassicCStringinsert (size_t pos, const RWClassicCString &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
size_t mbLength () const
RWClassicCStringprepend (const char *cs)
RWClassicCStringprepend (const char *cs, size_t N)
RWClassicCStringprepend (const RWClassicCString &str)
RWClassicCStringprepend (const RWClassicCString &cstr, size_t N)
RWClassicCStringprepend (char c, size_t rep=1)
std::istream & readFile (std::istream &s)
std::istream & readLine (std::istream &s, bool skipWhite=true)
std::istream & readString (std::istream &s)
std::istream & readToDelim (std::istream &s, char delim='\n')
std::istream & readToken (std::istream &s)
RWClassicCStringremove (size_t pos)
RWClassicCStringremove (size_t pos, size_t N)
RWClassicCStringreplace (size_t pos, size_t N, const char *cs)
RWClassicCStringreplace (size_t pos, size_t N1, const char *cs, size_t N2)
RWClassicCStringreplace (size_t pos, size_t N, const RWClassicCString &str)
RWClassicCStringreplace (size_t pos, size_t N1, const RWClassicCString &str, size_t N2)
RWClassicCStringreplace (const RWCRExpr &pattern, const char *replacement, scopeType scope=one)
RWClassicCStringreplace (const RWCRExpr &pattern, const RWClassicCString &replacement, scopeType scope=one)
void resize (size_t N)
RWClassicCSubString strip (stripType s=trailing, char c=' ')
void toLower ()
void toUpper ()

Static Public Member Functions

static unsigned hash (const RWClassicCString &str)
static size_t initialCapacity (size_t capacity=15)
static size_t maxWaste (size_t maxwaste=15)
static size_t resizeIncrement (size_t increment=16)

Friends

RWClassicCString operator+ (const RWClassicCString &s1, const RWClassicCString &s2)
RWClassicCString operator+ (const RWClassicCString &s, const char *cs)
RWClassicCString operator+ (const char *cs, const RWClassicCString &s)
bool operator== (const RWClassicCString &s1, const RWClassicCString &s2)
bool operator== (const RWClassicCString &s1, const char *s2)

Related Functions

(Note that these are not member functions.)



std::istream & operator>> (std::istream &s, RWClassicCString &cstr)
std::ostream & operator<< (std::ostream &s, const RWClassicCString &cstr)
RWvistreamoperator>> (RWvistream &str, RWClassicCString &cstr)
RWFileoperator>> (RWFile &file, RWClassicCString &cstr)
RWvostreamoperator<< (RWvostream &str, const RWClassicCString &cstr)
RWFileoperator<< (RWFile &file, const RWClassicCString &cstr)
RWClassicCString toLower (const RWClassicCString &)
RWClassicCString toUpper (const RWClassicCString &)
RWClassicCString strXForm (const RWClassicCString &)
bool operator== (const char *s1, const RWClassicCString &s2)
bool operator!= (const RWClassicCString &s1, const char *s2)
bool operator!= (const RWClassicCString &s1, const RWClassicCString &s2)
bool operator!= (const char *s1, const RWClassicCString &s2)
bool operator< (const RWClassicCString &s1, const RWClassicCString &s2)
bool operator> (const RWClassicCString &s1, const RWClassicCString &s2)
bool operator<= (const RWClassicCString &s1, const RWClassicCString &s2)
bool operator>= (const RWClassicCString &s1, const RWClassicCString &s2)
bool operator< (const RWClassicCString &s1, const char *s2)
bool operator> (const RWClassicCString &s1, const char *s2)
bool operator<= (const RWClassicCString &s1, const char *s2)
bool operator>= (const RWClassicCString &s1, const char *s2)
bool operator< (const char *s1, const RWClassicCString &s2)
bool operator> (const char *s1, const RWClassicCString &s2)
bool operator<= (const char *s1, const RWClassicCString &s2)
bool operator>= (const char *s1, const RWClassicCString &s2)
bool operator== (const RWClassicCString &s1, const RWClassicCSubString &s2)
bool operator!= (const RWClassicCString &s1, const RWClassicCSubString &s2)

Detailed Description

RWClassicCString is an alternate implementation of RWCString that does not depend on the C++ Standard Library. RWCString is a typedef for RWClassicCString if you define a non-Standard Library build.

Note:
Rogue Wave does not support non-standard library builds.

RWClassicCString is not designed for use with multibyte character sequences. To manipulate wide character strings, use RWClassicWString.

Note:
Member function overloads with std::string or RWCConstSubString appear only when building on top of the C++ Standard Library.

Synopsis

 #include <rw/tools/nostl/cstring.h>
 RWClassicCString a;

Persistence

Simple

Examples

 #include <iostream>
 #include <rw/re.h>
 #include <rw/cstring.h>
 
 int main()
 {
     RWClassicCString a("There is no joy in Beantown.");
 
     std::cout << "\"" << a << "\"" << " becomes ";
 
     // Any capitalized "town"
     RWCRExpr re("[A-Z][a-z]*town");
     a.replace(re, "Redmond");
 
     std::cout << "\"" << a << "\"" << std::endl;
 
     return 0;
 }

Program output:

 "There is no joy in Beantown." becomes "There is no joy in Redmond."

Member Enumeration Documentation

Used to specify whether comparisons, searches, and hashing functions should use case sensitive (exact) or case-insensitive (ignoreCase) semantics.

Enumerator:
exact 

match exactly

ignoreCase 

case-insensitive

ignoreCaseStrict 

case-insenstive for alpha characters only

Used to specify whether regular expression replace replaces the first one substring matched by the regular expression or replaces all substrings matched by the regular expression.

Enumerator:
one 

replace first substring matched

all 

replace all substrings matched

Used to specify whether characters are stripped from the beginning of the string, the end, or both.

Enumerator:
leading 

Remove characters at beginning.

trailing 

Remove characters at end.

both 

Remove characters at both ends.


Constructor & Destructor Documentation

RWClassicCString::RWClassicCString (  ) 

Creates a string of length zero (the null string).

RWClassicCString::RWClassicCString ( RWSize_T  ic  ) 

Constructs a string of length zero (the null string). The string's capacity (that is, the size it can grow to without resizing) is given by the parameter ic. We recommend creating an RWSize_T value from a numerical constant to pass into this constructor. While RWSize_T knows how to convert a size_t to itself, conforming compilers will choose the conversion to char instead.

RWClassicCString::RWClassicCString ( const RWClassicCString str  ) 

Copy constructor. Creates a string with a copy of the data in str.

RWClassicCString::RWClassicCString ( const char *  a  ) 

Constructs a string by the conversion of the null-terminated character string a. The created string copies the data pointed to by a up to the first terminating null.

Note:
This function is incompatible with strings with embedded nulls. This function may be incompatible with MBCS strings.
RWClassicCString::RWClassicCString ( const char *  a,
size_t  N 
)

Constructs a string from the character string a. The created string copies the data pointed to by a. Exactly N bytes are copied, including any embedded nulls. Hence, the buffer pointed to by a must be at least N bytes long.

RWClassicCString::RWClassicCString ( char  c  )  [inline]

Constructs a string containing the single character c.

RWClassicCString::RWClassicCString ( char  c,
size_t  N 
)

Constructs a string containing the character c repeated N times.

RWClassicCString::RWClassicCString ( const RWClassicCSubString ss  ) 

Constructs a string from a sub-string, copying the substring represented by ss.


Member Function Documentation

RWClassicCString& RWClassicCString::append ( char  c,
size_t  rep = 1 
)

Appends rep copies of the character c to self. Returns a reference to self. Defaults to 1.

RWClassicCString & RWClassicCString::append ( const RWClassicCString cs,
size_t  N 
) [inline]

Appends the first N bytes or the length of cs (whichever is less) to self. Returns a reference to self.

RWClassicCString & RWClassicCString::append ( const RWClassicCString cs  )  [inline]

Appends a copy of the string cs to self. Returns a reference to self.

RWClassicCString & RWClassicCString::append ( const char *  cs,
size_t  N 
) [inline]

Appends a copy of the character string cs to self. Exactly N bytes are copied, including any embedded nulls. Hence, the buffer pointed to by cs must be at least N bytes long. Returns a reference to self.

RWClassicCString & RWClassicCString::append ( const char *  cs  )  [inline]

Appends a copy of the null-terminated character string pointed to by cs to self. Returns a reference to self.

Note:
This function is incompatible with cs strings with embedded nulls. This function may be incompatible with cs MBCS strings.
RWspace RWClassicCString::binaryStoreSize (  )  const [inline]

Returns the number of bytes necessary to store the object using the global function:

size_t RWClassicCString::capacity ( size_t  N  ) 

Hint to the implementation to change the capacity of self to N. Returns the actual capacity.

size_t RWClassicCString::capacity (  )  const [inline]

Returns the current capacity of self. This is the number of bytes the string can hold without resizing.

int RWClassicCString::collate ( const RWClassicCString str  )  const [inline]

Returns an int less than, greater than, or equal to zero, according to the result of calling the standard C library function strcoll() on self and the argument str. This supports locale-dependent collation. Provided only on platforms that provide strcoll().

Note:
This function is incompatible with strings with embedded nulls.

int RWClassicCString::collate ( const char *  str  )  const [inline]

Returns an int less than, greater than, or equal to zero, according to the result of calling the standard C library function strcoll() on self and the argument str. This supports locale-dependent collation. Provided only on platforms that provide strcoll().

Note:
This function is incompatible with strings with embedded nulls.
int RWClassicCString::compareTo ( const char *  str,
caseCompare  cmp = exact 
) const [inline]

Returns an int less than, greater than, or equal to zero, according to the result of calling the standard C library function memcmp() on self and the argument str. Case sensitivity is according to the caseCompare argument, and may be RWClassicCString::exact or RWClassicCString::ignoreCase.

If caseCompare is RWClassicCString::exact, this function works for all string types. Otherwise, this function is incompatible with MBCS strings. This function is incompatible with const char* strings with embedded nulls. This function may be incompatible with const char* MBCS strings.

int RWClassicCString::compareTo ( const RWClassicCString str,
caseCompare  cmp = exact 
) const [inline]

Returns an int less than, greater than, or equal to zero, according to the result of calling the standard C library function memcmp() on self and the argument str. Case sensitivity is according to the caseCompare argument, and may be RWClassicCString::exact or RWClassicCString::ignoreCase.

If caseCompare is RWClassicCString::exact, this function works for all string types. Otherwise, this function is incompatible with MBCS strings. This function is incompatible with const char* strings with embedded nulls. This function may be incompatible with const char* MBCS strings.

bool RWClassicCString::contains ( const RWClassicCString str,
caseCompare  cmp = exact 
) const [inline]

Pattern matching. Returns true if str occurs in self. Case sensitivity is according to the caseCompare argument, and may be RWClassicCString::exact or RWClassicCString::ignoreCase.

If caseCompare is RWClassicCString::exact, this function works for all string types. Otherwise, this function is incompatible with MBCS strings. This function is incompatible with const char* strings with embedded nulls. This function may be incompatible with const char* MBCS strings.

bool RWClassicCString::contains ( const char *  str,
caseCompare  cmp = exact 
) const [inline]

Pattern matching. Returns true if str occurs in self. Case sensitivity is according to the caseCompare argument, and may be RWClassicCString::exact or RWClassicCString::ignoreCase.

If caseCompare is RWClassicCString::exact, this function works for all string types. Otherwise, this function is incompatible with MBCS strings. This function is incompatible with const char* strings with embedded nulls. This function may be incompatible with const char* MBCS strings.

const char* RWClassicCString::data ( void   )  const [inline]

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

size_t RWClassicCString::first ( const char *  str,
size_t  N 
) const [inline]

Returns the index of the first occurence in self of any character in str. Exactly N bytes in str are checked including any embedded nulls, so str must point to a buffer containing at least N bytes. Returns RW_NPOS if there is no match.

size_t RWClassicCString::first ( const char *  str  )  const [inline]

Returns the index of the first occurence in self of any character in str. Returns RW_NPOS if there is no match or if there is an embedded null prior to finding any character from str.

Note:
This function is incompatible with strings with embedded nulls. This function may be incompatible with MBCS strings.
size_t RWClassicCString::first ( char  c,
size_t  i 
) const [inline]

Returns the index of the first occurence of the character c in self. Continues to search past embedded nulls. Returns RW_NPOS if there is no such character.

Note:
This function is incompatible with MBCS strings.
size_t RWClassicCString::first ( char  c  )  const [inline]

Returns the index of the first occurence of the character c in self. Returns RW_NPOS if there is no such character or if there is an embedded null prior to finding c.

Note:
This function is incompatible with strings with embedded nulls, and with MBCS strings.
unsigned RWClassicCString::hash ( caseCompare  cmp = exact  )  const

Returns a suitable hash value. If caseCompare is RWClassicCString::ignoreCase, this function is incompatible with MBCS strings.

static unsigned RWClassicCString::hash ( const RWClassicCString str  )  [static]

Returns the hash value of str as returned by hash(caseCompare) const, where caseCompare is RWClassicCString::exact.

size_t RWClassicCString::index ( const RWCRegexp re,
size_t *  ext,
size_t  i = 0 
) const

Regular expression matching. Returns the index greater than or equal to i of the start of the first pattern that matches the regular expression re. Returns RW_NPOS if there is no such pattern. The length of the matching pattern is returned in the variable pointed to by ext.

Note:
This function is incompatible with strings with embedded nulls. This function may be incompatible with MBCS strings.

size_t RWClassicCString::index ( const RWCRExpr re,
size_t *  ext,
size_t  i = 0 
) const

Regular expression matching. Returns the index greater than or equal to i of the start of the first pattern that matches the regular expression re. Returns RW_NPOS if there is no such pattern. The length of the matching pattern is returned in the variable pointed to by ext.

Note:
This function is incompatible with strings with embedded nulls. This function may be incompatible with MBCS strings.
size_t RWClassicCString::index ( const RWCRegexp re,
size_t  i = 0 
) const

Regular expression matching. Returns the index greater than or equal to i of the start of the first pattern that matches the regular expression re. Returns RW_NPOS if there is no such pattern.

Note:
This function is incompatible with MBCS strings.

size_t RWClassicCString::index ( const RWCRExpr re,
size_t  i = 0 
) const

Regular expression matching. Returns the index greater than or equal to i of the start of the first pattern that matches the regular expression re. Returns RW_NPOS if there is no such pattern.

Note:
This function is incompatible with MBCS strings.
size_t RWClassicCString::index ( const RWClassicCString pat,
size_t  patlen,
size_t  i,
caseCompare  cmp 
) const [inline]

Pattern matching. Starting with index i, searches for the first occurrence of the first patlen bytes from pat in self and returns the index of the start of the match. Returns RW_NPOS if there is no such pattern. Case sensitivity is according to the caseCompare argument.

Note:
If caseCompare is RWClassicCString::exact, this function works for all string types. Otherwise, this function is incompatible with MBCS strings.

size_t RWClassicCString::index ( const char *  pat,
size_t  patlen,
size_t  i,
caseCompare  cmp 
) const

Pattern matching. Starting with index i, searches for the first occurrence of the first patlen bytes from pat in self and returns the index of the start of the match. Returns RW_NPOS if there is no such pattern. Case sensitivity is according to the caseCompare argument.

Note:
If caseCompare is RWClassicCString::exact, this function works for all string types. Otherwise, this function is incompatible with MBCS strings.
size_t RWClassicCString::index ( const RWClassicCString pat,
size_t  i = 0,
caseCompare  cmp = exact 
) const [inline]

Pattern matching. Starting with index i, searches for the first occurrence of pat in self and returns the index of the start of the match. Returns RW_NPOS if there is no such pattern. Case sensitivity is according to the caseCompare argument; it defaults to RWClassicCString::exact.

Note:
If caseCompare is RWClassicCString::exact, this function works for all string types. Otherwise, this function is incompatible with MBCS strings.

size_t RWClassicCString::index ( const char *  pat,
size_t  i = 0,
caseCompare  cmp = exact 
) const [inline]

Pattern matching. Starting with index i, searches for the first occurrence of pat in self and returns the index of the start of the match. Returns RW_NPOS if there is no such pattern. Case sensitivity is according to the caseCompare argument; it defaults to RWClassicCString::exact.

Note:
If caseCompare is RWClassicCString::exact, this function works for all string types. Otherwise, this function is incompatible with MBCS strings.
static size_t RWClassicCString::initialCapacity ( size_t  capacity = 15  )  [static]

Sets the minimum initial capacity of an RWClassicCString, and returns the old value. The initial setting is 15 bytes. Larger values use more memory but result in fewer resizes when concatenating or reading strings. Smaller values waste less memory but result in more resizes.

RWClassicCString & RWClassicCString::insert ( size_t  pos,
const RWClassicCString str,
size_t  N 
) [inline]

Inserts a copy of the first N bytes or the length of str (whichever is less) into self at byte position pos. Returns a reference to self.

RWClassicCString & RWClassicCString::insert ( size_t  pos,
const RWClassicCString str 
) [inline]

Inserts a copy of the string str into self at byte position pos. Returns a reference to self.

RWClassicCString & RWClassicCString::insert ( size_t  pos,
const char *  cs,
size_t  N 
) [inline]

Inserts a copy of the first N bytes of cs into self at byte position pos, thus expanding the string. Exactly N bytes are copied, including any embedded nulls. Hence, the buffer pointed to by cs must be at least N bytes long. Returns a reference to self.

RWClassicCString & RWClassicCString::insert ( size_t  pos,
const char *  cs 
) [inline]

Inserts a copy of the null-terminated string cs into self at byte position pos, thus expanding the string. Returns a reference to self.

Note:
This function is incompatible with cs strings with embedded nulls. This function may be incompatible with cs MBCS strings.
bool RWClassicCString::isAscii (  )  const

Returns true if self contains no bytes with the high bit set.

bool RWClassicCString::isNull ( void   )  const [inline]

Returns true if this is a zero lengthed string (i.e., the null string).

size_t RWClassicCString::last ( char  c,
size_t  N 
) const [inline]

Returns the index of the last occurrence in the string of the character c. Continues to search past embedded nulls. Returns RW_NPOS if there is no such character.

Note:
This function is incompatible with MBCS strings.
size_t RWClassicCString::last ( char  c  )  const [inline]

Returns the index of the last occurrence in the string of the character c. Returns RW_NPOS if there is no such character or if there is an embedded null to the right of c in self.

Note:
This function is incompatible with strings with embedded nulls. This function may be incompatible with MBCS strings.
size_t RWClassicCString::length (  )  const [inline]

Returns the number of bytes in self. Note that if self contains multibyte characters, this will not be the number of characters.

RWClassicCSubString RWClassicCString::match ( const RWCRExpr re,
size_t  start 
) const

Returns the first substring starting after index start, or after the beginning of the string if there is no start, that matches the regular expression re. If there is no such substring, the null substring is returned. The first variant can be used as an lvalue.

Note:
This method is used in place of operator()(const RWCRegexp&) or its variants, if you want to use extended regular expressions.

RWClassicCSubString RWClassicCString::match ( const RWCRExpr re  ) 

Returns the first substring starting after index start, or after the beginning of the string if there is no start, that matches the regular expression re. If there is no such substring, the null substring is returned. The first variant can be used as an lvalue.

Note:
This method is used in place of operator()(const RWCRegexp&) or its variants, if you want to use extended regular expressions.
static size_t RWClassicCString::maxWaste ( size_t  maxwaste = 15  )  [static]

Sets the maximum amount of unused space allowed in a string should it shrink, and returns the old value. The initial setting is 15 bytes. If more than maxwaste bytes are wasted, then excess space is reclaimed.

size_t RWClassicCString::mbLength (  )  const [inline]

Returns the number of multibyte characters in self, according to the Standard C function mblen(). Returns RW_NPOS if a bad character is encountered. Note that, in general, mbLength() = length(). Usable only on platforms that provide mblen().

RWClassicCString::operator const char * (  )  const [inline]

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

RWClassicCSubString RWClassicCString::operator() ( const RWCRegexp re,
size_t  start 
) const

Returns the first substring starting after index start, or after the beginning of the string if there is no start, that matches the regular expression re. If there is no such substring, the null substring is returned. The first variant can be used as an lvalue.

Note:
If you wish to use const RWCRExpr& for matching, you must use match(const RWCRExpr&) or its variants.
This function may be incompatible with strings with embedded nulls. This function is incompatible with MBCS strings.
RWClassicCSubString RWClassicCString::operator() ( const RWCRegexp re  )  const

Returns the first substring starting after index start, or after the beginning of the string if there is no start, that matches the regular expression re. If there is no such substring, the null substring is returned. The first variant can be used as an lvalue.

Note:
If you wish to use const RWCRExpr& for matching, you must use match(const RWCRExpr&) or its variants. There is no operator()(const RWCRExpr&...) because it would be ambiguous with this operator in the case of RWClassicCString::operator()("string"). Similarly, operator()(const char *) and operator()(size_t) are ambiguous in the case of RWClassicCString::operator(0).
This function may be incompatible with strings with embedded nulls. This function is incompatible with MBCS strings.
RWClassicCSubString RWClassicCString::operator() ( const RWCRegexp re,
size_t  start 
)

Returns the first substring starting after index start, or after the beginning of the string if there is no start, that matches the regular expression re. If there is no such substring, the null substring is returned. The first variant can be used as an lvalue.

Note:
If you wish to use const RWCRExpr& for matching, you must use match(const RWCRExpr&) or its variants.
This function may be incompatible with strings with embedded nulls. This function is incompatible with MBCS strings.
RWClassicCSubString RWClassicCString::operator() ( const RWCRegexp re  ) 

Returns the first substring starting after index start, or after the beginning of the string if there is no start, that matches the regular expression re. If there is no such substring, the null substring is returned. The first variant can be used as an lvalue.

Note:
If you wish to use const RWCRExpr& for matching, you must use match(const RWCRExpr&) or its variants.
This function may be incompatible with strings with embedded nulls. This function is incompatible with MBCS strings.
RWClassicCSubString RWClassicCString::operator() ( size_t  start,
size_t  len 
) const

Substring operator. Returns an RWClassicCSubString of self with length len, starting at index start. The first variant can be used as an lvalue. The sum of start plus len must be less than or equal to the string length. If the library was built using the RW_DEBUG flag, and start and len are out of range, throws an exception of type RWBoundsErr.

RWClassicCSubString RWClassicCString::operator() ( size_t  start,
size_t  len 
)

Substring operator. Returns an RWClassicCSubString of self with length len, starting at index start. The first variant can be used as an lvalue. The sum of start plus len must be less than or equal to the string length. If the library was built using the RW_DEBUG flag, and start and len are out of range, throws an exception of type RWBoundsErr.

char RWClassicCString::operator() ( size_t  i  )  const [inline]

Returns the i th byte. The first variant can be used as an lvalue. The index i must be between 0 and the length of the string, minus one. Bounds checking is performed if the pre-processor macro RWBOUNDS_CHECK has been defined before including <rw/tools/nostl/cstring.h>. If the index is out of range, throws an exception of type RWBoundsErr.

char & RWClassicCString::operator() ( size_t  i  )  [inline]

Returns the i th byte. The first variant can be used as an lvalue. The index i must be between 0 and the length of the string, minus one. Bounds checking is performed if the pre-processor macro RWBOUNDS_CHECK has been defined before including <rw/tools/nostl/cstring.h>. If the index is out of range, throws an exception of type RWBoundsErr.

RWClassicCString & RWClassicCString::operator+= ( const RWClassicCString str  )  [inline]

Appends the string str to self. Returns a reference to self.

RWClassicCString & RWClassicCString::operator+= ( const char *  cs  )  [inline]

Appends the null-terminated character string pointed to by cs to self. Returns a reference to self.

Note:
This function is incompatible with strings with embedded nulls. This function may be incompatible with MBCS strings.
RWClassicCString& RWClassicCString::operator= ( const RWClassicCString str  ) 

Assignment operator. The string copies the data in str. Returns a reference to self.

RWClassicCString& RWClassicCString::operator= ( const char *  cs  ) 

Assignment operator. Copies the null-terminated character string pointed to by cs into self. Returns a reference to self.

Note:
This function is incompatible with strings with embedded nulls. This function may be incompatible with MBCS strings.
char RWClassicCString::operator[] ( unsigned long long  i  )  const [inline]

Returns the i th byte. The first variant can be used as an lvalue. The index i must be between 0 and the length of the string, minus one. Bounds checking is performed. If the index is out of range, throws an exception of type RWBoundsErr.

char RWClassicCString::operator[] ( long long  i  )  const [inline]

Returns the i th byte. The first variant can be used as an lvalue. The index i must be between 0 and the length of the string, minus one. Bounds checking is performed. If the index is out of range, throws an exception of type RWBoundsErr.

char RWClassicCString::operator[] ( unsigned long  i  )  const [inline]

Returns the i th byte. The first variant can be used as an lvalue. The index i must be between 0 and the length of the string, minus one. Bounds checking is performed. If the index is out of range, throws an exception of type RWBoundsErr.

char RWClassicCString::operator[] ( unsigned int  i  )  const [inline]

Returns the i th byte. The first variant can be used as an lvalue. The index i must be between 0 and the length of the string, minus one. Bounds checking is performed. If the index is out of range, throws an exception of type RWBoundsErr.

char RWClassicCString::operator[] ( unsigned short  i  )  const [inline]

Returns the i th byte. The first variant can be used as an lvalue. The index i must be between 0 and the length of the string, minus one. Bounds checking is performed. If the index is out of range, throws an exception of type RWBoundsErr.

char RWClassicCString::operator[] ( long  i  )  const [inline]

Returns the i th byte. The first variant can be used as an lvalue. The index i must be between 0 and the length of the string, minus one. Bounds checking is performed. If the index is out of range, throws an exception of type RWBoundsErr.

char RWClassicCString::operator[] ( int  i  )  const [inline]

Returns the i th byte. The first variant can be used as an lvalue. The index i must be between 0 and the length of the string, minus one. Bounds checking is performed. If the index is out of range, throws an exception of type RWBoundsErr.

char RWClassicCString::operator[] ( short  i  )  const [inline]

Returns the i th byte. The first variant can be used as an lvalue. The index i must be between 0 and the length of the string, minus one. Bounds checking is performed. If the index is out of range, throws an exception of type RWBoundsErr.

char & RWClassicCString::operator[] ( unsigned long long  i  )  [inline]

Returns the i th byte. The first variant can be used as an lvalue. The index i must be between 0 and the length of the string, minus one. Bounds checking is performed. If the index is out of range, throws an exception of type RWBoundsErr.

char & RWClassicCString::operator[] ( long long  i  )  [inline]

Returns the i th byte. The first variant can be used as an lvalue. The index i must be between 0 and the length of the string, minus one. Bounds checking is performed. If the index is out of range, throws an exception of type RWBoundsErr.

char & RWClassicCString::operator[] ( unsigned long  i  )  [inline]

Returns the i th byte. The first variant can be used as an lvalue. The index i must be between 0 and the length of the string, minus one. Bounds checking is performed. If the index is out of range, throws an exception of type RWBoundsErr.

char & RWClassicCString::operator[] ( unsigned int  i  )  [inline]

Returns the i th byte. The first variant can be used as an lvalue. The index i must be between 0 and the length of the string, minus one. Bounds checking is performed. If the index is out of range, throws an exception of type RWBoundsErr.

char & RWClassicCString::operator[] ( unsigned short  i  )  [inline]

Returns the i th byte. The first variant can be used as an lvalue. The index i must be between 0 and the length of the string, minus one. Bounds checking is performed. If the index is out of range, throws an exception of type RWBoundsErr.

char & RWClassicCString::operator[] ( long  i  )  [inline]

Returns the i th byte. The first variant can be used as an lvalue. The index i must be between 0 and the length of the string, minus one. Bounds checking is performed. If the index is out of range, throws an exception of type RWBoundsErr.

char & RWClassicCString::operator[] ( int  i  )  [inline]

Returns the i th byte. The first variant can be used as an lvalue. The index i must be between 0 and the length of the string, minus one. Bounds checking is performed. If the index is out of range, throws an exception of type RWBoundsErr.

char & RWClassicCString::operator[] ( short  i  )  [inline]

Returns the i th byte. The first variant can be used as an lvalue. The index i must be between 0 and the length of the string, minus one. Bounds checking is performed. If the index is out of range, throws an exception of type RWBoundsErr.

RWClassicCString& RWClassicCString::prepend ( char  c,
size_t  rep = 1 
)

Prepends rep copies of character c to self. Returns a reference to self.

RWClassicCString & RWClassicCString::prepend ( const RWClassicCString cstr,
size_t  N 
) [inline]

Prepends the first N bytes or the length of cstr (whichever is less) to self. Returns a reference to self.

RWClassicCString & RWClassicCString::prepend ( const RWClassicCString str  )  [inline]

Prepends a copy of the string str to self. Returns a reference to self.

RWClassicCString & RWClassicCString::prepend ( const char *  cs,
size_t  N 
) [inline]

Prepends a copy of the character string cs to self. Exactly N bytes are copied, including any embedded nulls. Hence, the buffer pointed to by cs must be at least N bytes long. Returns a reference to self.

RWClassicCString & RWClassicCString::prepend ( const char *  cs  )  [inline]

Prepends a copy of the null-terminated character string pointed to by cs to self. Returns a reference to self.

Note:
This function is incompatible with cs strings with embedded nulls. This function may be incompatible with cs MBCS strings.
std::istream& RWClassicCString::readFile ( std::istream &  s  ) 

Reads characters from the input stream s, replacing the previous contents of self, until EOF is reached. Null characters are treated the same as other characters.

std::istream& RWClassicCString::readLine ( std::istream &  s,
bool  skipWhite = true 
)

Reads characters from the input stream s, replacing the previous contents of self, until a newline (or an EOF) is encountered. The newline is removed from the input stream but is not stored. Null characters are treated the same as other characters. If the skipWhite argument is true, then whitespace is skipped (using the std::iostream library manipulator ws) before saving characters.

std::istream& RWClassicCString::readString ( std::istream &  s  ) 

Reads characters from the input stream s, replacing the previous contents of self, until an EOF or null terminator is encountered. If the number of bytes remaining in the stream is large, you should resize the RWClassicCString to approximately the number of bytes to be read prior to using this method.

Note:
This function is incompatible with strings with embedded nulls. This function may be incompatible with MBCS strings.
std::istream& RWClassicCString::readToDelim ( std::istream &  s,
char  delim = '\n' 
)

Reads characters from the input stream s, replacing the previous contents of self, until an EOF or the delimiting character delim is encountered. The delimiter is removed from the input stream but is not stored. Null characters are treated the same as other characters.

Note:
If delim is '\0', this function is incompatible with strings with embedded nulls, and may be incompatible with MBCS strings.
std::istream& RWClassicCString::readToken ( std::istream &  s  ) 

Whitespace is skipped before saving characters. Characters are then read from the input stream s, replacing the previous contents of self, until trailing whitespace or an EOF is encountered. The whitespace is left on the input stream. Null characters are treated the same as other characters. Whitespace is identified by the standard C library function isspace().

Note:
This function is incompatible with MBCS strings.
RWClassicCString & RWClassicCString::remove ( size_t  pos,
size_t  N 
) [inline]

Removes N bytes or to the end of string (whichever comes first) starting at the byte position pos, which must be no greater than length(). Returns a reference to self.

RWClassicCString & RWClassicCString::remove ( size_t  pos  )  [inline]

Removes the bytes from the byte position pos, which must be no greater than length(), to the end of string. Returns a reference to self.

RWClassicCString& RWClassicCString::replace ( const RWCRExpr pattern,
const RWClassicCString replacement,
scopeType  scope = one 
)

Replaces substring matched by pattern with replacement string. The parameter pattern uses the extended regular expression class RWCRExpr, and scope is either one or all, which controls whether all matches of pattern are replaced with replacement or just the first match is replaced. The parameter replacement is the replacement pattern for the string. Here's an example:

 RWClassicCString s("hahahohoheehee");
 s.replace(RWCRExpr("(ho)+","HAR"); // s == "hahaHARheehee"
Note:
This function is incompatible with const char* replacement strings with embedded nulls. This function may be incompatible with const char* replacement MBCS strings.

RWClassicCString& RWClassicCString::replace ( const RWCRExpr pattern,
const char *  replacement,
scopeType  scope = one 
)

Replaces substring matched by pattern with replacement string. The parameter pattern uses the extended regular expression class RWCRExpr, and scope is either one or all, which controls whether all matches of pattern are replaced with replacement or just the first match is replaced. The parameter replacement is the replacement pattern for the string. Here's an example:

 RWClassicCString s("hahahohoheehee");
 s.replace(RWCRExpr("(ho)+","HAR"); // s == "hahaHARheehee"
Note:
This function is incompatible with const char* replacement strings with embedded nulls. This function may be incompatible with const char* replacement MBCS strings.
RWClassicCString & RWClassicCString::replace ( size_t  pos,
size_t  N1,
const RWClassicCString str,
size_t  N2 
) [inline]

Replaces N1 bytes or to the end of string (whichever comes first) starting at position pos, which must be no greater than length(), with a copy of the first N2 bytes, or the length of str (whichever is less), from str. Returns a reference to self.

RWClassicCString & RWClassicCString::replace ( size_t  pos,
size_t  N,
const RWClassicCString str 
) [inline]

Replaces N bytes or to the end of string (whichever comes first) starting at byte position pos, which must be no greater than length(), with a copy of the string str. Returns a reference to self.

RWClassicCString& RWClassicCString::replace ( size_t  pos,
size_t  N1,
const char *  cs,
size_t  N2 
)

Replaces N1 bytes or to the end of string (whichever comes first) starting at byte position pos, which must be no greater than length(), with a copy of the string cs. Exactly N2 bytes are copied, including any embedded nulls. Hence, the buffer pointed to by cs must be at least N2 bytes long. Returns a reference to self.

RWClassicCString & RWClassicCString::replace ( size_t  pos,
size_t  N,
const char *  cs 
) [inline]

Replaces N bytes or to the end of string (whichever comes first) starting at byte position pos, which must be no greater than length(), with a copy of the null-terminated string cs. Returns a reference to self.

Note:
This function is incompatible with cs strings with embedded nulls. This function may be incompatible with cs MBCS strings.
void RWClassicCString::resize ( size_t  N  ) 

Changes the length of self to N bytes, adding blanks or truncating as necessary.

static size_t RWClassicCString::resizeIncrement ( size_t  increment = 16  )  [static]

Sets the resize increment when more memory is needed to grow a string. Returns the old value. The initial setting is 16 bytes.

RWClassicCSubString RWClassicCString::strip ( stripType  s = trailing,
char  c = ' ' 
)

Returns a substring of self where the character c has been stripped off the beginning, end, or both ends of the string. The first variant can be used as an lvalue.

RWClassicCSubString RWClassicCString::subString ( const char *  cs,
size_t  start = 0,
caseCompare  cmp = exact 
) const

Returns a substring representing the first occurence of the null-terminated string pointed to by cs. The first variant can be used as an lvalue. Case sensitivity is according to the caseCompare argument; it defaults to RWClassicCString::exact. If caseCompare is RWClassicCString::ignoreCase then this function is incompatible with MBCS strings.

Note:
This function is incompatible with cs strings with embedded nulls. This function may be incompatible with cs MBCS strings.

RWClassicCSubString RWClassicCString::subString ( const char *  cs,
size_t  start = 0,
caseCompare  cmp = exact 
)

Returns a substring representing the first occurence of the null-terminated string pointed to by cs. The first variant can be used as an lvalue. Case sensitivity is according to the caseCompare argument; it defaults to RWClassicCString::exact. If caseCompare is RWClassicCString::ignoreCase then this function is incompatible with MBCS strings.

Note:
This function is incompatible with cs strings with embedded nulls. This function may be incompatible with cs MBCS strings.
void RWClassicCString::toLower (  ) 

Changes all upper-case letters in self to lower-case, using the standard C library facilities declared in <ctype.h>.

Note:
This function is incompatible with MBCS strings.
void RWClassicCString::toUpper (  ) 

Changes all lower-case letters in self to upper-case, using the standard C library facilities declared in <ctype.h>.

Note:
This function is incompatible with MBCS strings.

Friends And Related Function Documentation

bool operator!= ( const RWClassicCString s1,
const RWClassicCSubString s2 
) [related]

Returns the negation of the respective operator==().

bool operator!= ( const char *  s1,
const RWClassicCString s2 
) [related]

Logical inequality operator. Case sensitivity is exact.

Note:
This function is incompatible with const char* strings with embedded nulls. This function may be incompatible with const char* MBCS strings.
bool operator!= ( const RWClassicCString s1,
const RWClassicCString s2 
) [related]

Logical inequality operator. Case sensitivity is exact.

Note:
This function is incompatible with const char* strings with embedded nulls. This function may be incompatible with const char* MBCS strings.
bool operator!= ( const RWClassicCString s1,
const char *  s2 
) [related]

Logical inequality operator. Case sensitivity is exact.

Note:
This function is incompatible with const char* strings with embedded nulls. This function may be incompatible with const char* MBCS strings.
RWClassicCString operator+ ( const char *  cs,
const RWClassicCString s 
) [friend]

Concatenation operator. This function is incompatible with const char* strings with embedded nulls. This function may be incompatible with const char* MBCS strings.

RWClassicCString operator+ ( const RWClassicCString s,
const char *  cs 
) [friend]

Concatenation operator. This function is incompatible with const char* strings with embedded nulls. This function may be incompatible with const char* MBCS strings.

RWClassicCString operator+ ( const RWClassicCString s1,
const RWClassicCString s2 
) [friend]

Concatenation operator. This function is incompatible with const char* strings with embedded nulls. This function may be incompatible with const char* MBCS strings.

bool operator< ( const char *  s1,
const RWClassicCString s2 
) [related]

Comparisons are done lexicographically, byte by byte. Case sensitivity is exact. Use member collate() or strXForm() for locale sensitivity.

Note:
This function is incompatible with const char* strings with embedded nulls. This function may be incompatible with const char* MBCS strings.
bool operator< ( const RWClassicCString s1,
const char *  s2 
) [related]

Comparisons are done lexicographically, byte by byte. Case sensitivity is exact. Use member collate() or strXForm() for locale sensitivity.

Note:
This function is incompatible with const char* strings with embedded nulls. This function may be incompatible with const char* MBCS strings.
bool operator< ( const RWClassicCString s1,
const RWClassicCString s2 
) [related]

Comparisons are done lexicographically, byte by byte. Case sensitivity is exact. Use member collate() or strXForm() for locale sensitivity.

Note:
This function is incompatible with const char* strings with embedded nulls. This function may be incompatible with const char* MBCS strings.
RWFile & operator<< ( RWFile file,
const RWClassicCString cstr 
) [related]

Saves string cstr to an RWFile.

RWvostream & operator<< ( RWvostream str,
const RWClassicCString cstr 
) [related]

Saves string cstr to a virtual stream.

std::ostream & operator<< ( std::ostream &  s,
const RWClassicCString cstr 
) [related]

Write an RWClassicCString on ostream s.

bool operator<= ( const char *  s1,
const RWClassicCString s2 
) [related]

Comparisons are done lexicographically, byte by byte. Case sensitivity is exact. Use member collate() or strXForm() for locale sensitivity.

Note:
This function is incompatible with const char* strings with embedded nulls. This function may be incompatible with const char* MBCS strings.
bool operator<= ( const RWClassicCString s1,
const char *  s2 
) [related]

Comparisons are done lexicographically, byte by byte. Case sensitivity is exact. Use member collate() or strXForm() for locale sensitivity.

Note:
This function is incompatible with const char* strings with embedded nulls. This function may be incompatible with const char* MBCS strings.
bool operator<= ( const RWClassicCString s1,
const RWClassicCString s2 
) [related]

Comparisons are done lexicographically, byte by byte. Case sensitivity is exact. Use member collate() or strXForm() for locale sensitivity.

Note:
This function is incompatible with const char* strings with embedded nulls. This function may be incompatible with const char* MBCS strings.
bool operator== ( const RWClassicCString s1,
const RWClassicCSubString s2 
) [related]

Returns true if the substring is lexicographically equal to the character string or RWClassicCString argument. Case sensitivity is exact.

bool operator== ( const char *  s1,
const RWClassicCString s2 
) [related]

Logical equality operator. Case sensitivity is exact.

Note:
This function is incompatible with const char* strings with embedded nulls. This function may be incompatible with const char* MBCS strings.
bool operator== ( const RWClassicCString s1,
const char *  s2 
) [friend]

Logical equality operator. Case sensitivity is exact. This function is incompatible with const char* strings with embedded nulls. This function may be incompatible with const char* MBCS strings.

bool operator== ( const RWClassicCString s1,
const RWClassicCString s2 
) [friend]

Logical equality operator. Case sensitivity is exact. This function is incompatible with const char* strings with embedded nulls. This function may be incompatible with const char* MBCS strings.

bool operator> ( const char *  s1,
const RWClassicCString s2 
) [related]

Comparisons are done lexicographically, byte by byte. Case sensitivity is exact. Use member collate() or strXForm() for locale sensitivity.

Note:
This function is incompatible with const char* strings with embedded nulls. This function may be incompatible with const char* MBCS strings.
bool operator> ( const RWClassicCString s1,
const char *  s2 
) [related]

Comparisons are done lexicographically, byte by byte. Case sensitivity is exact. Use member collate() or strXForm() for locale sensitivity.

Note:
This function is incompatible with const char* strings with embedded nulls. This function may be incompatible with const char* MBCS strings.
bool operator> ( const RWClassicCString s1,
const RWClassicCString s2 
) [related]

Comparisons are done lexicographically, byte by byte. Case sensitivity is exact. Use member collate() or strXForm() for locale sensitivity.

Note:
This function is incompatible with const char* strings with embedded nulls. This function may be incompatible with const char* MBCS strings.
bool operator>= ( const char *  s1,
const RWClassicCString s2 
) [related]

Comparisons are done lexicographically, byte by byte. Case sensitivity is exact. Use member collate() or strXForm() for locale sensitivity.

Note:
This function is incompatible with const char* strings with embedded nulls. This function may be incompatible with const char* MBCS strings.
bool operator>= ( const RWClassicCString s1,
const char *  s2 
) [related]

Comparisons are done lexicographically, byte by byte. Case sensitivity is exact. Use member collate() or strXForm() for locale sensitivity.

Note:
This function is incompatible with const char* strings with embedded nulls. This function may be incompatible with const char* MBCS strings.
bool operator>= ( const RWClassicCString s1,
const RWClassicCString s2 
) [related]

Comparisons are done lexicographically, byte by byte. Case sensitivity is exact. Use member collate() or strXForm() for locale sensitivity.

Note:
This function is incompatible with const char* strings with embedded nulls. This function may be incompatible with const char* MBCS strings.
RWFile & operator>> ( RWFile file,
RWClassicCString cstr 
) [related]

Restores a string into cstr from an RWFile, replacing the previous contents of cstr.

RWvistream & operator>> ( RWvistream str,
RWClassicCString cstr 
) [related]

Restores a string into cstr from a virtual stream, replacing the previous contents of cstr.

std::istream & operator>> ( std::istream &  s,
RWClassicCString cstr 
) [related]

Calls str.readToken(s). That is, a token is read from the input stream s.

Note:
This function is incompatible with MBCS strings.
RWClassicCString strXForm ( const RWClassicCString  )  [related]

Returns the result of applying strxfrm() to the argument string, to allow quicker collation than RWClassicCString::collate(). Usable only on platforms that provide strxfrm().

Note:
This function is incompatible with strings with embedded nulls.
RWClassicCString toLower ( const RWClassicCString  )  [related]

Returns a version of str where all upper-case characters have been replaced with lower-case characters. Uses the standard C library function tolower().

Note:
This function is incompatible with MBCS strings.
RWClassicCString toUpper ( const RWClassicCString  )  [related]

Returns a version of str where all lower-case characters have been replaced with upper-case characters. Uses the standard C library function toupper().

Note:
This function is incompatible with MBCS strings.

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