Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:02:19

0001 //     __ _____ _____ _____
0002 //  __|  |   __|     |   | |  JSON for Modern C++
0003 // |  |  |__   |  |  | | | |  version 3.11.2
0004 // |_____|_____|_____|_|___|  https://github.com/nlohmann/json
0005 //
0006 // SPDX-FileCopyrightText: 2013-2022 Niels Lohmann <https://nlohmann.me>
0007 // SPDX-License-Identifier: MIT
0008 
0009 #pragma once
0010 
0011 #include <cstdint> // size_t
0012 #include <utility> // declval
0013 #include <string> // string
0014 
0015 #include <nlohmann/detail/abi_macros.hpp>
0016 #include <nlohmann/detail/meta/detected.hpp>
0017 #include <nlohmann/detail/meta/type_traits.hpp>
0018 
0019 NLOHMANN_JSON_NAMESPACE_BEGIN
0020 namespace detail
0021 {
0022 
0023 template<typename T>
0024 using null_function_t = decltype(std::declval<T&>().null());
0025 
0026 template<typename T>
0027 using boolean_function_t =
0028     decltype(std::declval<T&>().boolean(std::declval<bool>()));
0029 
0030 template<typename T, typename Integer>
0031 using number_integer_function_t =
0032     decltype(std::declval<T&>().number_integer(std::declval<Integer>()));
0033 
0034 template<typename T, typename Unsigned>
0035 using number_unsigned_function_t =
0036     decltype(std::declval<T&>().number_unsigned(std::declval<Unsigned>()));
0037 
0038 template<typename T, typename Float, typename String>
0039 using number_float_function_t = decltype(std::declval<T&>().number_float(
0040                                     std::declval<Float>(), std::declval<const String&>()));
0041 
0042 template<typename T, typename String>
0043 using string_function_t =
0044     decltype(std::declval<T&>().string(std::declval<String&>()));
0045 
0046 template<typename T, typename Binary>
0047 using binary_function_t =
0048     decltype(std::declval<T&>().binary(std::declval<Binary&>()));
0049 
0050 template<typename T>
0051 using start_object_function_t =
0052     decltype(std::declval<T&>().start_object(std::declval<std::size_t>()));
0053 
0054 template<typename T, typename String>
0055 using key_function_t =
0056     decltype(std::declval<T&>().key(std::declval<String&>()));
0057 
0058 template<typename T>
0059 using end_object_function_t = decltype(std::declval<T&>().end_object());
0060 
0061 template<typename T>
0062 using start_array_function_t =
0063     decltype(std::declval<T&>().start_array(std::declval<std::size_t>()));
0064 
0065 template<typename T>
0066 using end_array_function_t = decltype(std::declval<T&>().end_array());
0067 
0068 template<typename T, typename Exception>
0069 using parse_error_function_t = decltype(std::declval<T&>().parse_error(
0070         std::declval<std::size_t>(), std::declval<const std::string&>(),
0071         std::declval<const Exception&>()));
0072 
0073 template<typename SAX, typename BasicJsonType>
0074 struct is_sax
0075 {
0076   private:
0077     static_assert(is_basic_json<BasicJsonType>::value,
0078                   "BasicJsonType must be of type basic_json<...>");
0079 
0080     using number_integer_t = typename BasicJsonType::number_integer_t;
0081     using number_unsigned_t = typename BasicJsonType::number_unsigned_t;
0082     using number_float_t = typename BasicJsonType::number_float_t;
0083     using string_t = typename BasicJsonType::string_t;
0084     using binary_t = typename BasicJsonType::binary_t;
0085     using exception_t = typename BasicJsonType::exception;
0086 
0087   public:
0088     static constexpr bool value =
0089         is_detected_exact<bool, null_function_t, SAX>::value &&
0090         is_detected_exact<bool, boolean_function_t, SAX>::value &&
0091         is_detected_exact<bool, number_integer_function_t, SAX, number_integer_t>::value &&
0092         is_detected_exact<bool, number_unsigned_function_t, SAX, number_unsigned_t>::value &&
0093         is_detected_exact<bool, number_float_function_t, SAX, number_float_t, string_t>::value &&
0094         is_detected_exact<bool, string_function_t, SAX, string_t>::value &&
0095         is_detected_exact<bool, binary_function_t, SAX, binary_t>::value &&
0096         is_detected_exact<bool, start_object_function_t, SAX>::value &&
0097         is_detected_exact<bool, key_function_t, SAX, string_t>::value &&
0098         is_detected_exact<bool, end_object_function_t, SAX>::value &&
0099         is_detected_exact<bool, start_array_function_t, SAX>::value &&
0100         is_detected_exact<bool, end_array_function_t, SAX>::value &&
0101         is_detected_exact<bool, parse_error_function_t, SAX, exception_t>::value;
0102 };
0103 
0104 template<typename SAX, typename BasicJsonType>
0105 struct is_sax_static_asserts
0106 {
0107   private:
0108     static_assert(is_basic_json<BasicJsonType>::value,
0109                   "BasicJsonType must be of type basic_json<...>");
0110 
0111     using number_integer_t = typename BasicJsonType::number_integer_t;
0112     using number_unsigned_t = typename BasicJsonType::number_unsigned_t;
0113     using number_float_t = typename BasicJsonType::number_float_t;
0114     using string_t = typename BasicJsonType::string_t;
0115     using binary_t = typename BasicJsonType::binary_t;
0116     using exception_t = typename BasicJsonType::exception;
0117 
0118   public:
0119     static_assert(is_detected_exact<bool, null_function_t, SAX>::value,
0120                   "Missing/invalid function: bool null()");
0121     static_assert(is_detected_exact<bool, boolean_function_t, SAX>::value,
0122                   "Missing/invalid function: bool boolean(bool)");
0123     static_assert(is_detected_exact<bool, boolean_function_t, SAX>::value,
0124                   "Missing/invalid function: bool boolean(bool)");
0125     static_assert(
0126         is_detected_exact<bool, number_integer_function_t, SAX,
0127         number_integer_t>::value,
0128         "Missing/invalid function: bool number_integer(number_integer_t)");
0129     static_assert(
0130         is_detected_exact<bool, number_unsigned_function_t, SAX,
0131         number_unsigned_t>::value,
0132         "Missing/invalid function: bool number_unsigned(number_unsigned_t)");
0133     static_assert(is_detected_exact<bool, number_float_function_t, SAX,
0134                   number_float_t, string_t>::value,
0135                   "Missing/invalid function: bool number_float(number_float_t, const string_t&)");
0136     static_assert(
0137         is_detected_exact<bool, string_function_t, SAX, string_t>::value,
0138         "Missing/invalid function: bool string(string_t&)");
0139     static_assert(
0140         is_detected_exact<bool, binary_function_t, SAX, binary_t>::value,
0141         "Missing/invalid function: bool binary(binary_t&)");
0142     static_assert(is_detected_exact<bool, start_object_function_t, SAX>::value,
0143                   "Missing/invalid function: bool start_object(std::size_t)");
0144     static_assert(is_detected_exact<bool, key_function_t, SAX, string_t>::value,
0145                   "Missing/invalid function: bool key(string_t&)");
0146     static_assert(is_detected_exact<bool, end_object_function_t, SAX>::value,
0147                   "Missing/invalid function: bool end_object()");
0148     static_assert(is_detected_exact<bool, start_array_function_t, SAX>::value,
0149                   "Missing/invalid function: bool start_array(std::size_t)");
0150     static_assert(is_detected_exact<bool, end_array_function_t, SAX>::value,
0151                   "Missing/invalid function: bool end_array()");
0152     static_assert(
0153         is_detected_exact<bool, parse_error_function_t, SAX, exception_t>::value,
0154         "Missing/invalid function: bool parse_error(std::size_t, const "
0155         "std::string&, const exception&)");
0156 };
0157 
0158 }  // namespace detail
0159 NLOHMANN_JSON_NAMESPACE_END