Esempio n. 1
0
void ObjectDynArrayData::Deserialize( ArchiveT& archive )
{
    // if we are referring to a real field, clear its contents
    m_Data->Clear();

    archive.DeserializeArray( *m_Data );
}
Esempio n. 2
0
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;
        }
    }
}
Esempio n. 3
0
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;
        }
    }
}
Esempio n. 4
0
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);
    }
}
Esempio n. 5
0
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);
    }
}
Esempio n. 6
0
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 );
    }
}