Horizon
value_t.hpp
1 #pragma once
2 
3 #include <array> // array
4 #include <cstddef> // size_t
5 #include <cstdint> // uint8_t
6 #include <string> // string
7 
8 namespace nlohmann
9 {
10 namespace detail
11 {
13 // JSON type enumeration //
15 
40 enum class value_t : std::uint8_t
41 {
42  null,
43  object,
44  array,
45  string,
46  boolean,
49  number_float,
50  binary,
51  discarded
52 };
53 
67 inline bool operator<(const value_t lhs, const value_t rhs) noexcept
68 {
69  static constexpr std::array<std::uint8_t, 9> order = {{
70  0 /* null */, 3 /* object */, 4 /* array */, 5 /* string */,
71  1 /* boolean */, 2 /* integer */, 2 /* unsigned */, 2 /* float */,
72  6 /* binary */
73  }
74  };
75 
76  const auto l_index = static_cast<std::size_t>(lhs);
77  const auto r_index = static_cast<std::size_t>(rhs);
78  return l_index < order.size() && r_index < order.size() && order[l_index] < order[r_index];
79 }
80 } // namespace detail
81 } // namespace nlohmann
zip_uint8_t uint8_t
zip_uint8_t typedef.
Definition: zip.hpp:78
bool operator<(const value_t lhs, const value_t rhs) noexcept
comparison operator for JSON types
Definition: value_t.hpp:67
value_t
the JSON type enumeration
Definition: value_t.hpp:41
@ number_integer
number value (signed integer)
@ discarded
discarded by the parser callback function
@ binary
binary array (ordered collection of bytes)
@ object
object (unordered set of name/value pairs)
@ number_float
number value (floating-point)
@ number_unsigned
number value (unsigned integer)
@ array
array (ordered collection of values)
namespace for Niels Lohmann
Definition: adl_serializer.hpp:12