rwlogo
SourcePro C++ 12.0

SourcePro® C++ API Reference Guide



   SourcePro C++
Documentation Home

RWUStringIterator::RWUChar32Reference Class Reference
[Unicode String Processing]

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

#include <rw/i18n/RWUStringIterator.h>

List of all members.

Public Member Functions

 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() 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);
   }

Member Function Documentation

RWUStringIterator::RWUChar32Reference::operator RWUChar32 (  )  const

Returns the value of the code point referenced by self.

Exceptions:
RWBoundsErr Thrown if the iterator associated with self is invalid.
RWConversionErr Thrown 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:
RWBoundsErr Thrown if the iterator associated with self is invalid.
RWConversionErr Thrown 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:
RWBoundsErr Thrown if the iterator associated with self is invalid.
RWConversionErr Thrown 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.
 All Classes Functions Variables Typedefs Enumerations Enumerator Friends

© Copyright Rogue Wave Software, Inc. All Rights Reserved.
Rogue Wave and SourcePro are registered trademarks of Rogue Wave Software, Inc. in the United States and other countries. All other trademarks are the property of their respective owners.
Contact Rogue Wave about documentation or support issues.