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); }
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); }
bool LLBC_Variant::DeSerialize(LLBC_Stream &stream) { BecomeNil(); if (!stream.Read(_holder.type)) { return false; } if (IsNil()) { return true; } if (IsRaw()) { if (!stream.Read(_holder.raw.uint64Val)) { _holder.type = LLBC_VariantType::VT_NIL; return false; } } else if (IsStr()) { if (!stream.Read(_holder.str)) { _holder.type = LLBC_VariantType::VT_NIL; return false; } } else if (IsDict()) { uint32 count = 0; if (!stream.Read(count)) { _holder.type = LLBC_VariantType::VT_NIL; return false; } if (count == 0) { return true; } _holder.dict = new Dict; for (uint32 i = 0; i < count; i ++) { LLBC_Variant key; LLBC_Variant val; if (!stream.Read(key) || !stream.Read(val)) { LLBC_XDelete(_holder.dict); _holder.type = LLBC_VariantType::VT_NIL; return false; } _holder.dict->insert(std::make_pair(key, val)); } return true; } return false; }