void Serializer::Serialize (const string &name, const list <string> &stringList) { SerializeString (name); uint64 listSize = stringList.size(); Serialize (listSize); foreach (const string &item, stringList) SerializeString (item); }
Uint64 GetSerializedStringSize(std::string data) { Byte* p = nullptr; Uint64 size = SerializeString(data, data.size(), p); if (p != nullptr) delete p; return size; }
void URLParams::Serialize(nsAString& aValue) const { aValue.Truncate(); bool first = true; for (uint32_t i = 0, len = mParams.Length(); i < len; ++i) { if (first) { first = false; } else { aValue.Append('&'); } SerializeString(NS_ConvertUTF16toUTF8(mParams[i].mKey), aValue); aValue.Append('='); SerializeString(NS_ConvertUTF16toUTF8(mParams[i].mValue), aValue); } }
void Serializer::Serialize (const string &name, const ConstBufferPtr &data) { SerializeString (name); uint64 size = data.Size(); Serialize (size); DataStream->Write (data); }
//public: virtual wxOutputStream &NassiContinueBrick::Serialize(wxOutputStream &stream) { wxTextOutputStream out(stream); out << NASSI_BRICK_CONTINUE << _T('\n'); SerializeString(stream, *(GetTextByNumber(0)) ); if ( GetNext() != nullptr ) GetNext()->Serialize(stream); else out << NASSI_BRICK_ESC << _T('\n'); return stream; }
//public: virtual wxOutputStream &NassiInstructionBrick::Serialize(wxOutputStream &stream) { wxTextOutputStream out(stream); out << NASSI_BRICK_INSTRUCTION << _T('\n'); for (wxUint32 n = 0 ; n < 2 ; n++ ) SerializeString(stream,*GetTextByNumber(n)); if ( GetNext() != nullptr ) GetNext()->Serialize(stream); else out << NASSI_BRICK_ESC << _T('\n'); return stream; }
//public: virtual wxOutputStream &NassiBreakBrick::Serialize(wxOutputStream &stream) { wxTextOutputStream out(stream); out << NASSI_BRICK_BREAK << _T('\n'); SerializeString(stream, *(GetTextByNumber(0))); if ( GetNext() != (NassiBrick *)NULL ) GetNext()->Serialize(stream); else out << NASSI_BRICK_ESC << _T('\n'); return stream; }
//public: virtual wxOutputStream &NassiReturnBrick::Serialize(wxOutputStream &stream) { wxTextOutputStream out(stream); out << NASSI_BRICK_RETURN << _T('\n'); for (wxUint32 n = 0 ; n < 2 ; n++ ) SerializeString(stream, *(GetTextByNumber(n)) ); if ( GetNext() != (NassiBrick *)NULL ) GetNext()->Serialize(stream); else out << NASSI_BRICK_ESC << _T('\n'); return stream; }
wxString SearchTreeNode::Serialize(BasicSearchTree* tree,nSearchTreeNode node_id,bool withchildren) { wxString result,children,sparent,sdepth,slabelno,slabelstart,slabellen; SearchTreeLinkMap::iterator link; SearchTreeItemsMap::iterator item; sparent = U2S(m_Parent); sdepth = U2S(m_Depth); slabelno = U2S(m_Label); slabelstart = U2S(m_LabelStart); slabellen = U2S(m_LabelLen); result << _T(" <node id=\"") << node_id << _T("\" parent=\"") << sparent << _T("\""); result << _T(" depth=\"") << sdepth << _T("\" label=\""); result << slabelno << _T(',') << slabelstart << _T(',') << slabellen; result << _T("\">\n"); result << _T(" <items>\n"); for (item = m_Items.begin();item != m_Items.end();item++) { if (item->second) { result << _T(" <item depth=\"") << U2S(item->first) << _T("\" itemid=\"") << U2S(item->second) << _T("\"") << _T(" />\n"); } } result << _T(" </items>\n"); result << _T(" <children>\n"); for (link = m_Children.begin();link != m_Children.end();link++) { if (link->second) { result << _T(" <child char=\"") << SerializeString(wxString(link->first)) << _T("\" nodeid=\"") << U2S(link->second) << _T("\"") << _T(" />\n"); } } result << _T(" </children>\n"); result << _T(" </node>\n"); if (withchildren) { for (link = m_Children.begin();link != m_Children.end();link++) { if (link->second) { result << tree->GetNode(link->second,false)->Serialize(tree,link->second,true); } } } 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; }
int CpduStatus::sendGameNames(SOCKET sd) { type_ = PDU_Lounge_GameNames; length_ = PDU_HEADER_SIZE; char* buf = value_ + PDU_HEADER_SIZE; // Copy number of games to buffer u_int16_t numGames = CGame::GetNumGames(); u_int16_t* pint = (u_int16_t*)buf; *pint++ = htons(numGames); length_ += sizeof(numGames); // Copy game name strings to buffer GameIterator i = CGame::GetGames(); while (i.more()) { CGame& game = i.current(); // Put game type to buffer u_int16_t gameType = game.getGameSubType(); *pint++ = htons(gameType); buf = (char*)pint; // Put game name length & string to buffer const char* n = game.getGameName(); int l = n ? strlen(n) : 0; if (length_ + l >= MAXBUFFERSIZE) { Sys_LogError("CpduStatus: buffer size too small for game names!\n"); break; } int nameLength = SerializeString(buf, n); buf += nameLength; length_ += (sizeof(gameType) + nameLength); i.next(); pint = (u_int16_t*)buf; } stuffHeader(); return sendTo(sd); }
wxOutputStream &NassiWhileBrick::Serialize(wxOutputStream &stream) { wxTextOutputStream out(stream); out << NASSI_BRICK_WHILE << _T('\n'); for ( wxUint32 n = 0 ; n < 2 ; n++ ) SerializeString(stream, *(GetTextByNumber(n)) ); if ( GetChild(0) != nullptr ) GetChild(0)->Serialize(stream); else out << NASSI_BRICK_ESC << _T('\n'); if ( GetNext() != nullptr ) GetNext()->Serialize(stream); else out << NASSI_BRICK_ESC << _T('\n'); return stream; }
//public: virtual wxOutputStream &NassiSwitchBrick::Serialize(wxOutputStream &stream) { wxTextOutputStream out(stream); out << NASSI_BRICK_SWITCH << _T('\n'); wxUint32 k = nChilds; out << k << _T('\n'); for ( wxUint32 n = 0 ; n < 2*k+2 ; n++ ) SerializeString( stream, *(GetTextByNumber(n)) ); for ( wxUint32 n = 0 ; n < k ; n++ ) { if ( GetChild(n) != nullptr ) GetChild(n)->Serialize(stream); else out << NASSI_BRICK_ESC << _T('\n'); } if ( GetNext() != nullptr ) GetNext()->Serialize(stream); else out << NASSI_BRICK_ESC << _T('\n'); return stream; }
void SearchTreeNode::Dump(BasicSearchTree* tree, nSearchTreeNode node_id, const wxString& prefix, wxString& result) { wxString suffix(_T("")); suffix << _T("- \"") << SerializeString(GetLabel(tree)) << _T("\" (") << U2S(node_id) << _T(")"); if (prefix.length() && prefix[prefix.length()-1]=='|') result << prefix.substr(0,prefix.length()-1) << _T('+') << suffix << _T('\n'); else if (prefix.length() && prefix[prefix.length()-1]==' ') result << prefix.substr(0,prefix.length()-1) << _T('\\') << suffix << _T('\n'); else result << prefix << suffix << _T('\n'); wxString newprefix(prefix); newprefix.append(suffix.length() - 2, _T(' ')); newprefix << _T("|"); SearchTreeLinkMap::iterator i; unsigned int cnt = 0; for (i = m_Children.begin(); i!= m_Children.end(); i++) { if (cnt == m_Children.size() - 1) newprefix[newprefix.length() - 1] = _T(' '); tree->GetNode(i->second,false)->Dump(tree,i->second,newprefix,result); cnt++; } }
void Serializer::Serialize (const string &name, const wstring &data) { SerializeString (name); SerializeWString (data); }
void Serializer::Serialize (const string &name, uint64 data) { SerializeString (name); Serialize (data); }
void Serializer::Serialize (const string &name, int32 data) { SerializeString (name); Serialize ((uint32) data); }
void Serializer::Serialize (const string &name, byte data) { SerializeString (name); Serialize (data); }
void Serializer::Serialize (const string &name, bool data) { SerializeString (name); byte d = data ? 1 : 0; Serialize (d); }
push("reason_domain", data.domain); }, [&](const ActionSecureValuesSent &data) { pushAction("send_passport_values"); auto list = std::vector<QByteArray>(); for (const auto type : data.types) { list.push_back(SerializeString([&] { using Type = ActionSecureValuesSent::Type; switch (type) { case Type::PersonalDetails: return "personal_details"; case Type::Passport: return "passport"; case Type::DriverLicense: return "driver_license"; case Type::IdentityCard: return "identity_card"; case Type::InternalPassport: return "internal_passport"; case Type::Address: return "address_information"; case Type::UtilityBill: return "utility_bill"; case Type::BankStatement: return "bank_statement"; case Type::RentalAgreement: return "rental_agreement"; case Type::PassportRegistration: return "passport_registration"; case Type::TemporaryRegistration: return "temporary_registration"; case Type::Phone: return "phone_number"; case Type::Email: return "email"; } return ""; }())); } pushBare("values", SerializeArray(context, list)); }, [](std::nullopt_t) {}); if (!message.action.content) {