|
MIRA
|
Code for wrapping boost optional data types. More...
#include <python/BoostPythonWrapper.h>
Go to the source code of this file.
Classes | |
| struct | object_from_python< T, TfromPy > |
| struct | register_python_conversion< T, TtoPy, TfromPy > |
| struct | python_optional< T > |
| struct | python_optional< T >::optional_to_python |
| struct | python_optional< T >::optional_from_python |
Namespaces | |
| mira | |
| mira::python | |
Code for wrapping boost optional data types.
Code is a combination of the solutions provided at http://boost.2283326.n4.nabble.com/C-sig-Making-boost-optional-lt-T-gt-passable-to-from-Python-td2699832.html and https://stackoverflow.com/questions/36485840/wrap-boostoptional-using-boostpython
boost::none is mapped to None in Python and vice versa.
It is important to call "python_optional<Type>();" in module initialization when wrapping something which holds boost::optional<Type>. Instead of using converters with "def_readwrite" you have to use "add_property" like the following: .add_property("bar", boost::python::make_getter(&Foo::bar, boost::python::return_value_policy<bp::return_by_value>()), boost::python::make_setter(&Foo::bar, boost::python::return_value_policy<bp::return_by_value>()));
1.8.14