SourcePro® API Reference Guide

 
Loading...
Searching...
No Matches
RWWConstSubString Class Reference

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

#include <rw/wstring.h>

Public Member Functions

 RWWConstSubString (const RWWConstSubString &str)
 
 RWWConstSubString (const RWWSubString &str)
 
bool isNull () const
 
size_t length () const
 
int operator! () const
 
wchar_t operator() (size_t i) const
 
wchar_t operator[] (int i) const
 
wchar_t operator[] (long i) const
 
wchar_t operator[] (long long i) const
 
wchar_t operator[] (short i) const
 
wchar_t operator[] (unsigned int i) const
 
wchar_t operator[] (unsigned long i) const
 
wchar_t operator[] (unsigned long long i) const
 
wchar_t operator[] (unsigned short i) const
 
size_t start () const
 

Friends

class RWWString
 
class RWWSubString
 

Related Symbols

(Note that these are not member symbols.)

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

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"
Offers powerful and convenient facilities for manipulating wide character strings.
Definition stdwstring.h:784
Persistence
None
Example
#include <rw/wstring.h>
#include <iostream>
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:\n["
<< 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 three times is true.]

Constructor & Destructor Documentation

◆ RWWConstSubString() [1/2]

RWWConstSubString::RWWConstSubString ( const RWWSubString & str)
inline

Constructs an RWWConstSubString from an existing RWWSubString. The resulting substring references the same start and extent of the RWWString associated with str.

Note
The resulting substring instance should not be used if the RWWString associated with str is modified after the substring is instantiated.

◆ RWWConstSubString() [2/2]

RWWConstSubString::RWWConstSubString ( const RWWConstSubString & str)
inline

Copy constructor. The resulting substring references the same start and extent of the RWWString associated with str.

Note
The resulting substring instance should not be used if the RWWString associated with str is modified after the substring is instantiated.

Member Function Documentation

◆ isNull()

bool RWWConstSubString::isNull ( ) const
inline

Returns true if this is a null substring.

◆ length()

size_t RWWConstSubString::length ( ) const
inline

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

◆ operator!()

int RWWConstSubString::operator! ( ) const
inline

Returns true if this is a null substring.

◆ operator()()

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. Bounds checking is enabled by defining the preprocessor macro RWBOUNDS_CHECK before including <rw/wstring.h>.

Exceptions
RWBoundsErrif RWBOUNDS_CHECK is defined and the index is out of range.

◆ operator[]() [1/8]

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. i is converted to a size_t and bounds checking is performed.

Exceptions
RWBoundsErrif the index is out of range.

◆ operator[]() [2/8]

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. i is converted to a size_t and bounds checking is performed.

Exceptions
RWBoundsErrif the index is out of range.

◆ operator[]() [3/8]

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. i is converted to a size_t and bounds checking is performed.

Exceptions
RWBoundsErrif the index is out of range.

◆ operator[]() [4/8]

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. i is converted to a size_t and bounds checking is performed.

Exceptions
RWBoundsErrif the index is out of range.

◆ operator[]() [5/8]

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. i is converted to a size_t and bounds checking is performed.

Exceptions
RWBoundsErrif the index is out of range.

◆ operator[]() [6/8]

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. i is converted to a size_t and bounds checking is performed.

Exceptions
RWBoundsErrif the index is out of range.

◆ operator[]() [7/8]

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. i is converted to a size_t and bounds checking is performed.

Exceptions
RWBoundsErrif the index is out of range.

◆ operator[]() [8/8]

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. i is converted to a size_t and bounds checking is performed.

Exceptions
RWBoundsErrif the index is out of range.

◆ start()

size_t RWWConstSubString::start ( ) const
inline

Returns the starting element of the substring.

Friends And Related Symbol Documentation

◆ operator!=() [1/3]

bool operator!= ( const RWWConstSubString & lhs,
const RWWConstSubString & rhs )
related

The equivalent of calling:

!(lhs == rhs)

◆ operator!=() [2/3]

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

The equivalent of calling:

!(lhs == rhs)

◆ operator!=() [3/3]

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

The equivalent of calling:

!(lhs == rhs)

◆ operator==() [1/3]

bool operator== ( const RWWConstSubString & 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.

◆ operator==() [2/3]

bool operator== ( const RWWConstSubString & 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.

◆ operator==() [3/3]

bool operator== ( const wchar_t * 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.

Copyright © 2024 Rogue Wave Software, Inc., a Perforce company. All Rights Reserved.