void SaveFile::Serialize(string_t &str) { string_t::size_type len = str.length(); Serialize(len); if( len ) { if( loading() ) { std::vector<string_t::value_type> buffer(len); SerializeArray(&*buffer.begin(), len); str.resize(0); str.reserve(len); str.insert(str.begin(), buffer.begin(), buffer.end()); } else { SerializeArray(const_cast<string_t::value_type*>(str.data()), len); } } }
uint64_t ExprFrame::GetOrSerializeArray(const Array *array) { ExprSerializer::ArrayMap::iterator it = s_.serialized_arrays_.find(array); if (it != s_.serialized_arrays_.end()) { return it->second; } uint64_t result = SerializeArray(array); s_.serialized_arrays_.insert(std::make_pair(array, result)); return result; }
//---------------------------------------------------------------------------------------------- int ObjectSerializer::SerializeType(char* pMem, TypeNode* pType, fstream& pen) { switch (pType->Type) { case DTYPE_Array: return SerializeArray(pMem, pType, pen); case DTYPE_String: return SerializeString(pMem, pType, pen); case DTYPE_Vector: return SerializeContainerVector((ISerializable*)pMem, pType, pen); case DTYPE_Map: return SerializeContainerMap((ISerializable*)pMem, pType, pen); case DTYPE_Set: return SerializeContainerSet((ISerializable*)pMem, pType, pen); case DTYPE_Pair: return SerializePair((ISerializable*)pMem, pType, pen); case DTYPE_UserDefined: { string fullName = pType->FullName(); if (pType->Indirection) fullName.erase(fullName.size() - 1, 1); _ASSERTE(m_typeTable.find(fullName) != m_typeTable.end()); return SerializeUserDefinedType((ISerializable*)pMem, m_typeTable[fullName].TypeGraph, pType->Indirection, pen); } case DTYPE_Bool: case DTYPE_Char: case DTYPE_Short: case DTYPE_Int: case DTYPE_Unsigned: case DTYPE_Float: case DTYPE_Double: return SerializeBasicType(pMem, pType, pen); } // should not reach here _ASSERTE(false); return 0; }
} }; const auto pushReplyToMsgId = [&]( const QByteArray &label = "reply_to_message_id") { if (message.replyToMsgId) { push(label, message.replyToMsgId); } }; const auto pushUserNames = [&]( const std::vector<int32> &data, const QByteArray &label = "members") { auto list = std::vector<QByteArray>(); for (const auto userId : data) { list.push_back(wrapUserName(userId)); } pushBare(label, SerializeArray(context, list)); }; const auto pushActor = [&] { pushFrom("actor"); }; const auto pushAction = [&](const QByteArray &action) { push("action", action); }; const auto pushTTL = [&]( const QByteArray &label = "self_destruct_period_seconds") { if (const auto ttl = message.media.ttl) { push(label, ttl); } }; using SkipReason = Data::File::SkipReason;
void CDialogSession::Serialize(TSerialize ser) { //IEntitySystem* m_pEntitySystem; ctor //CDialogSystem* m_pDS; ctor //const CDialogScript* m_pScript; ctor //TIdToEntityMap m_idToEntityMap; SetActor //TListenerVec m_listenerVec; cleared //TActorContextMap m_actorContextMap; SetActor //CDialogSystem::SessionID m_sessionID; ctor //string m_debugName; ctor //CDialogScript::SActorSet m_actorSet; ctor(=0) then SetActor //float m_curTime; ctor 0 //float m_nextTimeDelay; ctor 0 //int m_curScriptLine; ctor -1 //int m_nextScriptLine; ctor -1 //unsigned int m_bPlaying : 1; ctor false //unsigned int m_bValidated : 1; ctor false //unsigned int m_bOK : 1; ctor false //unsigned int m_bHaveSchedule: 1; ctor false bool playing = m_bPlaying; ser.Value("m_bPlaying", playing); ser.Value("m_curScriptLine", m_curScriptLine); ser.Value("m_playerAwareAngle", m_playerAwareAngle); ser.Value("m_playerAwareDistance", m_playerAwareDistance); ser.Value("m_playerAwareGraceTime", m_playerAwareGraceTime); ser.Value("m_aiBehaviourMode", m_aiBehaviourMode); ser.Value("m_alertnessInterruptMode", *(alias_cast<int*>(&m_alertnessInterruptMode))); // IdToEntityMap if (ser.IsWriting()) { ser.Value("m_idToEntityMap", m_idToEntityMap); } else { TIdToEntityMap idmap; ser.Value("m_idToEntityMap", idmap); DiaLOG::Log(DiaLOG::eAlways, "CDialogSession::Serialize: %s was playing=%d --> ID2EntityMap", GetDebugName(), playing); TIdToEntityMap::iterator iter = idmap.begin(); TIdToEntityMap::iterator end = idmap.end(); while (iter != end) { DiaLOG::Log(DiaLOG::eAlways, "ID %d -> Entity %d", iter->first, iter->second); ++iter; } m_idToEntityMap = idmap; } // Serialize actor flags if (ser.IsReading()) { for (int i=0; i<CDialogScript::MAX_ACTORS; ++i) m_actorFlags[i] = DEFAULT_ACTOR_FLAGS; } if (!m_idToEntityMap.empty()) { static const size_t maxCount = sizeof(m_actorFlags)/sizeof(*m_actorFlags); assert (m_idToEntityMap.size() <= maxCount); const uint32 count = m_idToEntityMap.size() < maxCount ? m_idToEntityMap.size() : maxCount; SerializeArray(ser, "m_actorFlags", m_actorFlags, count); } }