SourcePro® API Reference Guide

 
Loading...
Searching...
No Matches
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= (RWUChar16 codeUnit)
 
RWUChar32Referenceoperator= (RWUChar32 codePoint)
 

Friends

class RWUStringIterator
 

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);
RWUStringIterator it = str.beginCodePointIterator();
// Replace all carriage return characters with NULL characters
for (; it != str.endCodePointIterator(); ++it) {
if (*it == RWUChar32(0x000d)) {
*it = RWUChar32(0x0000);
}
}
Bidirectional iterator that provides read-write access to the code points encoded by the code units w...
Definition RWUStringIterator.h:136
Stores and manipulates Unicode character sequences encoded as UTF-16 code units.
Definition RWUString.h:187
unspecified_32bit_type RWUChar32
Definition uchar.h:91
unspecified_16bit_type RWUChar16
Definition uchar.h:66

Constructor & Destructor Documentation

◆ RWUChar32Reference()

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

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

Member Function Documentation

◆ operator RWUChar32()

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.

◆ operator=() [1/2]

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.

◆ operator=() [2/2]

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.

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