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
00030
00031
00032
00033 #ifndef _CEGUIIteratorBase_h_
00034 #define _CEGUIIteratorBase_h_
00035
00036 #include "CEGUIBase.h"
00037
00038
00039
00040 namespace CEGUI
00041 {
00046 template<class T>
00047 class ConstBaseIterator
00048 {
00049 public:
00050 #if defined(_MSC_VER) && (_MSC_VER <= 1200) && !defined(_STLPORT_VERSION)
00051 typedef typename T::referent_type mapped_type;
00052 #else
00053 typedef typename T::mapped_type mapped_type;
00054 #endif
00055
00066 ConstBaseIterator(typename T::const_iterator start_iter, typename T::const_iterator end_iter) :
00067 d_currIter(start_iter),
00068 d_startIter(start_iter),
00069 d_endIter(end_iter)
00070 {
00071 }
00072
00073
00078 ~ConstBaseIterator(void)
00079 {
00080 }
00081
00082
00087 ConstBaseIterator(const ConstBaseIterator<T>& org) :
00088 d_currIter(org.d_currIter),
00089 d_startIter(org.d_startIter),
00090 d_endIter(org.d_endIter)
00091 {
00092 }
00093
00094
00099 ConstBaseIterator<T>& operator=(const ConstBaseIterator<T>& rhs)
00100 {
00101 d_currIter = rhs.d_currIter;
00102 d_startIter = rhs.d_startIter;
00103 d_endIter = rhs.d_endIter;
00104
00105 return *this;
00106 }
00107
00108
00113 typename T::key_type getCurrentKey(void) const
00114 {
00115 return d_currIter->first;
00116 }
00117
00118
00123 mapped_type getCurrentValue(void) const
00124 {
00125 return d_currIter->second;
00126 }
00127
00128
00133 bool isAtEnd(void) const
00134 {
00135 return d_currIter == d_endIter;
00136 }
00137
00138
00143 bool isAtStart(void) const
00144 {
00145 return d_currIter == d_startIter;
00146 }
00147
00148
00156 ConstBaseIterator<T>& operator++()
00157 {
00158 if (d_currIter != d_endIter)
00159 ++d_currIter;
00160
00161 return *this;
00162 }
00163
00164
00172 ConstBaseIterator<T> operator++(int)
00173 {
00174 ConstBaseIterator<T> tmp = *this;
00175 ++*this;
00176
00177 return tmp;
00178 }
00179
00180
00188 ConstBaseIterator<T>& operator--()
00189 {
00190 if (d_currIter != d_startIter)
00191 --d_currIter;
00192
00193 return *this;
00194 }
00195
00196
00204 ConstBaseIterator<T> operator--(int)
00205 {
00206 ConstBaseIterator<T> tmp = *this;
00207 --*this;
00208
00209 return tmp;
00210 }
00211
00212
00217 bool operator==(const ConstBaseIterator<T>& rhs) const
00218 {
00219 return d_currIter == rhs.d_currIter;
00220 }
00221
00222
00227 bool operator!=(const ConstBaseIterator<T>& rhs) const
00228 {
00229 return !this == rhs;
00230 }
00231
00232
00237 mapped_type operator*() const
00238 {
00239 return d_currIter->second;
00240 }
00241
00242
00247 void toStart(void)
00248 {
00249 d_currIter = d_startIter;
00250 }
00251
00252
00257 void toEnd(void)
00258 {
00259 d_currIter = d_endIter;
00260 }
00261
00262
00263 private:
00264
00265
00266
00267 ConstBaseIterator(void) {}
00268
00269
00270
00271
00272 typename T::const_iterator d_currIter;
00273 typename T::const_iterator d_startIter;
00274 typename T::const_iterator d_endIter;
00275 };
00276
00277 }
00278
00279
00280 #endif // end of guard _CEGUIIteratorBase_h_