From 5a7564f644e96cf8c42a4b470e57eb61fa1cb733 Mon Sep 17 00:00:00 2001 From: Ludovic 'Archivist' Lagouardette Date: Mon, 5 Oct 2020 18:13:34 +0200 Subject: [PATCH] cbor value types --- include/gp/enveloppe/cbor.hpp | 86 +++++++++++++++++++++++++++++++++++ 1 file changed, 86 insertions(+) create mode 100644 include/gp/enveloppe/cbor.hpp diff --git a/include/gp/enveloppe/cbor.hpp b/include/gp/enveloppe/cbor.hpp new file mode 100644 index 0000000..f223c80 --- /dev/null +++ b/include/gp/enveloppe/cbor.hpp @@ -0,0 +1,86 @@ +#pragma once + +#include +#include +#include +#include + + +namespace gp { + enum class cbor_type { + uint = 0, + nint = 1, + bstr = 2, + tstr = 3, + list = 4, + hmap = 5, + tags = 6, + oths = 7 + }; + + enum class cbor_oths { + value_false = 20, + value_true = 21, + value_null = 22, + value_undefined = 23, + byte = 24, + word = 25, + dword = 26, + qword = 27, + terminator = 31 + }; + + enum class cbor_tags { + datetime = 0, + unix_time = 1, + ubignum = 2, + nbignum = 3, + decimal = 4, + bigfloat = 5, + cose_encrypt0 = 16, + cose_mac0 = 17, + cose_sign1 = 18, + expected_base64url = 21, + expected_base64 = 22, + expected_base16 = 23, + encoded_cbor = 24, + url = 32, + base64url = 33, + base64 = 34, + regexp = 35, + mime = 36, + cose_encrypt = 96, + cose_mac = 97, + cose_sign = 98, + signature = 55799 + }; + + using cbor_number = gp::fixed_variant< + int8_t, + uint8_t, + int16_t, + uint16_t, + int32_t, + uint32_t, + int64_t, + uint64_t + >; + + using cbor_floating_point = gp::fixed_variant< + float, + double + >; + + struct undefined_t{}; + + class cbor_value : public gp::fixed_variant< + cbor_number, + gp::buffer, + bool, + gp::vector, + gp::vector>, + gp::nullopt_t, + undefined_t, + cbor_floating_point + >{}; +} \ No newline at end of file