ossrv_pub/boost_apis/boost/python/stl_iterator.hpp
changeset 0 e4d67989cc36
equal deleted inserted replaced
-1:000000000000 0:e4d67989cc36
       
     1 // Copyright Eric Niebler 2005.
       
     2 // Distributed under the Boost Software License, Version 1.0. (See
       
     3 // accompanying file LICENSE_1_0.txt or copy at
       
     4 // http://www.boost.org/LICENSE_1_0.txt)
       
     5 #ifndef STL_ITERATOR_EAN20051028_HPP
       
     6 # define STL_ITERATOR_EAN20051028_HPP
       
     7 
       
     8 # include <boost/python/detail/prefix.hpp>
       
     9 
       
    10 # include <boost/python/object/stl_iterator_core.hpp>
       
    11 
       
    12 # include <boost/iterator/iterator_facade.hpp>
       
    13 
       
    14 namespace boost { namespace python
       
    15 { 
       
    16 
       
    17 // An STL input iterator over a python sequence
       
    18 template<typename ValueT>
       
    19 struct stl_input_iterator
       
    20   : boost::iterator_facade<
       
    21         stl_input_iterator<ValueT>
       
    22       , ValueT
       
    23       , std::input_iterator_tag
       
    24       , ValueT
       
    25     >
       
    26 {
       
    27     stl_input_iterator()
       
    28       : impl_()
       
    29     {
       
    30     }
       
    31 
       
    32     // ob is the python sequence
       
    33     stl_input_iterator(boost::python::object const &ob)
       
    34       : impl_(ob)
       
    35     {
       
    36     }
       
    37 
       
    38 private:
       
    39     friend class boost::iterator_core_access;
       
    40 
       
    41     void increment()
       
    42     {
       
    43         this->impl_.increment();
       
    44     }
       
    45 
       
    46     ValueT dereference() const
       
    47     {
       
    48         return extract<ValueT>(this->impl_.current().get())();
       
    49     }
       
    50 
       
    51     bool equal(stl_input_iterator<ValueT> const &that) const
       
    52     {
       
    53         return this->impl_.equal(that.impl_);
       
    54     }
       
    55 
       
    56     objects::stl_input_iterator_impl impl_;
       
    57 };
       
    58 
       
    59 }} // namespace boost::python
       
    60 
       
    61 #endif // STL_ITERATOR_EAN20051028_HPP