OGRE  1.9.0
OgreIteratorRange.h
Go to the documentation of this file.
1/*
2-----------------------------------------------------------------------------
3This source file is part of OGRE
4(Object-oriented Graphics Rendering Engine)
5For the latest info, see http://www.ogre3d.org/
6
7Copyright (c) 2000-2014 Torus Knot Software Ltd
8
9Permission is hereby granted, free of charge, to any person obtaining a copy
10of this software and associated documentation files (the "Software"), to deal
11in the Software without restriction, including without limitation the rights
12to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13copies of the Software, and to permit persons to whom the Software is
14furnished to do so, subject to the following conditions:
15
16The above copyright notice and this permission notice shall be included in
17all copies or substantial portions of the Software.
18
19THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25THE 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
55namespace Ogre {
56
68template <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
118
120
125#else
127 public: typedef boost::iterator_range<T> type ;
128
129#endif
130};
131
132
141template<typename T>
142struct VectorRange : public iterator_range<typename T::iterator>::type
143{
144
151 {}
152
157 VectorRange( typename T::iterator b, typename T::iterator 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__
169 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
184template<typename T>
185struct ConstVectorRange : public iterator_range<typename T::const_iterator>::type
186{
187
194 {}
195
200 ConstVectorRange( typename T::iterator b, typename T::iterator e )
202 {}
203
208 ConstVectorRange( typename T::const_iterator b, typename T::const_iterator e )
210 {}
211
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__
230 operator ConstVectorIterator<T>(){return ConstVectorIterator<T>( this->begin(),this->end());}
231#endif
232
233};
234
235
236
245template<typename T>
246struct MapRange : public iterator_range<typename T::iterator>::type
247{
254 {}
255
260 MapRange( typename T::iterator b, typename T::iterator 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__
272 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
287template<typename T>
288struct ConstMapRange : public iterator_range<typename T::const_iterator>::type
289{
290
295 ConstMapRange( const T& c )
297 {}
298
303 ConstMapRange( typename T::iterator b, typename T::iterator e )
305 {}
306
311 ConstMapRange( typename T::const_iterator b, typename T::const_iterator e )
313 {}
314
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__
331 operator ConstMapIterator<T>(){return ConstMapIterator<T>( this->begin(),this->end());}
332#endif
333
334};
335
336}
337
338#include "OgreHeaderSuffix.h"
339
340#endif
Reference-counted shared pointer, used for objects where implicit destruction is required.
Base for an iterator_range.
T begin() const
access to the begin of the range
bool equal(const iterator_range &other) const
comparison for equality
iterator_range(T b, T e)
Constructor.
T end() const
access to the end of the range
iterator_range< T > type
defines the real used type
T iterator
typedef to fulfill container interface
T const_iterator
typedef to fulfill container interface
bool empty() const
informs if there are any elements in the range
bool operator==(const iterator_range &rhs) const
comparison operator for equality
bool operator!=(const iterator_range &rhs) const
comparison operator for inequality
ConstMapRange(typename T::const_iterator b, typename T::const_iterator e)
Constructor.
bool operator==(const ConstMapRange &rhs) const
comparison operator for equality
bool operator!=(const ConstMapRange &rhs) const
comparison operator for inequality
ConstMapRange(typename T::iterator b, typename T::iterator e)
Constructor.
ConstMapRange(const T &c)
Constructor.
ConstMapRange(const MapRange< T > &rhs)
Constructor.
ConstVectorRange(const VectorRange< T > &rhs)
Constructor.
bool operator==(const ConstVectorRange &rhs) const
comparison operator for equality
ConstVectorRange(typename T::const_iterator b, typename T::const_iterator e)
Constructor.
ConstVectorRange(typename T::iterator b, typename T::iterator e)
Constructor.
bool operator!=(const ConstVectorRange &rhs) const
comparison operator for inequality
ConstVectorRange(const T &c)
Constructor.
Predefined type.
MapRange(typename T::iterator b, typename T::iterator e)
Constructor.
bool operator!=(const MapRange &rhs) const
comparison operator for inequality
bool operator==(const MapRange &rhs) const
comparison operator for equality
MapRange(T &c)
Constructor.
Predefined type.
bool operator==(const VectorRange &rhs) const
comparison operator for equality
VectorRange(typename T::iterator b, typename T::iterator e)
Constructor.
bool operator!=(const VectorRange &rhs) const
comparison operator for inequality
VectorRange(T &c)
Constructor.