📄 ogreiteratordeclarator.h
字号:
#ifndef PYOGRE_ITERATORWRAPPERS_H_INCLUDED
# define PYOGRE_ITERATORWRAPPERS_H_INCLUDED
/** Used to declare an OgreIterator:
OgreIteratorDeclarator< SettingsIterator, String > declareSettingsIterator;
*/
template<typename IteratorType> // EnumeratedType could be deduced if defined in templated type
class OgreIteratorDeclarator
{
public:
typedef typename IteratorType::value_type ValueType;
OgreIteratorDeclarator( const std::string &className )
{
boost::python::class_< IteratorType >( className.c_str(), no_init )
.def( "next", &next )
.def( "__iter__", &iter )
;
}
static ValueType next( IteratorType &iterator )
{
if ( !iterator.hasMoreElements() )
boost::python::objects::stop_iteration_error(); // in object/iterator_core.hpp
return iterator.getNext();
}
static IteratorType iter( const IteratorType &iterator )
{
return iterator;
}
};
template<typename IteratorType> // EnumeratedType could be deduced if defined in templated type
class OgreMapIteratorDeclarator
{
public:
OgreMapIteratorDeclarator( const std::string &className )
{
boost::python::class_< IteratorType >( className.c_str(), no_init )
.def( "next", &next )
.def( "__iter__", &iter )
;
}
static boost::python::tuple next( IteratorType &iterator )
{
if ( !iterator.hasMoreElements() )
boost::python::objects::stop_iteration_error(); // in object/iterator_core.hpp
typename IteratorType::KeyType key = iterator.peekNextKey();
return boost::python::make_tuple( key, iterator.getNext() );
}
static IteratorType iter( const IteratorType &iterator )
{
return iterator;
}
};
#endif // PYOGRE_ITERATORWRAPPERS_H_INCLUDED
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -