Report a bug
If you spot a problem with this page, click here to create a GitHub issue.
Improve this page
Quickly fork, edit online, and submit a pull request for this page.
Requires a signed-in GitHub account. This works well for small changes.
If you'd like to make larger changes you may want to consider using
a local clone.
mir.ser.ion
High level Ion serialization API
- struct
IonSerializer
(TapeHolder, string[] compiletimeSymbolTable, bool tableGC = true); - Ion serialization back-end
- TapeHolder*
tapeHolder
; - IonSymbolTable!tableGC*
runtimeTable
; - int
serdeTarget
; - Mutable value used to choose format specidied or user-defined serialization specializations
- size_t
structBegin
(size_tlength
= size_t.max); - void
structEnd
(size_tstate
); - alias
listBegin
= structBegin; - void
listEnd
(size_tstate
); - alias
sexpBegin
= listBegin; - void
sexpEnd
(size_tstate
); - alias
stringBegin
= structBegin; - void
putStringPart
(scope const(char)[]str
); - Puts string part. The implementation allows to split string unicode points.
- void
stringEnd
(size_tstate
); - size_t
annotationsBegin
(); - void
annotationsEnd
(size_tstate
); - alias
annotationWrapperBegin
= structBegin; - void
annotationWrapperEnd
(size_tstate
); - void
putCompiletimeKey
(string key)(); - alias
putCompiletimeAnnotation
= putCompiletimeKey; - void
putKey
()(scope const char[]key
); - alias
putAnnotation
= putKey; - void
putKeyId
(T)(const Tid
)
if (__traits(isUnsigned, T)); - alias
putAnnotationId
= putKeyId; - void
putSymbolId
(size_tid
); - void
putSymbol
(scope const char[]key
); - void
putValue
(Num)(const Numnum
)
if (isNumeric!Num && !is(Num == enum)); - void
putValue
(W, WordEndian endian)(BigIntView!(W, endian)view
); - void
putValue
(size_t size)(auto const ref BigInt!sizenum
); - void
putValue
(size_t size)(auto const ref Decimal!sizenum
); - void
putValue
(typeof(null)); - void
putNull
(IonTypeCodecode
); - void
putValue
(boolb
); - void
putValue
(scope const char[]value
); - void
putValue
(Clobvalue
); - void
putValue
(Blobvalue
); - void
putValue
(Timestampvalue
); - void
elemBegin
(); - alias
sexpElemBegin
= elemBegin; - void
nextTopLevelValue
();
- immutable(ubyte)[]
serializeIon
(T)(auto ref Tvalue
, intserdeTarget
= SerdeTarget.ion); - Ion serialization function.Examples:
static struct S { string s; double aaaa; int bbbb; } enum s = S("str", 1.23, 123); static immutable ubyte[] data = [ 0xe0, 0x01, 0x00, 0xea, 0xee, 0x92, 0x81, 0x83, 0xde, 0x8e, 0x87, 0xbc, 0x81, 0x73, 0x84, 0x61, 0x61, 0x61, 0x61, 0x84, 0x62, 0x62, 0x62, 0x62, 0xde, 0x92, 0x8a, 0x83, 0x73, 0x74, 0x72, 0x8b, 0x48, 0x3f, 0xf3, 0xae, 0x14, 0x7a, 0xe1, 0x47, 0xae, 0x8c, 0x21, 0x7b, ]; assert (s.serializeIon == data); enum staticData = s.serializeIon; static assert (staticData == data);
Examples:import mir.serde: SerdeTarget; static immutable ubyte[] binaryDataAB = [0xe0, 0x01, 0x00, 0xea, 0xe9, 0x81, 0x83, 0xd6, 0x87, 0xb4, 0x81, 0x61, 0x81, 0x62, 0xd6, 0x8a, 0x21, 0x01, 0x8b, 0x21, 0x02]; static immutable ubyte[] binaryDataBA = [0xe0, 0x01, 0x00, 0xea, 0xe9, 0x81, 0x83, 0xd6, 0x87, 0xb4, 0x81, 0x62, 0x81, 0x61, 0xd6, 0x8a, 0x21, 0x02, 0x8b, 0x21, 0x01]; int[string] table = ["a" : 1, "b" : 2]; auto data = table.serializeIon(SerdeTarget.ion); assert(data == binaryDataAB || data == binaryDataBA);
- template
ionSerializer
(string sep = "") - Creates Ion serialization back-end. Use sep equal to "\t" or " " for pretty formatting.
- auto
ionSerializer
(Appender)(return Appender*appender
, intserdeTarget
=serdeTarget
.ion);
Copyright © 2016-2022 by Ilya Yaroshenko | Page generated by
Ddoc on Thu Mar 10 07:43:26 2022