\todo Move outside template so that it specialises the repr() in IECoreBinding.h
| 429 | |
| 430 | /// \todo Move outside template so that it specialises the repr() in IECoreBinding.h |
| 431 | static std::string repr( CompoundData &x ) |
| 432 | { |
| 433 | std::stringstream s; |
| 434 | |
| 435 | s << "IECore." << x.typeName() << "("; |
| 436 | |
| 437 | bool added = false; |
| 438 | for ( |
| 439 | CompoundDataMap::const_iterator it = x.readable().begin(); |
| 440 | it != x.readable().end(); |
| 441 | ++it ) |
| 442 | { |
| 443 | const std::string &key = it->first; |
| 444 | |
| 445 | object item( it->second ); |
| 446 | |
| 447 | if ( item.attr( "__repr__" ) != object() ) |
| 448 | { |
| 449 | std::string v = call_method< std::string >( item.ptr(), "__repr__" ); |
| 450 | |
| 451 | if ( !added ) |
| 452 | { |
| 453 | added = true; |
| 454 | s << "{"; |
| 455 | } |
| 456 | else |
| 457 | { |
| 458 | s << ","; |
| 459 | } |
| 460 | |
| 461 | s << "'"; |
| 462 | s << key; |
| 463 | s << "':"; |
| 464 | s << v; |
| 465 | } |
| 466 | } |
| 467 | |
| 468 | if ( added ) |
| 469 | { |
| 470 | s << "}"; |
| 471 | } |
| 472 | |
| 473 | s << ")"; |
| 474 | |
| 475 | return s.str(); |
| 476 | } |
| 477 | |
| 478 | protected: |
| 479 | /* |