SerializerWrapper

Serializer interface wrapper for common serializers.

Constructors

this
this(S serializer)

Members

Functions

annotationWrapperBegin
size_t annotationWrapperBegin()
Undocumented in source. Be warned that the author may not have intended to support it.
annotationWrapperEnd
void annotationWrapperEnd(size_t annotationsState, size_t state)
Undocumented in source. Be warned that the author may not have intended to support it.
annotationsEnd
size_t annotationsEnd(size_t state)
Undocumented in source. Be warned that the author may not have intended to support it.
elemBegin
void elemBegin()
Undocumented in source. Be warned that the author may not have intended to support it.
listBegin
size_t listBegin(size_t length)
Undocumented in source. Be warned that the author may not have intended to support it.
listEnd
void listEnd(size_t state)
Undocumented in source. Be warned that the author may not have intended to support it.
nextTopLevelValue
void nextTopLevelValue()
Undocumented in source. Be warned that the author may not have intended to support it.
putAnnotation
void putAnnotation(const(char)[] annotation)
Undocumented in source. Be warned that the author may not have intended to support it.
putKey
void putKey(char[] key)
Undocumented in source. Be warned that the author may not have intended to support it.
putNull
void putNull(IonTypeCode code)
Undocumented in source. Be warned that the author may not have intended to support it.
putStringPart
void putStringPart(const(char)[] value)
Undocumented in source. Be warned that the author may not have intended to support it.
putSymbol
void putSymbol(char[] symbol)
Undocumented in source. Be warned that the author may not have intended to support it.
putValue
void putValue(long value)
Undocumented in source. Be warned that the author may not have intended to support it.
putValue
void putValue(ulong value)
Undocumented in source. Be warned that the author may not have intended to support it.
putValue
void putValue(float value)
Undocumented in source. Be warned that the author may not have intended to support it.
putValue
void putValue(double value)
Undocumented in source. Be warned that the author may not have intended to support it.
putValue
void putValue(real value)
Undocumented in source. Be warned that the author may not have intended to support it.
putValue
void putValue(BigInt!128 value)
Undocumented in source. Be warned that the author may not have intended to support it.
putValue
void putValue(Decimal!128 value)
Undocumented in source. Be warned that the author may not have intended to support it.
putValue
void putValue(typeof(null) )
Undocumented in source. Be warned that the author may not have intended to support it.
putValue
void putValue(bool value)
Undocumented in source. Be warned that the author may not have intended to support it.
putValue
void putValue(char[] value)
Undocumented in source. Be warned that the author may not have intended to support it.
putValue
void putValue(Clob value)
Undocumented in source. Be warned that the author may not have intended to support it.
putValue
void putValue(Blob value)
Undocumented in source. Be warned that the author may not have intended to support it.
putValue
void putValue(Timestamp value)
Undocumented in source. Be warned that the author may not have intended to support it.
serdeTarget
int serdeTarget()
Undocumented in source. Be warned that the author may not have intended to support it.
sexpBegin
size_t sexpBegin(size_t length)
Undocumented in source. Be warned that the author may not have intended to support it.
sexpElemBegin
void sexpElemBegin()
Undocumented in source. Be warned that the author may not have intended to support it.
sexpEnd
void sexpEnd(size_t state)
Undocumented in source. Be warned that the author may not have intended to support it.
stringEnd
void stringEnd(size_t state)
Undocumented in source. Be warned that the author may not have intended to support it.
structBegin
size_t structBegin(size_t length)
Undocumented in source. Be warned that the author may not have intended to support it.
structEnd
void structEnd(size_t state)
Undocumented in source. Be warned that the author may not have intended to support it.

Inherited Members

From ISerializer

putStringPart
void putStringPart(const(char)[] value)

Puts string part. The implementation allows to split string unicode points.

stringEnd
void stringEnd(size_t state)
structBegin
size_t structBegin(size_t length)
structEnd
void structEnd(size_t state)
listBegin
size_t listBegin(size_t length)
listEnd
void listEnd(size_t state)
sexpBegin
size_t sexpBegin(size_t length)
sexpEnd
void sexpEnd(size_t state)
putSymbol
void putSymbol(char[] symbol)
putAnnotation
void putAnnotation(const(char)[] annotation)
annotationsEnd
size_t annotationsEnd(size_t state)
annotationWrapperBegin
size_t annotationWrapperBegin()
annotationWrapperEnd
void annotationWrapperEnd(size_t annotationsState, size_t state)
nextTopLevelValue
void nextTopLevelValue()
putKey
void putKey(char[] key)
putValue
void putValue(ubyte value)
putValue
void putValue(ushort value)
putValue
void putValue(uint value)
putValue
void putValue(byte value)
putValue
void putValue(short value)
putValue
void putValue(int value)
putValue
void putValue(long value)
putValue
void putValue(ulong value)
putValue
void putValue(float value)
putValue
void putValue(double value)
putValue
void putValue(real value)
putValue
void putValue(BigInt!128 value)
putValue
void putValue(Decimal!128 value)
putValue
void putValue(typeof(null) )
putNull
void putNull(IonTypeCode code)
putValue
void putValue(bool b)
putValue
void putValue(char[] value)
putValue
void putValue(Clob value)
putValue
void putValue(Blob value)
putValue
void putValue(Timestamp value)
elemBegin
void elemBegin()
sexpElemBegin
void sexpElemBegin()
serdeTarget
int serdeTarget()

Examples

static struct Wrapper(T)
{
    T value;

    void serialize(ISerializer serializer) const @safe
    {
        import mir.ser: serializeValue;
        serializeValue(serializer, value);
    }
}

static auto wrap(T)(T value)
{
    return Wrapper!T(value);
}

import mir.ion.conv;
import mir.ser.ion;
import mir.ser.json;
import mir.ser.text;
import mir.ion.stream;
import std.datetime.date;

assert(wrap(Date(1234, 5, 6)).serializeJson == `"1234-05-06"`);
assert(wrap(Date(1234, 5, 6)).serializeText == `1234-05-06`);
assert(wrap(Date(1234, 5, 6)).serializeIon.ion2text == `1234-05-06`);
immutable(ushort)[] imdata = [10, 20, 30];
assert(wrap(imdata).serializeIon.ion2text == `[10,20,30]`);

const ubyte[] data = [0xe0, 0x01, 0x00, 0xea, 0xe9, 0x81, 0x83, 0xd6, 0x87, 0xb4, 0x81, 0x61, 0x81, 0x62, 0xd6, 0x8a, 0x21, 0x01, 0x8b, 0x21, 0x02];
auto json = wrap(data.IonValueStream).serializeJson;
assert(json == `{"a":1,"b":2}`);

Meta