void StlStringStlVectorData::Serialize(ArchiveBinary& archive) { uint32_t count = (uint32_t)m_Data->size(); archive.GetStream().Write( &count ); for (size_t i=0; i<m_Data->size(); i++) { archive.GetStream().WriteString( m_Data->at( i ) ); } }
void BitfieldData::Deserialize(ArchiveBinary& archive) { const Enumeration* enumeration = NULL; if ( m_Field ) { enumeration = ReflectionCast< Enumeration >( m_Field->m_Type ); } else { HELIUM_BREAK(); // not really supported yet } uint32_t count = 0; archive.GetStream().Read(&count); std::vector< tstring > strs; strs.reserve( count ); while ( count-- > 0 ) { tstring str; archive.GetStream().ReadString( str ); strs.push_back( str ); } tstring str; std::vector< tstring >::const_iterator itr = strs.begin(); std::vector< tstring >::const_iterator end = strs.end(); for ( ; itr != end; ++itr ) { if (itr != strs.begin()) { str += TXT("|"); } str += *itr; } if (enumeration && !enumeration->GetBitfieldValue(strs, *m_Data)) { Log::Debug( TXT( "Unable to deserialize bitfield %s values '%s'\n" ), enumeration->m_Name, str.c_str() ); } else { m_String = str; } if (enumeration == NULL) { throw Reflect::TypeInformationException( TXT( "Missing type information" ) ); } }
void StlStringStlVectorData::Deserialize(ArchiveBinary& archive) { m_Data->clear(); uint32_t count = (uint32_t)m_Data->size(); archive.GetStream().Read( &count ); m_Data->resize(count); for ( uint32_t i=0; i<count; i++ ) { archive.GetStream().ReadString( m_Data->at( i ) ); } }
void TypeIDData::Deserialize(ArchiveBinary& archive) { uint32_t crc; archive.GetStream().Read(&crc); const Type* type = Registry::GetInstance()->GetType( crc ); if ( type ) { *m_Data = type; } }
void BitfieldData::Serialize(ArchiveBinary& archive) { const Enumeration* enumeration = NULL; if ( m_Field ) { enumeration = ReflectionCast< Enumeration >( m_Field->m_Type ); } else { HELIUM_BREAK(); // not really supported yet } if (enumeration) { std::vector< tstring > strs; if (!enumeration->GetBitfieldStrings( *m_Data, strs )) { throw Reflect::TypeInformationException( TXT( "Unable to serialize bitfield '%s', value %d" ), enumeration->m_Name, *m_Data ); } uint32_t count = (uint32_t)strs.size(); archive.GetStream().Write(&count); std::vector< tstring >::const_iterator itr = strs.begin(); std::vector< tstring >::const_iterator end = strs.end(); for ( ; itr != end; ++itr ) { archive.GetStream().WriteString( *itr ); } } if (enumeration == NULL) { throw Reflect::TypeInformationException( TXT( "Missing type information" ) ); } }
void TypeIDData::Serialize(ArchiveBinary& archive) { const Type* type = *m_Data; uint32_t crc = type ? Crc32( type->m_Name ) : BeginCrc32(); archive.GetStream().Write(&crc); }
void SimpleData<T>::Deserialize(ArchiveBinary& archive) { T* data = m_Data; archive.GetStream().Read( data ); }
void SimpleData<T>::Serialize(ArchiveBinary& archive) { const T* data = m_Data; archive.GetStream().Write( data ); }
void SimpleStlVectorData<T>::Deserialize(ArchiveBinary& archive) { // if we are referring to a real field, clear its contents m_Data->clear(); ReadVector( *m_Data, archive.GetStream() ); }
void SimpleStlVectorData<T>::Serialize(ArchiveBinary& archive) { WriteVector( *m_Data, archive.GetStream() ); }