Add stream.readValue

This commit is contained in:
Zahary Karadjov 2020-05-06 22:46:54 +03:00
parent dccba1e22b
commit 5ecae14972
No known key found for this signature in database
GPG Key ID: C8936F8A3073D609
1 changed files with 13 additions and 2 deletions

View File

@ -124,8 +124,19 @@ template borrowSerialization*(Alias: distinct type,
mixin readValue
value = Alias reader.readValue(OriginalType)
template writeValue*(stream: OutputStream, Format: type, value: auto) =
template readValue*(stream: InputStream,
Format: type,
ValueType: type,
params: varargs[untyped]): untyped =
mixin ReaderType, init, readValue
var reader = unpackArgs(init, [ReaderType(Format), stream, params])
readValue reader, ValueType
template writeValue*(stream: OutputStream,
Format: type,
value: auto,
params: varargs[untyped]) =
mixin WriterType, init, writeValue
var writer = init(WriterType(Format), stream)
var writer = unpackArgs(init, [WriterType(Format), stream])
writeValue writer, value