SourcePro® API Reference Guide

Product Documentation:
   SourcePro
Documentation Home
List of all members | Public Member Functions | Related Functions

Provides read-only access to a range of code units within a referenced RWUString. More...

#include <rw/i18n/RWUConstSubString.h>

Public Member Functions

 RWUConstSubString (const RWUConstSubString &sp)
 
size_t boundsCheckIndex (size_t offset) const
 
const RWUChar16data () const
 
bool isNull () const
 
size_t length () const
 
RWUChar16 operator() (size_t offset) const
 
RWUChar16 operator[] (size_t offset) const
 
size_t start () const
 

Related Functions

(Note that these are not member functions.)

bool operator!= (const RWUConstSubString &lhs, const RWUConstSubString &rhs)
 
bool operator!= (const RWUChar16 *lhs, const RWUConstSubString &rhs)
 
bool operator!= (const RWUConstSubString &lhs, const RWUChar16 *rhs)
 
bool operator!= (const RWUChar32 *lhs, const RWUConstSubString &rhs)
 
bool operator!= (const RWUConstSubString &lhs, const RWUChar32 *rhs)
 
bool operator!= (const RWBasicUString &lhs, const RWUConstSubString &rhs)
 
bool operator!= (const RWUConstSubString &lhs, const RWBasicUString &rhs)
 
bool operator< (const RWUConstSubString &lhs, const RWUConstSubString &rhs)
 
bool operator< (const RWUChar16 *lhs, const RWUConstSubString &rhs)
 
bool operator< (const RWUConstSubString &lhs, const RWUChar16 *rhs)
 
bool operator< (const RWUChar32 *lhs, const RWUConstSubString &rhs)
 
bool operator< (const RWUConstSubString &lhs, const RWUChar32 *rhs)
 
bool operator< (const RWBasicUString &lhs, const RWUConstSubString &rhs)
 
bool operator< (const RWUConstSubString &lhs, const RWBasicUString &rhs)
 
std::ostream & operator<< (std::ostream &os, const RWUConstSubString &ustr)
 
bool operator<= (const RWUConstSubString &lhs, const RWUConstSubString &rhs)
 
bool operator<= (const RWUChar16 *lhs, const RWUConstSubString &rhs)
 
bool operator<= (const RWUConstSubString &lhs, const RWUChar16 *rhs)
 
bool operator<= (const RWUChar32 *lhs, const RWUConstSubString &rhs)
 
bool operator<= (const RWUConstSubString &lhs, const RWUChar32 *rhs)
 
bool operator<= (const RWBasicUString &lhs, const RWUConstSubString &rhs)
 
bool operator<= (const RWUConstSubString &lhs, const RWBasicUString &rhs)
 
bool operator== (const RWUConstSubString &lhs, const RWUConstSubString &rhs)
 
bool operator== (const RWUChar16 *lhs, const RWUConstSubString &rhs)
 
bool operator== (const RWUConstSubString &lhs, const RWUChar16 *rhs)
 
bool operator== (const RWUChar32 *lhs, const RWUConstSubString &rhs)
 
bool operator== (const RWUConstSubString &lhs, const RWUChar32 *rhs)
 
bool operator== (const RWBasicUString &lhs, const RWUConstSubString &rhs)
 
bool operator== (const RWUConstSubString &lhs, const RWBasicUString &rhs)
 
bool operator> (const RWUConstSubString &lhs, const RWUConstSubString &rhs)
 
bool operator> (const RWUChar16 *lhs, const RWUConstSubString &rhs)
 
bool operator> (const RWUConstSubString &lhs, const RWUChar16 *rhs)
 
bool operator> (const RWUChar32 *lhs, const RWUConstSubString &rhs)
 
bool operator> (const RWUConstSubString &lhs, const RWUChar32 *rhs)
 
bool operator> (const RWBasicUString &lhs, const RWUConstSubString &rhs)
 
bool operator> (const RWUConstSubString &lhs, const RWBasicUString &rhs)
 
bool operator>= (const RWUConstSubString &lhs, const RWUConstSubString &rhs)
 
bool operator>= (const RWUChar16 *lhs, const RWUConstSubString &rhs)
 
bool operator>= (const RWUConstSubString &lhs, const RWUChar16 *rhs)
 
bool operator>= (const RWUChar32 *lhs, const RWUConstSubString &rhs)
 
bool operator>= (const RWUConstSubString &lhs, const RWUChar32 *rhs)
 
bool operator>= (const RWBasicUString &lhs, const RWUConstSubString &rhs)
 
bool operator>= (const RWUConstSubString &lhs, const RWBasicUString &rhs)
 

Detailed Description

RWUConstSubString allows read-only access to a range of code units within a referenced RWUString. The range is defined by a starting position and an length within the referenced string. For example, the 7th through the 11th elements, inclusive, would have starting position of 7 and an length of 5.

There are no public constructors. RWUConstSubString instances are constructed by various functions of the RWUString class. Typically, substrings are created and used anonymously, then destroyed immediately.

RWUConstSubString performs bounds checking in all methods that accept an offset value. These methods throw RWBoundsErr if an offset exceeds the current bounds of the substring.

Example
#include <rw/i18n/RWUString.h>
#include <rw/i18n/RWUConstSubString.h>
#include <rw/i18n/RWUConversionContext.h>
#include <iostream>
using std::cout;
using std::endl;
int
main()
{
// Indicate that source and target strings are
// encoded as Latin-1.
RWUConversionContext context("Latin-1");
// Initialize a const Unicode string.
const RWUString str(" Hello! ");
// Print the string and its length.
cout << "\"" << str << "\" is " << str.length() <<
" code units long." << endl;
// Strip off whitespace. When invoked on a const
// RWUString, strip() returns an RWUConstSubString.
// The assignment operator creates a copy.
// Print the result and its length.
cout << "\"" << copy << "\" is " << copy.length() <<
" code units long." << endl;
return 0;
} // main

Program Output:

" Hello !" is 10 code units long.
"Hello!" is 6 code units long.
See also
RWUString, RWUSubString

Constructor & Destructor Documentation

RWUConstSubString::RWUConstSubString ( const RWUConstSubString sp)
inline

Copy constructor.

Member Function Documentation

size_t RWUConstSubString::boundsCheckIndex ( size_t  offset) const
inline

Returns offset.

Exceptions
RWBoundsErrThrown if self is a null substring or if offset is greater than or equal to length().
const RWUChar16 * RWUConstSubString::data ( ) const
inline

Returns a pointer to the string contents referenced by self. The storage referenced by this pointer is owned by the RWUString associated with self. This storage may not be deleted or modified. The pointer becomes invalid if the RWUString is modified or destroyed.

Exceptions
RWBoundsErrThrown if self is a null substring.
bool RWUConstSubString::isNull ( void  ) const
inline

Returns true if the substring defined by self is null or empty; otherwise, false.

size_t RWUConstSubString::length ( ) const
inline

Returns the number of code units in the substring defined by self.

RWUChar16 RWUConstSubString::operator() ( size_t  offset) const
inline

Returns the code unit located at index offset within self. The value of offset must be less than length().

Exceptions
RWBoundsErrThrown if self is a null substring, or if offset is greater than or equal to length().
RWUChar16 RWUConstSubString::operator[] ( size_t  offset) const
inline

Returns the code unit located at index offset within self. The value of offset must be less than length().

Exceptions
RWBoundsErrThrown if self is a null substring, or if offset is greater than or equal to length().
size_t RWUConstSubString::start ( ) const
inline

Returns the start position of the substring defined by self within the RWUString referenced by self. A return value of RW_NPOS indicates that self is null substring.

Friends And Related Function Documentation

bool operator!= ( const RWUConstSubString lhs,
const RWUConstSubString rhs 
)
related

Returns true if lhs does not have the same length as, or lexicographically differs from, rhs; otherwise, false. Also returns false if both substrings are invalid. This operator represents the logical negation of operator==.

bool operator!= ( const RWUChar16 lhs,
const RWUConstSubString rhs 
)
related

Returns true if lhs does not have the same length as, or lexicographically differs from, rhs; otherwise, false. This operator represents the logical negation of operator==.

The lhs string must be null-terminated. This method cannot be used to compare strings containing embedded nulls; use RWBasicUString::compareCodeUnits() in that case.

bool operator!= ( const RWUConstSubString lhs,
const RWUChar16 rhs 
)
related

Returns true if lhs does not have the same length as, or lexicographically differs from, rhs; otherwise, false. This operator represents the logical negation of operator==.

The rhs string must be null-terminated. This method cannot be used to compare strings containing embedded nulls; use RWBasicUString::compareCodeUnits() in that case.

bool operator!= ( const RWUChar32 lhs,
const RWUConstSubString rhs 
)
related

Returns true if lhs does not have the same length as, or lexicographically differs from, rhs; otherwise, false. This operator represents the logical negation of operator==.

The lhs string must be null-terminated. This method cannot be used to compare strings containing embedded nulls; use RWBasicUString::compareCodePoints() in that case.

bool operator!= ( const RWUConstSubString lhs,
const RWUChar32 rhs 
)
related

Returns true if lhs does not have the same length as, or lexicographically differs from, rhs; otherwise, false. This operator represents the logical negation of operator==.

The rhs string must be null-terminated. This method cannot be used to compare strings containing embedded nulls; use RWBasicUString::compareCodePoints() in that case.

bool operator!= ( const RWBasicUString lhs,
const RWUConstSubString rhs 
)
related

Returns true if lhs does not have the same length as, or lexicographically differs from, rhs; otherwise, false. This operator represents the logical negation of operator==.

bool operator!= ( const RWUConstSubString lhs,
const RWBasicUString rhs 
)
related

Returns true if lhs does not have the same length as, or lexicographically differs from, rhs; otherwise, false. This operator represents the logical negation of operator==.

bool operator< ( const RWUConstSubString lhs,
const RWUConstSubString rhs 
)
related

Returns true if lhs is lexicographically less than rhs; otherwise, false. If the two strings are identical over the length of the shortest string, then the shorter string is considered less than the longer string.

bool operator< ( const RWUChar16 lhs,
const RWUConstSubString rhs 
)
related

Returns true if lhs is lexicographically less than rhs; otherwise, false. If the two strings are identical over the length of the shortest string, then the shorter string is considered less than the longer string.

The lhs string must be null-terminated. This method cannot be used to compare strings containing embedded nulls; use RWBasicUString::compareCodeUnits() in that case.

bool operator< ( const RWUConstSubString lhs,
const RWUChar16 rhs 
)
related

Returns true if lhs is lexicographically less than rhs; otherwise, false. If the two strings are identical over the length of the shortest string, then the shorter string is considered less than the longer string.

The rhs string must be null-terminated. This method cannot be used to compare strings containing embedded nulls; use RWBasicUString::compareCodeUnits() in that case.

bool operator< ( const RWUChar32 lhs,
const RWUConstSubString rhs 
)
related

Returns true if lhs is lexicographically less than rhs; otherwise, false. If the two strings are identical over the length of the shortest string, then the shorter string is considered less than the longer string.

The lhs string must be null-terminated. This method cannot be used to compare strings containing embedded nulls; use RWBasicUString::compareCodePoints() in that case.

bool operator< ( const RWUConstSubString lhs,
const RWUChar32 rhs 
)
related

Returns true if lhs is lexicographically less than rhs; otherwise, false. If the two strings are identical over the length of the shortest string, then the shorter string is considered less than the longer string.

The rhs string must be null-terminated. This method cannot be used to compare strings containing embedded nulls; use RWBasicUString::compareCodePoints() in that case.

bool operator< ( const RWBasicUString lhs,
const RWUConstSubString rhs 
)
related

Returns true if lhs is lexicographically less than rhs; otherwise, false. If the two strings are identical over the length of the shortest string, then the shorter string is considered less than the longer string.

bool operator< ( const RWUConstSubString lhs,
const RWBasicUString rhs 
)
related

Returns true if lhs is lexicographically less than rhs; otherwise, false. If the two strings are identical over the length of the shortest string, then the shorter string is considered less than the longer string.

std::ostream & operator<< ( std::ostream &  os,
const RWUConstSubString ustr 
)
related

Writes the sequence of bytes to std::ostream that are produced when contents of ustr are converted into the character encoding scheme specified by the currently active target RWUFromUnicodeConversionContext.

If os.width() is greater than the number of code points contained in the source string, the output is padded using a single space fill character (U+0020). If os.width() is less than the number of code points contained the source string, the entire contents of the string are inserted into the output stream. Any padding is inserted after the string if the std::ios_base::left format flag is set, or before if std::ios_base::right is set or if neither flag is set.

Exceptions
RWUExceptionThrown to report conversion errors.
std::ios_base::failureThrown to report any errors detected while performing stream operations.
bool operator<= ( const RWUConstSubString lhs,
const RWUConstSubString rhs 
)
related

Returns true if lhs has the same length and is lexicographically identical to rhs; otherwise, false. Returns true if both substrings are null. If the two strings are identical over the length of the shortest string, then the shorter string is considered less than the longer string.

bool operator<= ( const RWUChar16 lhs,
const RWUConstSubString rhs 
)
related

Returns true if lhs has the same length and is lexicographically identical to rhs; otherwise, false. If the two strings are identical over the length of the shortest string, then the shorter string is considered less than the longer string.

The lhs string must be null-terminated. This method cannot be used to compare strings containing embedded nulls; use RWBasicUString::compareCodeUnits() in that case.

bool operator<= ( const RWUConstSubString lhs,
const RWUChar16 rhs 
)
related

Returns true if lhs has the same length and is lexicographically identical to rhs; otherwise, false. If the two strings are identical over the length of the shortest string, then the shorter string is considered less than the longer string.

The rhs string must be null-terminated. This method cannot be used to compare strings containing embedded nulls; use RWBasicUString::compareCodeUnits() in that case.

bool operator<= ( const RWUChar32 lhs,
const RWUConstSubString rhs 
)
related

Returns true if lhs has the same length and is lexicographically identical to rhs; otherwise, false. If the two strings are identical over the length of the shortest string, then the shorter string is considered less than the longer string.

The lhs string must be null-terminated. This method cannot be used to compare strings containing embedded nulls; use RWBasicUString::compareCodePoints() in that case.

bool operator<= ( const RWUConstSubString lhs,
const RWUChar32 rhs 
)
related

Returns true if lhs has the same length and is lexicographically identical to rhs; otherwise, false. If the two strings are identical over the length of the shortest string, then the shorter string is considered less than the longer string.

The rhs string must be null-terminated. This method cannot be used to compare strings containing embedded nulls; use RWBasicUString::compareCodePoints() in that case.

bool operator<= ( const RWBasicUString lhs,
const RWUConstSubString rhs 
)
related

Returns true if lhs has the same length and is lexicographically identical to rhs; otherwise, false. If the two strings are identical over the length of the shortest string, then the shorter string is considered less than the longer string.

bool operator<= ( const RWUConstSubString lhs,
const RWBasicUString rhs 
)
related

Returns true if lhs has the same length and is lexicographically identical to rhs; otherwise, false. If the two strings are identical over the length of the shortest string, then the shorter string is considered less than the longer string.

bool operator== ( const RWUConstSubString lhs,
const RWUConstSubString rhs 
)
related

Returns true if lhs has the same length and is lexicographically identical to rhs; otherwise, false.

bool operator== ( const RWUChar16 lhs,
const RWUConstSubString rhs 
)
related

Returns true if lhs has the same length and is lexicographically identical to rhs; otherwise, false.

The lhs string must be null-terminated. This method cannot be used to compare strings containing embedded nulls; use RWBasicUString::compareCodeUnits() in that case.

bool operator== ( const RWUConstSubString lhs,
const RWUChar16 rhs 
)
related

Returns true if lhs has the same length and is lexicographically identical to rhs; otherwise, false.

The rhs string must be null-terminated. This method cannot be used to compare strings containing embedded nulls; use RWBasicUString::compareCodeUnits() in that case.

bool operator== ( const RWUChar32 lhs,
const RWUConstSubString rhs 
)
related

Returns true if lhs has the same length and is lexicographically identical to rhs; otherwise, false.

The lhs string must be null-terminated. This method cannot be used to compare strings containing embedded nulls; use RWBasicUString::compareCodePoints() in that case.

bool operator== ( const RWUConstSubString lhs,
const RWUChar32 rhs 
)
related

Returns true if lhs has the same length and is lexicographically identical to rhs; otherwise, false.

The rhs string must be null-terminated. This method cannot be used to compare strings containing embedded nulls; use RWBasicUString::compareCodePoints() in that case.

bool operator== ( const RWBasicUString lhs,
const RWUConstSubString rhs 
)
related

Returns true if lhs has the same length and is lexicographically identical to rhs; otherwise, false.

bool operator== ( const RWUConstSubString lhs,
const RWBasicUString rhs 
)
related

Returns true if lhs has the same length and is lexicographically identical to rhs; otherwise, false.

bool operator> ( const RWUConstSubString lhs,
const RWUConstSubString rhs 
)
related

Returns true if lhs is lexicographically greater than rhs; otherwise, false. If the two strings are identical over the length of the shortest string, then the longer string is considered greater than the shorter string.

bool operator> ( const RWUChar16 lhs,
const RWUConstSubString rhs 
)
related

Returns true if lhs is lexicographically greater than rhs; otherwise, false. If the two strings are identical over the length of the shortest string, then the longer string is considered greater than the shorter string.

The lhs string must be null-terminated. This method cannot be used to compare strings containing embedded nulls; use RWBasicUString::compareCodeUnits() in that case.

bool operator> ( const RWUConstSubString lhs,
const RWUChar16 rhs 
)
related

Returns true if lhs is lexicographically greater than rhs; otherwise, false. If the two strings are identical over the length of the shortest string, then the longer string is considered greater than the shorter string.

The rhs string must be null-terminated. This method cannot be used to compare strings containing embedded nulls; use RWBasicUString::compareCodeUnits() in that case.

bool operator> ( const RWUChar32 lhs,
const RWUConstSubString rhs 
)
related

Returns true if lhs is lexicographically greater than rhs; otherwise, false. If the two strings are identical over the length of the shortest string, then the longer string is considered greater than the shorter string.

The lhs string must be null-terminated. This method cannot be used to compare strings containing embedded nulls; use RWBasicUString::compareCodePoints() in that case.

bool operator> ( const RWUConstSubString lhs,
const RWUChar32 rhs 
)
related

Returns true if lhs is lexicographically greater than rhs; otherwise, false. If the two strings are identical over the length of the shortest string, then the longer string is considered greater than the shorter string.

The rhs string must be null-terminated. This method cannot be used to compare strings containing embedded nulls; use RWBasicUString::compareCodePoints() in that case.

bool operator> ( const RWBasicUString lhs,
const RWUConstSubString rhs 
)
related

Returns true if lhs is lexicographically greater than rhs; otherwise, false. If the two strings are identical over the length of the shortest string, then the longer string is considered greater than the shorter string.

bool operator> ( const RWUConstSubString lhs,
const RWBasicUString rhs 
)
related

Returns true if lhs is lexicographically greater than rhs; otherwise, false. If the two strings are identical over the length of the shortest string, then the longer string is considered greater than the shorter string.

bool operator>= ( const RWUConstSubString lhs,
const RWUConstSubString rhs 
)
related

Returns true if lhs is lexicographically greater than or equal to rhs; otherwise, false. If the two strings are identical over the length of the shortest string, then the longer string is considered greater than the shorter string.

bool operator>= ( const RWUChar16 lhs,
const RWUConstSubString rhs 
)
related

Returns true if lhs is lexicographically greater than or equal to rhs; otherwise, false. If the two strings are identical over the length of the shortest string, then the longer string is considered greater than the shorter string.

The lhs string must be null-terminated. This method cannot be used to compare strings containing embedded nulls; use RWBasicUString::compareCodeUnits() in that case.

bool operator>= ( const RWUConstSubString lhs,
const RWUChar16 rhs 
)
related

Returns true if lhs is lexicographically greater than or equal to rhs; otherwise, false. If the two strings are identical over the length of the shortest string, then the longer string is considered greater than the shorter string.

The rhs string must be null-terminated. This method cannot be used to compare strings containing embedded nulls; use RWBasicUString::compareCodeUnits() in that case.

bool operator>= ( const RWUChar32 lhs,
const RWUConstSubString rhs 
)
related

Returns true if lhs is lexicographically greater than or equal to rhs; otherwise, false. If the two strings are identical over the length of the shortest string, then the longer string is considered greater than the shorter string.

The lhs string must be null-terminated. This method cannot be used to compare strings containing embedded nulls; use RWBasicUString::compareCodePoints() in that case.

bool operator>= ( const RWUConstSubString lhs,
const RWUChar32 rhs 
)
related

Returns true if lhs is lexicographically greater than or equal to rhs; otherwise, false. If the two strings are identical over the length of the shortest string, then the longer string is considered greater than the shorter string.

The rhs string must be null-terminated. This method cannot be used to compare strings containing embedded nulls; use RWBasicUString::compareCodePoints() in that case.

bool operator>= ( const RWBasicUString lhs,
const RWUConstSubString rhs 
)
related

Returns true if lhs is lexicographically greater than or equal to rhs; otherwise, false. If the two strings are identical over the length of the shortest string, then the longer string is considered greater than the shorter string.

bool operator>= ( const RWUConstSubString lhs,
const RWBasicUString rhs 
)
related

Returns true if lhs is lexicographically greater than or equal to rhs; otherwise, false. If the two strings are identical over the length of the shortest string, then the longer string is considered greater than the shorter string.

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