void FormatData::load( LoadContextPtr context ) { Data::load( context ); assert( ( sizeof( FormatData::ValueType ) / sizeof( FormatData::BaseType ) ) == 4 ); const IndexedIO *container; FormatData::BaseType *p = FormatData::baseWritable(); try { container = context->rawContainer(); container->read( "window", (int*&)p, 4 ); } catch( ... ) { unsigned int v = 0; container = context->container( staticTypeName(), v ); container->read( "window", (int*&)p, 4 ); } const IndexedIO *rawContainer = context->rawContainer(); double aspect = 1.; rawContainer->read( "aspect", aspect ); writable().setPixelAspect( aspect ); }
void CompoundDataBase::load( LoadContextPtr context ) { Data::load( context ); unsigned int v = 0; ConstIndexedIOPtr container = nullptr; try { container = context->container( staticTypeName(), v ); } catch( const IOException &e ) { // probably a file with CORTEX_MAJOR_VERSION < 5, get the // data from CompoundData container instead. container = context->container( "CompoundData", v ); } CompoundDataMap &m = writable(); m.clear(); container = container->subdirectory( g_membersEntry ); IndexedIO::EntryIDList memberNames; container->entryIds( memberNames ); IndexedIO::EntryIDList::const_iterator it; for( it=memberNames.begin(); it!=memberNames.end(); it++ ) { m[*it] = context->load<Data>( container.get(), *it ); } }
void DateTimeData::load( LoadContextPtr context ) { Data::load( context ); const IndexedIO *container = context->rawContainer(); std::string t; container->read( g_valueEntry, t ); try { writable() = boost::posix_time::from_iso_string( t ); } catch ( boost::bad_lexical_cast ) { /// Do these checks here instead of first as they're likely to be the least-used cases. if ( t == "not-a-date-time" ) { writable() = boost::posix_time::not_a_date_time; } else if ( t == "+infinity" ) { writable() = boost::posix_time::pos_infin; } else if ( t == "-infinity" ) { writable() = boost::posix_time::neg_infin; } else { throw; } } }
void ParameterisedProcedural::load( LoadContextPtr context ) { VisibleRenderable::load( context ); unsigned int v = m_ioVersion; ConstIndexedIOPtr container = context->container( staticTypeName(), v ); m_parameters->setValue( context->load<Object>( container, g_parametersEntry ) ); }
void Options::load( LoadContextPtr context ) { PreWorldRenderable::load( context ); unsigned int v = m_ioVersion; ConstIndexedIOPtr container = context->container( staticTypeName(), v ); m_options = context->load<CompoundData>( container.get(), g_optionsEntry ); }
void MatrixTransform::load( LoadContextPtr context ) { Transform::load( context ); unsigned int v = m_ioVersion; ConstIndexedIOPtr container = context->container( staticTypeName(), v ); float *f = matrix.getValue(); container->read( g_matrixEntry, f, 16 ); }
void Shader::load( LoadContextPtr context ) { StateRenderable::load( context ); unsigned int v = m_ioVersion; ConstIndexedIOPtr container = context->container( staticTypeName(), v ); container->read( g_nameEntry, m_name ); container->read( g_typeEntry, m_type ); m_parameters = context->load<CompoundData>( container.get(), g_parametersEntry ); }
void TimeCodeData::load( LoadContextPtr context ) { Data::load( context ); const IndexedIO *container = context->rawContainer(); unsigned data[2]; unsigned *dataPtr = &data[0]; container->read( g_valueEntry, dataPtr, 2 ); Imf::TimeCode &timeCode = writable(); timeCode.setTimeAndFlags( data[0] ); timeCode.setUserData( data[1] ); }
void MatrixMotionTransform::load( LoadContextPtr context ) { Transform::load( context ); unsigned int v = m_ioVersion; ConstIndexedIOPtr container = context->container( staticTypeName(), v ); container = container->subdirectory( g_snapshotsEntry ); m_snapshots.clear(); IndexedIO::EntryIDList names; container->entryIds( names, IndexedIO::Directory ); IndexedIO::EntryIDList::const_iterator it; for( it=names.begin(); it!=names.end(); it++ ) { ConstIndexedIOPtr snapshotContainer = container->subdirectory( *it ); float t; snapshotContainer->read( g_timeEntry, t ); M44f m; float *f = m.getValue(); snapshotContainer->read( g_matrixEntry, f, 16 ); m_snapshots[t] = m; } }
void ObjectVector::load( LoadContextPtr context ) { Object::load( context ); unsigned int v = m_ioVersion; ConstIndexedIOPtr container = context->container( staticTypeName(), v ); unsigned int size = 0; container->read( g_sizeEntry, size ); m_members.resize( size ); std::fill( m_members.begin(), m_members.end(), (IECore::Object*)0 ); ConstIndexedIOPtr ioMembers = container->subdirectory( g_membersEntry ); IndexedIO::EntryIDList l; ioMembers->entryIds(l); for( IndexedIO::EntryIDList::const_iterator it=l.begin(); it!=l.end(); it++ ) { MemberContainer::size_type i = boost::lexical_cast<MemberContainer::size_type>( (*it).value() ); m_members[i] = context->load<Object>( ioMembers, *it ); } }
void PathMatcherData::load( LoadContextPtr context ) { Data::load( context ); unsigned int v = g_ioVersion; ConstIndexedIOPtr container = context->container( staticTypeName(), v ); const IndexedIO::Entry stringsEntry = container->entry( "strings" ); std::vector<InternedString> strings; strings.resize( stringsEntry.arrayLength() ); InternedString *stringsPtr = strings.data(); container->read( "strings", stringsPtr, stringsEntry.arrayLength() ); const IndexedIO::Entry pathLengthsEntry = container->entry( "pathLengths" ); std::vector<unsigned int> pathLengths; pathLengths.resize( pathLengthsEntry.arrayLength() ); unsigned int *pathLengthsPtr = pathLengths.data(); container->read( "pathLengths", pathLengthsPtr, pathLengthsEntry.arrayLength() ); const IndexedIO::Entry exactMatchesEntry = container->entry( "exactMatches" ); std::vector<unsigned char> exactMatches; exactMatches.resize( exactMatchesEntry.arrayLength() ); unsigned char *exactMatchesPtr = exactMatches.data(); container->read( "exactMatches", exactMatchesPtr, exactMatchesEntry.arrayLength() ); std::vector<InternedString> path; for( size_t i = 0, e = pathLengths.size(); i < e; ++i ) { path.resize( pathLengths[i] ); if( pathLengths[i] ) { path.back() = *stringsPtr++; } if( exactMatches[i] ) { writable().addPath( path ); } } }
void TypedData< TimePeriod >::load( LoadContextPtr context ) { Data::load( context ); unsigned int v = 0; ConstIndexedIOPtr container = context->container( staticTypeName(), v ); std::string beginStr; container->read( g_beginEntry, beginStr ); boost::posix_time::ptime begin; try { begin = boost::posix_time::from_iso_string( beginStr ); } catch ( boost::bad_lexical_cast ) { /// Do these checks here instead of first as they're likely to be the least-used cases. if ( beginStr == "not-a-date-time" ) { begin = boost::posix_time::not_a_date_time; } else if ( beginStr == "+infinity" ) { begin = boost::posix_time::pos_infin; } else if ( beginStr == "-infinity" ) { begin = boost::posix_time::neg_infin; } else { throw; } } std::string endStr; container->read( g_endEntry, endStr ); boost::posix_time::ptime end; try { end = boost::posix_time::from_iso_string( endStr ); } catch ( boost::bad_lexical_cast ) { /// Do these checks here instead of first as they're likely to be the least-used cases. if ( endStr == "not-a-date-time" ) { end = boost::posix_time::not_a_date_time; } else if ( endStr == "+infinity" ) { end = boost::posix_time::pos_infin; } else if ( endStr == "-infinity" ) { end = boost::posix_time::neg_infin; } else { throw; } } writable() = boost::posix_time::time_period( begin, end ); }