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 BUILTIN_CONVERTERS_DWA2002124_HPP # define BUILTIN_CONVERTERS_DWA2002124_HPP # include
# include
# include
# include
# include
# include
# include
# include
// Since all we can use to decide how to convert an object to_python // is its C++ type, there can be only one such converter for each // type. Therefore, for built-in conversions we can bypass registry // lookups using explicit specializations of arg_to_python and // result_to_python. namespace boost { namespace python { namespace converter { template
struct arg_to_python; BOOST_PYTHON_DECL PyObject* do_return_to_python(char); BOOST_PYTHON_DECL PyObject* do_return_to_python(char const*); BOOST_PYTHON_DECL PyObject* do_return_to_python(PyObject*); BOOST_PYTHON_DECL PyObject* do_arg_to_python(PyObject*); } // Provide specializations of to_python_value template
struct to_python_value; namespace detail { // Since there's no registry lookup, always report the existence of // a converter. struct builtin_to_python { // This information helps make_getter() decide whether to try to // return an internal reference or not. I don't like it much, // but it will have to serve for now. BOOST_STATIC_CONSTANT(bool, uses_registry = false); }; } // Use expr to create the PyObject corresponding to x # define BOOST_PYTHON_RETURN_TO_PYTHON_BY_VALUE(T, expr, pytype)\ template <> struct to_python_value
\ : detail::builtin_to_python \ { \ inline PyObject* operator()(T const& x) const \ { \ return (expr); \ } \ inline PyTypeObject const* get_pytype() const \ { \ return (pytype); \ } \ }; \ template <> struct to_python_value
\ : detail::builtin_to_python \ { \ inline PyObject* operator()(T const& x) const \ { \ return (expr); \ } \ inline PyTypeObject const* get_pytype() const \ { \ return (pytype); \ } \ }; # define BOOST_PYTHON_ARG_TO_PYTHON_BY_VALUE(T, expr) \ namespace converter \ { \ template <> struct arg_to_python< T > \ : handle<> \ { \ arg_to_python(T const& x) \ : python::handle<>(expr) {} \ }; \ } // Specialize argument and return value converters for T using expr # define BOOST_PYTHON_TO_PYTHON_BY_VALUE(T, expr, pytype) \ BOOST_PYTHON_RETURN_TO_PYTHON_BY_VALUE(T,expr, pytype) \ BOOST_PYTHON_ARG_TO_PYTHON_BY_VALUE(T,expr) // Specialize converters for signed and unsigned T to Python Int # define BOOST_PYTHON_TO_INT(T) \ BOOST_PYTHON_TO_PYTHON_BY_VALUE(signed T, ::PyInt_FromLong(x), &PyInt_Type) \ BOOST_PYTHON_TO_PYTHON_BY_VALUE( \ unsigned T \ , static_cast
(x) > static_cast
( \ (std::numeric_limits
::max)()) \ ? ::PyLong_FromUnsignedLong(x) \ : ::PyInt_FromLong(x), &PyInt_Type) // Bool is not signed. #if PY_VERSION_HEX >= 0x02030000 BOOST_PYTHON_TO_PYTHON_BY_VALUE(bool, ::PyBool_FromLong(x), &PyBool_Type) #else BOOST_PYTHON_TO_PYTHON_BY_VALUE(bool, ::PyInt_FromLong(x), &PyInt_Type) #endif // note: handles signed char and unsigned char, but not char (see below) BOOST_PYTHON_TO_INT(char) BOOST_PYTHON_TO_INT(short) BOOST_PYTHON_TO_INT(int) BOOST_PYTHON_TO_INT(long) // using Python's macro instead of Boost's - we don't seem to get the // config right all the time. # ifdef HAVE_LONG_LONG BOOST_PYTHON_TO_PYTHON_BY_VALUE(signed BOOST_PYTHON_LONG_LONG, ::PyLong_FromLongLong(x), &PyInt_Type) BOOST_PYTHON_TO_PYTHON_BY_VALUE(unsigned BOOST_PYTHON_LONG_LONG, ::PyLong_FromUnsignedLongLong(x), &PyInt_Type) # endif # undef BOOST_TO_PYTHON_INT BOOST_PYTHON_TO_PYTHON_BY_VALUE(char, converter::do_return_to_python(x), &PyString_Type) BOOST_PYTHON_TO_PYTHON_BY_VALUE(char const*, converter::do_return_to_python(x), &PyString_Type) BOOST_PYTHON_TO_PYTHON_BY_VALUE(std::string, ::PyString_FromStringAndSize(x.data(),implicit_cast
(x.size())), &PyString_Type) #if defined(Py_USING_UNICODE) && !defined(BOOST_NO_STD_WSTRING) BOOST_PYTHON_TO_PYTHON_BY_VALUE(std::wstring, ::PyUnicode_FromWideChar(x.data(),implicit_cast
(x.size())), &PyString_Type) # endif BOOST_PYTHON_TO_PYTHON_BY_VALUE(float, ::PyFloat_FromDouble(x), &PyFloat_Type) BOOST_PYTHON_TO_PYTHON_BY_VALUE(double, ::PyFloat_FromDouble(x), &PyFloat_Type) BOOST_PYTHON_TO_PYTHON_BY_VALUE(long double, ::PyFloat_FromDouble(x), &PyFloat_Type) BOOST_PYTHON_RETURN_TO_PYTHON_BY_VALUE(PyObject*, converter::do_return_to_python(x), 0) BOOST_PYTHON_TO_PYTHON_BY_VALUE(std::complex
, ::PyComplex_FromDoubles(x.real(), x.imag()), &PyComplex_Type) BOOST_PYTHON_TO_PYTHON_BY_VALUE(std::complex
, ::PyComplex_FromDoubles(x.real(), x.imag()), &PyComplex_Type) BOOST_PYTHON_TO_PYTHON_BY_VALUE(std::complex
, ::PyComplex_FromDoubles(x.real(), x.imag()), &PyComplex_Type) # undef BOOST_PYTHON_RETURN_TO_PYTHON_BY_VALUE # undef BOOST_PYTHON_ARG_TO_PYTHON_BY_VALUE # undef BOOST_PYTHON_TO_PYTHON_BY_VALUE # undef BOOST_PYTHON_TO_INT namespace converter { void initialize_builtin_converters(); } }} // namespace boost::python::converter #endif // BUILTIN_CONVERTERS_DWA2002124_HPP
builtin_converters.hpp
Page URL
File URL
Prev
5/27
Next
Download
( 7 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.