Creates a new serializer using the given archive.
The type of the serialized data. This is an untyped format.
The type of error callback.
The type of an ID.
Returns the receivers archive
Deserializes the given data to value of the given type.
Deserializes the value with the given associated key.
Deserializes the value with the given associated key.
Deserializes the base class(es) of an instance.
This callback will be called when an unexpected event occurs, i.e. an expected element is missing in the deserialization process.
This callback will be called when an unexpected event occurs, i.e. an expected element is missing in the deserialization process.
Overrides a globally registered deserializer for the given type with a deserializer local to the receiver.
Overrides a globally registered deserializer for the given type with a deserializer local to the receiver.
Overrides a globally registered serializer for the given type with a serializer local to the receiver.
Overrides a globally registered serializer for the given type with a serializer local to the receiver.
Resets the serializer.
Serializes the given value.
Serializes the base class(es) of an instance.
Set the error callback do nothing when an error occurs
Set the error callback to throw when an error occurs
Registers the given type for (de)serialization.
Registers a deserializer for the given type.
Registers a deserializer for the given type.
Registers a serializer for the given type.
Registers a serializer for the given type.
Resets all registered types registered via the "register" method
Resets all registered (de)serializers registered via the "registerSerializer" method. This method will not reset the overridden (de)serializers.
import std.stdio; import orange.serialization._; import orange.serialization.archives._; class Foo { int a; } void main () { auto archive = new XmlArchive!(); auto serializer = new Serializer; auto foo = new Foo; foo.a = 3; serializer.serialize(foo); auto foo2 = serializer.deserialize!(Foo)(archive.untypedData); writeln(foo2.a); // prints "3" assert(foo.a == foo2.a); }
This class represents a serializer. It's the main interface to the (de)serialization process and it's this class that actually performs most of the (de)serialization.
The serializer is the frontend in the serialization process, it's independent of the underlying archive type. It's responsible for collecting and tracking all values that should be (de)serialized. It's the serializer that adds keys and ID's to all values, keeps track of references to make sure that a given value (of reference type) is only (de)serialized once.
The serializer is also responsible for breaking up types that the underlying archive cannot handle, into primitive types that archive know how to (de)serialize.
Keys are used by the serializer to associate a name with a value. It's used to deserialize values independently of the order of the fields of a class or struct. They can also be used by the user to give a name to a value. Keys are unique within it's scope.
ID's are an unique identifier associated with each serialized value. The serializer uses the ID's to track values when (de)serializing reference types. An ID is unique across the whole serialized data.