SourcePro® API Reference Guide

 
Loading...
Searching...
No Matches
RWWSubString 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

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

Friends

class RWWConstSubString
 
class RWWString
 

Related Symbols

(Note that these are not member symbols.)

bool operator!= (const RWWConstSubString &lhs, const RWWSubString &rhs)
 
bool operator!= (const RWWSubString &lhs, const RWWConstSubString &rhs)
 
bool operator!= (const RWWSubString &lhs, const RWWSubString &rhs)
 
bool operator!= (const RWWSubString &lhs, const wchar_t *rhs)
 
bool operator!= (const wchar_t *lhs, const RWWSubString &rhs)
 
bool operator== (const RWWConstSubString &lhs, const RWWSubString &rhs)
 
bool operator== (const RWWSubString &lhs, const RWWConstSubString &rhs)
 
bool operator== (const RWWSubString &lhs, const RWWSubString &rhs)
 
bool operator== (const RWWSubString &lhs, const wchar_t *rhs)
 
bool operator== (const wchar_t *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"
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() {
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:\n["
<< 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

◆ isNull()

bool RWWSubString::isNull ( ) const
inline

Returns true if this is a null substring.

◆ length()

size_t RWWSubString::length ( ) const
inline

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

◆ operator!()

int RWWSubString::operator! ( ) const
inline

Returns true if this is a null substring.

◆ operator()() [1/2]

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 preprocessor macro RWBOUNDS_CHECK before including <rw/wstring.h>.

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

◆ operator()() [2/2]

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 preprocessor macro RWBOUNDS_CHECK before including <rw/wstring.h>.

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

◆ operator=() [1/5]

RWWSubString & RWWSubString::operator= ( const RWWConstSubString & str)
inline

Assignment from an RWWConstSubString. Example:

const RWWString a(10, L'a');
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.

◆ operator=() [2/5]

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

Assignment from an RWWString. Example:

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.

◆ operator=() [3/5]

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

Assignment from an RWWSubString. Example:

RWWString a(10, L'a');
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.

◆ operator=() [4/5]

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

Assignment from an RWWString. Example:

std::wstring a;
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.

◆ operator=() [5/5]

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.

◆ operator[]() [1/16]

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
RWBoundsErrif the index is out of range.

◆ operator[]() [2/16]

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
RWBoundsErrif the index is out of range.

◆ operator[]() [3/16]

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
RWBoundsErrif the index is out of range.

◆ operator[]() [4/16]

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
RWBoundsErrif the index is out of range.

◆ operator[]() [5/16]

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
RWBoundsErrif the index is out of range.

◆ operator[]() [6/16]

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
RWBoundsErrif the index is out of range.

◆ operator[]() [7/16]

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
RWBoundsErrif the index is out of range.

◆ operator[]() [8/16]

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
RWBoundsErrif the index is out of range.

◆ operator[]() [9/16]

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
RWBoundsErrif the index is out of range.

◆ operator[]() [10/16]

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
RWBoundsErrif the index is out of range.

◆ operator[]() [11/16]

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
RWBoundsErrif the index is out of range.

◆ operator[]() [12/16]

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
RWBoundsErrif the index is out of range.

◆ operator[]() [13/16]

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
RWBoundsErrif the index is out of range.

◆ operator[]() [14/16]

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
RWBoundsErrif the index is out of range.

◆ operator[]() [15/16]

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
RWBoundsErrif the index is out of range.

◆ operator[]() [16/16]

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
RWBoundsErrif the index is out of range.

◆ start()

size_t RWWSubString::start ( ) const
inline

Returns the index of the starting element of the substring.

◆ toLower()

void RWWSubString::toLower ( )
inline

Changes all upper-case letters in self to lower-case. Uses the C++ Standard Library function std::towlower().

◆ toUpper()

void RWWSubString::toUpper ( )
inline

Changes all lower-case letters in self to upper-case. Uses the C++ Standard Library function std::towupper().

Friends And Related Symbol Documentation

◆ operator!=() [1/5]

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

The equivalent of calling:

!(lhs == rhs)

◆ operator!=() [2/5]

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

The equivalent of calling:

!(lhs == rhs)

◆ operator!=() [3/5]

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

The equivalent of calling:

!(lhs == rhs)

◆ operator!=() [4/5]

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

The equivalent of calling:

!(lhs == rhs)

◆ operator!=() [5/5]

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

The equivalent of calling:

!(lhs == rhs)

◆ operator==() [1/5]

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.

◆ operator==() [2/5]

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.

◆ operator==() [3/5]

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.

◆ operator==() [4/5]

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.

◆ operator==() [5/5]

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.

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