rwlogo
SourcePro C++ 12.0

SourcePro® C++ API Reference Guide



   SourcePro C++
Documentation Home

RWWSubString Class Reference
[String Processing]

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

#include <rw/wstring.h>

List of all members.

Public Member Functions

RWWSubStringoperator= (const wchar_t *str)
RWWSubStringoperator= (const std::wstring &str)
RWWSubStringoperator= (const RWWString &str)
RWWSubStringoperator= (const RWWSubString &str)
RWWSubStringoperator= (const RWWConstSubString &str)
wchar_t & operator() (size_t i)
wchar_t operator() (size_t i) const
wchar_t & operator[] (short i)
wchar_t & operator[] (int i)
wchar_t & operator[] (long i)
wchar_t & operator[] (unsigned short i)
wchar_t & operator[] (unsigned int i)
wchar_t & operator[] (unsigned long i)
wchar_t operator[] (short i) const
wchar_t operator[] (int i) const
wchar_t operator[] (long i) const
wchar_t operator[] (unsigned short i) const
wchar_t operator[] (unsigned int i) const
wchar_t operator[] (unsigned long i) const
wchar_t & operator[] (long long i)
wchar_t & operator[] (unsigned long long i)
wchar_t operator[] (long long i) const
wchar_t operator[] (unsigned long long i) const
size_t length () const
size_t start () const
void toLower ()
void toUpper ()
bool isNull () const
int operator! () const

Related Functions

(Note that these are not member functions.)



bool operator== (const RWWSubString &lhs, const wchar_t *rhs)
bool operator== (const wchar_t *lhs, const RWWSubString &rhs)
bool operator== (const RWWSubString &lhs, const RWWSubString &rhs)
bool operator== (const RWWSubString &lhs, const RWWConstSubString &rhs)
bool operator!= (const RWWSubString &lhs, const wchar_t *rhs)
bool operator!= (const wchar_t *lhs, const RWWSubString &rhs)
bool operator!= (const RWWSubString &lhs, const RWWSubString &rhs)
bool operator!= (const RWWSubString &lhs, const RWWConstSubString &rhs)
bool operator== (const RWWConstSubString &lhs, const RWWSubString &rhs)
bool operator!= (const RWWConstSubString &lhs, const RWWSubString &rhs)

Detailed Description

The class RWWSubString allows some subsection of an RWWString to be addressed by defining a starting position and an extent. For example the 7th through the 11th elements, inclusive, would have a starting position of 7 and an extent of 5. The specification of a starting position and extent can also be done in your behalf by such functions as RWWString::strip() or the overloaded function call operator taking a regular expression as an argument. There are no public constructors; RWWSubString objects are constructed by various functions of the RWWString class and then destroyed immediately.

A zero length substring is one with a defined starting position and an extent of zero. It can be thought of as starting just before the indicated character, but not including it. It can be used as an lvalue. A null substring is also legal and is frequently used to indicate that a requested substring, perhaps through a search, does not exist. A null substring can be detected with member function isNull(). However, it cannot be used as an lvalue.

Synopsis

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

Persistence

None

Examples

 #include <iostream>
 #include <rw/wstring.h>
 
 int main()
 {
     RWWString s (L"What I tell you is true.");
 
     std::cout << "Take the string: [" << s << "]\n";
 
     // Create a substring and use it as an lvalue:
     s(16, 0) = L"three times ";
 
     std::cout << "After assigning text to a substring, the full string becomes: ["
               << s << "]" << std::endl;
 
     return 0;
 }

Program output (assuming your platform displays wide characters as US-ASCII if they are in the US-ASCII character set):

 Take the string: [What I tell you is true.]
 After assigning text to a substring, the full string becomes: [What I tell you three times is true.]

Member Function Documentation

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

Returns true if this is a null substring.

size_t RWWSubString::length (  )  const [inline]

Returns the extent (i.e., length) of the substring.

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

Returns true if this is a null substring.

wchar_t RWWSubString::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>.

Exceptions:
RWBoundsErr if RWBOUNDS_CHECK is defined and the index is out of range.
wchar_t & RWWSubString::operator() ( size_t  i  )  [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>.

Exceptions:
RWBoundsErr if RWBOUNDS_CHECK is defined and the index is out of range.
RWWSubString & RWWSubString::operator= ( const RWWConstSubString str  )  [inline]

Assignment from an RWWConstSubString. Example:

 const RWWString a(10, L'a');
 RWWString b;
 ...
 b(2, 3) = a(5,5);

Copies 5 characters of a's data 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, then the statement has no effect. Returns a reference to self.

RWWSubString & RWWSubString::operator= ( const RWWSubString str  )  [inline]

Assignment from an RWWSubString. Example:

 RWWString a(10, L'a');
 RWWString b;
 ...
 b(2, 3) = a(5,5);

Copies 5 characters of a's data 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, then the statement has no effect. Returns a reference to self.

RWWSubString & RWWSubString::operator= ( const RWWString str  )  [inline]

Assignment from an RWWString. Example:

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

Copies a's data 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, then the statement has no effect. Returns a reference to self.

RWWSubString & RWWSubString::operator= ( const std::wstring &  str  )  [inline]

Assignment from an RWWString. Example:

 std::wstring a;
 RWWString b;
 ...
 b(2, 3) = a;

Copies a's data 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, then the statement has no effect. Returns a reference to self.

RWWSubString & RWWSubString::operator= ( const wchar_t *  str  )  [inline]

Assignment from a wide character string. Example:

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

The number of characters selected need not match; if they differ, str is resized appropriately. If self is the null substring, then the statement has no effect.

Returns a reference to self.

wchar_t RWWSubString::operator[] ( unsigned long long  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. i is converted to a size_t and bounds checking is performed.

Exceptions:
RWBoundsErr if the index is out of range.

wchar_t RWWSubString::operator[] ( long long  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. i is converted to a size_t and bounds checking is performed.

Exceptions:
RWBoundsErr if the index is out of range.

wchar_t & RWWSubString::operator[] ( unsigned long long  i  )  [inline]

Returns the i th character of the substring. The index i must be between zero and the length of the substring less one. i is converted to a size_t and bounds checking is performed.

Exceptions:
RWBoundsErr if the index is out of range.

wchar_t & RWWSubString::operator[] ( long long  i  )  [inline]

Returns the i th character of the substring. The index i must be between zero and the length of the substring less one. i is converted to a size_t and bounds checking is performed.

Exceptions:
RWBoundsErr if the index is out of range.

wchar_t RWWSubString::operator[] ( unsigned long  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. i is converted to a size_t and bounds checking is performed.

Exceptions:
RWBoundsErr if the index is out of range.

wchar_t RWWSubString::operator[] ( unsigned int  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. i is converted to a size_t and bounds checking is performed.

Exceptions:
RWBoundsErr if the index is out of range.

wchar_t RWWSubString::operator[] ( unsigned short  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. i is converted to a size_t and bounds checking is performed.

Exceptions:
RWBoundsErr if the index is out of range.

wchar_t RWWSubString::operator[] ( long  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. i is converted to a size_t and bounds checking is performed.

Exceptions:
RWBoundsErr if the index is out of range.

wchar_t RWWSubString::operator[] ( int  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. i is converted to a size_t and bounds checking is performed.

Exceptions:
RWBoundsErr if the index is out of range.

wchar_t RWWSubString::operator[] ( short  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. i is converted to a size_t and bounds checking is performed.

Exceptions:
RWBoundsErr if the index is out of range.

wchar_t & RWWSubString::operator[] ( unsigned long  i  )  [inline]

Returns the i th character of the substring. The index i must be between zero and the length of the substring less one. i is converted to a size_t and bounds checking is performed.

Exceptions:
RWBoundsErr if the index is out of range.

wchar_t & RWWSubString::operator[] ( unsigned int  i  )  [inline]

Returns the i th character of the substring. The index i must be between zero and the length of the substring less one. i is converted to a size_t and bounds checking is performed.

Exceptions:
RWBoundsErr if the index is out of range.

wchar_t & RWWSubString::operator[] ( unsigned short  i  )  [inline]

Returns the i th character of the substring. The index i must be between zero and the length of the substring less one. i is converted to a size_t and bounds checking is performed.

Exceptions:
RWBoundsErr if the index is out of range.

wchar_t & RWWSubString::operator[] ( long  i  )  [inline]

Returns the i th character of the substring. The index i must be between zero and the length of the substring less one. i is converted to a size_t and bounds checking is performed.

Exceptions:
RWBoundsErr if the index is out of range.

wchar_t & RWWSubString::operator[] ( int  i  )  [inline]

Returns the i th character of the substring. The index i must be between zero and the length of the substring less one. i is converted to a size_t and bounds checking is performed.

Exceptions:
RWBoundsErr if the index is out of range.

wchar_t & RWWSubString::operator[] ( short  i  )  [inline]

Returns the i th character of the substring. The index i must be between zero and the length of the substring less one. i is converted to a size_t and bounds checking is performed.

Exceptions:
RWBoundsErr if the index is out of range.
size_t RWWSubString::start ( void   )  const [inline]

Returns the index of the starting element of the substring.

void RWWSubString::toLower (  )  [inline]

Changes all upper-case letters in self to lower-case. Uses the C library function towlower().

void RWWSubString::toUpper (  )  [inline]

Changes all lower-case letters in self to upper-case. Uses the C library function towupper().


Friends And Related Function Documentation

bool operator!= ( const RWWConstSubString lhs,
const RWWSubString rhs 
) [related]

The equivalent of calling:

 !(lhs == rhs)

bool operator!= ( const RWWSubString lhs,
const RWWConstSubString rhs 
) [related]

The equivalent of calling:

 !(lhs == rhs)

bool operator!= ( const RWWSubString lhs,
const RWWSubString rhs 
) [related]

The equivalent of calling:

 !(lhs == rhs)

bool operator!= ( const wchar_t *  lhs,
const RWWSubString rhs 
) [related]

The equivalent of calling:

 !(lhs == rhs)

bool operator!= ( const RWWSubString lhs,
const wchar_t *  rhs 
) [related]

The equivalent of calling:

 !(lhs == rhs)

bool operator== ( const RWWConstSubString lhs,
const RWWSubString rhs 
) [related]

Returns true if lhs is lexicographically equal to rhs. Otherwise returns false. Use member RWWString::collate() or RWWString::strXForm() for locale-sensitive comparisons.

bool operator== ( const RWWSubString lhs,
const RWWConstSubString rhs 
) [related]

Returns true if lhs is lexicographically equal to rhs. Otherwise returns false. Use member RWWString::collate() or RWWString::strXForm() for locale-sensitive comparisons.

bool operator== ( const RWWSubString lhs,
const RWWSubString rhs 
) [related]

Returns true if lhs is lexicographically equal to rhs. Otherwise returns false. Use member RWWString::collate() or RWWString::strXForm() for locale-sensitive comparisons.

bool operator== ( const wchar_t *  lhs,
const RWWSubString rhs 
) [related]

Returns true if lhs is lexicographically equal to rhs. Otherwise returns false. Use member RWWString::collate() or RWWString::strXForm() for locale-sensitive comparisons.

bool operator== ( const RWWSubString lhs,
const wchar_t *  rhs 
) [related]

Returns true if lhs is lexicographically equal to rhs. Otherwise returns false. Use member RWWString::collate() or RWWString::strXForm() for locale-sensitive comparisons.

 All Classes Functions Variables Typedefs Enumerations Enumerator Friends

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