From 0b0f28e96627984d736a7588820be07dd287c141 Mon Sep 17 00:00:00 2001 From: Mattias Wadman Date: Tue, 11 Jan 2022 21:24:54 +0100 Subject: [PATCH] cbor: Add decoder Does not decode sematic tag types Also fixes broken float16 support Fixes #71 --- .vscode/settings.json | 1 + README.md | 2 +- doc/formats.md | 1 + doc/formats.svg | 24 +- format/all/all.go | 1 + format/cbor/cbor.go | 267 ++++++++ format/cbor/cbor.jq | 13 + format/cbor/testdata/appendix_a.fqtest | 819 +++++++++++++++++++++++++ format/cbor/testdata/appendix_a.json | 636 +++++++++++++++++++ format/cbor/testdata/cbor.fqtest | 5 + format/format.go | 1 + internal/num/float16.go | 130 ++++ pkg/decode/read.go | 3 + pkg/interp/testdata/args.fqtest | 1 + 14 files changed, 1894 insertions(+), 10 deletions(-) create mode 100644 format/cbor/cbor.go create mode 100644 format/cbor/cbor.jq create mode 100644 format/cbor/testdata/appendix_a.fqtest create mode 100644 format/cbor/testdata/appendix_a.json create mode 100644 format/cbor/testdata/cbor.fqtest create mode 100644 internal/num/float16.go diff --git a/.vscode/settings.json b/.vscode/settings.json index b163242a..0d41ed67 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -14,6 +14,7 @@ "bson", "bxor", "bzip", + "cbor", "CCIT", "chzyer", "CLIUNICODE", diff --git a/README.md b/README.md index 5f114e5b..db493e71 100644 --- a/README.md +++ b/README.md @@ -104,7 +104,7 @@ go run fq.go [./formats_list.jq]: sh-start -aac_frame, adts, adts_frame, apev2, ar, av1_ccr, av1_frame, av1_obu, avc_annexb, avc_au, avc_dcr, avc_nalu, avc_pps, avc_sei, avc_sps, bencode, bsd_loopback_frame, bson, bzip2, dns, dns_tcp, elf, ether8023_frame, exif, flac, flac_frame, flac_metadatablock, flac_metadatablocks, flac_picture, flac_streaminfo, gif, gzip, hevc_annexb, hevc_au, hevc_dcr, hevc_nalu, icc_profile, icmp, id3v1, id3v11, id3v2, ipv4_packet, jpeg, json, matroska, mp3, mp3_frame, mp4, mpeg_asc, mpeg_es, mpeg_pes, mpeg_pes_packet, mpeg_spu, mpeg_ts, msgpack, ogg, ogg_page, opus_packet, pcap, pcapng, png, protobuf, protobuf_widevine, pssh_playready, raw, sll2_packet, sll_packet, tar, tcp_segment, tiff, udp_datagram, vorbis_comment, vorbis_packet, vp8_frame, vp9_cfm, vp9_frame, vpx_ccr, wav, webp, xing, zip +aac_frame, adts, adts_frame, apev2, ar, av1_ccr, av1_frame, av1_obu, avc_annexb, avc_au, avc_dcr, avc_nalu, avc_pps, avc_sei, avc_sps, bencode, bsd_loopback_frame, bson, bzip2, cbor, dns, dns_tcp, elf, ether8023_frame, exif, flac, flac_frame, flac_metadatablock, flac_metadatablocks, flac_picture, flac_streaminfo, gif, gzip, hevc_annexb, hevc_au, hevc_dcr, hevc_nalu, icc_profile, icmp, id3v1, id3v11, id3v2, ipv4_packet, jpeg, json, matroska, mp3, mp3_frame, mp4, mpeg_asc, mpeg_es, mpeg_pes, mpeg_pes_packet, mpeg_spu, mpeg_ts, msgpack, ogg, ogg_page, opus_packet, pcap, pcapng, png, protobuf, protobuf_widevine, pssh_playready, raw, sll2_packet, sll_packet, tar, tcp_segment, tiff, udp_datagram, vorbis_comment, vorbis_packet, vp8_frame, vp9_cfm, vp9_frame, vpx_ccr, wav, webp, xing, zip [#]: sh-end diff --git a/doc/formats.md b/doc/formats.md index a9564b91..b4015cb7 100644 --- a/doc/formats.md +++ b/doc/formats.md @@ -23,6 +23,7 @@ |`bsd_loopback_frame` |BSD loopback frame |`ipv4_packet`| |`bson` |Binary JSON || |`bzip2` |bzip2 compression |`probe`| +|`cbor` |Concise Binary Object Representation || |`dns` |DNS packet || |`dns_tcp` |DNS packet (TCP) || |`elf` |Executable and Linkable Format || diff --git a/doc/formats.svg b/doc/formats.svg index 9b97a13b..46c2ded8 100644 --- a/doc/formats.svg +++ b/doc/formats.svg @@ -1580,23 +1580,29 @@ bson - + +cbor + +cbor + + + dns_tcp - -dns_tcp + +dns_tcp - + msgpack - -msgpack + +msgpack - + raw - -raw + +raw diff --git a/format/all/all.go b/format/all/all.go index 41afa672..78206719 100644 --- a/format/all/all.go +++ b/format/all/all.go @@ -9,6 +9,7 @@ import ( _ "github.com/wader/fq/format/bencode" _ "github.com/wader/fq/format/bson" _ "github.com/wader/fq/format/bzip2" + _ "github.com/wader/fq/format/cbor" _ "github.com/wader/fq/format/dns" _ "github.com/wader/fq/format/elf" _ "github.com/wader/fq/format/flac" diff --git a/format/cbor/cbor.go b/format/cbor/cbor.go new file mode 100644 index 00000000..af19d46f --- /dev/null +++ b/format/cbor/cbor.go @@ -0,0 +1,267 @@ +package cbor + +// https://en.wikipedia.org/wiki/CBOR +// https://www.rfc-editor.org/rfc/rfc8949.html + +// TODO: streaming bytes test? +// TODO: decode some sematic tags + +import ( + "bytes" + "embed" + "strings" + + "github.com/wader/fq/format" + "github.com/wader/fq/format/registry" + "github.com/wader/fq/pkg/bitio" + "github.com/wader/fq/pkg/decode" + "github.com/wader/fq/pkg/scalar" +) + +//go:embed *.jq +var cborFS embed.FS + +func init() { + registry.MustRegister(decode.Format{ + Name: format.CBOR, + Description: "Concise Binary Object Representation", + DecodeFn: decodeCBOR, + Files: cborFS, + ToRepr: "_cbor_torepr", + }) +} + +type majorTypeEntry struct { + s scalar.S + d func(d *decode.D, shortCount uint64, count uint64) interface{} +} + +type majorTypeEntries map[uint64]majorTypeEntry + +func (mts majorTypeEntries) MapScalar(s scalar.S) (scalar.S, error) { + u := s.ActualU() + if fe, ok := mts[u]; ok { + s = fe.s + s.Actual = u + } + return s, nil +} + +const ( + shortCountVariable8Bit = 24 + shortCountVariable16Bit = 25 + shortCountVariable32Bit = 26 + shortCountVariable64Bit = 27 + shortCountIndefinite = 31 + + shortCountSpecialFalse = 20 + shortCountSpecialTrue = 21 + shortCountSpecialNull = 22 + shortCountSpecialUndefined = 23 + + shortCountSpecialFloat16Bit = 25 + shortCountSpecialFloat32Bit = 26 + shortCountSpecialFloat64Bit = 27 +) + +var shortCountMap = scalar.UToSymStr{ + shortCountVariable8Bit: "8bit", + shortCountVariable16Bit: "16bit", + shortCountVariable32Bit: "32bit", + shortCountVariable64Bit: "64bit", + shortCountIndefinite: "indefinite", +} + +var tagMap = scalar.UToSymStr{ + 0: "date_time", + 1: "epoch_date_time", + 2: "unsigned_bignum", + 3: "negative_bignum", + 4: "decimal_fraction", + 5: "bigfloat", + 21: "base64url", + 22: "base64", + 23: "base16", + 24: "encoded_cbor", + 32: "uri", + 33: "base64url", + 34: "base64", + 36: "mime_message", + 55799: "self_described_cbor", +} + +const ( + majorTypePositiveInt = 0 + majorTypeNegativeInt = 1 + majorTypeBytes = 2 + majorTypeUTF8 = 3 + majorTypeArray = 4 + majorTypeMap = 5 + majorTypeSematic = 6 + majorTypeSpecialFloat = 7 +) + +const ( + breakMarker = 0xff +) + +func decodeCBORValue(d *decode.D) interface{} { + majorTypeMap := majorTypeEntries{ + majorTypePositiveInt: {s: scalar.S{Sym: "positive_int"}, d: func(d *decode.D, shortCount uint64, count uint64) interface{} { + d.FieldValueU("value", count) + return count + }}, + majorTypeNegativeInt: {s: scalar.S{Sym: "negative_int"}, d: func(d *decode.D, shortCount uint64, count uint64) interface{} { + d.FieldValueS("value", int64(^count)) + return count + }}, + majorTypeBytes: {s: scalar.S{Sym: "bytes"}, d: func(d *decode.D, shortCount uint64, count uint64) interface{} { + if shortCount == shortCountIndefinite { + bb := &bytes.Buffer{} + d.FieldArray("items", func(d *decode.D) { + for d.PeekBits(8) != breakMarker { + d.FieldStruct("item", func(d *decode.D) { + v := decodeCBORValue(d) + switch v := v.(type) { + case []byte: + bb.Write(v) + default: + d.Fatalf("non-bytes in bytes stream %v", v) + } + }) + } + }) + d.FieldRootBitBuf("value", bitio.NewBufferFromBytes(bb.Bytes(), -1)) + // nil, nested indefinite bytes is not allowed + return nil + } + + bib := d.FieldRawLen("value", int64(count)*8) + bs, err := bib.Bytes() + if err != nil { + d.IOPanic(err, "bytes bb.Bytes") + } + return bs + }}, + majorTypeUTF8: {s: scalar.S{Sym: "utf8"}, d: func(d *decode.D, shortCount uint64, count uint64) interface{} { + if shortCount == shortCountIndefinite { + sb := &strings.Builder{} + d.FieldArray("items", func(d *decode.D) { + for d.PeekBits(8) != breakMarker { + d.FieldStruct("item", func(d *decode.D) { + v := decodeCBORValue(d) + switch v := v.(type) { + case string: + sb.WriteString(v) + default: + d.Fatalf("non-string in string stream %v", v) + } + }) + } + }) + d.FieldValueStr("value", sb.String()) + // nil, nested indefinite string is not allowed + return nil + } + + return d.FieldUTF8("value", int(count)) + }}, + majorTypeArray: {s: scalar.S{Sym: "array"}, d: func(d *decode.D, shortCount uint64, count uint64) interface{} { + d.FieldArray("elements", func(d *decode.D) { + for i := uint64(0); true; i++ { + if shortCount == shortCountIndefinite && d.PeekBits(8) == breakMarker { + break + } else if i >= count { + break + } + d.FieldStruct("element", func(d *decode.D) { decodeCBORValue(d) }) + } + }) + if shortCount == shortCountIndefinite { + d.FieldU8("break") + } + return nil + }}, + majorTypeMap: {s: scalar.S{Sym: "map"}, d: func(d *decode.D, shortCount uint64, count uint64) interface{} { + d.FieldArray("pairs", func(d *decode.D) { + for i := uint64(0); true; i++ { + if shortCount == shortCountIndefinite && d.PeekBits(8) == breakMarker { + break + } else if i >= count { + break + } + d.FieldStruct("pair", func(d *decode.D) { + d.FieldStruct("key", func(d *decode.D) { decodeCBORValue(d) }) + d.FieldStruct("value", func(d *decode.D) { decodeCBORValue(d) }) + }) + } + }) + if shortCount == shortCountIndefinite { + d.FieldU8("break") + } + return nil + }}, + majorTypeSematic: {s: scalar.S{Sym: "semantic"}, d: func(d *decode.D, shortCount uint64, count uint64) interface{} { + d.FieldValueU("tag", count, tagMap) + d.FieldStruct("value", func(d *decode.D) { decodeCBORValue(d) }) + return count + }}, + majorTypeSpecialFloat: {s: scalar.S{Sym: "special_float"}, d: func(d *decode.D, shortCount uint64, count uint64) interface{} { + switch shortCount { + // TODO: 0-19 + case shortCountSpecialFalse: + d.FieldValueBool("value", false) + case shortCountSpecialTrue: + d.FieldValueBool("value", true) + case shortCountSpecialNull: + // TODO: null + case shortCountSpecialUndefined: + // TODO: undefined + case 24: + // TODO: future + case shortCountSpecialFloat16Bit: + d.FieldF16("value") + case shortCountSpecialFloat32Bit: + d.FieldF32("value") + case shortCountSpecialFloat64Bit: + d.FieldF64("value") + case 28, 29, 30: + // TODO: future + } + return nil + }}, + } + + typ := d.FieldU3("major_type", majorTypeMap) + shortCount := d.FieldU5("short_count", shortCountMap) + count := shortCount + if typ != majorTypeSpecialFloat { + switch count { + // 0-23 value in shortCount + case shortCountVariable8Bit: + count = d.FieldU8("variable_count") + case shortCountVariable16Bit: + count = d.FieldU16("variable_count") + case shortCountVariable32Bit: + count = d.FieldU32("variable_count") + case shortCountVariable64Bit: + count = d.FieldU64("variable_count") + case 28, 29, 30: + d.Fatalf("incorrect shortCount %d", count) + } + } + + if mt, ok := majorTypeMap[typ]; ok { + if mt.d != nil { + return mt.d(d, shortCount, count) + } + return nil + } + + panic("unreachable") +} + +func decodeCBOR(d *decode.D, in interface{}) interface{} { + decodeCBORValue(d) + return nil +} diff --git a/format/cbor/cbor.jq b/format/cbor/cbor.jq new file mode 100644 index 00000000..85f811c0 --- /dev/null +++ b/format/cbor/cbor.jq @@ -0,0 +1,13 @@ +def _cbor_torepr: + def _f: + ( if .major_type == "map" then + ( .pairs + | map({key: (.key | _f), value: (.value | _f)}) + | from_entries + ) + elif .major_type == "array" then .elements | map(_f) + elif .major_type == "bytes" then .value | tostring + else .value | tovalue + end + ); + _f; diff --git a/format/cbor/testdata/appendix_a.fqtest b/format/cbor/testdata/appendix_a.fqtest new file mode 100644 index 00000000..f4936cb5 --- /dev/null +++ b/format/cbor/testdata/appendix_a.fqtest @@ -0,0 +1,819 @@ +# appendix_a.json from https://github.com/cbor/test-vectors +# TODO: "O///////////" fails due lack of bigint support (is smaller thax mmin int64), also the test JSON has issues truncating decoded value +# TODO: "w0kBAAAAAAAAAAA=" "wkkBAAAAAAAAAAA=" semantic bigint +$ fq -i -d json . appendix_a.json +json> length +82 +json> map(select(.decoded) | (.cbor | base64 | cbor | torepr) as $a | select( .decoded != $a) | {test: ., actual: $a}) +[ + { + "actual": { + "major_type": "bytes", + "short_count": 9, + "value": "<9>AQAAAAAAAAAA" + }, + "test": { + "cbor": "wkkBAAAAAAAAAAA=", + "decoded": 18446744073709552000, + "hex": "c249010000000000000000", + "roundtrip": true + } + }, + { + "actual": 0, + "test": { + "cbor": "O///////////", + "decoded": -18446744073709552000, + "hex": "3bffffffffffffffff", + "roundtrip": true + } + }, + { + "actual": { + "major_type": "bytes", + "short_count": 9, + "value": "<9>AQAAAAAAAAAA" + }, + "test": { + "cbor": "w0kBAAAAAAAAAAA=", + "decoded": -18446744073709552000, + "hex": "c349010000000000000000", + "roundtrip": true + } + } +] +json> .[] | select(.decoded) | .cbor | base64 | cbor | v + |00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f|0123456789abcdef|.{}: (cbor) 0x0-0x0.7 (1) +0x0|00| |.| | major_type: "positive_int" (0) 0x0-0x0.2 (0.3) +0x0|00| |.| | short_count: 0 0x0.3-0x0.7 (0.5) + | | | value: 0 0x1-NA (0) + |00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f|0123456789abcdef|.{}: (cbor) 0x0-0x0.7 (1) +0x0|01| |.| | major_type: "positive_int" (0) 0x0-0x0.2 (0.3) +0x0|01| |.| | short_count: 1 0x0.3-0x0.7 (0.5) + | | | value: 1 0x1-NA (0) + |00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f|0123456789abcdef|.{}: (cbor) 0x0-0x0.7 (1) +0x0|0a| |.| | major_type: "positive_int" (0) 0x0-0x0.2 (0.3) +0x0|0a| |.| | short_count: 10 0x0.3-0x0.7 (0.5) + | | | value: 10 0x1-NA (0) + |00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f|0123456789abcdef|.{}: (cbor) 0x0-0x0.7 (1) +0x0|17| |.| | major_type: "positive_int" (0) 0x0-0x0.2 (0.3) +0x0|17| |.| | short_count: 23 0x0.3-0x0.7 (0.5) + | | | value: 23 0x1-NA (0) + |00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f|0123456789abcdef|.{}: (cbor) 0x0-0x1.7 (2) +0x0|18 |. | major_type: "positive_int" (0) 0x0-0x0.2 (0.3) +0x0|18 |. | short_count: "8bit" (24) 0x0.3-0x0.7 (0.5) +0x0| 18| | .| | variable_count: 24 0x1-0x1.7 (1) + | | | value: 24 0x2-NA (0) + |00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f|0123456789abcdef|.{}: (cbor) 0x0-0x1.7 (2) +0x0|18 |. | major_type: "positive_int" (0) 0x0-0x0.2 (0.3) +0x0|18 |. | short_count: "8bit" (24) 0x0.3-0x0.7 (0.5) +0x0| 19| | .| | variable_count: 25 0x1-0x1.7 (1) + | | | value: 25 0x2-NA (0) + |00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f|0123456789abcdef|.{}: (cbor) 0x0-0x1.7 (2) +0x0|18 |. | major_type: "positive_int" (0) 0x0-0x0.2 (0.3) +0x0|18 |. | short_count: "8bit" (24) 0x0.3-0x0.7 (0.5) +0x0| 64| | d| | variable_count: 100 0x1-0x1.7 (1) + | | | value: 100 0x2-NA (0) + |00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f|0123456789abcdef|.{}: (cbor) 0x0-0x2.7 (3) +0x0|19 |. | major_type: "positive_int" (0) 0x0-0x0.2 (0.3) +0x0|19 |. | short_count: "16bit" (25) 0x0.3-0x0.7 (0.5) +0x0| 03 e8| | ..| | variable_count: 1000 0x1-0x2.7 (2) + | | | value: 1000 0x3-NA (0) + |00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f|0123456789abcdef|.{}: (cbor) 0x0-0x4.7 (5) +0x0|1a |. | major_type: "positive_int" (0) 0x0-0x0.2 (0.3) +0x0|1a |. | short_count: "32bit" (26) 0x0.3-0x0.7 (0.5) +0x0| 00 0f 42 40| | ..B@| | variable_count: 1000000 0x1-0x4.7 (4) + | | | value: 1000000 0x5-NA (0) + |00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f|0123456789abcdef|.{}: (cbor) 0x0-0x8.7 (9) +0x0|1b |. | major_type: "positive_int" (0) 0x0-0x0.2 (0.3) +0x0|1b |. | short_count: "64bit" (27) 0x0.3-0x0.7 (0.5) +0x0| 00 00 00 e8 d4 a5 10 00| | ........| | variable_count: 1000000000000 0x1-0x8.7 (8) + | | | value: 1000000000000 0x9-NA (0) + |00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f|0123456789abcdef|.{}: (cbor) 0x0-0x8.7 (9) +0x0|1b |. | major_type: "positive_int" (0) 0x0-0x0.2 (0.3) +0x0|1b |. | short_count: "64bit" (27) 0x0.3-0x0.7 (0.5) +0x0| ff ff ff ff ff ff ff ff| | ........| | variable_count: 18446744073709551615 0x1-0x8.7 (8) + | | | value: 18446744073709551615 0x9-NA (0) + |00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f|0123456789abcdef|.{}: (cbor) 0x0-0xa.7 (11) +0x0|c2 |. | major_type: "semantic" (6) 0x0-0x0.2 (0.3) +0x0|c2 |. | short_count: 2 0x0.3-0x0.7 (0.5) + | | | tag: "unsigned_bignum" (2) 0x1-NA (0) + | | | value{}: 0x1-0xa.7 (10) +0x0| 49 | I | major_type: "bytes" (2) 0x1-0x1.2 (0.3) +0x0| 49 | I | short_count: 9 0x1.3-0x1.7 (0.5) +0x0| 01 00 00 00 00 00 00 00 00| | .........| | value: raw bits 0x2-0xa.7 (9) + |00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f|0123456789abcdef|.{}: (cbor) 0x0-0x8.7 (9) +0x0|3b |; | major_type: "negative_int" (1) 0x0-0x0.2 (0.3) +0x0|3b |; | short_count: "64bit" (27) 0x0.3-0x0.7 (0.5) +0x0| ff ff ff ff ff ff ff ff| | ........| | variable_count: 18446744073709551615 0x1-0x8.7 (8) + | | | value: 0 0x9-NA (0) + |00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f|0123456789abcdef|.{}: (cbor) 0x0-0xa.7 (11) +0x0|c3 |. | major_type: "semantic" (6) 0x0-0x0.2 (0.3) +0x0|c3 |. | short_count: 3 0x0.3-0x0.7 (0.5) + | | | tag: "negative_bignum" (3) 0x1-NA (0) + | | | value{}: 0x1-0xa.7 (10) +0x0| 49 | I | major_type: "bytes" (2) 0x1-0x1.2 (0.3) +0x0| 49 | I | short_count: 9 0x1.3-0x1.7 (0.5) +0x0| 01 00 00 00 00 00 00 00 00| | .........| | value: raw bits 0x2-0xa.7 (9) + |00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f|0123456789abcdef|.{}: (cbor) 0x0-0x0.7 (1) +0x0|20| | | | major_type: "negative_int" (1) 0x0-0x0.2 (0.3) +0x0|20| | | | short_count: 0 0x0.3-0x0.7 (0.5) + | | | value: -1 0x1-NA (0) + |00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f|0123456789abcdef|.{}: (cbor) 0x0-0x0.7 (1) +0x0|29| |)| | major_type: "negative_int" (1) 0x0-0x0.2 (0.3) +0x0|29| |)| | short_count: 9 0x0.3-0x0.7 (0.5) + | | | value: -10 0x1-NA (0) + |00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f|0123456789abcdef|.{}: (cbor) 0x0-0x1.7 (2) +0x0|38 |8 | major_type: "negative_int" (1) 0x0-0x0.2 (0.3) +0x0|38 |8 | short_count: "8bit" (24) 0x0.3-0x0.7 (0.5) +0x0| 63| | c| | variable_count: 99 0x1-0x1.7 (1) + | | | value: -100 0x2-NA (0) + |00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f|0123456789abcdef|.{}: (cbor) 0x0-0x2.7 (3) +0x0|39 |9 | major_type: "negative_int" (1) 0x0-0x0.2 (0.3) +0x0|39 |9 | short_count: "16bit" (25) 0x0.3-0x0.7 (0.5) +0x0| 03 e7| | ..| | variable_count: 999 0x1-0x2.7 (2) + | | | value: -1000 0x3-NA (0) + |00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f|0123456789abcdef|.{}: (cbor) 0x0-0x2.7 (3) +0x0|f9 |. | major_type: "special_float" (7) 0x0-0x0.2 (0.3) +0x0|f9 |. | short_count: "16bit" (25) 0x0.3-0x0.7 (0.5) +0x0| 00 00| | ..| | value: 0 0x1-0x2.7 (2) + |00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f|0123456789abcdef|.{}: (cbor) 0x0-0x2.7 (3) +0x0|f9 |. | major_type: "special_float" (7) 0x0-0x0.2 (0.3) +0x0|f9 |. | short_count: "16bit" (25) 0x0.3-0x0.7 (0.5) +0x0| 80 00| | ..| | value: -0 0x1-0x2.7 (2) + |00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f|0123456789abcdef|.{}: (cbor) 0x0-0x2.7 (3) +0x0|f9 |. | major_type: "special_float" (7) 0x0-0x0.2 (0.3) +0x0|f9 |. | short_count: "16bit" (25) 0x0.3-0x0.7 (0.5) +0x0| 3c 00| | <.| | value: 1 0x1-0x2.7 (2) + |00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f|0123456789abcdef|.{}: (cbor) 0x0-0x8.7 (9) +0x0|fb |. | major_type: "special_float" (7) 0x0-0x0.2 (0.3) +0x0|fb |. | short_count: "64bit" (27) 0x0.3-0x0.7 (0.5) +0x0| 3f f1 99 99 99 99 99 9a| | ?.......| | value: 1.1 0x1-0x8.7 (8) + |00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f|0123456789abcdef|.{}: (cbor) 0x0-0x2.7 (3) +0x0|f9 |. | major_type: "special_float" (7) 0x0-0x0.2 (0.3) +0x0|f9 |. | short_count: "16bit" (25) 0x0.3-0x0.7 (0.5) +0x0| 3e 00| | >.| | value: 1.5 0x1-0x2.7 (2) + |00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f|0123456789abcdef|.{}: (cbor) 0x0-0x2.7 (3) +0x0|f9 |. | major_type: "special_float" (7) 0x0-0x0.2 (0.3) +0x0|f9 |. | short_count: "16bit" (25) 0x0.3-0x0.7 (0.5) +0x0| 7b ff| | {.| | value: 65504 0x1-0x2.7 (2) + |00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f|0123456789abcdef|.{}: (cbor) 0x0-0x4.7 (5) +0x0|fa |. | major_type: "special_float" (7) 0x0-0x0.2 (0.3) +0x0|fa |. | short_count: "32bit" (26) 0x0.3-0x0.7 (0.5) +0x0| 47 c3 50 00| | G.P.| | value: 100000 0x1-0x4.7 (4) + |00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f|0123456789abcdef|.{}: (cbor) 0x0-0x4.7 (5) +0x0|fa |. | major_type: "special_float" (7) 0x0-0x0.2 (0.3) +0x0|fa |. | short_count: "32bit" (26) 0x0.3-0x0.7 (0.5) +0x0| 7f 7f ff ff| | ....| | value: 3.4028234663852886e+38 0x1-0x4.7 (4) + |00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f|0123456789abcdef|.{}: (cbor) 0x0-0x8.7 (9) +0x0|fb |. | major_type: "special_float" (7) 0x0-0x0.2 (0.3) +0x0|fb |. | short_count: "64bit" (27) 0x0.3-0x0.7 (0.5) +0x0| 7e 37 e4 3c 88 00 75 9c| | ~7.<..u.| | value: 1e+300 0x1-0x8.7 (8) + |00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f|0123456789abcdef|.{}: (cbor) 0x0-0x2.7 (3) +0x0|f9 |. | major_type: "special_float" (7) 0x0-0x0.2 (0.3) +0x0|f9 |. | short_count: "16bit" (25) 0x0.3-0x0.7 (0.5) +0x0| 00 01| | ..| | value: 5.960464477539063e-08 0x1-0x2.7 (2) + |00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f|0123456789abcdef|.{}: (cbor) 0x0-0x2.7 (3) +0x0|f9 |. | major_type: "special_float" (7) 0x0-0x0.2 (0.3) +0x0|f9 |. | short_count: "16bit" (25) 0x0.3-0x0.7 (0.5) +0x0| 04 00| | ..| | value: 6.103515625e-05 0x1-0x2.7 (2) + |00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f|0123456789abcdef|.{}: (cbor) 0x0-0x2.7 (3) +0x0|f9 |. | major_type: "special_float" (7) 0x0-0x0.2 (0.3) +0x0|f9 |. | short_count: "16bit" (25) 0x0.3-0x0.7 (0.5) +0x0| c4 00| | ..| | value: -4 0x1-0x2.7 (2) + |00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f|0123456789abcdef|.{}: (cbor) 0x0-0x8.7 (9) +0x0|fb |. | major_type: "special_float" (7) 0x0-0x0.2 (0.3) +0x0|fb |. | short_count: "64bit" (27) 0x0.3-0x0.7 (0.5) +0x0| c0 10 66 66 66 66 66 66| | ..ffffff| | value: -4.1 0x1-0x8.7 (8) + |00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f|0123456789abcdef|.{}: (cbor) 0x0-0x0.7 (1) +0x0|f5| |.| | major_type: "special_float" (7) 0x0-0x0.2 (0.3) +0x0|f5| |.| | short_count: 21 0x0.3-0x0.7 (0.5) + | | | value: true 0x1-NA (0) + |00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f|0123456789abcdef|.{}: (cbor) 0x0-0x0.7 (1) +0x0|60| |`| | major_type: "utf8" (3) 0x0-0x0.2 (0.3) +0x0|60| |`| | short_count: 0 0x0.3-0x0.7 (0.5) + | | | value: "" 0x1-NA (0) + |00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f|0123456789abcdef|.{}: (cbor) 0x0-0x1.7 (2) +0x0|61 |a | major_type: "utf8" (3) 0x0-0x0.2 (0.3) +0x0|61 |a | short_count: 1 0x0.3-0x0.7 (0.5) +0x0| 61| | a| | value: "a" 0x1-0x1.7 (1) + |00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f|0123456789abcdef|.{}: (cbor) 0x0-0x4.7 (5) +0x0|64 |d | major_type: "utf8" (3) 0x0-0x0.2 (0.3) +0x0|64 |d | short_count: 4 0x0.3-0x0.7 (0.5) +0x0| 49 45 54 46| | IETF| | value: "IETF" 0x1-0x4.7 (4) + |00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f|0123456789abcdef|.{}: (cbor) 0x0-0x2.7 (3) +0x0|62 |b | major_type: "utf8" (3) 0x0-0x0.2 (0.3) +0x0|62 |b | short_count: 2 0x0.3-0x0.7 (0.5) +0x0| 22 5c| | "\| | value: "\"\\" 0x1-0x2.7 (2) + |00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f|0123456789abcdef|.{}: (cbor) 0x0-0x2.7 (3) +0x0|62 |b | major_type: "utf8" (3) 0x0-0x0.2 (0.3) +0x0|62 |b | short_count: 2 0x0.3-0x0.7 (0.5) +0x0| c3 bc| | ..| | value: "ΓΌ" 0x1-0x2.7 (2) + |00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f|0123456789abcdef|.{}: (cbor) 0x0-0x3.7 (4) +0x0|63 |c | major_type: "utf8" (3) 0x0-0x0.2 (0.3) +0x0|63 |c | short_count: 3 0x0.3-0x0.7 (0.5) +0x0| e6 b0 b4| | ...| | value: "ζ°΄" 0x1-0x3.7 (3) + |00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f|0123456789abcdef|.{}: (cbor) 0x0-0x4.7 (5) +0x0|64 |d | major_type: "utf8" (3) 0x0-0x0.2 (0.3) +0x0|64 |d | short_count: 4 0x0.3-0x0.7 (0.5) +0x0| f0 90 85 91| | ....| | value: "𐅑" 0x1-0x4.7 (4) + |00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f|0123456789abcdef|.{}: (cbor) 0x0-0x0.7 (1) +0x0|80| |.| | major_type: "array" (4) 0x0-0x0.2 (0.3) +0x0|80| |.| | short_count: 0 0x0.3-0x0.7 (0.5) + | | | elements[0:0]: 0x1-NA (0) + |00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f|0123456789abcdef|.{}: (cbor) 0x0-0x3.7 (4) +0x0|83 |. | major_type: "array" (4) 0x0-0x0.2 (0.3) +0x0|83 |. | short_count: 3 0x0.3-0x0.7 (0.5) + | | | elements[0:3]: 0x1-0x3.7 (3) + | | | [0]{}: element 0x1-0x1.7 (1) +0x0| 01 | . | major_type: "positive_int" (0) 0x1-0x1.2 (0.3) +0x0| 01 | . | short_count: 1 0x1.3-0x1.7 (0.5) + | | | value: 1 0x2-NA (0) + | | | [1]{}: element 0x2-0x2.7 (1) +0x0| 02 | . | major_type: "positive_int" (0) 0x2-0x2.2 (0.3) +0x0| 02 | . | short_count: 2 0x2.3-0x2.7 (0.5) + | | | value: 2 0x3-NA (0) + | | | [2]{}: element 0x3-0x3.7 (1) +0x0| 03| | .| | major_type: "positive_int" (0) 0x3-0x3.2 (0.3) +0x0| 03| | .| | short_count: 3 0x3.3-0x3.7 (0.5) + | | | value: 3 0x4-NA (0) + |00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f|0123456789abcdef|.{}: (cbor) 0x0-0x7.7 (8) +0x0|83 |. | major_type: "array" (4) 0x0-0x0.2 (0.3) +0x0|83 |. | short_count: 3 0x0.3-0x0.7 (0.5) + | | | elements[0:3]: 0x1-0x7.7 (7) + | | | [0]{}: element 0x1-0x1.7 (1) +0x0| 01 | . | major_type: "positive_int" (0) 0x1-0x1.2 (0.3) +0x0| 01 | . | short_count: 1 0x1.3-0x1.7 (0.5) + | | | value: 1 0x2-NA (0) + | | | [1]{}: element 0x2-0x4.7 (3) +0x0| 82 | . | major_type: "array" (4) 0x2-0x2.2 (0.3) +0x0| 82 | . | short_count: 2 0x2.3-0x2.7 (0.5) + | | | elements[0:2]: 0x3-0x4.7 (2) + | | | [0]{}: element 0x3-0x3.7 (1) +0x0| 02 | . | major_type: "positive_int" (0) 0x3-0x3.2 (0.3) +0x0| 02 | . | short_count: 2 0x3.3-0x3.7 (0.5) + | | | value: 2 0x4-NA (0) + | | | [1]{}: element 0x4-0x4.7 (1) +0x0| 03 | . | major_type: "positive_int" (0) 0x4-0x4.2 (0.3) +0x0| 03 | . | short_count: 3 0x4.3-0x4.7 (0.5) + | | | value: 3 0x5-NA (0) + | | | [2]{}: element 0x5-0x7.7 (3) +0x0| 82 | . | major_type: "array" (4) 0x5-0x5.2 (0.3) +0x0| 82 | . | short_count: 2 0x5.3-0x5.7 (0.5) + | | | elements[0:2]: 0x6-0x7.7 (2) + | | | [0]{}: element 0x6-0x6.7 (1) +0x0| 04 | . | major_type: "positive_int" (0) 0x6-0x6.2 (0.3) +0x0| 04 | . | short_count: 4 0x6.3-0x6.7 (0.5) + | | | value: 4 0x7-NA (0) + | | | [1]{}: element 0x7-0x7.7 (1) +0x0| 05| | .| | major_type: "positive_int" (0) 0x7-0x7.2 (0.3) +0x0| 05| | .| | short_count: 5 0x7.3-0x7.7 (0.5) + | | | value: 5 0x8-NA (0) + |00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f|0123456789abcdef|.{}: (cbor) 0x0-0x1c.7 (29) +0x00|98 |. | major_type: "array" (4) 0x0-0x0.2 (0.3) +0x00|98 |. | short_count: "8bit" (24) 0x0.3-0x0.7 (0.5) +0x00| 19 | . | variable_count: 25 0x1-0x1.7 (1) + | | | elements[0:25]: 0x2-0x1c.7 (27) + | | | [0]{}: element 0x2-0x2.7 (1) +0x00| 01 | . | major_type: "positive_int" (0) 0x2-0x2.2 (0.3) +0x00| 01 | . | short_count: 1 0x2.3-0x2.7 (0.5) + | | | value: 1 0x3-NA (0) + | | | [1]{}: element 0x3-0x3.7 (1) +0x00| 02 | . | major_type: "positive_int" (0) 0x3-0x3.2 (0.3) +0x00| 02 | . | short_count: 2 0x3.3-0x3.7 (0.5) + | | | value: 2 0x4-NA (0) + | | | [2]{}: element 0x4-0x4.7 (1) +0x00| 03 | . | major_type: "positive_int" (0) 0x4-0x4.2 (0.3) +0x00| 03 | . | short_count: 3 0x4.3-0x4.7 (0.5) + | | | value: 3 0x5-NA (0) + | | | [3]{}: element 0x5-0x5.7 (1) +0x00| 04 | . | major_type: "positive_int" (0) 0x5-0x5.2 (0.3) +0x00| 04 | . | short_count: 4 0x5.3-0x5.7 (0.5) + | | | value: 4 0x6-NA (0) + | | | [4]{}: element 0x6-0x6.7 (1) +0x00| 05 | . | major_type: "positive_int" (0) 0x6-0x6.2 (0.3) +0x00| 05 | . | short_count: 5 0x6.3-0x6.7 (0.5) + | | | value: 5 0x7-NA (0) + | | | [5]{}: element 0x7-0x7.7 (1) +0x00| 06 | . | major_type: "positive_int" (0) 0x7-0x7.2 (0.3) +0x00| 06 | . | short_count: 6 0x7.3-0x7.7 (0.5) + | | | value: 6 0x8-NA (0) + | | | [6]{}: element 0x8-0x8.7 (1) +0x00| 07 | . | major_type: "positive_int" (0) 0x8-0x8.2 (0.3) +0x00| 07 | . | short_count: 7 0x8.3-0x8.7 (0.5) + | | | value: 7 0x9-NA (0) + | | | [7]{}: element 0x9-0x9.7 (1) +0x00| 08 | . | major_type: "positive_int" (0) 0x9-0x9.2 (0.3) +0x00| 08 | . | short_count: 8 0x9.3-0x9.7 (0.5) + | | | value: 8 0xa-NA (0) + | | | [8]{}: element 0xa-0xa.7 (1) +0x00| 09 | . | major_type: "positive_int" (0) 0xa-0xa.2 (0.3) +0x00| 09 | . | short_count: 9 0xa.3-0xa.7 (0.5) + | | | value: 9 0xb-NA (0) + | | | [9]{}: element 0xb-0xb.7 (1) +0x00| 0a | . | major_type: "positive_int" (0) 0xb-0xb.2 (0.3) +0x00| 0a | . | short_count: 10 0xb.3-0xb.7 (0.5) + | | | value: 10 0xc-NA (0) + | | | [10]{}: element 0xc-0xc.7 (1) +0x00| 0b | . | major_type: "positive_int" (0) 0xc-0xc.2 (0.3) +0x00| 0b | . | short_count: 11 0xc.3-0xc.7 (0.5) + | | | value: 11 0xd-NA (0) + | | | [11]{}: element 0xd-0xd.7 (1) +0x00| 0c | . | major_type: "positive_int" (0) 0xd-0xd.2 (0.3) +0x00| 0c | . | short_count: 12 0xd.3-0xd.7 (0.5) + | | | value: 12 0xe-NA (0) + | | | [12]{}: element 0xe-0xe.7 (1) +0x00| 0d | . | major_type: "positive_int" (0) 0xe-0xe.2 (0.3) +0x00| 0d | . | short_count: 13 0xe.3-0xe.7 (0.5) + | | | value: 13 0xf-NA (0) + | | | [13]{}: element 0xf-0xf.7 (1) +0x00| 0e| .| major_type: "positive_int" (0) 0xf-0xf.2 (0.3) +0x00| 0e| .| short_count: 14 0xf.3-0xf.7 (0.5) + | | | value: 14 0x10-NA (0) + | | | [14]{}: element 0x10-0x10.7 (1) +0x10|0f |. | major_type: "positive_int" (0) 0x10-0x10.2 (0.3) +0x10|0f |. | short_count: 15 0x10.3-0x10.7 (0.5) + | | | value: 15 0x11-NA (0) + | | | [15]{}: element 0x11-0x11.7 (1) +0x10| 10 | . | major_type: "positive_int" (0) 0x11-0x11.2 (0.3) +0x10| 10 | . | short_count: 16 0x11.3-0x11.7 (0.5) + | | | value: 16 0x12-NA (0) + | | | [16]{}: element 0x12-0x12.7 (1) +0x10| 11 | . | major_type: "positive_int" (0) 0x12-0x12.2 (0.3) +0x10| 11 | . | short_count: 17 0x12.3-0x12.7 (0.5) + | | | value: 17 0x13-NA (0) + | | | [17]{}: element 0x13-0x13.7 (1) +0x10| 12 | . | major_type: "positive_int" (0) 0x13-0x13.2 (0.3) +0x10| 12 | . | short_count: 18 0x13.3-0x13.7 (0.5) + | | | value: 18 0x14-NA (0) + | | | [18]{}: element 0x14-0x14.7 (1) +0x10| 13 | . | major_type: "positive_int" (0) 0x14-0x14.2 (0.3) +0x10| 13 | . | short_count: 19 0x14.3-0x14.7 (0.5) + | | | value: 19 0x15-NA (0) + | | | [19]{}: element 0x15-0x15.7 (1) +0x10| 14 | . | major_type: "positive_int" (0) 0x15-0x15.2 (0.3) +0x10| 14 | . | short_count: 20 0x15.3-0x15.7 (0.5) + | | | value: 20 0x16-NA (0) + | | | [20]{}: element 0x16-0x16.7 (1) +0x10| 15 | . | major_type: "positive_int" (0) 0x16-0x16.2 (0.3) +0x10| 15 | . | short_count: 21 0x16.3-0x16.7 (0.5) + | | | value: 21 0x17-NA (0) + | | | [21]{}: element 0x17-0x17.7 (1) +0x10| 16 | . | major_type: "positive_int" (0) 0x17-0x17.2 (0.3) +0x10| 16 | . | short_count: 22 0x17.3-0x17.7 (0.5) + | | | value: 22 0x18-NA (0) + | | | [22]{}: element 0x18-0x18.7 (1) +0x10| 17 | . | major_type: "positive_int" (0) 0x18-0x18.2 (0.3) +0x10| 17 | . | short_count: 23 0x18.3-0x18.7 (0.5) + | | | value: 23 0x19-NA (0) + | | | [23]{}: element 0x19-0x1a.7 (2) +0x10| 18 | . | major_type: "positive_int" (0) 0x19-0x19.2 (0.3) +0x10| 18 | . | short_count: "8bit" (24) 0x19.3-0x19.7 (0.5) +0x10| 18 | . | variable_count: 24 0x1a-0x1a.7 (1) + | | | value: 24 0x1b-NA (0) + | | | [24]{}: element 0x1b-0x1c.7 (2) +0x10| 18 | . | major_type: "positive_int" (0) 0x1b-0x1b.2 (0.3) +0x10| 18 | . | short_count: "8bit" (24) 0x1b.3-0x1b.7 (0.5) +0x10| 19| | .| | variable_count: 25 0x1c-0x1c.7 (1) + | | | value: 25 0x1d-NA (0) + |00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f|0123456789abcdef|.{}: (cbor) 0x0-0x0.7 (1) +0x0|a0| |.| | major_type: "map" (5) 0x0-0x0.2 (0.3) +0x0|a0| |.| | short_count: 0 0x0.3-0x0.7 (0.5) + | | | pairs[0:0]: 0x1-NA (0) + |00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f|0123456789abcdef|.{}: (cbor) 0x0-0x8.7 (9) +0x0|a2 |. | major_type: "map" (5) 0x0-0x0.2 (0.3) +0x0|a2 |. | short_count: 2 0x0.3-0x0.7 (0.5) + | | | pairs[0:2]: 0x1-0x8.7 (8) + | | | [0]{}: pair 0x1-0x3.7 (3) + | | | key{}: 0x1-0x2.7 (2) +0x0| 61 | a | major_type: "utf8" (3) 0x1-0x1.2 (0.3) +0x0| 61 | a | short_count: 1 0x1.3-0x1.7 (0.5) +0x0| 61 | a | value: "a" 0x2-0x2.7 (1) + | | | value{}: 0x3-0x3.7 (1) +0x0| 01 | . | major_type: "positive_int" (0) 0x3-0x3.2 (0.3) +0x0| 01 | . | short_count: 1 0x3.3-0x3.7 (0.5) + | | | value: 1 0x4-NA (0) + | | | [1]{}: pair 0x4-0x8.7 (5) + | | | key{}: 0x4-0x5.7 (2) +0x0| 61 | a | major_type: "utf8" (3) 0x4-0x4.2 (0.3) +0x0| 61 | a | short_count: 1 0x4.3-0x4.7 (0.5) +0x0| 62 | b | value: "b" 0x5-0x5.7 (1) + | | | value{}: 0x6-0x8.7 (3) +0x0| 82 | . | major_type: "array" (4) 0x6-0x6.2 (0.3) +0x0| 82 | . | short_count: 2 0x6.3-0x6.7 (0.5) + | | | elements[0:2]: 0x7-0x8.7 (2) + | | | [0]{}: element 0x7-0x7.7 (1) +0x0| 02 | . | major_type: "positive_int" (0) 0x7-0x7.2 (0.3) +0x0| 02 | . | short_count: 2 0x7.3-0x7.7 (0.5) + | | | value: 2 0x8-NA (0) + | | | [1]{}: element 0x8-0x8.7 (1) +0x0| 03| | .| | major_type: "positive_int" (0) 0x8-0x8.2 (0.3) +0x0| 03| | .| | short_count: 3 0x8.3-0x8.7 (0.5) + | | | value: 3 0x9-NA (0) + |00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f|0123456789abcdef|.{}: (cbor) 0x0-0x7.7 (8) +0x0|82 |. | major_type: "array" (4) 0x0-0x0.2 (0.3) +0x0|82 |. | short_count: 2 0x0.3-0x0.7 (0.5) + | | | elements[0:2]: 0x1-0x7.7 (7) + | | | [0]{}: element 0x1-0x2.7 (2) +0x0| 61 | a | major_type: "utf8" (3) 0x1-0x1.2 (0.3) +0x0| 61 | a | short_count: 1 0x1.3-0x1.7 (0.5) +0x0| 61 | a | value: "a" 0x2-0x2.7 (1) + | | | [1]{}: element 0x3-0x7.7 (5) +0x0| a1 | . | major_type: "map" (5) 0x3-0x3.2 (0.3) +0x0| a1 | . | short_count: 1 0x3.3-0x3.7 (0.5) + | | | pairs[0:1]: 0x4-0x7.7 (4) + | | | [0]{}: pair 0x4-0x7.7 (4) + | | | key{}: 0x4-0x5.7 (2) +0x0| 61 | a | major_type: "utf8" (3) 0x4-0x4.2 (0.3) +0x0| 61 | a | short_count: 1 0x4.3-0x4.7 (0.5) +0x0| 62 | b | value: "b" 0x5-0x5.7 (1) + | | | value{}: 0x6-0x7.7 (2) +0x0| 61 | a | major_type: "utf8" (3) 0x6-0x6.2 (0.3) +0x0| 61 | a | short_count: 1 0x6.3-0x6.7 (0.5) +0x0| 63| | c| | value: "c" 0x7-0x7.7 (1) + |00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f|0123456789abcdef|.{}: (cbor) 0x0-0x14.7 (21) +0x00|a5 |. | major_type: "map" (5) 0x0-0x0.2 (0.3) +0x00|a5 |. | short_count: 5 0x0.3-0x0.7 (0.5) + | | | pairs[0:5]: 0x1-0x14.7 (20) + | | | [0]{}: pair 0x1-0x4.7 (4) + | | | key{}: 0x1-0x2.7 (2) +0x00| 61 | a | major_type: "utf8" (3) 0x1-0x1.2 (0.3) +0x00| 61 | a | short_count: 1 0x1.3-0x1.7 (0.5) +0x00| 61 | a | value: "a" 0x2-0x2.7 (1) + | | | value{}: 0x3-0x4.7 (2) +0x00| 61 | a | major_type: "utf8" (3) 0x3-0x3.2 (0.3) +0x00| 61 | a | short_count: 1 0x3.3-0x3.7 (0.5) +0x00| 41 | A | value: "A" 0x4-0x4.7 (1) + | | | [1]{}: pair 0x5-0x8.7 (4) + | | | key{}: 0x5-0x6.7 (2) +0x00| 61 | a | major_type: "utf8" (3) 0x5-0x5.2 (0.3) +0x00| 61 | a | short_count: 1 0x5.3-0x5.7 (0.5) +0x00| 62 | b | value: "b" 0x6-0x6.7 (1) + | | | value{}: 0x7-0x8.7 (2) +0x00| 61 | a | major_type: "utf8" (3) 0x7-0x7.2 (0.3) +0x00| 61 | a | short_count: 1 0x7.3-0x7.7 (0.5) +0x00| 42 | B | value: "B" 0x8-0x8.7 (1) + | | | [2]{}: pair 0x9-0xc.7 (4) + | | | key{}: 0x9-0xa.7 (2) +0x00| 61 | a | major_type: "utf8" (3) 0x9-0x9.2 (0.3) +0x00| 61 | a | short_count: 1 0x9.3-0x9.7 (0.5) +0x00| 63 | c | value: "c" 0xa-0xa.7 (1) + | | | value{}: 0xb-0xc.7 (2) +0x00| 61 | a | major_type: "utf8" (3) 0xb-0xb.2 (0.3) +0x00| 61 | a | short_count: 1 0xb.3-0xb.7 (0.5) +0x00| 43 | C | value: "C" 0xc-0xc.7 (1) + | | | [3]{}: pair 0xd-0x10.7 (4) + | | | key{}: 0xd-0xe.7 (2) +0x00| 61 | a | major_type: "utf8" (3) 0xd-0xd.2 (0.3) +0x00| 61 | a | short_count: 1 0xd.3-0xd.7 (0.5) +0x00| 64 | d | value: "d" 0xe-0xe.7 (1) + | | | value{}: 0xf-0x10.7 (2) +0x00| 61| a| major_type: "utf8" (3) 0xf-0xf.2 (0.3) +0x00| 61| a| short_count: 1 0xf.3-0xf.7 (0.5) +0x10|44 |D | value: "D" 0x10-0x10.7 (1) + | | | [4]{}: pair 0x11-0x14.7 (4) + | | | key{}: 0x11-0x12.7 (2) +0x10| 61 | a | major_type: "utf8" (3) 0x11-0x11.2 (0.3) +0x10| 61 | a | short_count: 1 0x11.3-0x11.7 (0.5) +0x10| 65 | e | value: "e" 0x12-0x12.7 (1) + | | | value{}: 0x13-0x14.7 (2) +0x10| 61 | a | major_type: "utf8" (3) 0x13-0x13.2 (0.3) +0x10| 61 | a | short_count: 1 0x13.3-0x13.7 (0.5) +0x10| 45| | E| | value: "E" 0x14-0x14.7 (1) + |00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f|0123456789abcdef|.{}: (cbor) 0x0-0xc.7 (13) +0x0|7f |. | major_type: "utf8" (3) 0x0-0x0.2 (0.3) +0x0|7f |. | short_count: "indefinite" (31) 0x0.3-0x0.7 (0.5) + | | | items[0:2]: 0x1-0xb.7 (11) + | | | [0]{}: item 0x1-0x6.7 (6) +0x0| 65 | e | major_type: "utf8" (3) 0x1-0x1.2 (0.3) +0x0| 65 | e | short_count: 5 0x1.3-0x1.7 (0.5) +0x0| 73 74 72 65 61 | strea | value: "strea" 0x2-0x6.7 (5) + | | | [1]{}: item 0x7-0xb.7 (5) +0x0| 64 | d | major_type: "utf8" (3) 0x7-0x7.2 (0.3) +0x0| 64 | d | short_count: 4 0x7.3-0x7.7 (0.5) +0x0| 6d 69 6e 67 | ming | value: "ming" 0x8-0xb.7 (4) + | | | value: "streaming" 0xc-NA (0) +0x0| ff| | .| | unknown0: raw bits 0xc-0xc.7 (1) + |00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f|0123456789abcdef|.{}: (cbor) 0x0-0x1.7 (2) +0x0|9f |. | major_type: "array" (4) 0x0-0x0.2 (0.3) +0x0|9f |. | short_count: "indefinite" (31) 0x0.3-0x0.7 (0.5) + | | | elements[0:0]: 0x1-NA (0) +0x0| ff| | .| | break: 255 0x1-0x1.7 (1) + |00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f|0123456789abcdef|.{}: (cbor) 0x0-0x9.7 (10) +0x0|9f |. | major_type: "array" (4) 0x0-0x0.2 (0.3) +0x0|9f |. | short_count: "indefinite" (31) 0x0.3-0x0.7 (0.5) + | | | elements[0:3]: 0x1-0x8.7 (8) + | | | [0]{}: element 0x1-0x1.7 (1) +0x0| 01 | . | major_type: "positive_int" (0) 0x1-0x1.2 (0.3) +0x0| 01 | . | short_count: 1 0x1.3-0x1.7 (0.5) + | | | value: 1 0x2-NA (0) + | | | [1]{}: element 0x2-0x4.7 (3) +0x0| 82 | . | major_type: "array" (4) 0x2-0x2.2 (0.3) +0x0| 82 | . | short_count: 2 0x2.3-0x2.7 (0.5) + | | | elements[0:2]: 0x3-0x4.7 (2) + | | | [0]{}: element 0x3-0x3.7 (1) +0x0| 02 | . | major_type: "positive_int" (0) 0x3-0x3.2 (0.3) +0x0| 02 | . | short_count: 2 0x3.3-0x3.7 (0.5) + | | | value: 2 0x4-NA (0) + | | | [1]{}: element 0x4-0x4.7 (1) +0x0| 03 | . | major_type: "positive_int" (0) 0x4-0x4.2 (0.3) +0x0| 03 | . | short_count: 3 0x4.3-0x4.7 (0.5) + | | | value: 3 0x5-NA (0) + | | | [2]{}: element 0x5-0x8.7 (4) +0x0| 9f | . | major_type: "array" (4) 0x5-0x5.2 (0.3) +0x0| 9f | . | short_count: "indefinite" (31) 0x5.3-0x5.7 (0.5) + | | | elements[0:2]: 0x6-0x7.7 (2) + | | | [0]{}: element 0x6-0x6.7 (1) +0x0| 04 | . | major_type: "positive_int" (0) 0x6-0x6.2 (0.3) +0x0| 04 | . | short_count: 4 0x6.3-0x6.7 (0.5) + | | | value: 4 0x7-NA (0) + | | | [1]{}: element 0x7-0x7.7 (1) +0x0| 05 | . | major_type: "positive_int" (0) 0x7-0x7.2 (0.3) +0x0| 05 | . | short_count: 5 0x7.3-0x7.7 (0.5) + | | | value: 5 0x8-NA (0) +0x0| ff | . | break: 255 0x8-0x8.7 (1) +0x0| ff| | .| | break: 255 0x9-0x9.7 (1) + |00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f|0123456789abcdef|.{}: (cbor) 0x0-0x8.7 (9) +0x0|9f |. | major_type: "array" (4) 0x0-0x0.2 (0.3) +0x0|9f |. | short_count: "indefinite" (31) 0x0.3-0x0.7 (0.5) + | | | elements[0:3]: 0x1-0x7.7 (7) + | | | [0]{}: element 0x1-0x1.7 (1) +0x0| 01 | . | major_type: "positive_int" (0) 0x1-0x1.2 (0.3) +0x0| 01 | . | short_count: 1 0x1.3-0x1.7 (0.5) + | | | value: 1 0x2-NA (0) + | | | [1]{}: element 0x2-0x4.7 (3) +0x0| 82 | . | major_type: "array" (4) 0x2-0x2.2 (0.3) +0x0| 82 | . | short_count: 2 0x2.3-0x2.7 (0.5) + | | | elements[0:2]: 0x3-0x4.7 (2) + | | | [0]{}: element 0x3-0x3.7 (1) +0x0| 02 | . | major_type: "positive_int" (0) 0x3-0x3.2 (0.3) +0x0| 02 | . | short_count: 2 0x3.3-0x3.7 (0.5) + | | | value: 2 0x4-NA (0) + | | | [1]{}: element 0x4-0x4.7 (1) +0x0| 03 | . | major_type: "positive_int" (0) 0x4-0x4.2 (0.3) +0x0| 03 | . | short_count: 3 0x4.3-0x4.7 (0.5) + | | | value: 3 0x5-NA (0) + | | | [2]{}: element 0x5-0x7.7 (3) +0x0| 82 | . | major_type: "array" (4) 0x5-0x5.2 (0.3) +0x0| 82 | . | short_count: 2 0x5.3-0x5.7 (0.5) + | | | elements[0:2]: 0x6-0x7.7 (2) + | | | [0]{}: element 0x6-0x6.7 (1) +0x0| 04 | . | major_type: "positive_int" (0) 0x6-0x6.2 (0.3) +0x0| 04 | . | short_count: 4 0x6.3-0x6.7 (0.5) + | | | value: 4 0x7-NA (0) + | | | [1]{}: element 0x7-0x7.7 (1) +0x0| 05 | . | major_type: "positive_int" (0) 0x7-0x7.2 (0.3) +0x0| 05 | . | short_count: 5 0x7.3-0x7.7 (0.5) + | | | value: 5 0x8-NA (0) +0x0| ff| | .| | break: 255 0x8-0x8.7 (1) + |00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f|0123456789abcdef|.{}: (cbor) 0x0-0x8.7 (9) +0x0|83 |. | major_type: "array" (4) 0x0-0x0.2 (0.3) +0x0|83 |. | short_count: 3 0x0.3-0x0.7 (0.5) + | | | elements[0:3]: 0x1-0x8.7 (8) + | | | [0]{}: element 0x1-0x1.7 (1) +0x0| 01 | . | major_type: "positive_int" (0) 0x1-0x1.2 (0.3) +0x0| 01 | . | short_count: 1 0x1.3-0x1.7 (0.5) + | | | value: 1 0x2-NA (0) + | | | [1]{}: element 0x2-0x4.7 (3) +0x0| 82 | . | major_type: "array" (4) 0x2-0x2.2 (0.3) +0x0| 82 | . | short_count: 2 0x2.3-0x2.7 (0.5) + | | | elements[0:2]: 0x3-0x4.7 (2) + | | | [0]{}: element 0x3-0x3.7 (1) +0x0| 02 | . | major_type: "positive_int" (0) 0x3-0x3.2 (0.3) +0x0| 02 | . | short_count: 2 0x3.3-0x3.7 (0.5) + | | | value: 2 0x4-NA (0) + | | | [1]{}: element 0x4-0x4.7 (1) +0x0| 03 | . | major_type: "positive_int" (0) 0x4-0x4.2 (0.3) +0x0| 03 | . | short_count: 3 0x4.3-0x4.7 (0.5) + | | | value: 3 0x5-NA (0) + | | | [2]{}: element 0x5-0x8.7 (4) +0x0| 9f | . | major_type: "array" (4) 0x5-0x5.2 (0.3) +0x0| 9f | . | short_count: "indefinite" (31) 0x5.3-0x5.7 (0.5) + | | | elements[0:2]: 0x6-0x7.7 (2) + | | | [0]{}: element 0x6-0x6.7 (1) +0x0| 04 | . | major_type: "positive_int" (0) 0x6-0x6.2 (0.3) +0x0| 04 | . | short_count: 4 0x6.3-0x6.7 (0.5) + | | | value: 4 0x7-NA (0) + | | | [1]{}: element 0x7-0x7.7 (1) +0x0| 05 | . | major_type: "positive_int" (0) 0x7-0x7.2 (0.3) +0x0| 05 | . | short_count: 5 0x7.3-0x7.7 (0.5) + | | | value: 5 0x8-NA (0) +0x0| ff| | .| | break: 255 0x8-0x8.7 (1) + |00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f|0123456789abcdef|.{}: (cbor) 0x0-0x8.7 (9) +0x0|83 |. | major_type: "array" (4) 0x0-0x0.2 (0.3) +0x0|83 |. | short_count: 3 0x0.3-0x0.7 (0.5) + | | | elements[0:3]: 0x1-0x8.7 (8) + | | | [0]{}: element 0x1-0x1.7 (1) +0x0| 01 | . | major_type: "positive_int" (0) 0x1-0x1.2 (0.3) +0x0| 01 | . | short_count: 1 0x1.3-0x1.7 (0.5) + | | | value: 1 0x2-NA (0) + | | | [1]{}: element 0x2-0x5.7 (4) +0x0| 9f | . | major_type: "array" (4) 0x2-0x2.2 (0.3) +0x0| 9f | . | short_count: "indefinite" (31) 0x2.3-0x2.7 (0.5) + | | | elements[0:2]: 0x3-0x4.7 (2) + | | | [0]{}: element 0x3-0x3.7 (1) +0x0| 02 | . | major_type: "positive_int" (0) 0x3-0x3.2 (0.3) +0x0| 02 | . | short_count: 2 0x3.3-0x3.7 (0.5) + | | | value: 2 0x4-NA (0) + | | | [1]{}: element 0x4-0x4.7 (1) +0x0| 03 | . | major_type: "positive_int" (0) 0x4-0x4.2 (0.3) +0x0| 03 | . | short_count: 3 0x4.3-0x4.7 (0.5) + | | | value: 3 0x5-NA (0) +0x0| ff | . | break: 255 0x5-0x5.7 (1) + | | | [2]{}: element 0x6-0x8.7 (3) +0x0| 82 | . | major_type: "array" (4) 0x6-0x6.2 (0.3) +0x0| 82 | . | short_count: 2 0x6.3-0x6.7 (0.5) + | | | elements[0:2]: 0x7-0x8.7 (2) + | | | [0]{}: element 0x7-0x7.7 (1) +0x0| 04 | . | major_type: "positive_int" (0) 0x7-0x7.2 (0.3) +0x0| 04 | . | short_count: 4 0x7.3-0x7.7 (0.5) + | | | value: 4 0x8-NA (0) + | | | [1]{}: element 0x8-0x8.7 (1) +0x0| 05| | .| | major_type: "positive_int" (0) 0x8-0x8.2 (0.3) +0x0| 05| | .| | short_count: 5 0x8.3-0x8.7 (0.5) + | | | value: 5 0x9-NA (0) + |00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f|0123456789abcdef|.{}: (cbor) 0x0-0x1c.7 (29) +0x00|9f |. | major_type: "array" (4) 0x0-0x0.2 (0.3) +0x00|9f |. | short_count: "indefinite" (31) 0x0.3-0x0.7 (0.5) + | | | elements[0:25]: 0x1-0x1b.7 (27) + | | | [0]{}: element 0x1-0x1.7 (1) +0x00| 01 | . | major_type: "positive_int" (0) 0x1-0x1.2 (0.3) +0x00| 01 | . | short_count: 1 0x1.3-0x1.7 (0.5) + | | | value: 1 0x2-NA (0) + | | | [1]{}: element 0x2-0x2.7 (1) +0x00| 02 | . | major_type: "positive_int" (0) 0x2-0x2.2 (0.3) +0x00| 02 | . | short_count: 2 0x2.3-0x2.7 (0.5) + | | | value: 2 0x3-NA (0) + | | | [2]{}: element 0x3-0x3.7 (1) +0x00| 03 | . | major_type: "positive_int" (0) 0x3-0x3.2 (0.3) +0x00| 03 | . | short_count: 3 0x3.3-0x3.7 (0.5) + | | | value: 3 0x4-NA (0) + | | | [3]{}: element 0x4-0x4.7 (1) +0x00| 04 | . | major_type: "positive_int" (0) 0x4-0x4.2 (0.3) +0x00| 04 | . | short_count: 4 0x4.3-0x4.7 (0.5) + | | | value: 4 0x5-NA (0) + | | | [4]{}: element 0x5-0x5.7 (1) +0x00| 05 | . | major_type: "positive_int" (0) 0x5-0x5.2 (0.3) +0x00| 05 | . | short_count: 5 0x5.3-0x5.7 (0.5) + | | | value: 5 0x6-NA (0) + | | | [5]{}: element 0x6-0x6.7 (1) +0x00| 06 | . | major_type: "positive_int" (0) 0x6-0x6.2 (0.3) +0x00| 06 | . | short_count: 6 0x6.3-0x6.7 (0.5) + | | | value: 6 0x7-NA (0) + | | | [6]{}: element 0x7-0x7.7 (1) +0x00| 07 | . | major_type: "positive_int" (0) 0x7-0x7.2 (0.3) +0x00| 07 | . | short_count: 7 0x7.3-0x7.7 (0.5) + | | | value: 7 0x8-NA (0) + | | | [7]{}: element 0x8-0x8.7 (1) +0x00| 08 | . | major_type: "positive_int" (0) 0x8-0x8.2 (0.3) +0x00| 08 | . | short_count: 8 0x8.3-0x8.7 (0.5) + | | | value: 8 0x9-NA (0) + | | | [8]{}: element 0x9-0x9.7 (1) +0x00| 09 | . | major_type: "positive_int" (0) 0x9-0x9.2 (0.3) +0x00| 09 | . | short_count: 9 0x9.3-0x9.7 (0.5) + | | | value: 9 0xa-NA (0) + | | | [9]{}: element 0xa-0xa.7 (1) +0x00| 0a | . | major_type: "positive_int" (0) 0xa-0xa.2 (0.3) +0x00| 0a | . | short_count: 10 0xa.3-0xa.7 (0.5) + | | | value: 10 0xb-NA (0) + | | | [10]{}: element 0xb-0xb.7 (1) +0x00| 0b | . | major_type: "positive_int" (0) 0xb-0xb.2 (0.3) +0x00| 0b | . | short_count: 11 0xb.3-0xb.7 (0.5) + | | | value: 11 0xc-NA (0) + | | | [11]{}: element 0xc-0xc.7 (1) +0x00| 0c | . | major_type: "positive_int" (0) 0xc-0xc.2 (0.3) +0x00| 0c | . | short_count: 12 0xc.3-0xc.7 (0.5) + | | | value: 12 0xd-NA (0) + | | | [12]{}: element 0xd-0xd.7 (1) +0x00| 0d | . | major_type: "positive_int" (0) 0xd-0xd.2 (0.3) +0x00| 0d | . | short_count: 13 0xd.3-0xd.7 (0.5) + | | | value: 13 0xe-NA (0) + | | | [13]{}: element 0xe-0xe.7 (1) +0x00| 0e | . | major_type: "positive_int" (0) 0xe-0xe.2 (0.3) +0x00| 0e | . | short_count: 14 0xe.3-0xe.7 (0.5) + | | | value: 14 0xf-NA (0) + | | | [14]{}: element 0xf-0xf.7 (1) +0x00| 0f| .| major_type: "positive_int" (0) 0xf-0xf.2 (0.3) +0x00| 0f| .| short_count: 15 0xf.3-0xf.7 (0.5) + | | | value: 15 0x10-NA (0) + | | | [15]{}: element 0x10-0x10.7 (1) +0x10|10 |. | major_type: "positive_int" (0) 0x10-0x10.2 (0.3) +0x10|10 |. | short_count: 16 0x10.3-0x10.7 (0.5) + | | | value: 16 0x11-NA (0) + | | | [16]{}: element 0x11-0x11.7 (1) +0x10| 11 | . | major_type: "positive_int" (0) 0x11-0x11.2 (0.3) +0x10| 11 | . | short_count: 17 0x11.3-0x11.7 (0.5) + | | | value: 17 0x12-NA (0) + | | | [17]{}: element 0x12-0x12.7 (1) +0x10| 12 | . | major_type: "positive_int" (0) 0x12-0x12.2 (0.3) +0x10| 12 | . | short_count: 18 0x12.3-0x12.7 (0.5) + | | | value: 18 0x13-NA (0) + | | | [18]{}: element 0x13-0x13.7 (1) +0x10| 13 | . | major_type: "positive_int" (0) 0x13-0x13.2 (0.3) +0x10| 13 | . | short_count: 19 0x13.3-0x13.7 (0.5) + | | | value: 19 0x14-NA (0) + | | | [19]{}: element 0x14-0x14.7 (1) +0x10| 14 | . | major_type: "positive_int" (0) 0x14-0x14.2 (0.3) +0x10| 14 | . | short_count: 20 0x14.3-0x14.7 (0.5) + | | | value: 20 0x15-NA (0) + | | | [20]{}: element 0x15-0x15.7 (1) +0x10| 15 | . | major_type: "positive_int" (0) 0x15-0x15.2 (0.3) +0x10| 15 | . | short_count: 21 0x15.3-0x15.7 (0.5) + | | | value: 21 0x16-NA (0) + | | | [21]{}: element 0x16-0x16.7 (1) +0x10| 16 | . | major_type: "positive_int" (0) 0x16-0x16.2 (0.3) +0x10| 16 | . | short_count: 22 0x16.3-0x16.7 (0.5) + | | | value: 22 0x17-NA (0) + | | | [22]{}: element 0x17-0x17.7 (1) +0x10| 17 | . | major_type: "positive_int" (0) 0x17-0x17.2 (0.3) +0x10| 17 | . | short_count: 23 0x17.3-0x17.7 (0.5) + | | | value: 23 0x18-NA (0) + | | | [23]{}: element 0x18-0x19.7 (2) +0x10| 18 | . | major_type: "positive_int" (0) 0x18-0x18.2 (0.3) +0x10| 18 | . | short_count: "8bit" (24) 0x18.3-0x18.7 (0.5) +0x10| 18 | . | variable_count: 24 0x19-0x19.7 (1) + | | | value: 24 0x1a-NA (0) + | | | [24]{}: element 0x1a-0x1b.7 (2) +0x10| 18 | . | major_type: "positive_int" (0) 0x1a-0x1a.2 (0.3) +0x10| 18 | . | short_count: "8bit" (24) 0x1a.3-0x1a.7 (0.5) +0x10| 19 | . | variable_count: 25 0x1b-0x1b.7 (1) + | | | value: 25 0x1c-NA (0) +0x10| ff| | .| | break: 255 0x1c-0x1c.7 (1) + |00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f|0123456789abcdef|.{}: (cbor) 0x0-0xa.7 (11) +0x0|bf |. | major_type: "map" (5) 0x0-0x0.2 (0.3) +0x0|bf |. | short_count: "indefinite" (31) 0x0.3-0x0.7 (0.5) + | | | pairs[0:2]: 0x1-0x9.7 (9) + | | | [0]{}: pair 0x1-0x3.7 (3) + | | | key{}: 0x1-0x2.7 (2) +0x0| 61 | a | major_type: "utf8" (3) 0x1-0x1.2 (0.3) +0x0| 61 | a | short_count: 1 0x1.3-0x1.7 (0.5) +0x0| 61 | a | value: "a" 0x2-0x2.7 (1) + | | | value{}: 0x3-0x3.7 (1) +0x0| 01 | . | major_type: "positive_int" (0) 0x3-0x3.2 (0.3) +0x0| 01 | . | short_count: 1 0x3.3-0x3.7 (0.5) + | | | value: 1 0x4-NA (0) + | | | [1]{}: pair 0x4-0x9.7 (6) + | | | key{}: 0x4-0x5.7 (2) +0x0| 61 | a | major_type: "utf8" (3) 0x4-0x4.2 (0.3) +0x0| 61 | a | short_count: 1 0x4.3-0x4.7 (0.5) +0x0| 62 | b | value: "b" 0x5-0x5.7 (1) + | | | value{}: 0x6-0x9.7 (4) +0x0| 9f | . | major_type: "array" (4) 0x6-0x6.2 (0.3) +0x0| 9f | . | short_count: "indefinite" (31) 0x6.3-0x6.7 (0.5) + | | | elements[0:2]: 0x7-0x8.7 (2) + | | | [0]{}: element 0x7-0x7.7 (1) +0x0| 02 | . | major_type: "positive_int" (0) 0x7-0x7.2 (0.3) +0x0| 02 | . | short_count: 2 0x7.3-0x7.7 (0.5) + | | | value: 2 0x8-NA (0) + | | | [1]{}: element 0x8-0x8.7 (1) +0x0| 03 | . | major_type: "positive_int" (0) 0x8-0x8.2 (0.3) +0x0| 03 | . | short_count: 3 0x8.3-0x8.7 (0.5) + | | | value: 3 0x9-NA (0) +0x0| ff | . | break: 255 0x9-0x9.7 (1) +0x0| ff| | .| | break: 255 0xa-0xa.7 (1) + |00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f|0123456789abcdef|.{}: (cbor) 0x0-0x8.7 (9) +0x0|82 |. | major_type: "array" (4) 0x0-0x0.2 (0.3) +0x0|82 |. | short_count: 2 0x0.3-0x0.7 (0.5) + | | | elements[0:2]: 0x1-0x8.7 (8) + | | | [0]{}: element 0x1-0x2.7 (2) +0x0| 61 | a | major_type: "utf8" (3) 0x1-0x1.2 (0.3) +0x0| 61 | a | short_count: 1 0x1.3-0x1.7 (0.5) +0x0| 61 | a | value: "a" 0x2-0x2.7 (1) + | | | [1]{}: element 0x3-0x8.7 (6) +0x0| bf | . | major_type: "map" (5) 0x3-0x3.2 (0.3) +0x0| bf | . | short_count: "indefinite" (31) 0x3.3-0x3.7 (0.5) + | | | pairs[0:1]: 0x4-0x7.7 (4) + | | | [0]{}: pair 0x4-0x7.7 (4) + | | | key{}: 0x4-0x5.7 (2) +0x0| 61 | a | major_type: "utf8" (3) 0x4-0x4.2 (0.3) +0x0| 61 | a | short_count: 1 0x4.3-0x4.7 (0.5) +0x0| 62 | b | value: "b" 0x5-0x5.7 (1) + | | | value{}: 0x6-0x7.7 (2) +0x0| 61 | a | major_type: "utf8" (3) 0x6-0x6.2 (0.3) +0x0| 61 | a | short_count: 1 0x6.3-0x6.7 (0.5) +0x0| 63 | c | value: "c" 0x7-0x7.7 (1) +0x0| ff| | .| | break: 255 0x8-0x8.7 (1) + |00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f|0123456789abcdef|.{}: (cbor) 0x0-0xb.7 (12) +0x0|bf |. | major_type: "map" (5) 0x0-0x0.2 (0.3) +0x0|bf |. | short_count: "indefinite" (31) 0x0.3-0x0.7 (0.5) + | | | pairs[0:2]: 0x1-0xa.7 (10) + | | | [0]{}: pair 0x1-0x5.7 (5) + | | | key{}: 0x1-0x4.7 (4) +0x0| 63 | c | major_type: "utf8" (3) 0x1-0x1.2 (0.3) +0x0| 63 | c | short_count: 3 0x1.3-0x1.7 (0.5) +0x0| 46 75 6e | Fun | value: "Fun" 0x2-0x4.7 (3) + | | | value{}: 0x5-0x5.7 (1) +0x0| f5 | . | major_type: "special_float" (7) 0x5-0x5.2 (0.3) +0x0| f5 | . | short_count: 21 0x5.3-0x5.7 (0.5) + | | | value: true 0x6-NA (0) + | | | [1]{}: pair 0x6-0xa.7 (5) + | | | key{}: 0x6-0x9.7 (4) +0x0| 63 | c | major_type: "utf8" (3) 0x6-0x6.2 (0.3) +0x0| 63 | c | short_count: 3 0x6.3-0x6.7 (0.5) +0x0| 41 6d 74 | Amt | value: "Amt" 0x7-0x9.7 (3) + | | | value{}: 0xa-0xa.7 (1) +0x0| 21 | ! | major_type: "negative_int" (1) 0xa-0xa.2 (0.3) +0x0| 21 | ! | short_count: 1 0xa.3-0xa.7 (0.5) + | | | value: -2 0xb-NA (0) +0x0| ff| | .| | break: 255 0xb-0xb.7 (1) +json> ^D diff --git a/format/cbor/testdata/appendix_a.json b/format/cbor/testdata/appendix_a.json new file mode 100644 index 00000000..7047bc34 --- /dev/null +++ b/format/cbor/testdata/appendix_a.json @@ -0,0 +1,636 @@ +[ + { + "cbor": "AA==", + "hex": "00", + "roundtrip": true, + "decoded": 0 + }, + { + "cbor": "AQ==", + "hex": "01", + "roundtrip": true, + "decoded": 1 + }, + { + "cbor": "Cg==", + "hex": "0a", + "roundtrip": true, + "decoded": 10 + }, + { + "cbor": "Fw==", + "hex": "17", + "roundtrip": true, + "decoded": 23 + }, + { + "cbor": "GBg=", + "hex": "1818", + "roundtrip": true, + "decoded": 24 + }, + { + "cbor": "GBk=", + "hex": "1819", + "roundtrip": true, + "decoded": 25 + }, + { + "cbor": "GGQ=", + "hex": "1864", + "roundtrip": true, + "decoded": 100 + }, + { + "cbor": "GQPo", + "hex": "1903e8", + "roundtrip": true, + "decoded": 1000 + }, + { + "cbor": "GgAPQkA=", + "hex": "1a000f4240", + "roundtrip": true, + "decoded": 1000000 + }, + { + "cbor": "GwAAAOjUpRAA", + "hex": "1b000000e8d4a51000", + "roundtrip": true, + "decoded": 1000000000000 + }, + { + "cbor": "G///////////", + "hex": "1bffffffffffffffff", + "roundtrip": true, + "decoded": 18446744073709551615 + }, + { + "cbor": "wkkBAAAAAAAAAAA=", + "hex": "c249010000000000000000", + "roundtrip": true, + "decoded": 18446744073709551616 + }, + { + "cbor": "O///////////", + "hex": "3bffffffffffffffff", + "roundtrip": true, + "decoded": -18446744073709551616 + }, + { + "cbor": "w0kBAAAAAAAAAAA=", + "hex": "c349010000000000000000", + "roundtrip": true, + "decoded": -18446744073709551617 + }, + { + "cbor": "IA==", + "hex": "20", + "roundtrip": true, + "decoded": -1 + }, + { + "cbor": "KQ==", + "hex": "29", + "roundtrip": true, + "decoded": -10 + }, + { + "cbor": "OGM=", + "hex": "3863", + "roundtrip": true, + "decoded": -100 + }, + { + "cbor": "OQPn", + "hex": "3903e7", + "roundtrip": true, + "decoded": -1000 + }, + { + "cbor": "+QAA", + "hex": "f90000", + "roundtrip": true, + "decoded": 0.0 + }, + { + "cbor": "+YAA", + "hex": "f98000", + "roundtrip": true, + "decoded": -0.0 + }, + { + "cbor": "+TwA", + "hex": "f93c00", + "roundtrip": true, + "decoded": 1.0 + }, + { + "cbor": "+z/xmZmZmZma", + "hex": "fb3ff199999999999a", + "roundtrip": true, + "decoded": 1.1 + }, + { + "cbor": "+T4A", + "hex": "f93e00", + "roundtrip": true, + "decoded": 1.5 + }, + { + "cbor": "+Xv/", + "hex": "f97bff", + "roundtrip": true, + "decoded": 65504.0 + }, + { + "cbor": "+kfDUAA=", + "hex": "fa47c35000", + "roundtrip": true, + "decoded": 100000.0 + }, + { + "cbor": "+n9///8=", + "hex": "fa7f7fffff", + "roundtrip": true, + "decoded": 3.4028234663852886e+38 + }, + { + "cbor": "+3435DyIAHWc", + "hex": "fb7e37e43c8800759c", + "roundtrip": true, + "decoded": 1.0e+300 + }, + { + "cbor": "+QAB", + "hex": "f90001", + "roundtrip": true, + "decoded": 5.960464477539063e-08 + }, + { + "cbor": "+QQA", + "hex": "f90400", + "roundtrip": true, + "decoded": 6.103515625e-05 + }, + { + "cbor": "+cQA", + "hex": "f9c400", + "roundtrip": true, + "decoded": -4.0 + }, + { + "cbor": "+8AQZmZmZmZm", + "hex": "fbc010666666666666", + "roundtrip": true, + "decoded": -4.1 + }, + { + "cbor": "+XwA", + "hex": "f97c00", + "roundtrip": true, + "diagnostic": "Infinity" + }, + { + "cbor": "+X4A", + "hex": "f97e00", + "roundtrip": true, + "diagnostic": "NaN" + }, + { + "cbor": "+fwA", + "hex": "f9fc00", + "roundtrip": true, + "diagnostic": "-Infinity" + }, + { + "cbor": "+n+AAAA=", + "hex": "fa7f800000", + "roundtrip": false, + "diagnostic": "Infinity" + }, + { + "cbor": "+n/AAAA=", + "hex": "fa7fc00000", + "roundtrip": false, + "diagnostic": "NaN" + }, + { + "cbor": "+v+AAAA=", + "hex": "faff800000", + "roundtrip": false, + "diagnostic": "-Infinity" + }, + { + "cbor": "+3/wAAAAAAAA", + "hex": "fb7ff0000000000000", + "roundtrip": false, + "diagnostic": "Infinity" + }, + { + "cbor": "+3/4AAAAAAAA", + "hex": "fb7ff8000000000000", + "roundtrip": false, + "diagnostic": "NaN" + }, + { + "cbor": "+//wAAAAAAAA", + "hex": "fbfff0000000000000", + "roundtrip": false, + "diagnostic": "-Infinity" + }, + { + "cbor": "9A==", + "hex": "f4", + "roundtrip": true, + "decoded": false + }, + { + "cbor": "9Q==", + "hex": "f5", + "roundtrip": true, + "decoded": true + }, + { + "cbor": "9g==", + "hex": "f6", + "roundtrip": true, + "decoded": null + }, + { + "cbor": "9w==", + "hex": "f7", + "roundtrip": true, + "diagnostic": "undefined" + }, + { + "cbor": "8A==", + "hex": "f0", + "roundtrip": true, + "diagnostic": "simple(16)" + }, + { + "cbor": "+Bg=", + "hex": "f818", + "roundtrip": true, + "diagnostic": "simple(24)" + }, + { + "cbor": "+P8=", + "hex": "f8ff", + "roundtrip": true, + "diagnostic": "simple(255)" + }, + { + "cbor": "wHQyMDEzLTAzLTIxVDIwOjA0OjAwWg==", + "hex": "c074323031332d30332d32315432303a30343a30305a", + "roundtrip": true, + "diagnostic": "0(\"2013-03-21T20:04:00Z\")" + }, + { + "cbor": "wRpRS2ew", + "hex": "c11a514b67b0", + "roundtrip": true, + "diagnostic": "1(1363896240)" + }, + { + "cbor": "wftB1FLZ7CAAAA==", + "hex": "c1fb41d452d9ec200000", + "roundtrip": true, + "diagnostic": "1(1363896240.5)" + }, + { + "cbor": "10QBAgME", + "hex": "d74401020304", + "roundtrip": true, + "diagnostic": "23(h'01020304')" + }, + { + "cbor": "2BhFZElFVEY=", + "hex": "d818456449455446", + "roundtrip": true, + "diagnostic": "24(h'6449455446')" + }, + { + "cbor": "2CB2aHR0cDovL3d3dy5leGFtcGxlLmNvbQ==", + "hex": "d82076687474703a2f2f7777772e6578616d706c652e636f6d", + "roundtrip": true, + "diagnostic": "32(\"http://www.example.com\")" + }, + { + "cbor": "QA==", + "hex": "40", + "roundtrip": true, + "diagnostic": "h''" + }, + { + "cbor": "RAECAwQ=", + "hex": "4401020304", + "roundtrip": true, + "diagnostic": "h'01020304'" + }, + { + "cbor": "YA==", + "hex": "60", + "roundtrip": true, + "decoded": "" + }, + { + "cbor": "YWE=", + "hex": "6161", + "roundtrip": true, + "decoded": "a" + }, + { + "cbor": "ZElFVEY=", + "hex": "6449455446", + "roundtrip": true, + "decoded": "IETF" + }, + { + "cbor": "YiJc", + "hex": "62225c", + "roundtrip": true, + "decoded": "\"\\" + }, + { + "cbor": "YsO8", + "hex": "62c3bc", + "roundtrip": true, + "decoded": "ΓΌ" + }, + { + "cbor": "Y+awtA==", + "hex": "63e6b0b4", + "roundtrip": true, + "decoded": "ζ°΄" + }, + { + "cbor": "ZPCQhZE=", + "hex": "64f0908591", + "roundtrip": true, + "decoded": "𐅑" + }, + { + "cbor": "gA==", + "hex": "80", + "roundtrip": true, + "decoded": [ + + ] + }, + { + "cbor": "gwECAw==", + "hex": "83010203", + "roundtrip": true, + "decoded": [ + 1, + 2, + 3 + ] + }, + { + "cbor": "gwGCAgOCBAU=", + "hex": "8301820203820405", + "roundtrip": true, + "decoded": [ + 1, + [ + 2, + 3 + ], + [ + 4, + 5 + ] + ] + }, + { + "cbor": "mBkBAgMEBQYHCAkKCwwNDg8QERITFBUWFxgYGBk=", + "hex": "98190102030405060708090a0b0c0d0e0f101112131415161718181819", + "roundtrip": true, + "decoded": [ + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 15, + 16, + 17, + 18, + 19, + 20, + 21, + 22, + 23, + 24, + 25 + ] + }, + { + "cbor": "oA==", + "hex": "a0", + "roundtrip": true, + "decoded": { + } + }, + { + "cbor": "ogECAwQ=", + "hex": "a201020304", + "roundtrip": true, + "diagnostic": "{1: 2, 3: 4}" + }, + { + "cbor": "omFhAWFiggID", + "hex": "a26161016162820203", + "roundtrip": true, + "decoded": { + "a": 1, + "b": [ + 2, + 3 + ] + } + }, + { + "cbor": "gmFhoWFiYWM=", + "hex": "826161a161626163", + "roundtrip": true, + "decoded": [ + "a", + { + "b": "c" + } + ] + }, + { + "cbor": "pWFhYUFhYmFCYWNhQ2FkYURhZWFF", + "hex": "a56161614161626142616361436164614461656145", + "roundtrip": true, + "decoded": { + "a": "A", + "b": "B", + "c": "C", + "d": "D", + "e": "E" + } + }, + { + "cbor": "X0IBAkMDBAX/", + "hex": "5f42010243030405ff", + "roundtrip": false, + "diagnostic": "(_ h'0102', h'030405')" + }, + { + "cbor": "f2VzdHJlYWRtaW5n/w==", + "hex": "7f657374726561646d696e67ff", + "roundtrip": false, + "decoded": "streaming" + }, + { + "cbor": "n/8=", + "hex": "9fff", + "roundtrip": false, + "decoded": [ + + ] + }, + { + "cbor": "nwGCAgOfBAX//w==", + "hex": "9f018202039f0405ffff", + "roundtrip": false, + "decoded": [ + 1, + [ + 2, + 3 + ], + [ + 4, + 5 + ] + ] + }, + { + "cbor": "nwGCAgOCBAX/", + "hex": "9f01820203820405ff", + "roundtrip": false, + "decoded": [ + 1, + [ + 2, + 3 + ], + [ + 4, + 5 + ] + ] + }, + { + "cbor": "gwGCAgOfBAX/", + "hex": "83018202039f0405ff", + "roundtrip": false, + "decoded": [ + 1, + [ + 2, + 3 + ], + [ + 4, + 5 + ] + ] + }, + { + "cbor": "gwGfAgP/ggQF", + "hex": "83019f0203ff820405", + "roundtrip": false, + "decoded": [ + 1, + [ + 2, + 3 + ], + [ + 4, + 5 + ] + ] + }, + { + "cbor": "nwECAwQFBgcICQoLDA0ODxAREhMUFRYXGBgYGf8=", + "hex": "9f0102030405060708090a0b0c0d0e0f101112131415161718181819ff", + "roundtrip": false, + "decoded": [ + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 15, + 16, + 17, + 18, + 19, + 20, + 21, + 22, + 23, + 24, + 25 + ] + }, + { + "cbor": "v2FhAWFinwID//8=", + "hex": "bf61610161629f0203ffff", + "roundtrip": false, + "decoded": { + "a": 1, + "b": [ + 2, + 3 + ] + } + }, + { + "cbor": "gmFhv2FiYWP/", + "hex": "826161bf61626163ff", + "roundtrip": false, + "decoded": [ + "a", + { + "b": "c" + } + ] + }, + { + "cbor": "v2NGdW71Y0FtdCH/", + "hex": "bf6346756ef563416d7421ff", + "roundtrip": false, + "decoded": { + "Fun": true, + "Amt": -2 + } + } + ] \ No newline at end of file diff --git a/format/cbor/testdata/cbor.fqtest b/format/cbor/testdata/cbor.fqtest new file mode 100644 index 00000000..46823965 --- /dev/null +++ b/format/cbor/testdata/cbor.fqtest @@ -0,0 +1,5 @@ +$ fq -n '"v2NGdW71Y0FtdCH/" | base64 | cbor | torepr' +{ + "Amt": -2, + "Fun": true +} diff --git a/format/format.go b/format/format.go index 832ffb91..af2d1cbd 100644 --- a/format/format.go +++ b/format/format.go @@ -13,6 +13,7 @@ const ( RAW = "raw" JSON = "json" BSON = "bson" + CBOR = "cbor" DNS = "dns" DNS_TCP = "dns_tcp" diff --git a/internal/num/float16.go b/internal/num/float16.go new file mode 100644 index 00000000..3709c9db --- /dev/null +++ b/internal/num/float16.go @@ -0,0 +1,130 @@ +// Copyright (C) 2014 The Android Open Source Project +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +//nolint:revive +package num + +import "unsafe" + +// Float16 represents a 16-bit floating point number, containing a single sign bit, 5 exponent bits +// and 10 fractional bits. This corresponds to IEEE 754-2008 binary16 (or half precision float) type. +// +// MSB LSB +// ╔════╦════╀════╀════╀════╀════╦════╀════╀════╀════╀════╀════╀════╀════╀════╀════╗ +// β•‘Signβ•‘ Eβ‚„ β”‚ E₃ β”‚ Eβ‚‚ β”‚ E₁ β”‚ Eβ‚€ β•‘ F₉ β”‚ Fβ‚ˆ β”‚ F₇ β”‚ F₆ β”‚ Fβ‚… β”‚ Fβ‚„ β”‚ F₃ β”‚ Fβ‚‚ β”‚ F₁ β”‚ Fβ‚€ β•‘ +// β•šβ•β•β•β•β•©β•β•β•β•β•§β•β•β•β•β•§β•β•β•β•β•§β•β•β•β•β•§β•β•β•β•β•©β•β•β•β•β•§β•β•β•β•β•§β•β•β•β•β•§β•β•β•β•β•§β•β•β•β•β•§β•β•β•β•β•§β•β•β•β•β•§β•β•β•β•β•§β•β•β•β•β•§β•β•β•β•β• +// Where E is the exponent bits and F is the fractional bits. +type Float16 uint16 + +const ( + float16ExpMask Float16 = 0x7c00 + float16ExpBias uint32 = 0xf + float16ExpShift uint32 = 10 + float16FracMask Float16 = 0x03ff + float16SignMask Float16 = 0x8000 + float32ExpMask uint32 = 0x7f800000 + float32ExpBias uint32 = 0x7f + float32ExpShift uint32 = 23 + float32FracMask uint32 = 0x007fffff +) + +// Float32 returns the Float16 value expanded to a float32. Infinities and NaNs are expanded as +// such. +func (f Float16) Float32() float32 { + u32 := expandF16ToF32(f) + ptr := unsafe.Pointer(&u32) + f32 := *(*float32)(ptr) + return f32 +} + +// IsNaN reports whether f is an β€œnot-a-number” value. +func (f Float16) IsNaN() bool { + return (f&float16ExpMask == float16ExpMask) && (f&float16FracMask != 0) +} + +// IsInf reports whether f is an infinity, according to sign. If sign > 0, IsInf reports whether +// f is positive infinity. If sign < 0, IsInf reports whether f is negative infinity. If sign == +// 0, IsInf reports whether f is either infinity. +func (f Float16) IsInf(sign int) bool { + return ((f == float16ExpMask) && sign >= 0) || + (f == (float16SignMask|float16ExpMask) && sign <= 0) +} + +// Float16NaN returns an β€œnot-a-number” value. +func NewFloat16NaN() Float16 { return float16ExpMask | float16FracMask } + +// Float16Inf returns positive infinity if sign >= 0, negative infinity if sign < 0. +func NewFloat16Inf(sign int) Float16 { + if sign >= 0 { + return float16ExpMask + } else { + return float16SignMask | float16ExpMask + } +} + +// NewFloat16 returns a Float16 encoding of a 32-bit floating point number. Infinities and NaNs +// are encoded as such. Very large and very small numbers get rounded to infinity and zero +// respectively. +func NewFloat16(f32 float32) Float16 { + ptr := unsafe.Pointer(&f32) + u32 := *(*uint32)(ptr) + sign := Float16(u32>>16) & float16SignMask + exp := (u32 & float32ExpMask) >> float32ExpShift + frac := u32 & 0x7fffff + if exp == 0xff { + // NaN or Infinity + if frac != 0 { // NaN + frac = 0x3f + } + return sign | float16ExpMask | Float16(frac) + } + if exp+float16ExpBias <= float32ExpBias { + // Exponent is too small to represent in a Float16 (or a zero). We need to output + // denormalized numbers (possibly rounding very small numbers to zero). + denorm := float32ExpBias - exp - 1 + frac += 1 << float32ExpShift + frac >>= denorm + return sign | Float16(frac) + } + if exp > float32ExpBias+float16ExpBias { + // Number too large to represent in a Float16 => round to Infinity. + return sign | float16ExpMask + } + // General case. + return sign | Float16(((exp+float16ExpBias-float32ExpBias)<>13)) +} +func expandF16ToF32(in Float16) uint32 { + sign := uint32(in&float16SignMask) << 16 + frac := uint32(in&float16FracMask) << 13 + exp := uint32(in&float16ExpMask) >> float16ExpShift + if exp == 0x1f { + // NaN of Infinity + return sign | float32ExpMask | frac + } + if exp == 0 { + if frac == 0 { + // Zero + return sign + } + // Denormalized number. In a float32 it must be stored in a normalized form, so + // we normalize it. + exp++ + for frac&float32ExpMask == 0 { + frac <<= 1 + exp-- + } + frac &= float32FracMask + } + exp += (float32ExpBias - float16ExpBias) + return sign | (exp << float32ExpShift) | frac +} diff --git a/pkg/decode/read.go b/pkg/decode/read.go index 8abdd487..677623a3 100644 --- a/pkg/decode/read.go +++ b/pkg/decode/read.go @@ -5,6 +5,7 @@ import ( "fmt" "math" + "github.com/wader/fq/internal/num" "github.com/wader/fq/pkg/bitio" "golang.org/x/text/encoding" "golang.org/x/text/encoding/unicode" @@ -57,6 +58,8 @@ func (d *D) tryFE(nBits int, endian Endian) (float64, error) { n = bitio.Uint64ReverseBytes(nBits, n) } switch nBits { + case 16: + return float64(num.Float16(uint16(n)).Float32()), nil case 32: return float64(math.Float32frombits(uint32(n))), nil case 64: diff --git a/pkg/interp/testdata/args.fqtest b/pkg/interp/testdata/args.fqtest index fa076608..18a29871 100644 --- a/pkg/interp/testdata/args.fqtest +++ b/pkg/interp/testdata/args.fqtest @@ -70,6 +70,7 @@ bencode BitTorrent bencoding bsd_loopback_frame BSD loopback frame bson Binary JSON bzip2 bzip2 compression +cbor Concise Binary Object Representation dns DNS packet dns_tcp DNS packet (TCP) elf Executable and Linkable Format