rwlogo
SourcePro 11.1

SourcePro® C++ API Reference Guide



   SourcePro C++
Documentation Home

RWWConstSubString Class Reference
[String Processing]

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

#include <rw/tools/wstring.h>

List of all members.

Public Member Functions

 RWWConstSubString (const RWWSubString &sp)
 RWWConstSubString (const RWWConstSubString &sp)
wchar_t operator() (size_t i) const
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) const
wchar_t operator[] (unsigned long long i) const
size_t length () const
size_t start () const
bool isNull () const
int operator! () const

Related Functions

(Note that these are not member functions.)



bool operator== (const RWWConstSubString &s1, const wchar_t *s2)
bool operator== (const wchar_t *s1, const RWWConstSubString &s2)
bool operator== (const RWWConstSubString &s1, const RWWConstSubString &s2)
bool operator== (const RWWConstSubString &s1, const RWWString &s2)
bool operator== (const RWWString &s1, const RWWConstSubString &s2)
bool operator== (const RWWConstSubString &s1, const RWWSubString &s2)
bool operator!= (const RWWConstSubString &s1, const wchar_t *s2)
bool operator!= (const wchar_t *s1, const RWWConstSubString &s2)
bool operator!= (const RWWConstSubString &s1, const RWWConstSubString &s2)
bool operator!= (const RWWConstSubString &s1, const RWWString &s2)
bool operator!= (const RWWString &s1, const RWWConstSubString &s2)
bool operator!= (const RWWConstSubString &s1, const RWWSubString &s2)

Detailed Description

The class RWWConstSubString 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 on your behalf by such functions as RWWString::strip(). There are no public constructors other than two that allow you to create an RWWConstSubString from an existing RWWSubString or RWWConstSubString. In general, RWWConstSubString 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("test string");
 s(6,3);     // "tri"

Persistence

None

Examples

 #include <iostream>
 #include <rw/wstring.h>
 
 int main()
 {
 const RWWString s (L"What I tell you is true.");
  
     std::cout << "Take the string: [" << s << "]\n";
 
     // Create a string from substrings:
 const RWWString s2 (s(0, 16) + L"three times " + s(16, 8));
 
     std::cout << "After creating a string from substrings, you have: ["
               << s2 << "]" << 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 creating a string from substrings, you have: [What I tell you is 
 three times true.]

Constructor & Destructor Documentation

RWWConstSubString::RWWConstSubString ( const RWWSubString sp  )  [inline]

Creates an RWWConstSubString from an existing RWWSubString.

RWWConstSubString::RWWConstSubString ( const RWWConstSubString sp  )  [inline]

Creates an RWWConstSubString from an existing RWWConstSubString.


Member Function Documentation

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

Returns true if this is a null substring.

size_t RWWConstSubString::length (  )  const [inline]

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

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

Returns true if this is a null substring.

wchar_t RWWConstSubString::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. Optional bounds checking is enabled by defining the pre-processor macro RWBOUNDS_CHECK before including <rw/wstring.h>.

Exceptions:
RWBoundsErr Thrown if the index is out of range.
wchar_t RWWConstSubString::operator[] ( unsigned long long  i  )  const

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.

Exceptions:
RWBoundsErr Thrown if the index is out of range.

wchar_t RWWConstSubString::operator[] ( long long  i  )  const

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.

Exceptions:
RWBoundsErr Thrown if the index is out of range.

wchar_t RWWConstSubString::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. Bounds checking is performed.

Exceptions:
RWBoundsErr Thrown if the index is out of range.

wchar_t RWWConstSubString::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. Bounds checking is performed.

Exceptions:
RWBoundsErr Thrown if the index is out of range.

wchar_t RWWConstSubString::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. Bounds checking is performed.

Exceptions:
RWBoundsErr Thrown if the index is out of range.

wchar_t RWWConstSubString::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. Bounds checking is performed.

Exceptions:
RWBoundsErr Thrown if the index is out of range.

wchar_t RWWConstSubString::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. Bounds checking is performed.

Exceptions:
RWBoundsErr Thrown if the index is out of range.

wchar_t RWWConstSubString::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. Bounds checking is performed.

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

Returns the starting element of the RWWConstSubString.


Friends And Related Function Documentation

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

Returns true if s1 is lexicographically equal to s2. Otherwise returns false. Case sensitivity is RWWString::exact.

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

Returns true if s1 is lexicographically equal to s2. Otherwise returns false. Case sensitivity is RWWString::exact.

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

Returns true if s1 is lexicographically equal to s2. Otherwise returns false. Case sensitivity is RWWString::exact.

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

Returns false if s1 is lexicographically equal to s2. Otherwise returns true. Case sensitivity is RWWString::exact.

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

Returns false if s1 is lexicographically equal to s2. Otherwise returns true. Case sensitivity is RWWString::exact.

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

Returns false if s1 is lexicographically equal to s2. Otherwise returns true. Case sensitivity is RWWString::exact.

bool operator== ( const RWWConstSubString s1,
const RWWSubString s2 
) [related]

Returns true if s1 is lexicographically equal to s2. Otherwise returns false. Case sensitivity is RWWString::exact.

bool operator== ( const RWWString s1,
const RWWConstSubString s2 
) [related]

Returns true if s1 is lexicographically equal to s2. Otherwise returns false. Case sensitivity is RWWString::exact.

bool operator== ( const RWWConstSubString s1,
const RWWString s2 
) [related]

Returns true if s1 is lexicographically equal to s2. Otherwise returns false. Case sensitivity is RWWString::exact.

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

Returns true if s1 is lexicographically equal to s2. Otherwise returns false. Case sensitivity is RWWString::exact.

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

Returns true if s1 is lexicographically equal to s2. Otherwise returns false. Case sensitivity is RWWString::exact.

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

Returns true if s1 is lexicographically equal to s2. Otherwise returns false. Case sensitivity is RWWString::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.