OgreIteratorRange.h
Go to the documentation of this file.
1 /*
2 -----------------------------------------------------------------------------
3 This source file is part of OGRE
4 (Object-oriented Graphics Rendering Engine)
5 For the latest info, see http://www.ogre3d.org/
6 
7 Copyright (c) 2000-2013 Torus Knot Software Ltd
8 
9 Permission is hereby granted, free of charge, to any person obtaining a copy
10 of this software and associated documentation files (the "Software"), to deal
11 in the Software without restriction, including without limitation the rights
12 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 copies of the Software, and to permit persons to whom the Software is
14 furnished to do so, subject to the following conditions:
15 
16 The above copyright notice and this permission notice shall be included in
17 all copies or substantial portions of the Software.
18 
19 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25 THE SOFTWARE.
26 -----------------------------------------------------------------------------
27 */
28 #ifndef __Ogre_Iterator_Range_H__
29 #define __Ogre_Iterator_Range_H__
30 
31 #include "OgreHeaderPrefix.h"
32 
33 #if OGRE_USE_BOOST
34 # if OGRE_COMPILER == OGRE_COMPILER_CLANG || OGRE_COMPILER == OGRE_COMPILER_GNUC
35 # pragma GCC diagnostic push
36 #if OGRE_COMPILER == OGRE_COMPILER_GNUC
37 # pragma GCC diagnostic ignored "-Wpragmas"
38 #elif OGRE_COMPILER == OGRE_COMPILER_CLANG
39 # pragma GCC diagnostic ignored "-Wdocumentation"
40 #endif
41 # pragma GCC diagnostic ignored "-Wshadow"
42 # pragma GCC diagnostic ignored "-Wpadded"
43 # pragma GCC diagnostic ignored "-Wweak-vtables"
44 # pragma GCC diagnostic ignored "-Wall"
45 # pragma GCC diagnostic ignored "-Wundef"
46 # endif
47 
48 # include <boost/range.hpp>
49 
50 # if OGRE_COMPILER == OGRE_COMPILER_CLANG || OGRE_COMPILER == OGRE_COMPILER_GNUC
51 # pragma GCC diagnostic pop
52 # endif
53 #endif
54 
55 namespace Ogre {
56 
68 template <typename T>
70 
71 #if !OGRE_USE_BOOST
72 
74 
75  public :
76 
81  iterator_range( T b , T e ) : mBegin(b) , mEnd(e){}
82 
84  T begin() const { return mBegin; }
85 
87  T end() const { return mEnd; }
88 
90  bool empty() const { return mBegin = mEnd ; }
91 
93  bool equal( const iterator_range& other ) const
94  {return mBegin == other.mBegin && mEnd == other.mEnd;}
95 
97  bool operator==( const iterator_range& rhs ) const
98  {return equal( rhs ) ;}
99 
101  bool operator!=( const iterator_range& rhs ) const { return !operator==(rhs); }
102 
109  typedef T iterator;
110 
117  typedef T const_iterator;
118 
120 
125 #else
126  public: typedef boost::iterator_range<T> type ;
128 
129 #endif
130 };
131 
132 
141 template<typename T>
142 struct VectorRange : public iterator_range<typename T::iterator>::type
143 {
144 
149  VectorRange( T& c )
150  : iterator_range<typename T::iterator>::type( c.begin(), c.end() )
151  {}
152 
157  VectorRange( typename T::iterator b, typename T::iterator e )
158  : iterator_range<typename T::iterator>::type( b, e )
159  {}
160 
162  bool operator==( const VectorRange& rhs ) const { return equal( rhs) ; }
164  bool operator!=( const VectorRange& rhs ) const { return !equal( rhs) ; }
165 
166 
167 #ifdef __Ogre_Iterator_Wrapper_H__
168  operator VectorIterator<T>(){return VectorIterator<T>( this->begin(), this->end());}
171  operator ConstVectorIterator<T>(){return ConstVectorIterator<T>( this->begin(), this->end());}
172 #endif
173 
174 };
175 
184 template<typename T>
185 struct ConstVectorRange : public iterator_range<typename T::const_iterator>::type
186 {
187 
192  ConstVectorRange( const T& c )
193  : iterator_range<typename T::const_iterator>::type( c.begin(), c.end() )
194  {}
195 
200  ConstVectorRange( typename T::iterator b, typename T::iterator e )
201  : iterator_range<typename T::const_iterator>::type( b, e )
202  {}
203 
208  ConstVectorRange( typename T::const_iterator b, typename T::const_iterator e )
209  : iterator_range<typename T::const_iterator>::type( b, e )
210  {}
211 
217  : iterator_range<typename T::const_iterator>::type( rhs.begin(), rhs.end() )
218  {}
219 
221  bool operator==( const ConstVectorRange& rhs ) const { return equal( rhs) ; }
223  bool operator!=( const ConstVectorRange& rhs ) const { return !equal( rhs) ; }
224 
225 
226 
227 
228 #ifdef __Ogre_Iterator_Wrapper_H__
229  operator ConstVectorIterator<T>(){return ConstVectorIterator<T>( this->begin(),this->end());}
231 #endif
232 
233 };
234 
235 
236 
245 template<typename T>
246 struct MapRange : public iterator_range<typename T::iterator>::type
247 {
252  MapRange( T& c )
253  : iterator_range<typename T::iterator>::type( c.begin(), c.end() )
254  {}
255 
260  MapRange( typename T::iterator b, typename T::iterator e )
261  : iterator_range<typename T::iterator>::type( b, e )
262  {}
263 
265  bool operator==( const MapRange& rhs ) const { return equal( rhs) ; }
267  bool operator!=( const MapRange& rhs ) const { return !equal( rhs) ; }
268 
269 
270 #ifdef __Ogre_Iterator_Wrapper_H__
271  operator MapIterator<T>(){return MapIterator<T>( this->begin(), this->end());}
274  operator ConstMapIterator<T>(){return ConstMapIterator<T>( this->begin(), this->end());}
275 #endif
276 
277 };
278 
287 template<typename T>
288 struct ConstMapRange : public iterator_range<typename T::const_iterator>::type
289 {
290 
295  ConstMapRange( const T& c )
296  : iterator_range<typename T::const_iterator>::type( c.begin(), c.end() )
297  {}
298 
303  ConstMapRange( typename T::iterator b, typename T::iterator e )
304  : iterator_range<typename T::const_iterator>::type( b, e )
305  {}
306 
311  ConstMapRange( typename T::const_iterator b, typename T::const_iterator e )
312  : iterator_range<typename T::const_iterator>::type( b, e )
313  {}
314 
320  : iterator_range<typename T::const_iterator>::type( rhs.begin(), rhs.end() )
321  {}
322 
324  bool operator==( const ConstMapRange& rhs ) const { return equal( rhs) ; }
326  bool operator!=( const ConstMapRange& rhs ) const { return !equal( rhs) ; }
327 
328 
329 #ifdef __Ogre_Iterator_Wrapper_H__
330  operator ConstMapIterator<T>(){return ConstMapIterator<T>( this->begin(),this->end());}
332 #endif
333 
334 };
335 
336 #include "OgreHeaderSuffix.h"
337 
338 }
339 #endif
OgreHeaderSuffix.h
Ogre::iterator_range::end
T end() const
access to the end of the range
Definition: OgreIteratorRange.h:87
Ogre::ConstMapRange::ConstMapRange
ConstMapRange(typename T::iterator b, typename T::iterator e)
Constructor.
Definition: OgreIteratorRange.h:303
Ogre::VectorRange
Predefined type.
Definition: OgreIteratorRange.h:142
Ogre::iterator_range::empty
bool empty() const
informs if there are any elements in the range
Definition: OgreIteratorRange.h:90
Ogre
Definition: OgreAndroidLogListener.h:34
Ogre::ConstVectorRange
Predefined type.
Definition: OgreIteratorRange.h:185
Ogre::iterator_range::mEnd
T mEnd
Definition: OgreIteratorRange.h:73
Ogre::iterator_range::iterator_range
iterator_range(T b, T e)
Constructor.
Definition: OgreIteratorRange.h:81
Ogre::iterator_range::mBegin
T mBegin
Definition: OgreIteratorRange.h:73
Ogre::MapRange::MapRange
MapRange(T &c)
Constructor.
Definition: OgreIteratorRange.h:252
Ogre::VectorIterator
Concrete IteratorWrapper for nonconst access to the underlying container.
Definition: OgreIteratorWrapper.h:186
Ogre::VectorRange::VectorRange
VectorRange(T &c)
Constructor.
Definition: OgreIteratorRange.h:149
Ogre::iterator_range::operator!=
bool operator!=(const iterator_range &rhs) const
comparison operator for inequality
Definition: OgreIteratorRange.h:101
Ogre::MapRange::MapRange
MapRange(typename T::iterator b, typename T::iterator e)
Constructor.
Definition: OgreIteratorRange.h:260
Ogre::iterator_range::iterator
T iterator
typedef to fulfill container interface
Definition: OgreIteratorRange.h:109
Ogre::MapRange::operator!=
bool operator!=(const MapRange &rhs) const
comparison operator for inequality
Definition: OgreIteratorRange.h:267
OgreHeaderPrefix.h
Ogre::iterator_range
Base for an iterator_range.
Definition: OgreIteratorRange.h:69
Ogre::ConstVectorRange::operator==
bool operator==(const ConstVectorRange &rhs) const
comparison operator for equality
Definition: OgreIteratorRange.h:221
Ogre::ConstMapRange::operator==
bool operator==(const ConstMapRange &rhs) const
comparison operator for equality
Definition: OgreIteratorRange.h:324
Ogre::ConstVectorRange::ConstVectorRange
ConstVectorRange(const T &c)
Constructor.
Definition: OgreIteratorRange.h:192
Ogre::iterator_range::equal
bool equal(const iterator_range &other) const
comparison for equality
Definition: OgreIteratorRange.h:93
Ogre::ConstMapRange::ConstMapRange
ConstMapRange(const MapRange< T > &rhs)
Constructor.
Definition: OgreIteratorRange.h:319
Ogre::ConstMapRange::ConstMapRange
ConstMapRange(typename T::const_iterator b, typename T::const_iterator e)
Constructor.
Definition: OgreIteratorRange.h:311
Ogre::ConstVectorRange::ConstVectorRange
ConstVectorRange(typename T::const_iterator b, typename T::const_iterator e)
Constructor.
Definition: OgreIteratorRange.h:208
Ogre::ConstVectorRange::ConstVectorRange
ConstVectorRange(typename T::iterator b, typename T::iterator e)
Constructor.
Definition: OgreIteratorRange.h:200
Ogre::ConstVectorRange::ConstVectorRange
ConstVectorRange(const VectorRange< T > &rhs)
Constructor.
Definition: OgreIteratorRange.h:216
Ogre::MapIterator
Concrete IteratorWrapper for nonconst access to the underlying key-value container.
Definition: OgreIteratorWrapper.h:319
Ogre::VectorRange::operator==
bool operator==(const VectorRange &rhs) const
comparison operator for equality
Definition: OgreIteratorRange.h:162
Ogre::ConstMapRange::ConstMapRange
ConstMapRange(const T &c)
Constructor.
Definition: OgreIteratorRange.h:295
Ogre::ConstMapRange
Predefined type.
Definition: OgreIteratorRange.h:288
Ogre::iterator_range::type
iterator_range< T > type
defines the real used type
Definition: OgreIteratorRange.h:124
Ogre::iterator_range::begin
T begin() const
access to the begin of the range
Definition: OgreIteratorRange.h:84
Ogre::VectorRange::operator!=
bool operator!=(const VectorRange &rhs) const
comparison operator for inequality
Definition: OgreIteratorRange.h:164
Ogre::ConstVectorRange::operator!=
bool operator!=(const ConstVectorRange &rhs) const
comparison operator for inequality
Definition: OgreIteratorRange.h:223
Ogre::VectorRange::VectorRange
VectorRange(typename T::iterator b, typename T::iterator e)
Constructor.
Definition: OgreIteratorRange.h:157
Ogre::ConstMapIterator
Concrete IteratorWrapper for const access to the underlying key-value container.
Definition: OgreIteratorWrapper.h:352
Ogre::ConstMapRange::operator!=
bool operator!=(const ConstMapRange &rhs) const
comparison operator for inequality
Definition: OgreIteratorRange.h:326
Ogre::iterator_range::const_iterator
T const_iterator
typedef to fulfill container interface
Definition: OgreIteratorRange.h:117
Ogre::MapRange
Predefined type.
Definition: OgreIteratorRange.h:246
Ogre::MapRange::operator==
bool operator==(const MapRange &rhs) const
comparison operator for equality
Definition: OgreIteratorRange.h:265
Ogre::iterator_range::operator==
bool operator==(const iterator_range &rhs) const
comparison operator for equality
Definition: OgreIteratorRange.h:97
Ogre::ConstVectorIterator
Concrete IteratorWrapper for const access to the underlying container.
Definition: OgreIteratorWrapper.h:217

Copyright © 2012 Torus Knot Software Ltd
Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.