Module vibe.data.serialization
Generic serialization framework.
This module provides general means for implementing (de-)serialization with a standardized behavior.
Serializers are implemented in terms of struct with template methods that get called by the serialization framework:
struct ExampleSerializer { enum isSupportedValueType(T) = is(T == string) || is(T == typeof(null)); // serialization auto getSerializedResult(); void beginWriteDictionary(T)(); void endWriteDictionary(T)(); void beginWriteDictionaryEntry(T)(string name); void endWriteDictionaryEntry(T)(); void beginWriteArray(T)(size_t length); void endWriteArray(T)(); void beginWriteArrayEntry(T)(); void endWriteArrayEntry(T)(); void writeValue(T)(T value); // deserialization void readDictionary(T)(scope void delegate(string) entry_callback); void readArray(T)(scope void delegate(size_t) size_callback, scope void delegate() entry_callback); void readValue(T)(); bool tryReadNull(); }
Functions
Name | Description |
---|---|
asArray
|
Attribute for representing a struct/class as an array instead of an object. |
byName
|
Attribute for forcing serialization of enum fields by name instead of by value.
|
deserialize
|
Deserializes and returns a serialized value. |
ignore
|
Attribute for marking non-serialized fields. |
name
|
Attribute for overriding the field name during (de-)serialization.
|
optional
|
Attribute marking a field as optional during deserialization.
|
serialize
|
Serializes a value with the given serializer .
|
Structs
Name | Description |
---|---|
AsArrayAttribute
|
User defined attribute (not intended for direct use) |
ByNameAttribute
|
User defined attribute (not intended for direct use) |
IgnoreAttribute
|
User defined attribute (not intended for direct use) |
NameAttribute
|
User defined attribute (not intended for direct use) |
OptionalAttribute
|
User defined attribute (not intended for direct use) |
Enums
Name | Description |
---|---|
FieldExistence
|
Global variables
Name | Type | Description |
---|---|---|
isCustomSerializable
|
void
|
|
isISOExtStringSerializable
|
void
|
|
isStringSerializable
|
void
|
Authors
Sönke Ludwig
Copyright
© 2013-2014 rejectedsoftware e.K.
License
Subject to the terms of the MIT license, as written in the included LICENSE.txt file.