1#if SIMDJSON_SUPPORTS_CONCEPTS
3#ifndef SIMDJSON_ONDEMAND_DESERIALIZE_H
4#ifndef SIMDJSON_CONDITIONAL_INCLUDE
5#define SIMDJSON_ONDEMAND_DESERIALIZE_H
6#include "simdjson/generic/ondemand/base.h"
7#include "simdjson/generic/ondemand/array.h"
12struct deserialize_tag;
15template <
typename>
struct is_builtin_deserializable : std::false_type {};
16template <>
struct is_builtin_deserializable<int64_t> : std::true_type {};
17template <>
struct is_builtin_deserializable<uint64_t> : std::true_type {};
18template <>
struct is_builtin_deserializable<double> : std::true_type {};
19template <>
struct is_builtin_deserializable<bool> : std::true_type {};
20template <>
struct is_builtin_deserializable<SIMDJSON_IMPLEMENTATION::ondemand::array> : std::true_type {};
21template <>
struct is_builtin_deserializable<SIMDJSON_IMPLEMENTATION::ondemand::object> : std::true_type {};
22template <>
struct is_builtin_deserializable<SIMDJSON_IMPLEMENTATION::ondemand::value> : std::true_type {};
23template <>
struct is_builtin_deserializable<SIMDJSON_IMPLEMENTATION::ondemand::raw_json_string> : std::true_type {};
24template <>
struct is_builtin_deserializable<std::string_view> : std::true_type {};
25#if SIMDJSON_SUPPORTS_CHAR8_T
26template <>
struct is_builtin_deserializable<std::u8string_view> : std::true_type {};
30concept is_builtin_deserializable_v = is_builtin_deserializable<T>::value;
32template <
typename T,
typename ValT = SIMDJSON_IMPLEMENTATION::ondemand::value>
33concept custom_deserializable = tag_invocable<deserialize_tag, ValT&, T&>;
35template <
typename T,
typename ValT = SIMDJSON_IMPLEMENTATION::ondemand::value>
36concept deserializable = custom_deserializable<T, ValT> || is_builtin_deserializable_v<T> || concepts::optional_type<T>;
38template <
typename T,
typename ValT = SIMDJSON_IMPLEMENTATION::ondemand::value>
39concept nothrow_custom_deserializable = nothrow_tag_invocable<deserialize_tag, ValT&, T&>;
42template <
typename T,
typename ValT = SIMDJSON_IMPLEMENTATION::ondemand::value>
43concept nothrow_deserializable = nothrow_custom_deserializable<T, ValT> || is_builtin_deserializable_v<T>;
46template <
typename T,
typename ValT = SIMDJSON_IMPLEMENTATION::ondemand::value>
47concept nothrow_gettable = !custom_deserializable<T, ValT> || nothrow_custom_deserializable<T, ValT>;
50inline constexpr struct deserialize_tag {
51 using array_type = SIMDJSON_IMPLEMENTATION::ondemand::array;
52 using object_type = SIMDJSON_IMPLEMENTATION::ondemand::object;
53 using value_type = SIMDJSON_IMPLEMENTATION::ondemand::value;
54 using document_type = SIMDJSON_IMPLEMENTATION::ondemand::document;
55 using document_reference_type = SIMDJSON_IMPLEMENTATION::ondemand::document_reference;
59 requires custom_deserializable<T, value_type>
60 simdjson_warn_unused
constexpr auto operator()(array_type &
object, T& output)
const noexcept(nothrow_custom_deserializable<T, value_type>) {
61 return tag_invoke(*
this,
object, output);
66 requires custom_deserializable<T, value_type>
67 simdjson_warn_unused
constexpr auto operator()(object_type &
object, T& output)
const noexcept(nothrow_custom_deserializable<T, value_type>) {
68 return tag_invoke(*
this,
object, output);
73 requires custom_deserializable<T, value_type>
74 simdjson_warn_unused
constexpr auto operator()(value_type &
object, T& output)
const noexcept(nothrow_custom_deserializable<T, value_type>) {
75 return tag_invoke(*
this,
object, output);
80 requires custom_deserializable<T, document_type>
81 simdjson_warn_unused
constexpr auto operator()(document_type &
object, T& output)
const noexcept(nothrow_custom_deserializable<T, document_type>) {
82 return tag_invoke(*
this,
object, output);
87 requires custom_deserializable<T, document_reference_type>
88 simdjson_warn_unused
constexpr auto operator()(document_reference_type &
object, T& output)
const noexcept(nothrow_custom_deserializable<T, document_reference_type>) {
89 return tag_invoke(*
this,
object, output);
The top level simdjson namespace, containing everything the library provides.