Line data Source code
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 :
10 : #ifndef BOOST_JSON_DETAIL_LITERALS_HPP
11 : #define BOOST_JSON_DETAIL_LITERALS_HPP
12 :
13 : #include <boost/json/detail/config.hpp>
14 : #include <boost/mp11/integral.hpp>
15 :
16 : namespace boost {
17 : namespace json {
18 : namespace detail {
19 :
20 : enum class literals
21 : {
22 : null = 0,
23 : true_,
24 : false_,
25 : infinity,
26 : neg_infinity,
27 : nan,
28 : resume,
29 : };
30 :
31 : constexpr char const* literal_strings[] = {
32 : "null",
33 : "true",
34 : "false",
35 : "Infinity",
36 : "-Infinity",
37 : "NaN",
38 : "",
39 : };
40 :
41 : constexpr std::size_t literal_sizes[] = {
42 : 4,
43 : 4,
44 : 5,
45 : 8,
46 : 9,
47 : 3,
48 : 0,
49 : };
50 :
51 : template<literals L>
52 : using literals_c = std::integral_constant<literals, L>;
53 :
54 : constexpr
55 : unsigned char
56 1007 : literal_index(literals l)
57 : {
58 1007 : return static_cast<unsigned char>(l);
59 : }
60 :
61 : } // namespace detail
62 : } // namespace json
63 : } // namespace boost
64 :
65 : #endif // BOOST_JSON_DETAIL_LITERALS_HPP
|