24 #ifndef PXR_USD_SDF_PY_CHILDREN_PROXY_H
25 #define PXR_USD_SDF_PY_CHILDREN_PROXY_H
35 #include <hboost/python.hpp>
36 #include <hboost/python/slice.hpp>
40 template <
class _View>
60 _proxy(view, type, permission)
67 return _proxy == other._proxy;
72 return _proxy != other._proxy;
77 typedef typename View::const_iterator _view_const_iterator;
82 return hboost::python::make_tuple(i->first, i->second);
93 struct _ExtractValue {
105 _owner(hboost::python::
extract<const
This&>(object)()._proxy)
107 _cur = _owner.begin();
110 _Iterator<E> GetCopy()
const
117 if (_cur == _owner.end()) {
128 _const_iterator _cur;
133 TfPyWrapOnce<This>(&This::_Wrap);
138 using namespace hboost::python;
143 class_<This>(
name.c_str(), no_init)
169 class_<_Iterator<_ExtractItem> >
170 ((
name +
"_Iterator").c_str(), no_init)
171 .def(
"__iter__", &This::template _Iterator<_ExtractItem>::GetCopy)
172 .def(
"__next__", &This::template _Iterator<_ExtractItem>::GetNext)
175 class_<_Iterator<_ExtractKey> >
176 ((
name +
"_KeyIterator").c_str(), no_init)
177 .def(
"__iter__", &This::template _Iterator<_ExtractKey>::GetCopy)
178 .def(
"__next__", &This::template _Iterator<_ExtractKey>::GetNext)
181 class_<_Iterator<_ExtractValue> >
182 ((
name +
"_ValueIterator").c_str(), no_init)
183 .def(
"__iter__", &This::template _Iterator<_ExtractValue>::GetCopy)
184 .def(
"__next__", &This::template _Iterator<_ExtractValue>::GetNext)
191 ArchGetDemangled<View>();
200 const View& _GetView()
const
213 if (! _proxy.
empty()) {
214 _const_iterator i = _proxy.
begin(),
n = _proxy.
end();
227 return _proxy.
size();
232 _view_const_iterator i = _GetView().find(key);
233 if (i == _GetView().
end()) {
245 return _GetView()[
index];
251 _proxy._GetType().c_str());
254 void _SetItemBySlice(
const hboost::python::slice& slice,
263 _proxy._Copy(values);
267 void _DelItemByKey(
const key_type& key)
269 if (_GetView().
find(key) == _GetView().
end()) {
275 void _DelItemByIndex(
int index)
277 _proxy._Erase(_GetView().key(_GetItemByIndex(index)));
287 _proxy._Insert(value, _proxy.
size());
290 void _InsertItemByIndex(
int index,
const mapped_type& value)
293 index = index < (
int)_proxy.
size()
297 _proxy._Insert(value, index);
302 _view_const_iterator i = _GetView().find(key);
304 hboost::python::object(*i);
310 _view_const_iterator i = _GetView().find(key);
312 hboost::python::object(*i);
315 bool _HasKey(
const key_type& key)
const
317 return _GetView().find(key) != _GetView().end();
322 return _GetView().find(value) != _GetView().end();
328 return _Iterator<_ExtractItem>(
x);
334 return _Iterator<_ExtractKey>(
x);
340 return _Iterator<_ExtractValue>(
x);
344 hboost::python::list _Get()
const
346 hboost::python::list
result;
347 for (_const_iterator i = _proxy.
begin(),
n = _proxy.
end(); i !=
n; ++i){
348 result.append(E::Get(i));
353 int _FindIndexByKey(
const key_type& key)
const
356 return i == _GetView().size() ? -1 : i;
359 int _FindIndexByValue(
const mapped_type& value)
const
362 return i == _GetView().size() ? -1 : i;
373 #endif // PXR_USD_SDF_PY_CHILDREN_PROXY_H
typedef int(APIENTRYP RE_PFNGLXSWAPINTERVALSGIPROC)(int)
_Iterator< const This *, _inner_iterator, value_type > const_iterator
SdfPyChildrenProxy< View > This
GLsizei const GLchar *const * string
Proxy::mapped_vector_type mapped_vector_type
bool operator!=(const This &other) const
Proxy::size_type size_type
TF_API void TfPyThrowStopIteration(const char *msg)
**But if you need a result
bool operator==(const This &other) const
View::size_type size_type
std::string TfPyRepr(T const &t)
OIIO_FORCEINLINE bool extract(const vbool4 &a)
static const int CanErase
SdfPyChildrenProxy(const Proxy &proxy)
GLuint const GLchar * name
std::vector< mapped_type > mapped_vector_type
View::value_type mapped_type
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
GLenum GLsizei GLsizei GLint * values
#define PXR_NAMESPACE_CLOSE_SCOPE
TF_API void TfPyThrowIndexError(const char *msg)
TF_API int64_t TfPyNormalizeIndex(int64_t index, uint64_t size, bool throwError=false)
Proxy::mapped_type mapped_type
SIM_API const UT_StringHolder distance
static const int CanInsert
SdfChildrenProxy< View > Proxy
TF_API bool TfPyIsNone(hboost::python::object const &obj)
Return true iff obj is None.
TF_API std::string TfStringReplace(const std::string &source, const std::string &from, const std::string &to)
SdfPyChildrenProxy(const View &view, const std::string &type, int permission=Proxy::CanSet|Proxy::CanInsert|Proxy::CanErase)
FMT_CONSTEXPR auto find(Ptr first, Ptr last, T value, Ptr &out) -> bool
PcpNodeRef_ChildrenIterator begin(const PcpNodeRef::child_const_range &r)
Support for range-based for loops for PcpNodeRef children ranges.