Add json serialization utils for objects to save/load from raw bytes

This commit is contained in:
Wojtek Figat
2022-01-02 01:29:31 +01:00
parent 32a73727b0
commit 0f9f3905ed
6 changed files with 170 additions and 4 deletions

View File

@@ -8,6 +8,7 @@
struct CommonValue;
struct Variant;
struct VariantType;
class ISerializable;
/// <summary>
/// Base class for all data write streams
@@ -240,6 +241,14 @@ public:
WriteBytes(data.Get(), size * sizeof(T));
}
/// <summary>
/// Serializes object to Json and writes it as a raw data (ver+length+bytes).
/// </summary>
/// <remarks>Writes version number, data length and actual data bytes to the stream.</remarks>
/// <param name="obj">The object to serialize.</param>
/// <param name="otherObj">The instance of the object to compare with and serialize only the modified properties. If null, then serialize all properties.</param>
void WriteJson(ISerializable* obj, const void* otherObj = nullptr);
public:
// [Stream]