Rogue Wave banner
Previous fileTop of DocumentContentsIndex pageNext file
Internationalization Module Reference Guide
Rogue Wave web site:  Home Page  |  Main Documentation Page

RWUStringIterator

Module:  Internationalization Module   Group:  Unicode String Processing


Does Not Inherit

Local Index

Members

Non-Members

Header File

#include <rw/i18n/RWUStringIterator.h> 

Description

RWUStringIterator provides read-write access to the code points encoded by the code units within an RWUString. Code points within a given string are accessed in forward or reverse order, starting from the beginning or end of the string, respectively.

Attempting to dereference or advance an iterator that is positioned past the end of the string, such as the iterator returned by RWUString::endCodePointIterator(), throws RWBoundsErr.

The code points in an RWBasicUString can be changed using an RWUStringIterator. For example, consider an RWUStringIterator iter, and a code point stored in an RWUChar32 named codePoint. This statement changes the code point referenced by iter to the value in codePoint:

Note that this operation may change the length of the original string if a surrogate pair (two 16-bit code units) is replaced with a single 16-bit code point, or vice-versa.

Bounds Checking

Bounds checking always occurs when repositioning or dereferencing an iterator. Any attempt to dereference an iterator that is in the past-the-end condition throws RWBoundsErr.

Conversion Errors

An RWUStringIterator converts code units into code points. Code points with scalar values greater than 0xFFFF are encoded as a pair of surrogate code units within the string. An RWUStringIterator cannot advance over or dereference an incomplete surrogate pair. RWUStringIterator throws RWConversionErr if an incomplete surrogate pair is encountered.

Example

Related Classes

RWBasicUString, RWUString, RWUConstStringIterator

Public Typedefs

typedef int difference_type;
typedef RW_SL_STD(bidirectional_iterator_tag) 
   iterator_category;
typedef value_type* pointer;
typedef value_type& reference;
typedef size_t size_type;
typedef RWUChar32 value_type;

Global Operators

bool
operator==(const RWUStringIterator& lhs,
           const RWUStringIterator& rhs);
bool
operator==(const RWUStringIterator& lhs,
           const RWUConstStringIterator& rhs);
bool
operator!=(const RWUStringIterator& lhs,
           const RWUStringIterator& rhs);
bool
operator!=(const RWUStringIterator& lhs,
           const RWUConstStringIterator& rhs);

Public Constructor

RWUStringIterator();
RWUStringIterator(RWBasicUString& ustr);
RWUStringIterator(const RWUStringIterator& iter);

Public Member Operators

RWUStringIterator&
operator=(const RWUStringIterator& iter);
RWUStringIterator&
operator++();
RWUStringIterator
operator++(int);
RWUStringIterator&
operator--();
RWUStringIterator
operator--(int);
RWUChar32
operator*() const;
RWUChar32Reference
operator*();
operator size_t() const;

Returns the current code unit offset of self.

Public Member Functions

void
advanceCodePoints(int offset);
const RWUChar16*
data() const;

Class RWUChar32Reference

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 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:

Public Member Operators

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


Previous fileTop of DocumentContentsIndex pageNext file

© 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.