#if SIMDJSON_SUPPORTS_DESERIALIZATION #ifndef SIMDJSON_ONDEMAND_DESERIALIZE_H #ifndef SIMDJSON_CONDITIONAL_INCLUDE #define SIMDJSON_ONDEMAND_DESERIALIZE_H #include "simdjson/generic/ondemand/base.h" #include "simdjson/generic/ondemand/array.h" #endif // SIMDJSON_CONDITIONAL_INCLUDE #include namespace simdjson { namespace tag_invoke_fn_ns { void tag_invoke(); struct tag_invoke_fn { template requires requires(Tag tag, Args &&...args) { tag_invoke(std::forward(tag), std::forward(args)...); } constexpr auto operator()(Tag tag, Args &&...args) const noexcept(noexcept(tag_invoke(std::forward(tag), std::forward(args)...))) -> decltype(tag_invoke(std::forward(tag), std::forward(args)...)) { return tag_invoke(std::forward(tag), std::forward(args)...); } }; } // namespace tag_invoke_fn_ns inline namespace tag_invoke_ns { inline constexpr tag_invoke_fn_ns::tag_invoke_fn tag_invoke = {}; } // namespace tag_invoke_ns template concept tag_invocable = requires(Tag tag, Args... args) { tag_invoke(std::forward(tag), std::forward(args)...); }; template concept nothrow_tag_invocable = tag_invocable && requires(Tag tag, Args... args) { { tag_invoke(std::forward(tag), std::forward(args)...) } noexcept; }; template using tag_invoke_result = std::invoke_result; template using tag_invoke_result_t = std::invoke_result_t; template using tag_t = std::decay_t; struct deserialize_tag; /// These types are deserializable in a built-in way template struct is_builtin_deserializable : std::false_type {}; template <> struct is_builtin_deserializable : std::true_type {}; template <> struct is_builtin_deserializable : std::true_type {}; template <> struct is_builtin_deserializable : std::true_type {}; template <> struct is_builtin_deserializable : std::true_type {}; template <> struct is_builtin_deserializable : std::true_type {}; template <> struct is_builtin_deserializable : std::true_type {}; template <> struct is_builtin_deserializable : std::true_type {}; template <> struct is_builtin_deserializable : std::true_type {}; template <> struct is_builtin_deserializable : std::true_type {}; template concept is_builtin_deserializable_v = is_builtin_deserializable::value; template concept custom_deserializable = tag_invocable; template concept deserializable = custom_deserializable || is_builtin_deserializable_v; template concept nothrow_custom_deserializable = nothrow_tag_invocable; // built-in types are noexcept and if an error happens, the value simply gets ignored and the error is returned. template concept nothrow_deserializable = nothrow_custom_deserializable || is_builtin_deserializable_v; /// Deserialize Tag inline constexpr struct deserialize_tag { using array_type = SIMDJSON_IMPLEMENTATION::ondemand::array; using object_type = SIMDJSON_IMPLEMENTATION::ondemand::object; using value_type = SIMDJSON_IMPLEMENTATION::ondemand::value; using document_type = SIMDJSON_IMPLEMENTATION::ondemand::document; using document_reference_type = SIMDJSON_IMPLEMENTATION::ondemand::document_reference; // Customization Point for array template requires custom_deserializable [[nodiscard]] constexpr /* error_code */ auto operator()(array_type &object, T& output) const noexcept(nothrow_custom_deserializable) { return tag_invoke(*this, object, output); } // Customization Point for object template requires custom_deserializable [[nodiscard]] constexpr /* error_code */ auto operator()(object_type &object, T& output) const noexcept(nothrow_custom_deserializable) { return tag_invoke(*this, object, output); } // Customization Point for value template requires custom_deserializable [[nodiscard]] constexpr /* error_code */ auto operator()(value_type &object, T& output) const noexcept(nothrow_custom_deserializable) { return tag_invoke(*this, object, output); } // Customization Point for document template requires custom_deserializable [[nodiscard]] constexpr /* error_code */ auto operator()(document_type &object, T& output) const noexcept(nothrow_custom_deserializable) { return tag_invoke(*this, object, output); } // Customization Point for document reference template requires custom_deserializable [[nodiscard]] constexpr /* error_code */ auto operator()(document_reference_type &object, T& output) const noexcept(nothrow_custom_deserializable) { return tag_invoke(*this, object, output); } } deserialize{}; } // namespace simdjson #endif // SIMDJSON_ONDEMAND_DESERIALIZE_H #endif // SIMDJSON_SUPPORTS_DESERIALIZATION