| 49 | } |
| 50 | |
| 51 | void 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 | |
| 82 | void cbor_reputon_example() |
| 83 | { |
no test coverage detected