Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   File Members  

otk::ustring_Iterator< T > Class Template Reference

#include <ustring.hh>

Collaboration diagram for otk::ustring_Iterator< T >:

Collaboration graph
[legend]
List of all members.

Detailed Description

template<class T>
class otk::ustring_Iterator< T >

The iterator type for ustring.

Note this is not a random access iterator but a bidirectional one, since all index operations need to iterate over the UTF-8 data. Use std::advance() to move to a certain position.

A writeable iterator isn't provided because: The number of bytes of the old UTF-8 character and the new one to write could be different. Therefore, any write operation would invalidate all other iterators pointing into the same string.

Definition at line 52 of file ustring.hh.

Public Types

typedef std::bidirectional_iterator_tag iterator_category
typedef unichar value_type
typedef std::string::difference_type difference_type
typedef void pointer

Public Methods

 ustring_Iterator ()
 ustring_Iterator (const ustring_Iterator< std::string::iterator > &other)
value_type operator * () const
ustring_Iterator< T > & operator++ ()
ustring_Iterator< T > & operator-- ()
 ustring_Iterator (T pos)
base () const

Private Attributes

_pos


Member Typedef Documentation

template<class T>
typedef std::string::difference_type otk::ustring_Iterator< T >::difference_type
 

Definition at line 57 of file ustring.hh.

template<class T>
typedef std::bidirectional_iterator_tag otk::ustring_Iterator< T >::iterator_category
 

Definition at line 55 of file ustring.hh.

template<class T>
typedef void otk::ustring_Iterator< T >::pointer
 

Definition at line 59 of file ustring.hh.

template<class T>
typedef unichar otk::ustring_Iterator< T >::value_type
 

Definition at line 56 of file ustring.hh.


Constructor & Destructor Documentation

template<class T>
otk::ustring_Iterator< T >::ustring_Iterator   [inline]
 

Definition at line 61 of file ustring.hh.

00061 {}

template<class T>
otk::ustring_Iterator< T >::ustring_Iterator const ustring_Iterator< std::string::iterator > &    other [inline]
 

Definition at line 62 of file ustring.hh.

References otk::ustring_Iterator< T >::_pos, and otk::ustring_Iterator< T >::base().

00063                : _pos(other.base()) {}

template<class T>
otk::ustring_Iterator< T >::ustring_Iterator   pos [inline, explicit]
 

Definition at line 82 of file ustring.hh.

References otk::ustring_Iterator< T >::_pos.

00082 : _pos(pos) {}


Member Function Documentation

template<class T>
T otk::ustring_Iterator< T >::base   const [inline]
 

Definition at line 83 of file ustring.hh.

References otk::ustring_Iterator< T >::_pos.

Referenced by otk::ustring_Iterator< T >::ustring_Iterator().

00083 { return _pos; }

template<class T>
value_type otk::ustring_Iterator< T >::operator *   const [inline]
 

Definition at line 66 of file ustring.hh.

References otk::ustring_Iterator< T >::_pos, and otk::utf8_get_char().

00066                                       {
00067     // get an iterator to the internal string
00068     std::string::const_iterator pos = _pos;
00069     return utf8_get_char(&(*pos));
00070   }

template<class T>
ustring_Iterator<T>& otk::ustring_Iterator< T >::operator++   [inline]
 

Definition at line 73 of file ustring.hh.

00073                                                 {
00074     pos_ += g_utf8_skip[static_cast<unsigned char>(*pos_)];
00075     return *this;
00076   }

template<class T>
ustring_Iterator<T>& otk::ustring_Iterator< T >::operator--   [inline]
 

Definition at line 77 of file ustring.hh.

References otk::ustring_Iterator< T >::_pos.

00077                                                 {
00078     do { --_pos; } while((*_pos & '\xC0') == '\x80');
00079     return *this;
00080   }


Member Data Documentation

template<class T>
T otk::ustring_Iterator< T >::_pos [private]
 

Definition at line 86 of file ustring.hh.

Referenced by otk::ustring_Iterator< T >::base(), otk::ustring_Iterator< T >::operator *(), otk::ustring_Iterator< T >::operator--(), and otk::ustring_Iterator< T >::ustring_Iterator().


The documentation for this class was generated from the following file:
Generated on Tue Feb 4 23:00:30 2003 for Openbox by doxygen1.3-rc2