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