7 #include <nlohmann/detail/meta/detected.hpp>
8 #include <nlohmann/detail/meta/type_traits.hpp>
15 using null_function_t = decltype(std::declval<T&>().
null());
18 using boolean_function_t =
19 decltype(std::declval<T&>().
boolean(std::declval<bool>()));
21 template<
typename T,
typename Integer>
22 using number_integer_function_t =
23 decltype(std::declval<T&>().
number_integer(std::declval<Integer>()));
25 template<
typename T,
typename Un
signed>
26 using number_unsigned_function_t =
29 template<
typename T,
typename Float,
typename String>
30 using number_float_function_t = decltype(std::declval<T&>().
number_float(
31 std::declval<Float>(), std::declval<const String&>()));
33 template<
typename T,
typename String>
34 using string_function_t =
35 decltype(std::declval<T&>().
string(std::declval<String&>()));
37 template<
typename T,
typename Binary>
38 using binary_function_t =
39 decltype(std::declval<T&>().
binary(std::declval<Binary&>()));
42 using start_object_function_t =
43 decltype(std::declval<T&>().start_object(std::declval<std::size_t>()));
45 template<
typename T,
typename String>
46 using key_function_t =
47 decltype(std::declval<T&>().
key(std::declval<String&>()));
50 using end_object_function_t = decltype(std::declval<T&>().end_object());
53 using start_array_function_t =
54 decltype(std::declval<T&>().start_array(std::declval<std::size_t>()));
57 using end_array_function_t = decltype(std::declval<T&>().end_array());
59 template<
typename T,
typename Exception>
60 using parse_error_function_t = decltype(std::declval<T&>().parse_error(
61 std::declval<std::size_t>(), std::declval<const std::string&>(),
62 std::declval<const Exception&>()));
64 template<
typename SAX,
typename BasicJsonType>
69 "BasicJsonType must be of type basic_json<...>");
71 using number_integer_t =
typename BasicJsonType::number_integer_t;
72 using number_unsigned_t =
typename BasicJsonType::number_unsigned_t;
73 using number_float_t =
typename BasicJsonType::number_float_t;
74 using string_t =
typename BasicJsonType::string_t;
75 using binary_t =
typename BasicJsonType::binary_t;
76 using exception_t =
typename BasicJsonType::exception;
79 static constexpr
bool value =
80 is_detected_exact<bool, null_function_t, SAX>::value &&
81 is_detected_exact<bool, boolean_function_t, SAX>::value &&
82 is_detected_exact<bool, number_integer_function_t, SAX, number_integer_t>::value &&
83 is_detected_exact<bool, number_unsigned_function_t, SAX, number_unsigned_t>::value &&
84 is_detected_exact<bool, number_float_function_t, SAX, number_float_t, string_t>::value &&
85 is_detected_exact<bool, string_function_t, SAX, string_t>::value &&
86 is_detected_exact<bool, binary_function_t, SAX, binary_t>::value &&
87 is_detected_exact<bool, start_object_function_t, SAX>::value &&
88 is_detected_exact<bool, key_function_t, SAX, string_t>::value &&
89 is_detected_exact<bool, end_object_function_t, SAX>::value &&
90 is_detected_exact<bool, start_array_function_t, SAX>::value &&
91 is_detected_exact<bool, end_array_function_t, SAX>::value &&
92 is_detected_exact<bool, parse_error_function_t, SAX, exception_t>::value;
95 template<
typename SAX,
typename BasicJsonType>
100 "BasicJsonType must be of type basic_json<...>");
102 using number_integer_t =
typename BasicJsonType::number_integer_t;
103 using number_unsigned_t =
typename BasicJsonType::number_unsigned_t;
104 using number_float_t =
typename BasicJsonType::number_float_t;
105 using string_t =
typename BasicJsonType::string_t;
106 using binary_t =
typename BasicJsonType::binary_t;
107 using exception_t =
typename BasicJsonType::exception;
110 static_assert(is_detected_exact<bool, null_function_t, SAX>::value,
111 "Missing/invalid function: bool null()");
112 static_assert(is_detected_exact<bool, boolean_function_t, SAX>::value,
113 "Missing/invalid function: bool boolean(bool)");
114 static_assert(is_detected_exact<bool, boolean_function_t, SAX>::value,
115 "Missing/invalid function: bool boolean(bool)");
117 is_detected_exact<
bool, number_integer_function_t, SAX,
118 number_integer_t>::
value,
119 "Missing/invalid function: bool number_integer(number_integer_t)");
121 is_detected_exact<
bool, number_unsigned_function_t, SAX,
122 number_unsigned_t>::
value,
123 "Missing/invalid function: bool number_unsigned(number_unsigned_t)");
124 static_assert(is_detected_exact<
bool, number_float_function_t, SAX,
125 number_float_t, string_t>::
value,
126 "Missing/invalid function: bool number_float(number_float_t, const string_t&)");
128 is_detected_exact<bool, string_function_t, SAX, string_t>::value,
129 "Missing/invalid function: bool string(string_t&)");
131 is_detected_exact<bool, binary_function_t, SAX, binary_t>::value,
132 "Missing/invalid function: bool binary(binary_t&)");
133 static_assert(is_detected_exact<bool, start_object_function_t, SAX>::value,
134 "Missing/invalid function: bool start_object(std::size_t)");
135 static_assert(is_detected_exact<bool, key_function_t, SAX, string_t>::value,
136 "Missing/invalid function: bool key(string_t&)");
137 static_assert(is_detected_exact<bool, end_object_function_t, SAX>::value,
138 "Missing/invalid function: bool end_object()");
139 static_assert(is_detected_exact<bool, start_array_function_t, SAX>::value,
140 "Missing/invalid function: bool start_array(std::size_t)");
141 static_assert(is_detected_exact<bool, end_array_function_t, SAX>::value,
142 "Missing/invalid function: bool end_array()");
144 is_detected_exact<bool, parse_error_function_t, SAX, exception_t>::value,
145 "Missing/invalid function: bool parse_error(std::size_t, const "
146 "std::string&, const exception&)");
@ number_integer
number value (signed integer)
@ binary
binary array (ordered collection of bytes)
@ number_float
number value (floating-point)
@ number_unsigned
number value (unsigned integer)
@ value
the parser finished reading a JSON value
@ key
the parser read a key of a value in an object
namespace for Niels Lohmann
Definition: adl_serializer.hpp:12
Definition: type_traits.hpp:42
Definition: is_sax.hpp:97
Definition: is_sax.hpp:66