/usr/include/cegui-0.8.4/CEGUI/IteratorBase.h is in libcegui-mk2-dev 0.8.4+dfsg-4ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 | /***********************************************************************
created: 26/7/2004
author: Paul D Turner
purpose: Defines interface for base iterator class
*************************************************************************/
/***************************************************************************
* Copyright (C) 2004 - 2006 Paul D Turner & The CEGUI Development Team
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
***************************************************************************/
/*************************************************************************
This is based somewhat on MapIterator in the Ogre library (www.ogre3d.org)
*************************************************************************/
#ifndef _CEGUIIteratorBase_h_
#define _CEGUIIteratorBase_h_
#include "CEGUI/Base.h"
// Start of CEGUI namespace section
namespace CEGUI
{
/*!
\brief
Base class constant iterator used to offer iteration over various collections within the system.
*/
template<typename T, typename V = typename T::value_type>
class ConstBaseIterator
{
public:
typedef V value_type;
/*!
\brief
ConstBaseIterator constructor
\param start_iter
'real' iterator that will be the start of the range to be iterated over by this iterator.
\param end_iter
'real' iterator that will be the end of the range to be iterated over by this iterator.
*/
ConstBaseIterator(typename T::const_iterator start_iter, typename T::const_iterator end_iter) :
d_currIter(start_iter),
d_startIter(start_iter),
d_endIter(end_iter)
{
}
/*!
\brief
ConstBaseIterator destructor
*/
virtual ~ConstBaseIterator(void)
{
}
/*!
\brief
ConstBaseIterator copy constructor
*/
ConstBaseIterator(const ConstBaseIterator<T, V>& org) :
d_currIter(org.d_currIter),
d_startIter(org.d_startIter),
d_endIter(org.d_endIter)
{
}
/*!
\brief
ConstBaseIterator assignment operator
*/
ConstBaseIterator<T, V>& operator=(const ConstBaseIterator<T, V>& rhs)
{
d_currIter = rhs.d_currIter;
d_startIter = rhs.d_startIter;
d_endIter = rhs.d_endIter;
return *this;
}
/*!
\brief
Return the value for the item at the current iterator position.
*/
virtual value_type getCurrentValue(void) const = 0;
/*!
\brief
Return whether the current iterator position is at the end of the iterators range.
*/
bool isAtEnd(void) const
{
return d_currIter == d_endIter;
}
/*!
\brief
Return whether the current iterator position is at the start of the iterators range.
*/
bool isAtStart(void) const
{
return d_currIter == d_startIter;
}
/*!
\brief
Compares two iterators. Return true if the current position of both iterators are equivalent.
*/
bool operator==(const ConstBaseIterator<T, V>& rhs) const
{
return d_currIter == rhs.d_currIter;
}
/*!
\brief
Compares two iterators. Return true if the current position of the iterators are different.
*/
bool operator!=(const ConstBaseIterator<T, V>& rhs) const
{
return !operator==(rhs);
}
/*!
\brief
Return the value for the current iterator position.
*/
value_type operator*() const
{
return getCurrentValue();
}
/*!
\brief
Set the iterator current position to the start position.
*/
void toStart(void)
{
d_currIter = d_startIter;
}
/*!
\brief
Set the iterator current position to the end position.
*/
void toEnd(void)
{
d_currIter = d_endIter;
}
protected:
/*************************************************************************
No default construction available
*************************************************************************/
ConstBaseIterator(void) {}
/*************************************************************************
Implementation Data
*************************************************************************/
typename T::const_iterator d_currIter; //!< 'real' iterator describing the current position within the collection.
typename T::const_iterator d_startIter; //!< 'real' iterator describing the start position within the collection (or what we were told was the start).
typename T::const_iterator d_endIter; //!< 'real' iterator describing the end position within the collection (or what we were told was the end).
};
//! iterator class for maps
template<class T>
class ConstMapIterator : public ConstBaseIterator<T, typename T::mapped_type>
{
public:
ConstMapIterator(typename T::const_iterator start_iter, typename T::const_iterator end_iter) :
ConstBaseIterator<T, typename T::mapped_type>(start_iter, end_iter)
{}
typename ConstBaseIterator<T, typename T::mapped_type>::value_type
getCurrentValue() const
{
return this->d_currIter->second;
}
/*!
\brief
Return the key for the item at the current iterator position.
*/
typename T::key_type getCurrentKey() const
{
return this->d_currIter->first;
}
/*!
\brief
Increase the iterator position (prefix increment).
\note
The iterator is checked, and this call will always succeed, so do not rely on some exception to exit a loop.
*/
ConstMapIterator<T>& operator++()
{
if (ConstBaseIterator<T, typename T::mapped_type>::d_currIter != ConstBaseIterator<T, typename T::mapped_type>::d_endIter)
++ConstBaseIterator<T, typename T::mapped_type>::d_currIter;
return *this;
}
/*!
\brief
Decrease the iterator position (prefix decrement).
\note
The iterator is checked, and this call will always succeed, so do not rely on some exception to exit a loop.
*/
ConstMapIterator<T>& operator--()
{
if (ConstBaseIterator<T, typename T::mapped_type>::d_currIter != ConstBaseIterator<T, typename T::mapped_type>::d_startIter)
--ConstBaseIterator<T, typename T::mapped_type>::d_currIter;
return *this;
}
/*!
\brief
Increase the iterator position (postfix increment).
\note
The iterator is checked, and this call will always succeed, so do not rely on some exception to exit a loop.
*/
ConstMapIterator<T> operator++(int)
{
ConstMapIterator<T> tmp = *this;
++*this;
return tmp;
}
/*!
\brief
Decrease the iterator position (postfix decrement).
\note
The iterator is checked, and this call will always succeed, so do not rely on some exception to exit a loop.
*/
ConstMapIterator<T> operator--(int)
{
ConstMapIterator<T> tmp = *this;
--*this;
return tmp;
}
protected:
/*************************************************************************
No default construction available
*************************************************************************/
ConstMapIterator(void) {}
};
//! iterator for vectors
template<class T>
class ConstVectorIterator : public ConstBaseIterator<T>
{
public:
ConstVectorIterator(typename T::const_iterator start_iter, typename T::const_iterator end_iter) :
ConstBaseIterator<T>(start_iter, end_iter)
{}
typename ConstBaseIterator<T>::value_type
getCurrentValue() const
{
return *this->d_currIter;
}
/*!
\brief
Increase the iterator position (prefix increment).
\note
The iterator is checked, and this call will always succeed, so do not rely on some exception to exit a loop.
*/
ConstVectorIterator<T>& operator++()
{
if (ConstBaseIterator<T, typename T::value_type>::d_currIter != ConstBaseIterator<T, typename T::value_type>::d_endIter)
++ConstBaseIterator<T, typename T::value_type>::d_currIter;
return *this;
}
/*!
\brief
Decrease the iterator position (prefix decrement).
\note
The iterator is checked, and this call will always succeed, so do not rely on some exception to exit a loop.
*/
ConstVectorIterator<T>& operator--()
{
if (ConstBaseIterator<T, typename T::value_type>::d_currIter != ConstBaseIterator<T, typename T::value_type>::d_startIter)
--ConstBaseIterator<T, typename T::value_type>::d_currIter;
return *this;
}
/*!
\brief
Increase the iterator position (postfix increment).
\note
The iterator is checked, and this call will always succeed, so do not rely on some exception to exit a loop.
*/
ConstVectorIterator<T> operator++(int)
{
ConstVectorIterator<T> tmp = *this;
++*this;
return tmp;
}
/*!
\brief
Decrease the iterator position (postfix decrement).
\note
The iterator is checked, and this call will always succeed, so do not rely on some exception to exit a loop.
*/
ConstVectorIterator<T> operator--(int)
{
ConstVectorIterator<T> tmp = *this;
--*this;
return tmp;
}
protected:
/*************************************************************************
No default construction available
*************************************************************************/
ConstVectorIterator(void) {}
};
} // End of CEGUI namespace section
#endif // end of guard _CEGUIIteratorBase_h_
|