24 #ifndef PXR_BASE_TF_PY_OPTIONAL_H
25 #define PXR_BASE_TF_PY_OPTIONAL_H
32 #include <hboost/noncopyable.hpp>
33 #include <hboost/optional.hpp>
34 #include <hboost/python/converter/from_python.hpp>
35 #include <hboost/python/extract.hpp>
36 #include <hboost/python/to_python_converter.hpp>
37 #include <hboost/python/to_python_value.hpp>
44 namespace TfPyOptional {
46 template <
typename T,
typename TfromPy>
50 hboost::python::converter::registry::push_back
51 (&TfromPy::convertible, &TfromPy::construct,
52 hboost::python::type_id<T>());
56 template <
typename T,
typename TtoPy,
typename TfromPy>
60 hboost::python::to_python_converter<T, TtoPy>();
77 return hboost::python::detail::none();
85 using namespace hboost::python::converter;
87 if ((source == Py_None) || hboost::python::extract<T>(source).check())
94 hboost::python::converter::rvalue_from_python_stage1_data *
data)
96 using namespace hboost::python::converter;
99 ((rvalue_from_python_storage<T> *)data)->storage.bytes;
101 if (data->convertible == Py_None) {
102 new (
storage) hboost::optional<T>();
104 new (
storage) hboost::optional<T>(hboost::python::extract<T>(source));
121 #endif // PXR_BASE_TF_PY_OPTIONAL_H
getFileOption("OpenEXR:storage") storage
static void construct(PyObject *source, hboost::python::converter::rvalue_from_python_stage1_data *data)
static void * convertible(PyObject *source)
GLsizei GLsizei GLchar * source
hboost::python::object TfPyObject(T const &t, bool complainOnFailure=true)
register_python_conversion()
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
#define PXR_NAMESPACE_CLOSE_SCOPE
static PyObject * convert(const hboost::optional< T > &value)