bool IComplexDatum::DeserializeAEONScript (CDatum::ESerializationFormats iFormat, const CString &sTypename, CCharStream *pStream) // DeserializeAEONScript // // Deserialize AEONScript { int i; DWORD dwFlags = OnGetSerializeFlags(); // If we have an open brace then we've stored everything as a structure. if (pStream->GetChar() == '{') { // Object must support this if (!(dwFlags & FLAG_SERIALIZE_AS_STRUCT)) return false; // Parse the structure CAEONScriptParser Parser(pStream); CDatum dData; CAEONScriptParser::ETokens iToken = Parser.ParseToken(&dData); if (iToken != CAEONScriptParser::tkDatum) return false; // Take all the fields in the structure and apply them to our object // (our descendants will do the right thing). for (i = 0; i < dData.GetCount(); i++) SetElement(dData.GetKey(i), dData.GetElement(i)); } // Otherwise we expect base64 encoded data else { // Backup one character because we want the OnDeserialize call to read it. pStream->UnreadChar(); // Deserialize CBase64Decoder Decoder(pStream->GetByteStream()); if (!OnDeserialize(iFormat, sTypename, Decoder)) return false; // Read the next character into the stream pStream->RefreshStream(); pStream->ReadChar(); } return true; }
bool IComplexDatum::DeserializeJSON (const CString &sTypename, const TArray<CDatum> &Data) // DeserializeJSON // // Deserialize from JSON { if (Data.GetCount() == 0 || Data[0].GetBasicType() != CDatum::typeString) return false; // LATER: Handle serialization/deserialization of struct-based objects // Default deserialization CStringBuffer Buffer(Data[0]); CBase64Decoder Decoder(&Buffer); if (!OnDeserialize(CDatum::formatJSON, sTypename, Decoder)) return false; return true; }
void NetworkRequestData::Deserialize(BufferDecode &decode) { OnDeserialize(decode); decode.Clear(); }