Exemple #1
0
bool LLBC_Dictionary::DeSerializeInl(LLBC_Stream &s, bool extended)
{
    if (!_objFactory)
    {
        return false;
    }

    this->Clear();

    LLBC_STREAM_BEGIN_READ(s, bool, false);

    uint64 bucketSize = 0;
    LLBC_STREAM_READ(bucketSize);
    this->SetHashBucketSize(static_cast<size_type>(bucketSize));

    uint64 size = 0;
    LLBC_STREAM_READ(size);
    for (uint64 i = 0; i < size; i++)
    {
        uint8 intKeyFlag = 0;
        LLBC_STREAM_READ(intKeyFlag);

        if (intKeyFlag)
        {
            int intKey = 0;
            LLBC_STREAM_READ(intKey);

            LLBC_Object *o = _objFactory->CreateObject();
            if (!(!extended ? s.Read(*o) : s.ReadEx(*o)))
            {
                o->Release();
                return false;
            }

            this->Insert(intKey, o);
            o->Release();
        }
        else
        {
            LLBC_String strKey;
            LLBC_STREAM_READ(strKey);

            LLBC_Object *o = _objFactory->CreateObject();
            if (!(!extended ? s.Read(*o) : s.ReadEx(*o)))
            {
                o->Release();
                return false;
            }

            this->Insert(strKey, o);
            o->Release();
        }
    }

    LLBC_STREAM_END_READ_RET(true);
}
Exemple #2
0
bool LLBC_Array::DeSerializeInl(LLBC_Stream &s, bool extended)
{
    if (UNLIKELY(!_objFactory))
    {
        return false;
    }

    Clear();

    LLBC_STREAM_BEGIN_READ(s, bool, false);

    uint64 size = 0;
    LLBC_STREAM_READ(size);

    for (uint64 i = 0; i < size; i++)
    {
        LLBC_Object *o = _objFactory->CreateObject();
        if (!(!extended ? s.Read(*o) : s.ReadEx(*o)))
        {
            o->Release();
            Clear();

            return false;
        }

        PushBack(o);
        o->Release();
    }

    LLBC_STREAM_END_READ_RET(true);
}