OgreIteratorRange.h
Go to the documentation of this file.
/*
-----------------------------------------------------------------------------
This source file is part of OGRE
(Object-oriented Graphics Rendering Engine)
For the latest info, see http://www.ogre3d.org/
Copyright (c) 2000-2013 Torus Knot Software Ltd
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 OR COPYRIGHT HOLDERS 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.
-----------------------------------------------------------------------------
*/
#ifndef __Ogre_Iterator_Range_H__
#define __Ogre_Iterator_Range_H__
#include "OgreHeaderPrefix.h"
#if OGRE_USE_BOOST
# if OGRE_COMPILER == OGRE_COMPILER_CLANG || OGRE_COMPILER == OGRE_COMPILER_GNUC
# pragma GCC diagnostic push
#if OGRE_COMPILER == OGRE_COMPILER_GNUC
# pragma GCC diagnostic ignored "-Wpragmas"
#elif OGRE_COMPILER == OGRE_COMPILER_CLANG
# pragma GCC diagnostic ignored "-Wdocumentation"
#endif
# pragma GCC diagnostic ignored "-Wshadow"
# pragma GCC diagnostic ignored "-Wpadded"
# pragma GCC diagnostic ignored "-Wweak-vtables"
# pragma GCC diagnostic ignored "-Wall"
# pragma GCC diagnostic ignored "-Wundef"
# endif
# include <boost/range.hpp>
# if OGRE_COMPILER == OGRE_COMPILER_CLANG || OGRE_COMPILER == OGRE_COMPILER_GNUC
# pragma GCC diagnostic pop
# endif
#endif
namespace Ogre {
template <typename T>
class iterator_range{
#if !OGRE_USE_BOOST
T mBegin, mEnd;
public :
iterator_range( T b , T e ) : mBegin(b) , mEnd(e){}
T begin() const { return mBegin; }
T end() const { return mEnd; }
bool empty() const { return mBegin = mEnd ; }
bool equal( const iterator_range& other ) const
{return mBegin == other.mBegin && mEnd == other.mEnd;}
bool operator==( const iterator_range& rhs ) const
{return equal( rhs ) ;}
bool operator!=( const iterator_range& rhs ) const { return !operator==(rhs); }
typedef T iterator;
typedef T const_iterator;
typedef iterator_range<T> type;
#else
public: typedef boost::iterator_range<T> type ;
#endif
};
template<typename T>
struct VectorRange : public iterator_range<typename T::iterator>::type
{
VectorRange( T& c )
: iterator_range<typename T::iterator>::type( c.begin(), c.end() )
{}
VectorRange( typename T::iterator b, typename T::iterator e )
: iterator_range<typename T::iterator>::type( b, e )
{}
bool operator==( const VectorRange& rhs ) const { return equal( rhs) ; }
bool operator!=( const VectorRange& rhs ) const { return !equal( rhs) ; }
#ifdef __Ogre_Iterator_Wrapper_H__
operator VectorIterator<T>(){return VectorIterator<T>( this->begin(), this->end());}
operator ConstVectorIterator<T>(){return ConstVectorIterator<T>( this->begin(), this->end());}
#endif
};
template<typename T>
struct ConstVectorRange : public iterator_range<typename T::const_iterator>::type
{
ConstVectorRange( const T& c )
: iterator_range<typename T::const_iterator>::type( c.begin(), c.end() )
{}
ConstVectorRange( typename T::iterator b, typename T::iterator e )
: iterator_range<typename T::const_iterator>::type( b, e )
{}
ConstVectorRange( typename T::const_iterator b, typename T::const_iterator e )
: iterator_range<typename T::const_iterator>::type( b, e )
{}
ConstVectorRange( const VectorRange<T>& rhs )
: iterator_range<typename T::const_iterator>::type( rhs.begin(), rhs.end() )
{}
bool operator==( const ConstVectorRange& rhs ) const { return equal( rhs) ; }
bool operator!=( const ConstVectorRange& rhs ) const { return !equal( rhs) ; }
#ifdef __Ogre_Iterator_Wrapper_H__
operator ConstVectorIterator<T>(){return ConstVectorIterator<T>( this->begin(),this->end());}
#endif
};
template<typename T>
struct MapRange : public iterator_range<typename T::iterator>::type
{
MapRange( T& c )
: iterator_range<typename T::iterator>::type( c.begin(), c.end() )
{}
MapRange( typename T::iterator b, typename T::iterator e )
: iterator_range<typename T::iterator>::type( b, e )
{}
bool operator==( const MapRange& rhs ) const { return equal( rhs) ; }
bool operator!=( const MapRange& rhs ) const { return !equal( rhs) ; }
#ifdef __Ogre_Iterator_Wrapper_H__
operator MapIterator<T>(){return MapIterator<T>( this->begin(), this->end());}
operator ConstMapIterator<T>(){return ConstMapIterator<T>( this->begin(), this->end());}
#endif
};
template<typename T>
struct ConstMapRange : public iterator_range<typename T::const_iterator>::type
{
ConstMapRange( const T& c )
: iterator_range<typename T::const_iterator>::type( c.begin(), c.end() )
{}
ConstMapRange( typename T::iterator b, typename T::iterator e )
: iterator_range<typename T::const_iterator>::type( b, e )
{}
ConstMapRange( typename T::const_iterator b, typename T::const_iterator e )
: iterator_range<typename T::const_iterator>::type( b, e )
{}
ConstMapRange( const MapRange<T>& rhs )
: iterator_range<typename T::const_iterator>::type( rhs.begin(), rhs.end() )
{}
bool operator==( const ConstMapRange& rhs ) const { return equal( rhs) ; }
bool operator!=( const ConstMapRange& rhs ) const { return !equal( rhs) ; }
#ifdef __Ogre_Iterator_Wrapper_H__
operator ConstMapIterator<T>(){return ConstMapIterator<T>( this->begin(),this->end());}
#endif
};
#include "OgreHeaderSuffix.h"
}
#endif
Ogre::MapRange
Predefined type.
Definition: OgreIteratorRange.h:246
Ogre::VectorRange
Predefined type.
Definition: OgreIteratorRange.h:142
Ogre::ConstMapRange
Predefined type.
Definition: OgreIteratorRange.h:288
Ogre::VectorIterator
Concrete IteratorWrapper for nonconst access to the underlying container.
Definition: OgreIteratorWrapper.h:186
Ogre::MapRange::operator==
bool operator==(const MapRange &rhs) const
comparison operator for equality
Definition: OgreIteratorRange.h:265
Ogre::ConstMapRange::ConstMapRange
ConstMapRange(typename T::iterator b, typename T::iterator e)
Constructor.
Definition: OgreIteratorRange.h:303
Ogre::MapIterator
Concrete IteratorWrapper for nonconst access to the underlying key-value container.
Definition: OgreIteratorWrapper.h:319
Ogre::ConstMapIterator
Concrete IteratorWrapper for const access to the underlying key-value container.
Definition: OgreIteratorWrapper.h:352
Ogre::ConstVectorRange
Predefined type.
Definition: OgreIteratorRange.h:185
Ogre::VectorRange::operator!=
bool operator!=(const VectorRange &rhs) const
comparison operator for inequality
Definition: OgreIteratorRange.h:164
Ogre::iterator_range::operator==
bool operator==(const iterator_range &rhs) const
comparison operator for equality
Definition: OgreIteratorRange.h:97
Ogre::iterator_range::empty
bool empty() const
informs if there are any elements in the range
Definition: OgreIteratorRange.h:90
Ogre::ConstVectorRange::ConstVectorRange
ConstVectorRange(typename T::iterator b, typename T::iterator e)
Constructor.
Definition: OgreIteratorRange.h:200
Ogre::VectorRange::operator==
bool operator==(const VectorRange &rhs) const
comparison operator for equality
Definition: OgreIteratorRange.h:162
Ogre::iterator_range::mEnd
T mEnd
Definition: OgreIteratorRange.h:73
Ogre::iterator_range::mBegin
T mBegin
Definition: OgreIteratorRange.h:73
Ogre::MapRange::MapRange
MapRange(typename T::iterator b, typename T::iterator e)
Constructor.
Definition: OgreIteratorRange.h:260
Ogre::ConstVectorRange::ConstVectorRange
ConstVectorRange(const T &c)
Constructor.
Definition: OgreIteratorRange.h:192
Ogre::MapRange::MapRange
MapRange(T &c)
Constructor.
Definition: OgreIteratorRange.h:252
Ogre::iterator_range::iterator_range
iterator_range(T b, T e)
Constructor.
Definition: OgreIteratorRange.h:81
Ogre::VectorRange::VectorRange
VectorRange(typename T::iterator b, typename T::iterator e)
Constructor.
Definition: OgreIteratorRange.h:157
Ogre::iterator_range::operator!=
bool operator!=(const iterator_range &rhs) const
comparison operator for inequality
Definition: OgreIteratorRange.h:101
Ogre::iterator_range::iterator
T iterator
typedef to fulfill container interface
Definition: OgreIteratorRange.h:109
Ogre::ConstMapRange::operator!=
bool operator!=(const ConstMapRange &rhs) const
comparison operator for inequality
Definition: OgreIteratorRange.h:326
Ogre::ConstVectorRange::ConstVectorRange
ConstVectorRange(typename T::const_iterator b, typename T::const_iterator e)
Constructor.
Definition: OgreIteratorRange.h:208
Ogre::MapRange::operator!=
bool operator!=(const MapRange &rhs) const
comparison operator for inequality
Definition: OgreIteratorRange.h:267
Ogre::iterator_range
Base for an iterator_range.
Definition: OgreIteratorRange.h:69
Ogre::iterator_range::type
iterator_range< T > type
defines the real used type
Definition: OgreIteratorRange.h:124
OgreHeaderSuffix.h
Ogre::ConstMapRange::ConstMapRange
ConstMapRange(typename T::const_iterator b, typename T::const_iterator e)
Constructor.
Definition: OgreIteratorRange.h:311
Ogre::ConstMapRange::ConstMapRange
ConstMapRange(const T &c)
Constructor.
Definition: OgreIteratorRange.h:295
Ogre::iterator_range::equal
bool equal(const iterator_range &other) const
comparison for equality
Definition: OgreIteratorRange.h:93
Ogre::ConstVectorRange::operator==
bool operator==(const ConstVectorRange &rhs) const
comparison operator for equality
Definition: OgreIteratorRange.h:221
Ogre
Definition: OgreAndroidLogListener.h:34
Ogre::iterator_range::const_iterator
T const_iterator
typedef to fulfill container interface
Definition: OgreIteratorRange.h:117
Ogre::VectorRange::VectorRange
VectorRange(T &c)
Constructor.
Definition: OgreIteratorRange.h:149
Ogre::ConstVectorIterator
Concrete IteratorWrapper for const access to the underlying container.
Definition: OgreIteratorWrapper.h:217
OgreHeaderPrefix.h
Ogre::ConstMapRange::operator==
bool operator==(const ConstMapRange &rhs) const
comparison operator for equality
Definition: OgreIteratorRange.h:324
Ogre::ConstMapRange::ConstMapRange
ConstMapRange(const MapRange< T > &rhs)
Constructor.
Definition: OgreIteratorRange.h:319
Ogre::iterator_range::end
T end() const
access to the end of the range
Definition: OgreIteratorRange.h:87
Ogre::iterator_range::begin
T begin() const
access to the begin of the range
Definition: OgreIteratorRange.h:84
Ogre::ConstVectorRange::ConstVectorRange
ConstVectorRange(const VectorRange< T > &rhs)
Constructor.
Definition: OgreIteratorRange.h:216
Ogre::ConstVectorRange::operator!=
bool operator!=(const ConstVectorRange &rhs) const
comparison operator for inequality
Definition: OgreIteratorRange.h:223

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