24 #ifndef PXR_BASE_TF_PY_RESULT_CONVERSIONS_H 25 #define PXR_BASE_TF_PY_RESULT_CONVERSIONS_H 31 #include <boost/python/tuple.hpp> 32 #include <boost/python/list.hpp> 33 #include <boost/python/dict.hpp> 35 #include <type_traits> 37 PXR_NAMESPACE_OPEN_SCOPE
39 template <
typename T>
struct Tf_PySequenceToListConverter;
40 template <
typename T>
struct Tf_PySequenceToSetConverter;
41 template <
typename T>
struct Tf_PyMapToDictionaryConverter;
42 template <
typename T>
struct Tf_PySequenceToTupleConverter;
43 template <
typename First,
typename Second>
struct Tf_PyPairToTupleConverter;
70 typedef Tf_PySequenceToListConverter<T> type;
99 typedef Tf_PySequenceToSetConverter<T> type;
108 template <
typename T>
110 typedef Tf_PyMapToDictionaryConverter<T> type;
120 template <
typename T>
122 typedef Tf_PySequenceToTupleConverter<T> type;
129 template <
typename T>
131 typedef Tf_PyPairToTupleConverter<
typename T::first_type,
132 typename T::second_type> type;
136 template <
typename T>
137 struct Tf_PySequenceToListConverter {
138 typedef std::remove_reference_t<T> SeqType;
139 bool convertible()
const {
142 PyObject *operator()(T seq)
const {
143 return boost::python::incref(TfPyCopySequenceToList(seq).ptr());
145 PyTypeObject *get_pytype() {
150 template <
typename T>
151 struct Tf_PySequenceToSetConverter {
152 typedef std::remove_reference_t<T> SeqType;
153 bool convertible()
const {
156 PyObject *operator()(T seq)
const {
159 PyTypeObject *get_pytype() {
164 template <
typename T>
165 struct Tf_PyMapToDictionaryConverter {
166 typedef std::remove_reference_t<T> SeqType;
169 bool convertible()
const {
172 PyObject *operator()(T seq)
const {
175 PyTypeObject *get_pytype() {
180 template <
typename T>
181 struct Tf_PySequenceToTupleConverter {
182 typedef std::remove_reference_t<T> SeqType;
183 bool convertible()
const {
186 PyObject *operator()(T seq)
const {
187 return boost::python::incref(TfPyCopySequenceToTuple(seq).ptr());
189 PyTypeObject *get_pytype() {
190 return &PyTuple_Type;
194 template <
typename First,
typename Second>
195 struct Tf_PyPairToTupleConverter {
196 typedef std::pair<First, Second> PairType;
197 bool convertible()
const {
200 PyObject *operator()(PairType
const& a)
const {
201 boost::python::tuple result =
202 boost::python::make_tuple(a.first, a.second);
203 return boost::python::incref(result.ptr());
205 PyTypeObject *get_pytype() {
206 return &PyTuple_Type;
210 PXR_NAMESPACE_CLOSE_SCOPE
212 #endif // TF_RESULT_CONVERSIONS_H A boost::python result converter generator which converts standard library sequences to tuples.
Miscellaneous Utilities for dealing with script.
A boost::python result converter generator which converts standard library sequences to sets.
A boost::python result converter generator which converts standard library pairs to tuples.
boost::python::object TfPyCopySequenceToSet(Seq const &seq)
Create a python set from an iterable sequence.
A boost::python result converter generator which converts standard library maps to dictionaries.
A boost::python result converter generator which converts standard library sequences to lists.
boost::python::dict TfPyCopyMapToDictionary(Map const &map)
Creates a python dictionary from a std::map.