1  
//
1  
//
2  
// Copyright (c) 2024 Dmitry Arkhipov (grisumbras@yandex.ru)
2  
// Copyright (c) 2024 Dmitry Arkhipov (grisumbras@yandex.ru)
3  
//
3  
//
4  
// Distributed under the Boost Software License, Version 1.0. (See accompanying
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)
5  
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6  
//
6  
//
7  
// Official repository: https://github.com/boostorg/json
7  
// Official repository: https://github.com/boostorg/json
8  
//
8  
//
9  

9  

10  
#ifndef BOOST_JSON_DETAIL_LITERALS_HPP
10  
#ifndef BOOST_JSON_DETAIL_LITERALS_HPP
11  
#define BOOST_JSON_DETAIL_LITERALS_HPP
11  
#define BOOST_JSON_DETAIL_LITERALS_HPP
12  

12  

13  
#include <boost/json/detail/config.hpp>
13  
#include <boost/json/detail/config.hpp>
14  
#include <boost/mp11/integral.hpp>
14  
#include <boost/mp11/integral.hpp>
15  

15  

16  
namespace boost {
16  
namespace boost {
17  
namespace json {
17  
namespace json {
18  
namespace detail {
18  
namespace detail {
19  

19  

20  
enum class literals
20  
enum class literals
21  
{
21  
{
22  
    null = 0,
22  
    null = 0,
23  
    true_,
23  
    true_,
24  
    false_,
24  
    false_,
25  
    infinity,
25  
    infinity,
26  
    neg_infinity,
26  
    neg_infinity,
27  
    nan,
27  
    nan,
28  
    resume,
28  
    resume,
29  
};
29  
};
30  

30  

31  
constexpr char const* literal_strings[] = {
31  
constexpr char const* literal_strings[] = {
32  
    "null",
32  
    "null",
33  
    "true",
33  
    "true",
34  
    "false",
34  
    "false",
35  
    "Infinity",
35  
    "Infinity",
36  
    "-Infinity",
36  
    "-Infinity",
37  
    "NaN",
37  
    "NaN",
38  
    "",
38  
    "",
39  
};
39  
};
40  

40  

41  
constexpr std::size_t literal_sizes[] = {
41  
constexpr std::size_t literal_sizes[] = {
42  
    4,
42  
    4,
43  
    4,
43  
    4,
44  
    5,
44  
    5,
45  
    8,
45  
    8,
46  
    9,
46  
    9,
47  
    3,
47  
    3,
48  
    0,
48  
    0,
49  
};
49  
};
50  

50  

51  
template<literals L>
51  
template<literals L>
52  
using literals_c = std::integral_constant<literals, L>;
52  
using literals_c = std::integral_constant<literals, L>;
53  

53  

54  
constexpr
54  
constexpr
55  
unsigned char
55  
unsigned char
56  
literal_index(literals l)
56  
literal_index(literals l)
57  
{
57  
{
58  
    return static_cast<unsigned char>(l);
58  
    return static_cast<unsigned char>(l);
59  
}
59  
}
60  

60  

61  
} // namespace detail
61  
} // namespace detail
62  
} // namespace json
62  
} // namespace json
63  
} // namespace boost
63  
} // namespace boost
64  

64  

65  
#endif // BOOST_JSON_DETAIL_LITERALS_HPP
65  
#endif // BOOST_JSON_DETAIL_LITERALS_HPP