void ObjectDynArrayData::Deserialize( ArchiveT& archive ) { // if we are referring to a real field, clear its contents m_Data->Clear(); archive.DeserializeArray( *m_Data ); }
void SimpleObjectSortedMapData< KeyT, CompareKeyT, AllocatorT >::Deserialize( ArchiveT& archive ) { DynArray< ObjectPtr > components; archive.DeserializeArray( components, ArchiveFlags::Sparse ); size_t componentCount = components.GetSize(); if ( componentCount % 2 != 0 ) { throw Reflect::DataFormatException( TXT( "Unmatched map objects" ) ); } // if we are referring to a real field, clear its contents m_Data->Clear(); m_Data->Reserve( componentCount / 2 ); DynArray< ObjectPtr >::Iterator itr = components.Begin(); DynArray< ObjectPtr >::Iterator end = components.End(); while ( itr != end ) { Data* key = SafeCast< Data >( *itr ); ++itr; Object* value = *itr; ++itr; if ( key ) // The object value can be null, so don't check it here. { KeyT k; Data::GetValue( key, k ); (*m_Data)[ k ] = value; } } }
void SimpleObjectStlMapData<KeyT>::Deserialize(ArchiveT& archive) { std::vector< ObjectPtr > components; archive.DeserializeArray(components, ArchiveFlags::Sparse); if (components.size() % 2 != 0) { throw Reflect::DataFormatException( TXT( "Unmatched map objects" ) ); } // if we are referring to a real field, clear its contents m_Data->clear(); std::vector< ObjectPtr >::iterator itr = components.begin(); std::vector< ObjectPtr >::iterator end = components.end(); for ( ; itr != end; ++itr ) { Data* key = SafeCast<Data>(*itr); Object* value = *(++itr); if ( key ) // The object value can be null, so don't check it here. { KeyT k; Data::GetValue( key, k ); (*m_Data)[ k ] = value; } } }
void SimpleObjectSortedMapData< KeyT, CompareKeyT, AllocatorT >::Serialize( ArchiveT& archive ) { DynArray< ObjectPtr > components; components.Reserve( m_Data->GetSize() * 2 ); { DataType::ConstIterator itr = m_Data->Begin(); DataType::ConstIterator end = m_Data->End(); for ( ; itr != end; ++itr ) { ObjectPtr elem = Registry::GetInstance()->CreateInstance( Reflect::GetDataClass< KeyT >() ); Data* ser = AssertCast< Data >( elem.Ptr() ); ser->ConnectData( const_cast< KeyT* >( &itr->First() ) ); HELIUM_VERIFY( components.New( ser ) ); HELIUM_VERIFY( components.New( itr->Second() ) ); } } archive.SerializeArray( components ); { DynArray< ObjectPtr >::Iterator itr = components.Begin(); DynArray< ObjectPtr >::Iterator end = components.End(); for ( ; itr != end; ++itr ) { Data* ser = AssertCast< Data >( *itr ); ser->Disconnect(); ++itr; // Skip over the object reference. // might be useful to cache the data object here } } }
void SimpleObjectStlMapData<KeyT>::Serialize(ArchiveT& archive) { std::vector< ObjectPtr > components; components.resize(m_Data->size() * 2); { DataType::const_iterator itr = m_Data->begin(); DataType::const_iterator end = m_Data->end(); for ( int i = 0; itr != end; ++itr ) { ObjectPtr elem = Registry::GetInstance()->CreateInstance( Reflect::GetDataClass<KeyT>() ); Data* ser = AssertCast<Data>(elem.Ptr()); ser->ConnectData((void*)&(itr->first)); components[i++] = ser; components[i++] = itr->second; } } archive.SerializeArray( components ); { std::vector< ObjectPtr >::iterator itr = components.begin(); std::vector< ObjectPtr >::iterator end = components.end(); for ( ; itr != end; ++itr ) { Data* ser = AssertCast<Data>(*itr); ser->Disconnect(); ++itr; // might be useful to cache the data object here } } }
void SimpleSortedSetData< KeyT, CompareKeyT, AllocatorT >::Serialize( ArchiveT& archive ) { DynArray< ObjectPtr > components; components.Reserve( m_Data->GetSize() ); { DataType::ConstIterator itr = m_Data->Begin(); DataType::ConstIterator end = m_Data->End(); for ( ; itr != end; ++itr ) { ObjectPtr dataElem = Registry::GetInstance()->CreateInstance( Reflect::GetDataClass< KeyT >() ); // downcast to data type Data* dataSer = AssertCast< Data >( dataElem ); // connect to our map data memory address dataSer->ConnectData( const_cast< KeyT* >( &( *itr ) ) ); // serialize to the archive stream HELIUM_VERIFY( components.New( dataSer ) ); } } archive.SerializeArray( components ); DynArray< ObjectPtr >::Iterator itr = components.Begin(); DynArray< ObjectPtr >::Iterator end = components.End(); for ( ; itr != end; ++itr ) { Data* ser = AssertCast< Data >( *itr ); ser->Disconnect(); // might be useful to cache the data object here } }
void ObjectStlSetData::Serialize(ArchiveT& archive) { std::vector< ObjectPtr > components; DataType::const_iterator itr = m_Data->begin(); DataType::const_iterator end = m_Data->end(); for ( ; itr != end; ++itr ) { components.push_back(*itr); } archive.SerializeArray( components ); }
void StructureDynArrayData::Serialize( ArchiveT& archive ) { const Structure *structure = GetInternalStructure(); DynArray< ObjectPtr > components; components.Resize( structure->m_DynArrayAdapter->GetSize(GetInternalPtr(structure)) ); for (size_t i = 0; i < components.GetSize(); ++i) { components[i] = structure->m_DynArrayAdapter->GetItem(GetInternalPtr(structure), i, m_Instance, m_Field); } archive.SerializeArray( components ); }
void ObjectStlSetData::Deserialize(ArchiveT& archive) { std::vector< ObjectPtr > components; archive.DeserializeArray(components); // if we are referring to a real field, clear its contents m_Data->clear(); std::vector< ObjectPtr >::const_iterator itr = components.begin(); std::vector< ObjectPtr >::const_iterator end = components.end(); for ( ; itr != end; ++itr ) { m_Data->insert(*itr); } }
void StructureDynArrayData::Deserialize( ArchiveT& archive ) { const Structure *structure = GetInternalStructure(); DynArray< ObjectPtr > components; archive.DeserializeArray(components); // if we are referring to a real field, clear its contents structure->m_DynArrayAdapter->Resize(GetInternalPtr(structure), components.GetSize()); for (size_t i = 0; i < components.GetSize(); ++i) { Data* data = SafeCast<Data>(components[i]); structure->m_DynArrayAdapter->SetItem(GetInternalPtr(structure), i, data, m_Instance, m_Field); } }
void SimpleSortedSetData< KeyT, CompareKeyT, AllocatorT >::Deserialize( ArchiveT& archive ) { DynArray< ObjectPtr > components; archive.DeserializeArray( components ); // if we are referring to a real field, clear its contents m_Data->Clear(); m_Data->Reserve( components.GetSize() ); DynArray< ObjectPtr >::Iterator itr = components.Begin(); DynArray< ObjectPtr >::Iterator end = components.End(); for ( ; itr != end; ++itr ) { Data* data = SafeCast< Data >( *itr ); if ( !data ) { throw LogisticException( TXT( "SortedSet value type has changed, this is unpossible" ) ); } KeyT k; Data::GetValue( data, k ); m_Data->Insert( k ); } }
void ObjectDynArrayData::Serialize( ArchiveT& archive ) { archive.SerializeArray( *m_Data ); }