MCPcopy Create free account
hub / github.com/ImageEngine/cortex / pop

Method pop

src/IECorePython/CompoundDataBinding.cpp:376–408  ·  view source on GitHub ↗

binding for pop method

Source from the content-addressed store, hash-verified

374
375 /// binding for pop method
376 static data_type
377 pop( CompoundData &x, PyObject *i, PyObject *v )
378 {
379 key_type key = convertKey( x, i );
380 const CompoundDataMap &xData = x.readable();
381 CompoundDataMap::const_iterator value = xData.find( key );
382 if ( value == xData.end() )
383 {
384 if ( v == Py_None )
385 {
386 PyErr_SetString( PyExc_KeyError, key );
387 throw_error_already_set();
388 }
389 extract<data_type> elem( v );
390 if ( elem.check() )
391 {
392 return elem();
393 }
394 else
395 {
396 PyErr_SetString( PyExc_TypeError, "Invalid parameter" );
397 throw_error_already_set();
398 }
399 return data_type();
400 }
401 // save the returning value.
402 data_type ret( value->second );
403 // delete it from the map
404 CompoundDataMap &writableX = x.writable();
405 CompoundDataMap::iterator writableValue = writableX.find( key );
406 writableX.erase( writableValue );
407 return ret;
408 }
409
410 /// binding for popitem method
411 static boost::python::tuple

Callers

nothing calls this directly

Calls 6

readableMethod · 0.80
findMethod · 0.45
endMethod · 0.45
checkMethod · 0.45
writableMethod · 0.45
eraseMethod · 0.45

Tested by

no test coverage detected