UtfString
Public Member Functions | List of all members
UtfString::Utf8String::iterator Class Reference

An iterator that iterates through the code points in a UTF-8 string. More...

#include <Utf8String.h>

Inherits iterator< std::random_access_iterator_tag, Utf8Char >.

Public Member Functions

 iterator (std::string &basicString, const std::string::iterator &basicStringIterator)
 Constructs an iterator for Utf8String using the base class iterator. More...
 
 iterator (const Utf8String::iterator &otherIterator)
 Constructs an iterator for Utf8String using another iterator. More...
 
 iterator (const Utf8String::reverse_iterator &reverseIterator)
 Constructs an iterator for Utf8String using a reverse iterator. More...
 
 ~iterator ()
 Cleans up before the iterator is destroyed.
 
iteratoroperator= (const Utf8String::iterator &otherIterator)
 Assigns the value of another iterator to this iterator. More...
 
bool operator== (const iterator &otherIterator) const
 Compares this iterator with another iterator and tests for equality. More...
 
bool operator!= (const iterator &otherIterator) const
 Compares this iterator with another iterator and tests for inequality. More...
 
bool operator< (const iterator &otherIterator)
 Compares this iterator to another iterator and tests whether this iterator comes before the other iterator in the string. More...
 
bool operator<= (const iterator &otherIterator)
 Compares this iterator to another iterator and tests whether this iterator comes before or is at the same position the other iterator in the string. More...
 
bool operator> (const iterator &otherIterator)
 Compares this iterator to another iterator and tests whether this iterator comes after the other iterator in the string. More...
 
bool operator>= (const iterator &otherIterator)
 Compares this iterator to another iterator and tests whether this iterator comes after or is at the same position the other iterator in the string. More...
 
iteratoroperator++ ()
 Increments this iterator to the next position in the Utf8String. More...
 
iterator operator++ (int)
 Increments this iterator to the next position in the Utf8String. More...
 
iteratoroperator+= (size_t offset)
 Increments this iterator by a specific offset. More...
 
iterator operator+ (size_t offset)
 Creates an iterator that has the position of this iterator incremented by a specific offset. More...
 
iteratoroperator-- ()
 Decrements this iterator to the previous position in the Utf16String. More...
 
iterator operator-- (int)
 Decrements this iterator to the previous position in the Utf16String. More...
 
iteratoroperator-= (size_t offset)
 Decrements this iterator by a specific offset. More...
 
iterator operator- (size_t offset)
 Creates an iterator that has the position of this iterator decremented by a specific offset. More...
 
Utf8CharReference operator* ()
 Gets the character at the position of this iterator. More...
 
Utf8CharReferenceoperator-> ()
 Gets a pointer to the character at the position of this iterator. More...
 

Detailed Description

An iterator that iterates through the code points in a UTF-8 string.

This iterator assumes that the UTF-8 string being iterated over is a valid UTF-8 string.

Constructor & Destructor Documentation

UtfString::Utf8String::iterator::iterator ( std::string &  basicString,
const std::string::iterator &  basicStringIterator 
)

Constructs an iterator for Utf8String using the base class iterator.

This function assumes that basicStringIterator is a valid iterator

Parameters
[in]basicStringA reference to the string that baseStringIterator points to
[in]basicStringIteratorThe base class iterator to use in constructing this iterator
UtfString::Utf8String::iterator::iterator ( const Utf8String::iterator otherIterator)

Constructs an iterator for Utf8String using another iterator.

This iterator will take on the same characteristics and position as the other iterator

Parameters
[in]otherIteratorThe other iterator to use in constructing this iterator
UtfString::Utf8String::iterator::iterator ( const Utf8String::reverse_iterator reverseIterator)

Constructs an iterator for Utf8String using a reverse iterator.

This iterator will take on the same position as the reverse iterator.

Parameters
[in]reverseIteratorThe reverse iterator to use in constructing this iterator

Member Function Documentation

bool UtfString::Utf8String::iterator::operator!= ( const iterator otherIterator) const

Compares this iterator with another iterator and tests for inequality.

Parameters
[in]otherIteratorThe other iterator to be compared with this iterator
Returns
false if otherIterator is pointing to the same position as this iterator, otherwise true
Utf8CharReference UtfString::Utf8String::iterator::operator* ( )

Gets the character at the position of this iterator.

If this iterator is not pointing to a position in a Utf8String, the result will be undefined.

The reference returned by this function will be invalidated if the iterator is changed in any way. Changing the value of the returned object will not change the string.

Returns
A reference to the the character being pointed to by this iterator
iterator UtfString::Utf8String::iterator::operator+ ( size_t  offset)

Creates an iterator that has the position of this iterator incremented by a specific offset.

Note that since a UTF-16 string contains variable-width characters, we have to iterate over the code units. As a result, this operator has a performance of O(N). Hence, this operator should be used with care.

Parameters
[in]offsetThe offset to be used when incrementing this position of this iterator
Returns
An iterator that points to the offset position
iterator& UtfString::Utf8String::iterator::operator++ ( )

Increments this iterator to the next position in the Utf8String.

This is the prefix operator.

Returns
A reference to this object after the position has been incremented
iterator UtfString::Utf8String::iterator::operator++ ( int  )

Increments this iterator to the next position in the Utf8String.

This is a postfix operator.

Returns
A copy of this object before the position was incremented
iterator& UtfString::Utf8String::iterator::operator+= ( size_t  offset)

Increments this iterator by a specific offset.

Note that since a UTF-8 string contains variable-width characters, we have to iterate over the code units. As a result, this operator has a performance of O(N). Hence, this operator should be used with care.

Parameters
[in]offsetThe offset to use in incrementing this iterator
Returns
A reference to this iterator
iterator UtfString::Utf8String::iterator::operator- ( size_t  offset)

Creates an iterator that has the position of this iterator decremented by a specific offset.

Note that since a UTF-16 string contains variable-width characters, we have to iterate over the code units. As a result, this operator has a performance of O(N). Hence, this operator should be used with care.

Parameters
[in]offsetThe offset to use in decrementing the position of this iterator
Returns
An iterator that points to the offset position
iterator& UtfString::Utf8String::iterator::operator-- ( )

Decrements this iterator to the previous position in the Utf16String.

This is a prefix operator.

Returns
A reference to this object after the position has been decremented
iterator UtfString::Utf8String::iterator::operator-- ( int  )

Decrements this iterator to the previous position in the Utf16String.

This is a postfix operator.

Returns
A copy of this object before the position was decremented
iterator& UtfString::Utf8String::iterator::operator-= ( size_t  offset)

Decrements this iterator by a specific offset.

Note that since a UTF-16 string contains variable-width characters, we have to iterate over the code units. As a result, this operator has a performance of O(N). Hence, this operator should be used with care.

Parameters
[in]offsetThe offset to use in decrementing this iterator
Returns
A reference to this iterator
Utf8CharReference* UtfString::Utf8String::iterator::operator-> ( )

Gets a pointer to the character at the position of this iterator.

If this iterator is not pointing to a position in a Utf16String, the result will be undefined.

The pointer returned by this function will be invalidated if the iterator is changed in any way.

Returns
A pointer to the character being pointed to by this iterator
bool UtfString::Utf8String::iterator::operator< ( const iterator otherIterator)

Compares this iterator to another iterator and tests whether this iterator comes before the other iterator in the string.

This operator has a performance of O(1).

Parameters
[in]otherIteratorThe other iterator to be compared with this iterator
Returns
true if this iterator comes before the other iterator in a string, otherwise false
bool UtfString::Utf8String::iterator::operator<= ( const iterator otherIterator)

Compares this iterator to another iterator and tests whether this iterator comes before or is at the same position the other iterator in the string.

This operator has a performance of O(1).

Parameters
[in]otherIteratorThe other iterator to be compared with this iterator
Returns
true if this iterator comes before or is at the same position the other iterator in a string, otherwise false
iterator& UtfString::Utf8String::iterator::operator= ( const Utf8String::iterator otherIterator)

Assigns the value of another iterator to this iterator.

This iterator will take on the same characteristics and position as the other iterator

Parameters
[in]otherIteratorThe other iterator to be assigned to this iterator
Returns
A reference to this object after the assignment has been completed
bool UtfString::Utf8String::iterator::operator== ( const iterator otherIterator) const

Compares this iterator with another iterator and tests for equality.

Parameters
[in]otherIteratorThe other iterator to be compared with this iterator
Returns
true if otherIterator is pointing to the same position as this iterator, otherwise false
bool UtfString::Utf8String::iterator::operator> ( const iterator otherIterator)

Compares this iterator to another iterator and tests whether this iterator comes after the other iterator in the string.

This operator has a performance of O(1).

Parameters
[in]otherIteratorThe other iterator to be compared with this iterator
Returns
true if this iterator comes after the other iterator in a string, otherwise false
bool UtfString::Utf8String::iterator::operator>= ( const iterator otherIterator)

Compares this iterator to another iterator and tests whether this iterator comes after or is at the same position the other iterator in the string.

This operator has a performance of O(1).

Parameters
[in]otherIteratorThe other iterator to be compared with this iterator
Returns
true if this iterator comes after or is at the same position the other iterator in a string, otherwise false

The documentation for this class was generated from the following file: