c++-gtk-utils
|
A class which will iterate in reverse through a std::string object by reference to unicode characters rather than by bytes. More...
#include <c++-gtk-utils/convert.h>
Public Types | |
typedef gunichar | value_type |
typedef gunichar | reference |
typedef void | pointer |
typedef std::string::difference_type | difference_type |
typedef std::bidirectional_iterator_tag | iterator_category |
Public Member Functions | |
ReverseIterator & | operator++ () |
ReverseIterator | operator++ (int) |
ReverseIterator & | operator-- () |
ReverseIterator | operator-- (int) |
ReverseIterator & | operator= (const std::string::const_reverse_iterator &iter) |
ReverseIterator & | operator= (const std::string::reverse_iterator &iter) |
ReverseIterator & | operator= (const ReverseIterator &iter) |
ReverseIterator & | operator= (const Iterator &iter) |
ReverseIterator::value_type | operator* () const |
std::string::const_iterator | base () const |
ReverseIterator (const std::string::const_reverse_iterator &iter) | |
ReverseIterator (const std::string::reverse_iterator &iter) | |
ReverseIterator (const ReverseIterator &iter) | |
ReverseIterator (const Iterator &iter) | |
ReverseIterator () | |
A class which will iterate in reverse through a std::string object by reference to unicode characters rather than by bytes.
The Cgu::Utf8::ReverseIterator class does the same as std::string::const_reverse_iterator, except that when iterating through a std::string object using the ++ and - - postfix and prefix operators, it iterates by increments of whole unicode code points rather than by reference to bytes. In addition, the dereferencing operator returns the whole unicode code point (a UCS-4 gunichar type) rather than a char type.
Before use, the Cgu::Utf8::ReverseIterator object must be initialized by a std::string::const_reverse_iterator or std::string::reverse_iterator object representing the first byte of a valid UTF-8 character in the string (or by another Cgu::Utf8::ReverseIterator object or by a Cgu::Utf8::Iterator object): so assuming the string contains valid UTF-8 text, it is always valid to initialise a Cgu::Utf8::ReverseIterator with std::string::rbegin(). Initialization by std::string::rend() is also valid if the first interation is backwards with the -- operator. This initialization can be done either in the constructor or by assignment. Comparison operators ==, !=, <, <=, > and >= are provided enabling the position of Cgu::Utf8::ReverseIterator objects to be compared with each other or with std::string::const_reverse_iterator and std::string::reverse_iterator objects.
This is an example:
For further information on its use, see the Utf8::Iterator documentation.
typedef std::string::difference_type Cgu::Utf8::ReverseIterator::difference_type |
typedef std::bidirectional_iterator_tag Cgu::Utf8::ReverseIterator::iterator_category |
typedef void Cgu::Utf8::ReverseIterator::pointer |
typedef gunichar Cgu::Utf8::ReverseIterator::reference |
typedef gunichar Cgu::Utf8::ReverseIterator::value_type |
|
inline |
Constructs this iterator and initialises it with a std::string::const_reverse_iterator object. It should represent the beginning of a UTF-8 character (eg std::string::rbegin()) or comprise std::string::rend(). It will not throw provided that copy constructing a std::string::const_iterator object does not throw, as it will not in any sane implementation. This is a type conversion constructor (it is not marked explicit) so that it can be used with Cgu::Utf8::ReverseIterator comparison operators to compare the position of Cgu::Utf8::ReverseIterator with std::string::const_reverse_iterator objects.
iter | The const_reverse_iterator. |
Since 1.0.1
|
inline |
Constructs this iterator and initialises it with a std::string::reverse_iterator object. It should represent the beginning of a UTF-8 character (eg std::string::rbegin()) or comprise std::string::rend(). It will not throw provided that copy constructing a std::string::const_iterator object does not throw, as it will not in any sane implementation. This is a type conversion constructor (it is not marked explicit) so that it can be used with Cgu::Utf8::ReverseIterator comparison operators to compare the position of Cgu::Utf8::ReverseIterator with std::string::reverse_iterator objects.
iter | The reverse_iterator. |
Since 1.0.1
|
inline |
Constructs this iterator and initialises it with another Cgu::Utf8::ReverseIterator object. It will not throw provided that copy constructing a std::string::const_iterator object does not throw, as it will not in any sane implementation.
iter | The iterator. |
Since 1.0.1
|
inlineexplicit |
Constructs this iterator and initialises it with a Cgu::Utf8::Iterator object, so that this iterator adopts the same physical position (but the logical position will be offset to the previous UTF-8 character in the std::string object concerned). It will not throw provided that copy constructing a std::string::const_iterator object does not throw, as it will not in any sane implementation.
iter | The iterator. |
Since 1.0.1
|
inline |
The default constructor will not throw.
Since 1.0.1
|
inline |
Since 1.0.1
|
inline |
The dereference operator. Note that although this method is const, it is not thread safe for concurrent reads without external synchronization because it writes to an internal cache.
Since 1.0.1
|
inline |
Increments the iterator in the reverse direction so that it moves from the beginning of the current UTF-8 character to the beginning of the previous UTF-8 character in the std::string object concerned. It is a prefix operator. It will not throw provided assigning a std::string::const_iterator object does not throw, as it will not in any sane implementation.
Since 1.0.1
|
inline |
Increments the iterator in the reverse direction so that it moves from the beginning of the current UTF-8 character to the beginning of the previous UTF-8 character in the std::string object concerned. It is a postfix operator. It will not throw provided that copy constructing and assigning a std::string::const_iterator object does not throw, as it will not in any sane implementation.
Since 1.0.1
|
inline |
Decrements the iterator in the reverse direction so that it moves from the beginning of the current UTF-8 character to the beginning of the following UTF-8 character in the std::string object concerned. It is a prefix operator. It will not throw provided assigning a std::string::const_iterator object does not throw, as it will not in any sane implementation.
Since 1.0.1
|
inline |
Decrements the iterator in the reverse direction so that it moves from the beginning of the current UTF-8 character to the beginning of the following UTF-8 character in the std::string object concerned. It is a postfix operator. It will not throw provided that copy constructing and assigning a std::string::const_iterator object does not throw, as it will not in any sane implementation.
Since 1.0.1
|
inline |
Assigns a Cgu::Utf8::Iterator object to this object, so that this iterator adopts the same physical position (but the logical position will be offset to the previous UTF-8 character in the std::string object concerned). It will not throw provided assigning a std::string::const_iterator object does not throw, as it will not in any sane implementation.
iter | The iterator. |
Since 1.0.1
|
inline |
Assigns a Cgu::Utf8::ReverseIterator object to this object. It will not throw provided assigning a std::string::const_iterator object does not throw, as it will not in any sane implementation.
iter | The iterator. |
Since 1.0.1
|
inline |
Assigns a std::string::const_reverse_iterator object to this object. It should represent the beginning of a UTF-8 character (eg std::string::rbegin()) or comprise std::string::rend(). It will not throw provided assigning a std::string::const_iterator object does not throw, as it will not in any sane implementation.
iter | The const_reverse_iterator. |
Since 1.0.1
|
inline |
Assigns a std::string::reverse_iterator object to this object. It should represent the beginning of a UTF-8 character (eg std::string::rbegin()) or comprise std::string::rend(). It will not throw provided assigning a std::string::const_iterator object does not throw, as it will not in any sane implementation.
iter | The reverse_iterator. |
Since 1.0.1