Esempio n. 1
0
void PathSerializer::Deserialize( Archive& archive )
{
    switch ( archive.GetType() )
    {
    case ArchiveTypes::XML:
        {
            ArchiveXML& xml (static_cast<ArchiveXML&>(archive));

            tstring buf;
            std::streamsize size = xml.GetStream().ElementsAvailable(); 
            buf.resize( (size_t)size );
            xml.GetStream().ReadBuffer( const_cast<tchar*>( buf.c_str() ), size );
            m_Data.Ref().Set( buf );
            break;
        }

    case ArchiveTypes::Binary:
        {
            ArchiveBinary& binary (static_cast<ArchiveBinary&>(archive));

            i32 index = -1;
            binary.GetStream().Read( &index ); 

            if ( index >= 0 )
            {
                const tstring& str ( binary.GetStrings().Get( index ) );

                m_Data.Ref().Set( str );
            }

            break;
        }
    }
}
Esempio n. 2
0
void TypeIDSerializer::Deserialize(Archive& archive)
{
    tstring str;

    switch (archive.GetType())
    {
    case ArchiveTypes::XML:
        {
            ArchiveXML& xml (static_cast<ArchiveXML&>(archive));

            std::streamsize size = xml.GetStream().ElementsAvailable(); 
            str.resize( (size_t)size );
            xml.GetStream().ReadBuffer(const_cast<tchar*>(str.c_str()), size);
            break;
        }

    case ArchiveTypes::Binary:
        {
            ArchiveBinary& binary (static_cast<ArchiveBinary&>(archive));

            i32 index;
            binary.GetStream().Read(&index); 
            str = binary.GetStrings().Get(index);
            break;
        }
    }

    const Reflect::Type* type = Reflect::Registry::GetInstance()->GetType( str );

    if ( type )
    {
        m_Data.Set( type->m_TypeID );
    }
}
Esempio n. 3
0
void PathSerializer::Serialize( Archive& archive ) const
{
    tstring data = m_Data.Get().Get();

    switch ( archive.GetType() )
    {
    case ArchiveTypes::XML:
        {
            ArchiveXML& xml (static_cast<ArchiveXML&>(archive));

            xml.GetStream() << data;
            break;
        }

    case ArchiveTypes::Binary:
        {
            ArchiveBinary& binary (static_cast<ArchiveBinary&>(archive));

            // get string pool index
            i32 index = binary.GetStrings().Insert( data );

            // write that index
            binary.GetStream().Write( &index ); 
            break;
        }
    }
}
Esempio n. 4
0
void TypeIDSerializer::Serialize(Archive& archive) const
{
    const Reflect::Type* type = Reflect::Registry::GetInstance()->GetType( m_Data.Get() );

    switch (archive.GetType())
    {
    case ArchiveTypes::XML:
        {
            ArchiveXML& xml (static_cast<ArchiveXML&>(archive));

            if ( type )
            {
                xml.GetStream() << "<![CDATA[" << type->m_ShortName << "]]>";
            }

            break;
        }

    case ArchiveTypes::Binary:
        {
            ArchiveBinary& binary (static_cast<ArchiveBinary&>(archive));

            i32 index = binary.GetStrings().Insert( type ? type->m_ShortName : TXT("") );
            binary.GetStream().Write(&index); 
            break;
        }
    }
}