Cross-Platform C++

ot
class StringIterator

#include "ot/base/StringIterator.h"

Iterator class that will iterate over each Unicode character contained within a controlled sequence of CharType characters encoded according to the internal OpenTop encoding. For convenience, de-referencing a StringIterator results in a Character object, from which the Unicode character can be directly obtained.

This class implements the required interface for a bidirectional iterator as defined by the C++ Standard Library.

This class enables algorithms from the C++ Standard Library to be used on Unicode strings that have been encoded into the internal OpenTop String encoding.




Constructor/Destructor Summary
StringIterator()
         Default constructor.
StringIterator(const CharType* ptr)
         Creates a StringIterator positioned at the first character of the sequence of CharType characters starting at ptr.

Method Summary
 const CharType* data() const
         Returns a pointer to the current position within the CharType sequence.
 StringIterator& operator--()
         Prefix decrement operator.
 StringIterator operator--(int )
         Postfix decrement operator.
 Character operator *() const
         Dereference operator.
 bool operator!=(const StringIterator& rhs) const
         Inequality operator.
 StringIterator& operator++()
         Prefix increment operator.
 StringIterator operator++(int )
         Postfix increment operator.
 StringIterator& operator=(const CharType* ptr)
         Assignment operator.
 bool operator==(const StringIterator& rhs) const
         Equality operator.

Typedefs

difference_type

typedef ptrdiff_t difference_type


iterator_category

typedef std::bidirectional_iterator_tag iterator_category


pointer

typedef CharType* pointer


reference

typedef Character& reference


value_type

typedef Character value_type

Constructor/Destructor Detail

StringIterator

 StringIterator()
Default constructor.


StringIterator

 StringIterator(const CharType* ptr)
Creates a StringIterator positioned at the first character of the sequence of CharType characters starting at ptr.


Method Detail

data

const CharTypedata() const
Returns a pointer to the current position within the CharType sequence.

Returns:
a pointer to the current data position of this iterator.

operator--

StringIterator& operator--()
Prefix decrement operator. Positions the iterator at the previous Unicode character in the sequence and returns a reference to self.


operator--

StringIterator operator--(int )
Postfix decrement operator. Positions the iterator at the previous Unicode character in the sequence and returns a copy of self positioned at the original location.


operator *

Character operator *() const
Dereference operator.

Returns:
the Unicode character represented by the CharType sequence starting at the current location of the iterator.

operator!=

bool operator!=(const StringIterator& rhs) const
Inequality operator.

Returns:
false if this StringIterator is pointing at the same location as rhs; true otherwise.

operator++

StringIterator& operator++()
Prefix increment operator. Positions the iterator at the next Unicode character in the sequence and returns a reference to self.


operator++

StringIterator operator++(int )
Postfix increment operator. Positions the iterator at the next Unicode character in the sequence and returns a copy of self positioned at the original location.


operator=

StringIterator& operator=(const CharType* ptr)
Assignment operator. Sets the position of this StringIterator to be the first character of the sequence of CharType characters starting at ptr.


operator==

bool operator==(const StringIterator& rhs) const
Equality operator.

Returns:
true if this StringIterator is pointing at the same location as rhs; false otherwise.


Cross-Platform C++

Found a bug or missing feature? Please email us at support@elcel.com

Copyright © 2000-2003 ElCel Technology   Trademark Acknowledgements