binding for get method
| 299 | |
| 300 | /// binding for get method |
| 301 | static data_type |
| 302 | get( CompoundData &x, PyObject *i, PyObject *v ) |
| 303 | { |
| 304 | key_type key = convertKey( x, i ); |
| 305 | const CompoundDataMap &xData = x.readable(); |
| 306 | CompoundDataMap::const_iterator value = xData.find( key ); |
| 307 | if ( value == xData.end() ) |
| 308 | { |
| 309 | extract<data_type> elem( v ); |
| 310 | if ( elem.check() ) |
| 311 | { |
| 312 | return elem(); |
| 313 | } |
| 314 | else |
| 315 | { |
| 316 | PyErr_SetString( PyExc_TypeError, "Invalid parameter" ); |
| 317 | throw_error_already_set(); |
| 318 | } |
| 319 | return data_type(); |
| 320 | } |
| 321 | // return the value from the map |
| 322 | return value->second; |
| 323 | } |
| 324 | |
| 325 | |
| 326 | /// binding for setdefault method |