literals.hpp 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. //
  2. // Copyright (c) 2024 Dmitry Arkhipov (grisumbras@yandex.ru)
  3. //
  4. // Distributed under the Boost Software License, Version 1.0. (See accompanying
  5. // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  6. //
  7. // Official repository: https://github.com/boostorg/json
  8. //
  9. #ifndef BOOST_JSON_DETAIL_LITERALS_HPP
  10. #define BOOST_JSON_DETAIL_LITERALS_HPP
  11. #include <boost/json/detail/config.hpp>
  12. #include <boost/mp11/integral.hpp>
  13. namespace boost {
  14. namespace json {
  15. namespace detail {
  16. enum class literals
  17. {
  18. null = 0,
  19. true_,
  20. false_,
  21. infinity,
  22. neg_infinity,
  23. nan,
  24. resume,
  25. };
  26. constexpr char const* literal_strings[] = {
  27. "null",
  28. "true",
  29. "false",
  30. "Infinity",
  31. "-Infinity",
  32. "NaN",
  33. "",
  34. };
  35. constexpr std::size_t literal_sizes[] = {
  36. 4,
  37. 4,
  38. 5,
  39. 8,
  40. 9,
  41. 3,
  42. 0,
  43. };
  44. template<literals L>
  45. using literals_c = std::integral_constant<literals, L>;
  46. constexpr
  47. unsigned char
  48. literal_index(literals l)
  49. {
  50. return static_cast<unsigned char>(l);
  51. }
  52. } // namespace detail
  53. } // namespace json
  54. } // namespace boost
  55. #endif // BOOST_JSON_DETAIL_LITERALS_HPP