General Purpose library for Freestanding C++ and POSIX systems
Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

85 Zeilen
1.3 KiB

vor 4 Jahren
  1. #pragma once
  2. #include <gp/variant.hpp>
  3. #include <gp/optional.hpp>
  4. #include <gp/vector.hpp>
  5. #include <gp/pair.hpp>
  6. namespace gp {
  7. enum class cbor_type {
  8. uint = 0,
  9. nint = 1,
  10. bstr = 2,
  11. tstr = 3,
  12. list = 4,
  13. hmap = 5,
  14. tags = 6,
  15. oths = 7
  16. };
  17. enum class cbor_oths {
  18. value_false = 20,
  19. value_true = 21,
  20. value_null = 22,
  21. value_undefined = 23,
  22. byte = 24,
  23. word = 25,
  24. dword = 26,
  25. qword = 27,
  26. terminator = 31
  27. };
  28. enum class cbor_tags {
  29. datetime = 0,
  30. unix_time = 1,
  31. ubignum = 2,
  32. nbignum = 3,
  33. decimal = 4,
  34. bigfloat = 5,
  35. cose_encrypt0 = 16,
  36. cose_mac0 = 17,
  37. cose_sign1 = 18,
  38. expected_base64url = 21,
  39. expected_base64 = 22,
  40. expected_base16 = 23,
  41. encoded_cbor = 24,
  42. url = 32,
  43. base64url = 33,
  44. base64 = 34,
  45. regexp = 35,
  46. mime = 36,
  47. cose_encrypt = 96,
  48. cose_mac = 97,
  49. cose_sign = 98,
  50. signature = 55799
  51. };
  52. using cbor_number = gp::fixed_variant<
  53. int8_t,
  54. uint8_t,
  55. int16_t,
  56. uint16_t,
  57. int32_t,
  58. uint32_t,
  59. int64_t,
  60. uint64_t
  61. >;
  62. using cbor_floating_point = gp::fixed_variant<
  63. float,
  64. double
  65. >;
  66. struct undefined_t{};
  67. class cbor_value : public gp::fixed_variant<
  68. cbor_number,
  69. gp::buffer<std::byte>,
  70. bool,
  71. gp::vector<cbor_value>,
  72. gp::vector<gp::pair<cbor_value, cbor_value>>,
  73. gp::nullopt_t,
  74. undefined_t,
  75. cbor_floating_point
  76. >{};
  77. }