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 <boost/type_traits/add_reference.hpp> 36 #include <boost/type_traits/remove_reference.hpp> 38 #include <type_traits> 40 PXR_NAMESPACE_OPEN_SCOPE
42 template <
typename T>
struct Tf_PySequenceToListConverter;
43 template <
typename T>
struct Tf_PySequenceToSetConverter;
44 template <
typename T>
struct Tf_PyMapToDictionaryConverter;
45 template <
typename T>
struct Tf_PySequenceToTupleConverter;
46 template <
typename First,
typename Second>
struct Tf_PyPairToTupleConverter;
73 typedef Tf_PySequenceToListConverter<T> type;
100 template <
typename T>
102 typedef Tf_PySequenceToSetConverter<T> type;
111 template <
typename T>
113 typedef Tf_PyMapToDictionaryConverter<T> type;
123 template <
typename T>
125 typedef Tf_PySequenceToTupleConverter<T> type;
132 template <
typename T>
134 typedef Tf_PyPairToTupleConverter<
typename T::first_type,
135 typename T::second_type> type;
139 template <
typename T>
140 struct Tf_PySequenceToListConverter {
141 typedef typename boost::remove_reference<T>::type SeqType;
142 bool convertible()
const {
145 PyObject *operator()(T seq)
const {
146 return boost::python::incref(TfPyCopySequenceToList(seq).ptr());
148 PyTypeObject *get_pytype() {
153 template <
typename T>
154 struct Tf_PySequenceToSetConverter {
155 typedef typename std::remove_reference<T>::type SeqType;
156 bool convertible()
const {
159 PyObject *operator()(T seq)
const {
162 PyTypeObject *get_pytype() {
167 template <
typename T>
168 struct Tf_PyMapToDictionaryConverter {
169 typedef typename boost::remove_reference<T>::type SeqType;
172 bool convertible()
const {
175 PyObject *operator()(T seq)
const {
178 PyTypeObject *get_pytype() {
183 template <
typename T>
184 struct Tf_PySequenceToTupleConverter {
185 typedef typename boost::remove_reference<T>::type SeqType;
186 bool convertible()
const {
189 PyObject *operator()(T seq)
const {
190 return boost::python::incref(TfPyCopySequenceToTuple(seq).ptr());
192 PyTypeObject *get_pytype() {
193 return &PyTuple_Type;
197 template <
typename First,
typename Second>
198 struct Tf_PyPairToTupleConverter {
199 typedef std::pair<First, Second> PairType;
200 bool convertible()
const {
203 PyObject *operator()(PairType
const& a)
const {
204 boost::python::tuple result =
205 boost::python::make_tuple(a.first, a.second);
206 return boost::python::incref(result.ptr());
208 PyTypeObject *get_pytype() {
209 return &PyTuple_Type;
213 PXR_NAMESPACE_CLOSE_SCOPE
215 #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.