2018-11-11 11:40:19 +00:00
|
|
|
import
|
|
|
|
serialization/[streams, object_serialization]
|
|
|
|
|
|
|
|
export
|
|
|
|
streams, object_serialization
|
2018-11-10 00:14:43 +00:00
|
|
|
|
2018-11-29 01:33:45 +00:00
|
|
|
proc encodeImpl(w: var auto, value: auto): auto =
|
|
|
|
mixin writeValue, getOutput
|
2018-11-10 00:14:43 +00:00
|
|
|
w.writeValue value
|
|
|
|
return w.getOutput
|
|
|
|
|
2018-11-29 01:33:45 +00:00
|
|
|
template encode*(Writer: type, value: auto, params: varargs[untyped]): auto =
|
|
|
|
mixin init, writeValue, getOutput
|
|
|
|
var w = Writer.init(params)
|
|
|
|
encodeImpl(w, value)
|
|
|
|
|