class
BinarySerializer
Encodes/decodes all the fields of the provided object into/from a binary format.
Fields are encoded using their unique IDs. Encoded data will remain compatible for decoding even if you modify the encoded class, as long as you assign new unique field IDs to added/modified fields.
Like for any serializable class, fields are defined in RTTIType that each IReflectable class must be able to return.
Any data the object or its children are pointing to will also be serialized (unless the pointer isn't registered in RTTIType). Upon decoding the pointer addresses will be set to proper values.
Public
Constructors
BinarySerializer
Methods
Encode
Encodes all serializable fields provided by into a binary format.
- object
- Object to encode into binary format.
- stream
- Stream into which to output the encoded data. The stream must own its memory buffer so it may grow as required during encoding, or your must guarantee the stream is of adequate size otherwise.
- context
- Optional object that will be passed along to all serialized objects through RTTI operation notify methods. Can be used for controlling serialization, maintaining state or sharing information between objects during serialization.
- flags
- Flags used for controlling serialization.
Encode
Overload of Encode(IReflectable*, const SPtr <DataStream > & , BinarySerializerFlags, RTTIOperationContext & ) that uses default constructed context.
Decode
Decodes an object from binary data.
- stream
- Stream containing the binary data to decode.
- dataLength
- Length of the data in bytes. If zero, all the data from the stream will be read.
- context
- Optional object that will be passed along to all serialized objects through their deserialization callbacks. Can be used for controlling deserialization, maintaining state or sharing information between objects during deserialization.
- progress
- Optional callback that will occasionally trigger, reporting the current progress of the operation. The reported value is in range [0, 1].
- schema
- RTTI schema that contains information about types as they were when the data was originally serialized. Schema is only used (and required) if BinarySerializerFlag::NoMeta is set, otherwise this information is read directly from the encoded data.
Decode
Overload of Decode(const SPtr <DataStream > & , u32, RTTIOperationContext, BinarySerializerFlags, Function <void (float)>, SPtr <RTTISchema >) that uses default constructed context.