rwlogo
SourcePro 11.1

SourcePro® C++ API Reference Guide



   SourcePro C++
Documentation Home

RWClassicWSubString Class Reference
[String Processing]

Allows some subsection of an RWClassicWString to be addressed by defining a starting position and an extent. More...

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

List of all members.

Public Member Functions

RWClassicWSubStringoperator= (const wchar_t *wstr)
RWClassicWSubStringoperator= (const RWClassicWString &wstr)
RWClassicWSubStringoperator= (const RWClassicWSubString &wstr)
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
size_t length () const
size_t start () const
void toLower ()
void toUpper ()
bool isNull () const
int operator! () const

Friends

bool operator== (const RWClassicWSubString &s1, const RWClassicWSubString &s2)
bool operator== (const RWClassicWSubString &s1, const RWClassicWString &s2)
bool operator== (const RWClassicWSubString &s1, const wchar_t *s2)

Related Functions

(Note that these are not member functions.)



bool operator== (const RWClassicWString &s1, const RWClassicWSubString &s2)
bool operator== (const wchar_t *s1, const RWClassicWSubString &s2)
bool operator!= (const RWClassicWSubString &s1, const wchar_t *s2)
bool operator!= (const RWClassicWSubString &s1, const RWClassicWString &s2)
bool operator!= (const RWClassicWSubString &s1, const RWClassicWSubString &s2)
bool operator!= (const RWClassicWString &s1, const RWClassicWSubString &s2)
bool operator!= (const wchar_t *s1, const RWClassicWSubString &s2)

Detailed Description

The class RWClassicWSubString allows some subsection of an RWClassicWString to be addressed by defining a starting position and an extent.

For more information, see RWWSubString.

Synopsis

 #include <rw/wstring.h>
 RWWString s(L"test string");
 s(6,3);   // "tri"

Persistence

None

Examples

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

 main(){
  RWClassicWString s(L"What I tell you is true.");
  // Create a substring and use it as an lvalue:
  s(16,0) = RWClassicWString(L"three times ");
  cout << s << endl;
  return 0;
 }

Program output:

What I tell you three times is true.


Member Function Documentation

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

Returns true if this is a null substring.

size_t RWClassicWSubString::length (  )  const [inline]

Returns the extent (length) of the RWClassicWSubString.

int RWClassicWSubString::operator! (  )  const [inline]

Returns true if this is a null substring.

wchar_t RWClassicWSubString::operator() ( size_t  i  )  const [inline]

Returns the i th character of the substring. The index i must be between zero and the length of the substring less one. Bounds checking is enabled by defining the pre-processor macro RWBOUNDS_CHECK before including <rw/wstring.h>. In that case, if the index is out of range, throws an exception of type RWBoundsErr.

wchar_t& RWClassicWSubString::operator() ( size_t  i  ) 

Returns the i th character of the substring. The index i must be between zero and the length of the substring less one. Bounds checking is enabled by defining the pre-processor macro RWBOUNDS_CHECK before including <rw/wstring.h>. In that case, if the index is out of range, throws an exception of type RWBoundsErr.

RWClassicWSubString& RWClassicWSubString::operator= ( const RWClassicWSubString wstr  ) 

Assignment from an RWClassicWString. The statements:

 RWClassicWString a;
 RWClassicWString b;
 ...
 b(2, 3) = a;
copy the data in a into the substring b(2,3). The number of elements need not match: if they differ, b is resized appropriately. If self is the null substring, the statement has no effect.

RWClassicWSubString& RWClassicWSubString::operator= ( const RWClassicWString wstr  ) 

Assignment from an RWClassicWString. The statements:

 RWClassicWString a;
 RWClassicWString b;
 ...
 b(2, 3) = a;

copy the data in a into the substring b(2,3). The number of elements need not match: if they differ, b is resized appropriately. If self is the null substring, the statement has no effect.

RWClassicWSubString& RWClassicWSubString::operator= ( const wchar_t *  wstr  ) 

Assignment from a wide character string. Example:

 RWClassicWString wstr(L"Mary had a little lamb");
 wchar_t dat[] = L"Perrier";
 wstr(11,4) = dat;   // "Mary had a Perrier"

Note that the number of characters selected need not match: if they differ, wstr is resized appropriately. If self is the null substring, the statement has no effect.

wchar_t RWClassicWSubString::operator[] ( size_t  i  )  const [inline]

Returns the i th character of the substring. The index i must be between zero and the length of the substring less one. Bounds checking is performed. If the index is out of range, throws an exception of type RWBoundsErr.

wchar_t& RWClassicWSubString::operator[] ( size_t  i  ) 

Returns the i th character of the substring. The index i must be between zero and the length of the substring less one. Bounds checking is performed. If the index is out of range, throws an exception of type RWBoundsErr.

size_t RWClassicWSubString::start ( void   )  const [inline]

Returns the starting element of the RWClassicWSubString.

void RWClassicWSubString::toLower (  ) 

Changes all uppercase letters in self to lowercase. Uses the C library function towlower().

void RWClassicWSubString::toUpper (  ) 

Changes all lowercase letters in self to uppercase. Uses the C library function towupper().


Friends And Related Function Documentation

bool operator!= ( const wchar_t *  s1,
const RWClassicWSubString s2 
) [related]

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

bool operator!= ( const RWClassicWString s1,
const RWClassicWSubString s2 
) [related]

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

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

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

bool operator!= ( const RWClassicWSubString s1,
const RWClassicWString s2 
) [related]

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

bool operator!= ( const RWClassicWSubString s1,
const wchar_t *  s2 
) [related]

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

bool operator== ( const wchar_t *  s1,
const RWClassicWSubString s2 
) [related]

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

bool operator== ( const RWClassicWString s1,
const RWClassicWSubString s2 
) [related]

Returns true if the substring is lexicographically equal to the RWClassicWString argument. Case sensitivity is exact.

bool operator== ( const RWClassicWSubString s1,
const wchar_t *  s2 
) [friend]

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

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

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

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

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


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