void ArgumentEncoder::encodeVariableLengthByteArray(const DataReference& dataReference) { // Encode the size. encodeUInt64(static_cast<uint64_t>(dataReference.size())); encodeFixedLengthData(dataReference.data(), dataReference.size(), 1); }
bool StringReference::decode(ArgumentDecoder& decoder, StringReference& result) { DataReference dataReference; if (!decoder.decode(dataReference)) return false; result.m_data = reinterpret_cast<const char*>(dataReference.data()); result.m_size = dataReference.size(); return true; }
MessageDecoder::MessageDecoder(const DataReference& buffer, Deque<Attachment>& attachments) : ArgumentDecoder(buffer.data(), buffer.size(), attachments) { if (!decode(m_messageReceiverName)) return; if (!decode(m_messageName)) return; decodeUInt64(m_destinationID); }
static bool decodeGKeyFile(ArgumentDecoder* decoder, GOwnPtr<GKeyFile>& keyFile) { DataReference dataReference; if (!decoder->decode(dataReference)) return false; if (!dataReference.size()) return true; keyFile.set(g_key_file_new()); if (!g_key_file_load_from_data(keyFile.get(), reinterpret_cast<const gchar*>(dataReference.data()), dataReference.size(), G_KEY_FILE_NONE, 0)) { keyFile.clear(); return false; } return true; }
static bool decodeGKeyFile(Decoder& decoder, GUniquePtr<GKeyFile>& keyFile) { DataReference dataReference; if (!decoder.decode(dataReference)) return false; if (!dataReference.size()) return true; keyFile.reset(g_key_file_new()); if (!g_key_file_load_from_data(keyFile.get(), reinterpret_cast<const gchar*>(dataReference.data()), dataReference.size(), G_KEY_FILE_NONE, 0)) { keyFile.reset(); return false; } return true; }