SourcePro® API Reference Guide

 
Loading...
Searching...
No Matches
RWCConstSubString Class Reference

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

#include <rw/cstring.h>

Public Member Functions

 RWCConstSubString (const RWCConstSubString &str)
 
 RWCConstSubString (const RWCSubString &str)
 
bool isNull () const
 
size_t length () const
 
int operator! () const
 
char operator() (size_t i) const
 
char operator[] (char i) const
 
char operator[] (int i) const
 
char operator[] (long i) const
 
char operator[] (long long i) const
 
char operator[] (short i) const
 
char operator[] (signed char i) const
 
char operator[] (unsigned char i) const
 
char operator[] (unsigned int i) const
 
char operator[] (unsigned long i) const
 
char operator[] (unsigned long long i) const
 
char operator[] (unsigned short i) const
 
size_t start () const
 

Friends

class RWCString
 
class RWCSubString
 

Related Symbols

(Note that these are not member symbols.)

bool operator!= (char lhs, const RWCConstSubString &rhs)
 
bool operator!= (const char *lhs, const RWCConstSubString &rhs)
 
bool operator!= (const RWCConstSubString &lhs, char rhs)
 
bool operator!= (const RWCConstSubString &lhs, const char *rhs)
 
bool operator!= (const RWCConstSubString &lhs, const RWCConstSubString &rhs)
 
bool operator!= (const RWCConstSubString &lhs, const std::string &rhs)
 
bool operator!= (const std::string &lhs, const RWCConstSubString &rhs)
 
bool operator< (char lhs, const RWCConstSubString &rhs)
 
bool operator< (const char *lhs, const RWCConstSubString &rhs)
 
bool operator< (const RWCConstSubString &lhs, char rhs)
 
bool operator< (const RWCConstSubString &lhs, const char *rhs)
 
bool operator< (const RWCConstSubString &lhs, const RWCConstSubString &rhs)
 
bool operator< (const RWCConstSubString &lhs, const std::string &rhs)
 
bool operator< (const std::string &lhs, const RWCConstSubString &rhs)
 
bool operator<= (char lhs, const RWCConstSubString &rhs)
 
bool operator<= (const char *lhs, const RWCConstSubString &rhs)
 
bool operator<= (const RWCConstSubString &lhs, char rhs)
 
bool operator<= (const RWCConstSubString &lhs, const char *rhs)
 
bool operator<= (const RWCConstSubString &lhs, const RWCConstSubString &rhs)
 
bool operator<= (const RWCConstSubString &lhs, const std::string &rhs)
 
bool operator<= (const std::string &lhs, const RWCConstSubString &rhs)
 
bool operator== (char lhs, const RWCConstSubString &rhs)
 
bool operator== (const char *lhs, const RWCConstSubString &rhs)
 
bool operator== (const RWCConstSubString &lhs, char rhs)
 
bool operator== (const RWCConstSubString &lhs, const char *rhs)
 
bool operator== (const RWCConstSubString &lhs, const RWCConstSubString &rhs)
 
bool operator== (const RWCConstSubString &lhs, const std::string &rhs)
 
bool operator== (const std::string &lhs, const RWCConstSubString &rhs)
 
bool operator> (char lhs, const RWCConstSubString &rhs)
 
bool operator> (const char *lhs, const RWCConstSubString &rhs)
 
bool operator> (const RWCConstSubString &lhs, char rhs)
 
bool operator> (const RWCConstSubString &lhs, const char *rhs)
 
bool operator> (const RWCConstSubString &lhs, const RWCConstSubString &rhs)
 
bool operator> (const RWCConstSubString &lhs, const std::string &rhs)
 
bool operator> (const std::string &lhs, const RWCConstSubString &rhs)
 
bool operator>= (char lhs, const RWCConstSubString &rhs)
 
bool operator>= (const char *lhs, const RWCConstSubString &rhs)
 
bool operator>= (const RWCConstSubString &lhs, char rhs)
 
bool operator>= (const RWCConstSubString &lhs, const char *rhs)
 
bool operator>= (const RWCConstSubString &lhs, const RWCConstSubString &rhs)
 
bool operator>= (const RWCConstSubString &lhs, const std::string &rhs)
 
bool operator>= (const std::string &lhs, const RWCConstSubString &rhs)
 

Detailed Description

The class RWCConstSubString allows some subsection of an RWCString 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 is also done on your behalf by such functions as RWCString::strip(). There are no public constructors other than one that creates an RWCConstSubString from an existing RWCSubString. In general, RWCConstSubStrings are constructed by various functions of the RWCString 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/cstring.h>
const RWCString s("test string");
s(6, 3); // "tri"
Offers powerful and convenient facilities for manipulating strings.
Definition stdcstring.h:826
Persistence
None
Example
#include <rw/cstring.h>
#include <iostream>
int main() {
const RWCString s("What I tell you is true.");
std::cout << "Take the string: [" << s << "]\n";
// Create a string from substrings:
const RWCString s2(s(0, 16) + "three times " + s(16, 8));
std::cout << "After creating a string from substrings, you have: ["
<< s2 << "]" << std::endl;
return 0;
}

Program output:

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

◆ RWCConstSubString() [1/2]

RWCConstSubString::RWCConstSubString ( const RWCConstSubString & str)
inline

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

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

◆ RWCConstSubString() [2/2]

RWCConstSubString::RWCConstSubString ( const RWCSubString & str)
inline

Constructs an RWCConstSubString from an existing RWCSubString. The resulting substring references the same start and extent of the RWCString associated with str.

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

Member Function Documentation

◆ isNull()

bool RWCConstSubString::isNull ( ) const
inline

Returns true if this is a null substring.

◆ length()

size_t RWCConstSubString::length ( ) const
inline

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

◆ operator!()

int RWCConstSubString::operator! ( ) const
inline

Returns true if this is a null substring.

◆ operator()()

char RWCConstSubString::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/cstring.h>.

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

◆ operator[]() [1/11]

char RWCConstSubString::operator[] ( char 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/11]

char RWCConstSubString::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/11]

char RWCConstSubString::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[]() [4/11]

char RWCConstSubString::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[]() [5/11]

char RWCConstSubString::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[]() [6/11]

char RWCConstSubString::operator[] ( signed char 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/11]

char RWCConstSubString::operator[] ( unsigned char 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[]() [8/11]

char RWCConstSubString::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[]() [9/11]

char RWCConstSubString::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[]() [10/11]

char RWCConstSubString::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[]() [11/11]

char RWCConstSubString::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 RWCConstSubString::start ( ) const
inline

Returns the index of the starting element of the substring.

Friends And Related Symbol Documentation

◆ operator!=() [1/7]

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

The equivalent of calling:

!(lhs == rhs)

◆ operator!=() [2/7]

bool operator!= ( const char * lhs,
const RWCConstSubString & rhs )
related

The equivalent of calling:

!(lhs == rhs)

◆ operator!=() [3/7]

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

The equivalent of calling:

!(lhs == rhs)

◆ operator!=() [4/7]

bool operator!= ( const RWCConstSubString & lhs,
const char * rhs )
related

The equivalent of calling:

!(lhs == rhs)

◆ operator!=() [5/7]

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

The equivalent of calling:

!(lhs == rhs)

◆ operator!=() [6/7]

bool operator!= ( const RWCConstSubString & lhs,
const std::string & rhs )
related

The equivalent of calling:

!(lhs == rhs)

◆ operator!=() [7/7]

bool operator!= ( const std::string & lhs,
const RWCConstSubString & rhs )
related

The equivalent of calling:

!(lhs == rhs)

◆ operator<() [1/7]

bool operator< ( char lhs,
const RWCConstSubString & rhs )
related

Returns true if the length of rhs is at least one and the first character of rhs is greater than lhs.

◆ operator<() [2/7]

bool operator< ( const char * lhs,
const RWCConstSubString & rhs )
related

Returns true if lhs lexicographically precedes rhs. Otherwise returns false. Use member RWCString::collate() or RWCString::strXForm() for locale-sensitive comparisons.

Note
This function is incompatible with lhs strings with embedded nulls.

◆ operator<() [3/7]

bool operator< ( const RWCConstSubString & lhs,
char rhs )
related

Returns true if lhs is empty or the first character in lhs is less than rhs. Otherwise returns false.

◆ operator<() [4/7]

bool operator< ( const RWCConstSubString & lhs,
const char * rhs )
related

Returns true if lhs lexicographically precedes rhs. Otherwise returns false. Use member RWCString::collate() or RWCString::strXForm() for locale-sensitive comparisons.

Note
This function is incompatible with rhs strings with embedded nulls.

◆ operator<() [5/7]

bool operator< ( const RWCConstSubString & lhs,
const RWCConstSubString & rhs )
related

Returns true if lhs lexicographically precedes rhs. Otherwise returns false. Use member RWCString::collate() or RWCString::strXForm() for locale-sensitive comparisons.

◆ operator<() [6/7]

bool operator< ( const RWCConstSubString & lhs,
const std::string & rhs )
related

Returns true if lhs lexicographically precedes rhs. Otherwise returns false. Use member RWCString::collate() or RWCString::strXForm() for locale-sensitive comparisons.

◆ operator<() [7/7]

bool operator< ( const std::string & lhs,
const RWCConstSubString & rhs )
related

Returns true if lhs lexicographically precedes rhs. Otherwise returns false. Use member RWCString::collate() or RWCString::strXForm() for locale-sensitive comparisons.

◆ operator<=() [1/7]

bool operator<= ( char lhs,
const RWCConstSubString & rhs )
related

The equivalent of calling:

!(rhs < lhs)

◆ operator<=() [2/7]

bool operator<= ( const char * lhs,
const RWCConstSubString & rhs )
related

The equivalent of calling:

!(rhs < lhs)

◆ operator<=() [3/7]

bool operator<= ( const RWCConstSubString & lhs,
char rhs )
related

The equivalent of calling:

!(rhs < lhs)

◆ operator<=() [4/7]

bool operator<= ( const RWCConstSubString & lhs,
const char * rhs )
related

The equivalent of calling:

!(rhs < lhs)

◆ operator<=() [5/7]

bool operator<= ( const RWCConstSubString & lhs,
const RWCConstSubString & rhs )
related

The equivalent of calling:

!(rhs < lhs)

◆ operator<=() [6/7]

bool operator<= ( const RWCConstSubString & lhs,
const std::string & rhs )
related

The equivalent of calling:

!(rhs < lhs)

◆ operator<=() [7/7]

bool operator<= ( const std::string & lhs,
const RWCConstSubString & rhs )
related

The equivalent of calling:

!(rhs < lhs)

◆ operator==() [1/7]

bool operator== ( char lhs,
const RWCConstSubString & rhs )
related

Returns true if rhs has a length of one and the first character rhs is identical to the char lhs.

◆ operator==() [2/7]

bool operator== ( const char * lhs,
const RWCConstSubString & rhs )
related

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

Note
This function is incompatible with lhs strings with embedded nulls.

◆ operator==() [3/7]

bool operator== ( const RWCConstSubString & lhs,
char rhs )
related

Returns true if lhs has a length of one and the first character lhs is identical to the char rhs.

◆ operator==() [4/7]

bool operator== ( const RWCConstSubString & lhs,
const char * rhs )
related

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

Note
This function is incompatible with rhs strings with embedded nulls.

◆ operator==() [5/7]

bool operator== ( const RWCConstSubString & lhs,
const RWCConstSubString & rhs )
related

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

◆ operator==() [6/7]

bool operator== ( const RWCConstSubString & lhs,
const std::string & rhs )
related

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

◆ operator==() [7/7]

bool operator== ( const std::string & lhs,
const RWCConstSubString & rhs )
related

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

◆ operator>() [1/7]

bool operator> ( char lhs,
const RWCConstSubString & rhs )
related

The equivalent of calling:

!(rhs < lhs)

◆ operator>() [2/7]

bool operator> ( const char * lhs,
const RWCConstSubString & rhs )
related

The equivalent of calling:

!(rhs < lhs)

◆ operator>() [3/7]

bool operator> ( const RWCConstSubString & lhs,
char rhs )
related

The equivalent of calling:

!(rhs < lhs)

◆ operator>() [4/7]

bool operator> ( const RWCConstSubString & lhs,
const char * rhs )
related

The equivalent of calling:

!(rhs < lhs)

◆ operator>() [5/7]

bool operator> ( const RWCConstSubString & lhs,
const RWCConstSubString & rhs )
related

The equivalent of calling:

!(rhs < lhs)

◆ operator>() [6/7]

bool operator> ( const RWCConstSubString & lhs,
const std::string & rhs )
related

The equivalent of calling:

!(rhs < lhs)

◆ operator>() [7/7]

bool operator> ( const std::string & lhs,
const RWCConstSubString & rhs )
related

The equivalent of calling:

!(rhs < lhs)

◆ operator>=() [1/7]

bool operator>= ( char lhs,
const RWCConstSubString & rhs )
related

The equivalent of calling:

!(lhs < rhs)

◆ operator>=() [2/7]

bool operator>= ( const char * lhs,
const RWCConstSubString & rhs )
related

The equivalent of calling:

!(lhs < rhs)

◆ operator>=() [3/7]

bool operator>= ( const RWCConstSubString & lhs,
char rhs )
related

The equivalent of calling:

!(lhs < rhs)

◆ operator>=() [4/7]

bool operator>= ( const RWCConstSubString & lhs,
const char * rhs )
related

The equivalent of calling:

!(lhs < rhs)

◆ operator>=() [5/7]

bool operator>= ( const RWCConstSubString & lhs,
const RWCConstSubString & rhs )
related

The equivalent of calling:

!(lhs < rhs)

◆ operator>=() [6/7]

bool operator>= ( const RWCConstSubString & lhs,
const std::string & rhs )
related

The equivalent of calling:

!(lhs < rhs)

◆ operator>=() [7/7]

bool operator>= ( const std::string & lhs,
const RWCConstSubString & rhs )
related

The equivalent of calling:

!(lhs < rhs)

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