24 #ifndef PXR_USD_SDF_PY_CHILDREN_VIEW_H
25 #define PXR_USD_SDF_PY_CHILDREN_VIEW_H
34 #include <hboost/python.hpp>
38 template <
class _View>
51 TfPyWrapOnce<View>(&This::_Wrap);
58 return hboost::python::make_tuple(x.key(i), *i);
69 struct _ExtractValue {
81 _owner(hboost::python::
extract<const
View&>(object)),
88 _Iterator<E> GetCopy()
const
112 using namespace hboost::python;
121 class_<View>(
name.c_str(), no_init)
122 .def(
"__repr__", &This::_GetRepr)
124 .def(
"__getitem__", &This::_GetItemByKey)
125 .def(
"__getitem__", &This::_GetItemByIndex)
126 .def(
"get", &This::_PyGet)
127 .def(
"__contains__", &This::_HasKey)
128 .def(
"__contains__", &This::_HasValue)
129 .def(
"__iter__", &This::_GetValueIterator)
130 .def(
"items", &This::_GetItemIterator)
131 .def(
"keys", &This::_GetKeyIterator)
132 .def(
"values", &This::_GetValueIterator)
133 .def(
"index", &This::_FindIndexByKey)
134 .def(
"index", &This::_FindIndexByValue)
139 class_<_Iterator<_ExtractItem> >
140 ((
name +
"_Iterator").c_str(), no_init)
141 .def(
"__iter__", &This::template _Iterator<_ExtractItem>::GetCopy)
142 .def(
"__next__", &This::template _Iterator<_ExtractItem>::GetNext)
145 class_<_Iterator<_ExtractKey> >
146 ((
name +
"_KeyIterator").c_str(), no_init)
147 .def(
"__iter__", &This::template _Iterator<_ExtractKey>::GetCopy)
148 .def(
"__next__", &This::template _Iterator<_ExtractKey>::GetNext)
151 class_<_Iterator<_ExtractValue> >
152 ((
name +
"_ValueIterator").c_str(), no_init)
153 .def(
"__iter__", &This::template _Iterator<_ExtractValue>::GetCopy)
154 .def(
"__next__", &This::template _Iterator<_ExtractValue>::GetNext)
161 ArchGetDemangled<ChildPolicy>() +
"_" +
162 ArchGetDemangled<Predicate>();
199 if (index >= x.size()) {
209 hboost::python::
object(*i);
214 return x.find(key) != x.end();
219 return x.find(value) != x.end();
225 return _Iterator<_ExtractItem>(
x);
231 return _Iterator<_ExtractKey>(
x);
237 return _Iterator<_ExtractValue>(
x);
241 static hboost::python::list _Get(
const View& x)
243 hboost::python::list
result;
245 result.append(E::Get(x, i));
250 static int _FindIndexByKey(
const View& x,
const key_type& key)
253 return i == x.size() ? -1 : i;
256 static int _FindIndexByValue(
const View& x,
const value_type& value)
259 return i == x.size() ? -1 : i;
265 #endif // PXR_USD_SDF_PY_CHILDREN_VIEW_H
View::ChildPolicy ChildPolicy
GLsizei const GLchar *const * string
View::const_iterator const_iterator
TF_API void TfPyThrowStopIteration(const char *msg)
**But if you need a result
View::value_type value_type
std::string TfPyRepr(T const &t)
OIIO_FORCEINLINE bool extract(const vbool4 &a)
View::Predicate Predicate
SdfPyWrapChildrenView< View > This
GLuint const GLchar * name
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
#define PXR_NAMESPACE_CLOSE_SCOPE
TF_API void TfPyThrowIndexError(const char *msg)
SIM_API const UT_StringHolder distance
TF_API std::string TfStringReplace(const std::string &source, const std::string &from, const std::string &to)
PcpNodeRef_ChildrenIterator begin(const PcpNodeRef::child_const_range &r)
Support for range-based for loops for PcpNodeRef children ranges.