decoding: parse single-byte boolean streams
This commit is contained in:
parent
cd6812ae07
commit
1fee875909
|
@ -19,11 +19,14 @@ proc decodePreserves*(s: Stream): Value {.gcsafe.}
|
|||
|
||||
proc decodePreserves(s: Stream; tag: uint8): Value =
|
||||
## Decode a Preserves value from a binary-encoded stream.
|
||||
if s.atEnd: raise newException(IOError, "End of Preserves stream")
|
||||
const endMarker = 0x84
|
||||
case tag
|
||||
of 0x80: result = Value(kind: pkBoolean, bool: false)
|
||||
of 0x81: result = Value(kind: pkBoolean, bool: true)
|
||||
of 0x80: return Value(kind: pkBoolean, bool: false)
|
||||
of 0x81: return Value(kind: pkBoolean, bool: true)
|
||||
else: discard
|
||||
if s.atEnd:
|
||||
raise newException(IOError, "End of Preserves stream")
|
||||
case tag
|
||||
of 0x85:
|
||||
discard decodePreserves(s)
|
||||
result = decodePreserves(s)
|
||||
|
|
Loading…
Reference in New Issue