SourcePro® API Reference Guide

Product Documentation:
   SourcePro
Documentation Home
List of all members | Public Member Functions
RWUStringIterator::RWUChar32Reference Class Reference

Provides transparent read-write access to a code point referenced by an RWUStringIterator. More...

#include <rw/i18n/RWUStringIterator.h>

Public Member Functions

 RWUChar32Reference (const RWUChar32Reference &)
 
 operator RWUChar32 () const
 
RWUChar32Referenceoperator= (RWUChar32 codePoint)
 
RWUChar32Referenceoperator= (RWUChar16 codeUnit)
 

Detailed Description

RWUStringIterator::RWUChar32Reference provides transparent read-write access to a code point referenced by an RWUStringIterator. The code points are made available for read access as RWUChar32 values via the RWUChar32Reference::operator RWUChar32() const conversion.

The code points are made available for write access using two assignment operators. One assignment operator accepts an RWUChar16 value while the other accepts an RWUChar32 value. Both assignment operators properly update the state of both the referenced RWUString and the iterator from which the reference was created. Specifically, the assignment operators ensure that if an assignment is made that changes the length of the referenced RWUString, the RWUString will be updated, and the RWUStringIterator will be updated so as not to be invalidated by the operation. Note, however, that such an assignment may invalidate other iterators, if it changes the number of code units in the string.

RWUStringIterator::RWUChar32Reference objects are obtained from the non-const dereference operator on RWUStringIterator, and are typically used anonymously. For example:

RWUChar16 buf[16] = { 0x0048, 0x0065, 0x006c, 0x006c, 0x006f,
0x002c, 0x000d, 0x0020, 0x0077, 0x006f,
0x0072, 0x006c, 0x0064, 0x002e, 0x000d,
x0000 };
RWUString str(buf);
// Replace all carriage return characters with NULL characters
for (; it != str.endCodePointIterator(); ++it) {
if (*it == RWUChar32(0x000d)) *it = RWUChar32(0x0000);
}

Constructor & Destructor Documentation

RWUStringIterator::RWUChar32Reference::RWUChar32Reference ( const RWUChar32Reference ref)
inline

Constructs an RWUChar32Reference referring to the same code unit as source.

Member Function Documentation

RWUStringIterator::RWUChar32Reference::operator RWUChar32 ( ) const

Returns the value of the code point referenced by self.

Exceptions
RWBoundsErrThrown if the iterator associated with self is invalid.
RWConversionErrThrown if the iterator associated with self points to a code unit sequence that contains an incomplete surrogate pair where either the high surrogate or the low surrogate code unit is missing.
RWUChar32Reference& RWUStringIterator::RWUChar32Reference::operator= ( RWUChar32  codePoint)

Replaces the code point referenced by self with the value given for codePoint and returns a reference to self.

If the operation changes the length of the original RWUString, then both the RWUString and the RWUStringIterator are updated to reflect the change. The iterator is not invalidated. Note, however, that such an assignment may invalidate other iterators, if it changes the number of code units in the string.

Exceptions
RWBoundsErrThrown if the iterator associated with self is invalid.
RWConversionErrThrown if the iterator associated with self points to a code unit sequence that contains an incomplete surrogate pair where either the high surrogate or the low surrogate code unit is missing.
RWUStringIterator::RWUChar32Reference & RWUStringIterator::RWUChar32Reference::operator= ( RWUChar16  codeUnit)
inline

Replaces the code point referenced by self with the value given for codeUnit and returns a reference to self.

If the operation changes the length of the original RWUString, then both the RWBasicUString and the RWUStringIterator are updated to reflect the change. The iterator is not invalidated. Note, however, that such an assignment may invalidate other iterators, if it changes the number of code units in the string.

Exceptions
RWBoundsErrThrown if the iterator associated with self is invalid.
RWConversionErrThrown if the iterator associated with self points to a code unit sequence that contains an incomplete surrogate pair where either the high surrogate or the low surrogate code unit is missing.

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