MCPcopy Create free account
hub / github.com/danielaparker/jsoncons / encode_to_cbor_stream

Function encode_to_cbor_stream

examples/src/cbor_examples.cpp:51–80  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

49}
50
51void encode_to_cbor_stream()
52{
53 std::ostringstream os;
54 cbor::cbor_stream_encoder encoder(os);
55
56 encoder.begin_array(3); // array of length 3
57 encoder.string_value("-18446744073709551617", semantic_tag::bigint);
58 encoder.string_value("184467440737095516.16", semantic_tag::bigdec);
59 encoder.int64_value(1431027667, semantic_tag::epoch_second);
60 encoder.end_array();
61 encoder.flush();
62
63 std::cout << byte_string_view(os.str()) << "\n\n";
64
65/*
66 83 -- array of length 3
67 c3 -- Tag 3 (negative bignum)
68 49 -- Byte string value of length 9
69 010000000000000000 -- Bytes content
70 c4 -- Tag 4 (decimal fraction)
71 82 -- Array of length 2
72 21 -- -2 (exponent)
73 c2 Tag 2 (positive bignum)
74 49 -- Byte string value of length 9
75 010000000000000000
76 c1 -- Tag 1 (seconds relative to 1970-01-01T00:00Z in UTC time)
77 1a -- 32 bit unsigned integer
78 554bbfd3 -- 1431027667
79*/
80}
81
82void cbor_reputon_example()
83{

Callers 1

mainFunction · 0.85

Calls 6

byte_string_viewClass · 0.85
begin_arrayMethod · 0.45
string_valueMethod · 0.45
int64_valueMethod · 0.45
end_arrayMethod · 0.45
flushMethod · 0.45

Tested by

no test coverage detected