DriveHQ Start Menu
Cloud Drive Mapping
Folder Sync
Cloud Backup
True Drop Box
FTP/SFTP Hosting
Group Account
DriveHQ Start Menu
Online File Server
My Storage
|
Manage Shares
|
Publishes
|
Drop Boxes
|
Group Account
WebDAV Drive Mapping
Cloud Drive Home
|
WebDAV Guide
|
Drive Mapping Tool
|
Drive Mapping URL
Complete Data Backup
Backup Guide
|
Online Backup Tool
|
Cloud-to-Cloud Backup
FTP, Email & Web Service
FTP Home
|
FTP Hosting FAQ
|
Email Hosting
|
EmailManager
|
Web Hosting
Help & Resources
About
|
Enterprise Service
|
Partnership
|
Comparisons
|
Support
Quick Links
Security and Privacy
Download Software
Service Manual
Use Cases
Group Account
Online Help
Blog
Contact
Cloud Surveillance
Sign Up
Login
Features
Business Features
Online File Server
FTP Hosting
Cloud Drive Mapping
Cloud File Backup
Email Backup & Hosting
Cloud File Sharing
Folder Synchronization
Group Management
True Drop Box
Full-text Search
AD Integration/SSO
Mobile Access
IP Camera & DVR Solution
More...
Personal Features
Personal Cloud Drive
Backup All Devices
Mobile APPs
Personal Web Hosting
Sub-Account (for Kids)
Home/PC/Kids Monitoring
More...
Software
DriveHQ Drive Mapping Tool
DriveHQ FileManager
DriveHQ Online Backup
DriveHQ Mobile Apps
Pricing
Business Plans & Pricing
Personal Plans & Pricing
Price Comparison with Others
Feature Comparison with Others
Install Mobile App
Sign up
Creating account...
Invalid character in username! Only 0-9, a-z, A-Z, _, -, . allowed.
Username is required!
Invalid email address!
E-mail is required!
Password is required!
Password is invalid!
Password and confirmation do not match.
Confirm password is required!
I accept
Membership Agreement
Please read the Membership Agreement and check "I accept"!
Free Quick Sign-up
Sign-up Page
Log in
Signing in...
Username or e-mail address is required!
Password is required!
Keep me logged in
Quick Login
Forgot Password
Up
Upload
Download
Share
Publish
New Folder
New File
Copy
Cut
Delete
Paste
Rate
Upgrade
Rotate
Effect
Edit
Slide
History
// Copyright David Abrahams 2002. // Distributed under the Boost Software License, Version 1.0. (See // accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) #ifndef ITERATOR_DWA2002510_HPP # define ITERATOR_DWA2002510_HPP # include
# include
# include
# include
# include
# include
# include
# include
# include
# include
# include
# include
# include
# include
# include
# include
# include
namespace boost { namespace python { namespace objects { // CallPolicies for the next() method of iterators. We don't want // users to have to explicitly specify that the references returned by // iterators are copied, so we just replace the result_converter from // the default_iterator_call_policies with a permissive one which // always copies the result. typedef return_value_policy
default_iterator_call_policies; // Instantiations of these are wrapped to produce Python iterators. template
struct iterator_range { iterator_range(object sequence, Iterator start, Iterator finish); typedef boost::detail::iterator_traits
traits_t; struct next { typedef typename mpl::if_< is_reference< typename traits_t::reference > , typename traits_t::reference , typename traits_t::value_type >::type result_type; result_type operator()(iterator_range
& self) { if (self.m_start == self.m_finish) stop_iteration_error(); return *self.m_start++; } # if BOOST_WORKAROUND(__MWERKS__, BOOST_TESTED_AT(0x3003)) // CWPro8 has a codegen problem when this is an empty class int garbage; # endif }; # ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION // for compilers which can't deduce the value_type of pointers, we // have a special implementation of next. This takes advantage of // the fact that T* results are treated like T& results by // Boost.Python's function wrappers. struct next_ptr { typedef Iterator result_type; result_type operator()(iterator_range
& self) { if (self.m_start == self.m_finish) stop_iteration_error(); return self.m_start++; } }; typedef mpl::if_< is_same< boost::detail::please_invoke_BOOST_TT_BROKEN_COMPILER_SPEC_on_cv_unqualified_pointee
, typename traits_t::value_type > , next_ptr , next >::type next_fn; # else typedef next next_fn; # endif object m_sequence; // Keeps the sequence alive while iterating. Iterator m_start; Iterator m_finish; }; namespace detail { // Get a Python class which contains the given iterator and // policies, creating it if necessary. Requires: NextPolicies is // default-constructible. template
object demand_iterator_class(char const* name, Iterator* = 0, NextPolicies const& policies = NextPolicies()) { typedef iterator_range
range_; // Check the registry. If one is already registered, return it. handle<> class_obj( objects::registered_class_object(python::type_id
())); if (class_obj.get() != 0) return object(class_obj); typedef typename range_::next_fn next_fn; typedef typename next_fn::result_type result_type; return class_
(name, no_init) .def("__iter__", identity_function()) .def( "next" , make_function( next_fn() , policies , mpl::vector2
() )); } // A function object which builds an iterator_range. template < class Target , class Iterator , class Accessor1 , class Accessor2 , class NextPolicies > struct py_iter_ { py_iter_(Accessor1 const& get_start, Accessor2 const& get_finish) : m_get_start(get_start) , m_get_finish(get_finish) {} // Extract an object x of the Target type from the first Python // argument, and invoke get_start(x)/get_finish(x) to produce // iterators, which are used to construct a new iterator_range<> // object that gets wrapped into a Python iterator. iterator_range
operator()(back_reference
x) const { // Make sure the Python class is instantiated. detail::demand_iterator_class("iterator", (Iterator*)0, NextPolicies()); return iterator_range
( x.source() , m_get_start(x.get()) , m_get_finish(x.get()) ); } private: Accessor1 m_get_start; Accessor2 m_get_finish; }; template
inline object make_iterator_function( Accessor1 const& get_start , Accessor2 const& get_finish , NextPolicies const& /*next_policies*/ , Iterator const& (*)() , boost::type
* , int ) { return make_function( py_iter_
(get_start, get_finish) , default_call_policies() , mpl::vector2
, back_reference
>() ); } template
inline object make_iterator_function( Accessor1 const& get_start , Accessor2 const& get_finish , NextPolicies const& next_policies , Iterator& (*)() , boost::type
* , ...) { return make_iterator_function( get_start , get_finish , next_policies , (Iterator const&(*)())0 , (boost::type
*)0 , 0 ); } } // Create a Python callable object which accepts a single argument // convertible to the C++ Target type and returns a Python // iterator. The Python iterator uses get_start(x) and get_finish(x) // (where x is an instance of Target) to produce begin and end // iterators for the range, and an instance of NextPolicies is used as // CallPolicies for the Python iterator's next() function. template
inline object make_iterator_function( Accessor1 const& get_start , Accessor2 const& get_finish , NextPolicies const& next_policies , boost::type
* = 0 ) { typedef typename Accessor1::result_type iterator; typedef typename add_const
::type iterator_const; typedef typename add_reference
::type iterator_cref; return detail::make_iterator_function( get_start , get_finish , next_policies , (iterator_cref(*)())0 , (boost::type
*)0 , 0 ); } // // implementation // template
inline iterator_range
::iterator_range( object sequence, Iterator start, Iterator finish) : m_sequence(sequence), m_start(start), m_finish(finish) { } }}} // namespace boost::python::objects #endif // ITERATOR_DWA2002510_HPP
iterator.hpp
Page URL
File URL
Prev
16/27
Next
Download
( 8 KB )
Note: The DriveHQ service banners will NOT be displayed if the file owner is a paid member.
Comments
Total ratings:
0
Average rating:
Not Rated
Would you like to comment?
Join DriveHQ
for a free account, or
Logon
if you are already a member.