+ typedef wxUniChar const_reference;
+
+ #define WX_STR_ITERATOR_IMPL(iterator_name, pointer_type, \
+ reference_type, reference_ctor) \
+ public: \
+ typedef wxUniChar value_type; \
+ typedef reference_type reference; \
+ typedef pointer_type pointer; \
+ \
+ iterator_name(const iterator_name& i) : m_cur(i.m_cur) {} \
+ \
+ reference operator*() const { return reference_ctor; } \
+ \
+ iterator_name& operator++() \
+ { ++m_cur; return *this; } \
+ iterator_name operator++(int) \
+ { iterator_name tmp = *this; ++m_cur; return tmp; } \
+ iterator_name& operator--() \
+ { --m_cur; return *this; } \
+ iterator_name operator--(int) \
+ { iterator_name tmp = *this; --m_cur; return tmp; } \
+ \
+ iterator_name operator+(int n) const \
+ { return iterator_name(m_cur + n); } \
+ iterator_name operator+(size_t n) const \
+ { return iterator_name(m_cur + n); } \
+ iterator_name operator-(int n) const \
+ { return iterator_name(m_cur - n); } \
+ iterator_name operator-(size_t n) const \
+ { return iterator_name(m_cur - n); } \
+ iterator_name operator+=(int n) \
+ { m_cur += n; return *this; } \
+ iterator_name operator+=(size_t n) \
+ { m_cur += n; return *this; } \
+ iterator_name operator-=(int n) \
+ { m_cur -= n; return *this; } \
+ iterator_name operator-=(size_t n) \
+ { m_cur -= n; return *this; } \
+ \
+ unsigned operator-(const iterator_name& i) const \
+ { return m_cur - i.m_cur; } \
+ \
+ bool operator==(const iterator_name&i) const \
+ { return m_cur == i.m_cur; } \
+ bool operator!=(const iterator_name& i) const \
+ { return m_cur != i.m_cur; } \
+ \
+ bool operator<(const iterator_name& i) const \
+ { return m_cur < i.m_cur; } \
+ bool operator>(const iterator_name& i) const \
+ { return m_cur > i.m_cur; } \
+ bool operator<=(const iterator_name& i) const \
+ { return m_cur <= i.m_cur; } \
+ bool operator>=(const iterator_name& i) const \
+ { return m_cur >= i.m_cur; } \
+ \
+ protected: \
+ /* for internal wxString use only: */ \
+ iterator_name(pointer ptr) : m_cur(ptr) {} \
+ operator pointer() const { return m_cur; } \
+ \
+ friend class WXDLLIMPEXP_BASE wxString; \
+ friend class WXDLLIMPEXP_BASE wxStringBase; \
+ friend class WXDLLIMPEXP_BASE wxCStrData; \
+ \
+ protected: \
+ pointer m_cur;
+
+ class const_iterator;
+
+ class iterator
+ {
+ WX_STR_ITERATOR_IMPL(iterator, wxChar*, wxUniCharRef,
+ wxUniCharRef::CreateForString(m_cur))
+
+ friend class const_iterator;
+ };
+
+ class const_iterator
+ {
+ // NB: reference_type is intentionally value, not reference, the character
+ // may be encoded differently in wxString data:
+ WX_STR_ITERATOR_IMPL(const_iterator, const wxChar*, wxUniChar,
+ wxUniChar(*m_cur))
+
+ public:
+ const_iterator(const iterator& i) : m_cur(i.m_cur) {}
+ };
+
+ #undef WX_STR_ITERATOR
+
+ template <typename T>
+ class reverse_iterator_impl
+ {
+ public:
+ typedef T iterator_type;
+ typedef typename T::value_type value_type;
+ typedef typename T::reference reference;
+ typedef typename T::pointer *pointer;
+
+ reverse_iterator_impl(iterator_type i) : m_cur(i) {}
+ reverse_iterator_impl(const reverse_iterator_impl& ri)
+ : m_cur(ri.m_cur) {}
+
+ iterator_type base() const { return m_cur; }
+
+ reference operator*() const { return *(m_cur-1); }
+
+ reverse_iterator_impl& operator++()
+ { --m_cur; return *this; }
+ reverse_iterator_impl operator++(int)
+ { reverse_iterator_impl tmp = *this; --m_cur; return tmp; }
+ reverse_iterator_impl& operator--()
+ { ++m_cur; return *this; }
+ reverse_iterator_impl operator--(int)
+ { reverse_iterator_impl tmp = *this; ++m_cur; return tmp; }
+
+ bool operator==(const reverse_iterator_impl& ri) const
+ { return m_cur == ri.m_cur; }
+ bool operator!=(const reverse_iterator_impl& ri) const
+ { return !(*this == ri); }
+
+ private:
+ iterator_type m_cur;
+ };
+
+ typedef reverse_iterator_impl<iterator> reverse_iterator;
+ typedef reverse_iterator_impl<const_iterator> const_reverse_iterator;
+