| 602 | } |
| 603 | |
| 604 | IECore::DataPtr data( const OIIO::ParamValue &value ) |
| 605 | { |
| 606 | OIIO::TypeDesc type = value.type(); |
| 607 | switch( type.basetype ) |
| 608 | { |
| 609 | case TypeDesc::CHAR : |
| 610 | { |
| 611 | if ( type.aggregate == TypeDesc::SCALAR ) |
| 612 | { |
| 613 | return extractScalarData<char>( value ); |
| 614 | } |
| 615 | return nullptr; |
| 616 | } |
| 617 | case TypeDesc::UCHAR : |
| 618 | { |
| 619 | if ( type.aggregate == TypeDesc::SCALAR ) |
| 620 | { |
| 621 | return extractScalarData<unsigned char>( value ); |
| 622 | } |
| 623 | return nullptr; |
| 624 | } |
| 625 | case TypeDesc::STRING : |
| 626 | { |
| 627 | if ( type.aggregate == TypeDesc::SCALAR ) |
| 628 | { |
| 629 | if ( type.arraylen == 0 ) |
| 630 | { |
| 631 | return new StringData( static_cast<const ustring *>( value.data() )->string() ); |
| 632 | } |
| 633 | else |
| 634 | { |
| 635 | const ustring *typedData = static_cast<const ustring *>( value.data() ); |
| 636 | |
| 637 | StringVectorDataPtr vectorData = new StringVectorData(); |
| 638 | auto &writable = vectorData->writable(); |
| 639 | writable.resize( type.arraylen ); |
| 640 | for (int i = 0; i < type.arraylen; ++i) |
| 641 | { |
| 642 | writable[i] = typedData[i].string(); |
| 643 | } |
| 644 | return vectorData; |
| 645 | } |
| 646 | } |
| 647 | return nullptr; |
| 648 | } |
| 649 | case TypeDesc::USHORT : |
| 650 | { |
| 651 | if ( type.aggregate == TypeDesc::SCALAR ) |
| 652 | { |
| 653 | return extractScalarData<unsigned short>( value ); |
| 654 | } |
| 655 | return nullptr; |
| 656 | } |
| 657 | case TypeDesc::SHORT : |
| 658 | { |
| 659 | if ( type.aggregate == TypeDesc::SCALAR ) |
| 660 | { |
| 661 | return extractScalarData<short>( value ); |