WPILibC++ 2024.3.2
is_sax.h
Go to the documentation of this file.
1// __ _____ _____ _____
2// __| | __| | | | JSON for Modern C++
3// | | |__ | | | | | | version 3.11.2
4// |_____|_____|_____|_|___| https://github.com/nlohmann/json
5//
6// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann <https://nlohmann.me>
7// SPDX-License-Identifier: MIT
8
9#pragma once
10
11#include <cstdint> // size_t
12#include <utility> // declval
13#include <string> // string
14
18
20namespace detail
21{
22
23template<typename T>
24using null_function_t = decltype(std::declval<T&>().null());
25
26template<typename T>
28 decltype(std::declval<T&>().boolean(std::declval<bool>()));
29
30template<typename T, typename Integer>
32 decltype(std::declval<T&>().number_integer(std::declval<Integer>()));
33
34template<typename T, typename Unsigned>
36 decltype(std::declval<T&>().number_unsigned(std::declval<Unsigned>()));
37
38template<typename T, typename Float, typename String>
39using number_float_function_t = decltype(std::declval<T&>().number_float(
40 std::declval<Float>(), std::declval<const String&>()));
41
42template<typename T, typename String>
44 decltype(std::declval<T&>().string(std::declval<String&>()));
45
46template<typename T, typename Binary>
48 decltype(std::declval<T&>().binary(std::declval<Binary&>()));
49
50template<typename T>
52 decltype(std::declval<T&>().start_object(std::declval<std::size_t>()));
53
54template<typename T, typename String>
56 decltype(std::declval<T&>().key(std::declval<String&>()));
57
58template<typename T>
59using end_object_function_t = decltype(std::declval<T&>().end_object());
60
61template<typename T>
63 decltype(std::declval<T&>().start_array(std::declval<std::size_t>()));
64
65template<typename T>
66using end_array_function_t = decltype(std::declval<T&>().end_array());
67
68template<typename T, typename Exception>
69using parse_error_function_t = decltype(std::declval<T&>().parse_error(
70 std::declval<std::size_t>(), std::declval<const std::string&>(),
71 std::declval<const Exception&>()));
72
73template<typename SAX, typename BasicJsonType>
74struct is_sax
75{
76 private:
78 "BasicJsonType must be of type basic_json<...>");
79
80 using number_integer_t = typename BasicJsonType::number_integer_t;
81 using number_unsigned_t = typename BasicJsonType::number_unsigned_t;
82 using number_float_t = typename BasicJsonType::number_float_t;
83 using string_t = typename BasicJsonType::string_t;
84 using binary_t = typename BasicJsonType::binary_t;
85 using exception_t = typename BasicJsonType::exception;
86
87 public:
88 static constexpr bool value =
102};
103
104template<typename SAX, typename BasicJsonType>
106{
107 private:
109 "BasicJsonType must be of type basic_json<...>");
110
111 using number_integer_t = typename BasicJsonType::number_integer_t;
112 using number_unsigned_t = typename BasicJsonType::number_unsigned_t;
113 using number_float_t = typename BasicJsonType::number_float_t;
114 using string_t = typename BasicJsonType::string_t;
115 using binary_t = typename BasicJsonType::binary_t;
116 using exception_t = typename BasicJsonType::exception;
117
118 public:
120 "Missing/invalid function: bool null()");
122 "Missing/invalid function: bool boolean(bool)");
124 "Missing/invalid function: bool boolean(bool)");
125 static_assert(
127 number_integer_t>::value,
128 "Missing/invalid function: bool number_integer(number_integer_t)");
129 static_assert(
131 number_unsigned_t>::value,
132 "Missing/invalid function: bool number_unsigned(number_unsigned_t)");
133 static_assert(is_detected_exact<bool, number_float_function_t, SAX,
134 number_float_t, string_t>::value,
135 "Missing/invalid function: bool number_float(number_float_t, const string_t&)");
136 static_assert(
138 "Missing/invalid function: bool string(string_t&)");
139 static_assert(
141 "Missing/invalid function: bool binary(binary_t&)");
143 "Missing/invalid function: bool start_object(std::size_t)");
145 "Missing/invalid function: bool key(string_t&)");
147 "Missing/invalid function: bool end_object()");
149 "Missing/invalid function: bool start_array(std::size_t)");
151 "Missing/invalid function: bool end_array()");
152 static_assert(
154 "Missing/invalid function: bool parse_error(std::size_t, const "
155 "std::string&, const exception&)");
156};
157
158} // namespace detail
you may not use this file except in compliance with the License You may obtain a copy of the License at software distributed under the License is distributed on an AS IS WITHOUT WARRANTIES OR CONDITIONS OF ANY either express or implied See the License for the specific language governing permissions and limitations under the License LLVM Exceptions to the Apache License As an exception
Definition: ThirdPartyNotices.txt:289
#define WPI_JSON_NAMESPACE_END
Definition: abi_macros.h:59
#define WPI_JSON_NAMESPACE_BEGIN
Definition: abi_macros.h:53
Definition: core.h:1238
detail namespace with internal helper functions
Definition: xchar.h:20
std::is_same< Expected, detected_t< Op, Args... > > is_detected_exact
Definition: detected.h:63
decltype(std::declval< T & >().start_array(std::declval< std::size_t >())) start_array_function_t
Definition: is_sax.h:63
decltype(std::declval< T & >().parse_error(std::declval< std::size_t >(), std::declval< const std::string & >(), std::declval< const Exception & >())) parse_error_function_t
Definition: is_sax.h:71
decltype(std::declval< T & >().number_integer(std::declval< Integer >())) number_integer_function_t
Definition: is_sax.h:32
decltype(std::declval< T & >().number_float(std::declval< Float >(), std::declval< const String & >())) number_float_function_t
Definition: is_sax.h:40
decltype(std::declval< T & >().binary(std::declval< Binary & >())) binary_function_t
Definition: is_sax.h:48
decltype(std::declval< T & >().end_array()) end_array_function_t
Definition: is_sax.h:66
decltype(std::declval< T & >().null()) null_function_t
Definition: is_sax.h:24
decltype(std::declval< T & >().string(std::declval< String & >())) string_function_t
Definition: is_sax.h:44
decltype(std::declval< T & >().boolean(std::declval< bool >())) boolean_function_t
Definition: is_sax.h:28
decltype(std::declval< T & >().end_object()) end_object_function_t
Definition: is_sax.h:59
decltype(std::declval< T & >().start_object(std::declval< std::size_t >())) start_object_function_t
Definition: is_sax.h:52
decltype(std::declval< T & >().number_unsigned(std::declval< Unsigned >())) number_unsigned_function_t
Definition: is_sax.h:36
decltype(std::declval< T & >().key(std::declval< String & >())) key_function_t
Definition: is_sax.h:56
Definition: type_traits.h:49
Definition: is_sax.h:106
Definition: is_sax.h:75