00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 #ifndef _CEGUIIteratorBase_h_
00030 #define _CEGUIIteratorBase_h_
00031
00032 #include "CEGUIBase.h"
00033
00034
00035
00036 namespace CEGUI
00037 {
00042 template<class T>
00043 class ConstBaseIterator
00044 {
00045 public:
00046 #if defined(_MSC_VER) && (_MSC_VER <= 1200) && !defined(_STLPORT_VERSION)
00047 typedef typename T::referent_type mapped_type;
00048 #else
00049 typedef typename T::mapped_type mapped_type;
00050 #endif
00051
00062 ConstBaseIterator(typename T::const_iterator start_iter, typename T::const_iterator end_iter) :
00063 d_currIter(start_iter),
00064 d_startIter(start_iter),
00065 d_endIter(end_iter)
00066 {
00067 }
00068
00069
00074 ~ConstBaseIterator(void)
00075 {
00076 }
00077
00078
00083 ConstBaseIterator(const ConstBaseIterator<T>& org) :
00084 d_currIter(org.d_currIter),
00085 d_startIter(org.d_startIter),
00086 d_endIter(org.d_endIter)
00087 {
00088 }
00089
00090
00095 ConstBaseIterator<T>& operator=(const ConstBaseIterator<T>& rhs)
00096 {
00097 d_currIter = rhs.d_currIter;
00098 d_startIter = rhs.d_startIter;
00099 d_endIter = rhs.d_endIter;
00100
00101 return *this;
00102 }
00103
00104
00109 typename T::key_type getCurrentKey(void) const
00110 {
00111 return d_currIter->first;
00112 }
00113
00114
00119 mapped_type getCurrentValue(void) const
00120 {
00121 return d_currIter->second;
00122 }
00123
00124
00129 bool isAtEnd(void) const
00130 {
00131 return d_currIter == d_endIter;
00132 }
00133
00134
00139 bool isAtStart(void) const
00140 {
00141 return d_currIter == d_startIter;
00142 }
00143
00144
00152 ConstBaseIterator<T>& operator++()
00153 {
00154 if (d_currIter != d_endIter)
00155 ++d_currIter;
00156
00157 return *this;
00158 }
00159
00160
00168 ConstBaseIterator<T> operator++(int)
00169 {
00170 ConstBaseIterator<T> tmp = *this;
00171 ++*this;
00172
00173 return tmp;
00174 }
00175
00176
00184 ConstBaseIterator<T>& operator--()
00185 {
00186 if (d_currIter != d_startIter)
00187 --d_currIter;
00188
00189 return *this;
00190 }
00191
00192
00200 ConstBaseIterator<T> operator--(int)
00201 {
00202 ConstBaseIterator<T> tmp = *this;
00203 --*this;
00204
00205 return tmp;
00206 }
00207
00208
00213 bool operator==(const ConstBaseIterator<T>& rhs) const
00214 {
00215 return d_currIter == rhs.d_currIter;
00216 }
00217
00218
00223 bool operator!=(const ConstBaseIterator<T>& rhs) const
00224 {
00225 return !this == rhs;
00226 }
00227
00228
00233 mapped_type operator*() const
00234 {
00235 return d_currIter->second;
00236 }
00237
00238
00243 void toStart(void)
00244 {
00245 d_currIter = d_startIter;
00246 }
00247
00248
00253 void toEnd(void)
00254 {
00255 d_currIter = d_endIter;
00256 }
00257
00258
00259 private:
00260
00261
00262
00263 ConstBaseIterator(void) {}
00264
00265
00266
00267
00268 typename T::const_iterator d_currIter;
00269 typename T::const_iterator d_startIter;
00270 typename T::const_iterator d_endIter;
00271 };
00272
00273 }
00274
00275
00276 #endif // end of guard _CEGUIIteratorBase_h_