mqt-core 3.0.2__cp310-cp310-win_amd64.whl → 3.2.0__cp310-cp310-win_amd64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of mqt-core might be problematic. Click here for more details.

Files changed (111) hide show
  1. mqt/core/__init__.py +3 -3
  2. mqt/core/_version.py +2 -2
  3. mqt/core/bin/mqt-core-algorithms.dll +0 -0
  4. mqt/core/bin/mqt-core-circuit-optimizer.dll +0 -0
  5. mqt/core/bin/mqt-core-dd.dll +0 -0
  6. mqt/core/bin/mqt-core-ds.dll +0 -0
  7. mqt/core/bin/mqt-core-ir.dll +0 -0
  8. mqt/core/bin/mqt-core-na.dll +0 -0
  9. mqt/core/bin/mqt-core-qasm.dll +0 -0
  10. mqt/core/bin/mqt-core-zx.dll +0 -0
  11. mqt/core/dd.cp310-win_amd64.pyd +0 -0
  12. mqt/core/dd.pyi +9 -22
  13. mqt/core/include/mqt-core/datastructures/DirectedAcyclicGraph.hpp +4 -4
  14. mqt/core/include/mqt-core/datastructures/DirectedGraph.hpp +7 -7
  15. mqt/core/include/mqt-core/datastructures/UndirectedGraph.hpp +8 -8
  16. mqt/core/include/mqt-core/dd/Approximation.hpp +45 -0
  17. mqt/core/include/mqt-core/dd/Complex.hpp +6 -0
  18. mqt/core/include/mqt-core/dd/ComplexNumbers.hpp +0 -18
  19. mqt/core/include/mqt-core/dd/ComputeTable.hpp +4 -1
  20. mqt/core/include/mqt-core/dd/DDDefinitions.hpp +0 -7
  21. mqt/core/include/mqt-core/dd/Edge.hpp +16 -0
  22. mqt/core/include/mqt-core/dd/Export.hpp +1 -2
  23. mqt/core/include/mqt-core/dd/Node.hpp +26 -49
  24. mqt/core/include/mqt-core/dd/Operations.hpp +27 -0
  25. mqt/core/include/mqt-core/dd/Package.hpp +141 -123
  26. mqt/core/include/mqt-core/dd/RealNumber.hpp +49 -66
  27. mqt/core/include/mqt-core/dd/RealNumberUniqueTable.hpp +14 -25
  28. mqt/core/include/mqt-core/dd/StateGeneration.hpp +143 -0
  29. mqt/core/include/mqt-core/dd/UnaryComputeTable.hpp +6 -4
  30. mqt/core/include/mqt-core/dd/UniqueTable.hpp +13 -39
  31. mqt/core/include/mqt-core/dd/statistics/PackageStatistics.hpp +8 -7
  32. mqt/core/include/mqt-core/dd/statistics/UniqueTableStatistics.hpp +0 -10
  33. mqt/core/include/mqt-core/ir/QuantumComputation.hpp +3 -0
  34. mqt/core/include/mqt-core/ir/operations/CompoundOperation.hpp +2 -0
  35. mqt/core/include/mqt-core/ir/operations/Expression.hpp +1 -1
  36. mqt/core/include/mqt-core/ir/operations/Operation.hpp +2 -2
  37. mqt/core/ir/operations.pyi +58 -86
  38. mqt/core/ir.cp310-win_amd64.pyd +0 -0
  39. mqt/core/lib/mqt-core-algorithms.lib +0 -0
  40. mqt/core/lib/mqt-core-circuit-optimizer.lib +0 -0
  41. mqt/core/lib/mqt-core-dd.lib +0 -0
  42. mqt/core/lib/mqt-core-ds.lib +0 -0
  43. mqt/core/lib/mqt-core-ir.lib +0 -0
  44. mqt/core/lib/mqt-core-na.lib +0 -0
  45. mqt/core/lib/mqt-core-qasm.lib +0 -0
  46. mqt/core/lib/mqt-core-zx.lib +0 -0
  47. mqt/core/plugins/__init__.py +0 -8
  48. mqt/core/plugins/qiskit/qiskit_to_mqt.py +6 -0
  49. mqt/core/share/cmake/mqt-core/AddMQTPythonBinding.cmake +52 -0
  50. mqt/core/share/cmake/mqt-core/PackageAddTest.cmake +4 -4
  51. mqt/core/share/cmake/mqt-core/mqt-core-config-version.cmake +3 -3
  52. mqt/core/share/cmake/mqt-core/mqt-core-config.cmake +1 -0
  53. mqt/core/share/cmake/mqt-core/mqt-core-targets.cmake +2 -2
  54. mqt_core-3.2.0.dist-info/DELVEWHEEL +2 -0
  55. {mqt_core-3.0.2.dist-info → mqt_core-3.2.0.dist-info}/METADATA +49 -23
  56. {mqt_core-3.0.2.dist-info → mqt_core-3.2.0.dist-info}/RECORD +60 -107
  57. {mqt_core-3.0.2.dist-info → mqt_core-3.2.0.dist-info}/WHEEL +1 -1
  58. mqt_core.libs/msvcp140.dll +0 -0
  59. mqt/core/include/nlohmann/adl_serializer.hpp +0 -55
  60. mqt/core/include/nlohmann/byte_container_with_subtype.hpp +0 -103
  61. mqt/core/include/nlohmann/detail/abi_macros.hpp +0 -100
  62. mqt/core/include/nlohmann/detail/conversions/from_json.hpp +0 -497
  63. mqt/core/include/nlohmann/detail/conversions/to_chars.hpp +0 -1118
  64. mqt/core/include/nlohmann/detail/conversions/to_json.hpp +0 -446
  65. mqt/core/include/nlohmann/detail/exceptions.hpp +0 -257
  66. mqt/core/include/nlohmann/detail/hash.hpp +0 -129
  67. mqt/core/include/nlohmann/detail/input/binary_reader.hpp +0 -3009
  68. mqt/core/include/nlohmann/detail/input/input_adapters.hpp +0 -492
  69. mqt/core/include/nlohmann/detail/input/json_sax.hpp +0 -727
  70. mqt/core/include/nlohmann/detail/input/lexer.hpp +0 -1633
  71. mqt/core/include/nlohmann/detail/input/parser.hpp +0 -519
  72. mqt/core/include/nlohmann/detail/input/position_t.hpp +0 -37
  73. mqt/core/include/nlohmann/detail/iterators/internal_iterator.hpp +0 -35
  74. mqt/core/include/nlohmann/detail/iterators/iter_impl.hpp +0 -751
  75. mqt/core/include/nlohmann/detail/iterators/iteration_proxy.hpp +0 -242
  76. mqt/core/include/nlohmann/detail/iterators/iterator_traits.hpp +0 -61
  77. mqt/core/include/nlohmann/detail/iterators/json_reverse_iterator.hpp +0 -130
  78. mqt/core/include/nlohmann/detail/iterators/primitive_iterator.hpp +0 -132
  79. mqt/core/include/nlohmann/detail/json_custom_base_class.hpp +0 -39
  80. mqt/core/include/nlohmann/detail/json_pointer.hpp +0 -988
  81. mqt/core/include/nlohmann/detail/json_ref.hpp +0 -78
  82. mqt/core/include/nlohmann/detail/macro_scope.hpp +0 -482
  83. mqt/core/include/nlohmann/detail/macro_unscope.hpp +0 -45
  84. mqt/core/include/nlohmann/detail/meta/call_std/begin.hpp +0 -17
  85. mqt/core/include/nlohmann/detail/meta/call_std/end.hpp +0 -17
  86. mqt/core/include/nlohmann/detail/meta/cpp_future.hpp +0 -171
  87. mqt/core/include/nlohmann/detail/meta/detected.hpp +0 -70
  88. mqt/core/include/nlohmann/detail/meta/identity_tag.hpp +0 -21
  89. mqt/core/include/nlohmann/detail/meta/is_sax.hpp +0 -159
  90. mqt/core/include/nlohmann/detail/meta/std_fs.hpp +0 -29
  91. mqt/core/include/nlohmann/detail/meta/type_traits.hpp +0 -795
  92. mqt/core/include/nlohmann/detail/meta/void_t.hpp +0 -24
  93. mqt/core/include/nlohmann/detail/output/binary_writer.hpp +0 -1838
  94. mqt/core/include/nlohmann/detail/output/output_adapters.hpp +0 -147
  95. mqt/core/include/nlohmann/detail/output/serializer.hpp +0 -988
  96. mqt/core/include/nlohmann/detail/string_concat.hpp +0 -146
  97. mqt/core/include/nlohmann/detail/string_escape.hpp +0 -72
  98. mqt/core/include/nlohmann/detail/value_t.hpp +0 -118
  99. mqt/core/include/nlohmann/json.hpp +0 -5258
  100. mqt/core/include/nlohmann/json_fwd.hpp +0 -75
  101. mqt/core/include/nlohmann/ordered_map.hpp +0 -359
  102. mqt/core/include/nlohmann/thirdparty/hedley/hedley.hpp +0 -2045
  103. mqt/core/include/nlohmann/thirdparty/hedley/hedley_undef.hpp +0 -158
  104. mqt/core/nlohmann_json.natvis +0 -278
  105. mqt/core/share/cmake/nlohmann_json/nlohmann_jsonConfig.cmake +0 -15
  106. mqt/core/share/cmake/nlohmann_json/nlohmann_jsonConfigVersion.cmake +0 -20
  107. mqt/core/share/cmake/nlohmann_json/nlohmann_jsonTargets.cmake +0 -110
  108. mqt/core/share/pkgconfig/nlohmann_json.pc +0 -4
  109. mqt_core-3.0.2.dist-info/DELVEWHEEL +0 -2
  110. {mqt_core-3.0.2.dist-info → mqt_core-3.2.0.dist-info}/entry_points.txt +0 -0
  111. {mqt_core-3.0.2.dist-info → mqt_core-3.2.0.dist-info}/licenses/LICENSE.md +0 -0
@@ -1,100 +0,0 @@
1
- // __ _____ _____ _____
2
- // __| | __| | | | JSON for Modern C++
3
- // | | |__ | | | | | | version 3.11.3
4
- // |_____|_____|_____|_|___| https://github.com/nlohmann/json
5
- //
6
- // SPDX-FileCopyrightText: 2013-2023 Niels Lohmann <https://nlohmann.me>
7
- // SPDX-License-Identifier: MIT
8
-
9
- #pragma once
10
-
11
- // This file contains all macro definitions affecting or depending on the ABI
12
-
13
- #ifndef JSON_SKIP_LIBRARY_VERSION_CHECK
14
- #if defined(NLOHMANN_JSON_VERSION_MAJOR) && defined(NLOHMANN_JSON_VERSION_MINOR) && defined(NLOHMANN_JSON_VERSION_PATCH)
15
- #if NLOHMANN_JSON_VERSION_MAJOR != 3 || NLOHMANN_JSON_VERSION_MINOR != 11 || NLOHMANN_JSON_VERSION_PATCH != 3
16
- #warning "Already included a different version of the library!"
17
- #endif
18
- #endif
19
- #endif
20
-
21
- #define NLOHMANN_JSON_VERSION_MAJOR 3 // NOLINT(modernize-macro-to-enum)
22
- #define NLOHMANN_JSON_VERSION_MINOR 11 // NOLINT(modernize-macro-to-enum)
23
- #define NLOHMANN_JSON_VERSION_PATCH 3 // NOLINT(modernize-macro-to-enum)
24
-
25
- #ifndef JSON_DIAGNOSTICS
26
- #define JSON_DIAGNOSTICS 0
27
- #endif
28
-
29
- #ifndef JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON
30
- #define JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON 0
31
- #endif
32
-
33
- #if JSON_DIAGNOSTICS
34
- #define NLOHMANN_JSON_ABI_TAG_DIAGNOSTICS _diag
35
- #else
36
- #define NLOHMANN_JSON_ABI_TAG_DIAGNOSTICS
37
- #endif
38
-
39
- #if JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON
40
- #define NLOHMANN_JSON_ABI_TAG_LEGACY_DISCARDED_VALUE_COMPARISON _ldvcmp
41
- #else
42
- #define NLOHMANN_JSON_ABI_TAG_LEGACY_DISCARDED_VALUE_COMPARISON
43
- #endif
44
-
45
- #ifndef NLOHMANN_JSON_NAMESPACE_NO_VERSION
46
- #define NLOHMANN_JSON_NAMESPACE_NO_VERSION 0
47
- #endif
48
-
49
- // Construct the namespace ABI tags component
50
- #define NLOHMANN_JSON_ABI_TAGS_CONCAT_EX(a, b) json_abi ## a ## b
51
- #define NLOHMANN_JSON_ABI_TAGS_CONCAT(a, b) \
52
- NLOHMANN_JSON_ABI_TAGS_CONCAT_EX(a, b)
53
-
54
- #define NLOHMANN_JSON_ABI_TAGS \
55
- NLOHMANN_JSON_ABI_TAGS_CONCAT( \
56
- NLOHMANN_JSON_ABI_TAG_DIAGNOSTICS, \
57
- NLOHMANN_JSON_ABI_TAG_LEGACY_DISCARDED_VALUE_COMPARISON)
58
-
59
- // Construct the namespace version component
60
- #define NLOHMANN_JSON_NAMESPACE_VERSION_CONCAT_EX(major, minor, patch) \
61
- _v ## major ## _ ## minor ## _ ## patch
62
- #define NLOHMANN_JSON_NAMESPACE_VERSION_CONCAT(major, minor, patch) \
63
- NLOHMANN_JSON_NAMESPACE_VERSION_CONCAT_EX(major, minor, patch)
64
-
65
- #if NLOHMANN_JSON_NAMESPACE_NO_VERSION
66
- #define NLOHMANN_JSON_NAMESPACE_VERSION
67
- #else
68
- #define NLOHMANN_JSON_NAMESPACE_VERSION \
69
- NLOHMANN_JSON_NAMESPACE_VERSION_CONCAT(NLOHMANN_JSON_VERSION_MAJOR, \
70
- NLOHMANN_JSON_VERSION_MINOR, \
71
- NLOHMANN_JSON_VERSION_PATCH)
72
- #endif
73
-
74
- // Combine namespace components
75
- #define NLOHMANN_JSON_NAMESPACE_CONCAT_EX(a, b) a ## b
76
- #define NLOHMANN_JSON_NAMESPACE_CONCAT(a, b) \
77
- NLOHMANN_JSON_NAMESPACE_CONCAT_EX(a, b)
78
-
79
- #ifndef NLOHMANN_JSON_NAMESPACE
80
- #define NLOHMANN_JSON_NAMESPACE \
81
- nlohmann::NLOHMANN_JSON_NAMESPACE_CONCAT( \
82
- NLOHMANN_JSON_ABI_TAGS, \
83
- NLOHMANN_JSON_NAMESPACE_VERSION)
84
- #endif
85
-
86
- #ifndef NLOHMANN_JSON_NAMESPACE_BEGIN
87
- #define NLOHMANN_JSON_NAMESPACE_BEGIN \
88
- namespace nlohmann \
89
- { \
90
- inline namespace NLOHMANN_JSON_NAMESPACE_CONCAT( \
91
- NLOHMANN_JSON_ABI_TAGS, \
92
- NLOHMANN_JSON_NAMESPACE_VERSION) \
93
- {
94
- #endif
95
-
96
- #ifndef NLOHMANN_JSON_NAMESPACE_END
97
- #define NLOHMANN_JSON_NAMESPACE_END \
98
- } /* namespace (inline namespace) NOLINT(readability/namespace) */ \
99
- } // namespace nlohmann
100
- #endif
@@ -1,497 +0,0 @@
1
- // __ _____ _____ _____
2
- // __| | __| | | | JSON for Modern C++
3
- // | | |__ | | | | | | version 3.11.3
4
- // |_____|_____|_____|_|___| https://github.com/nlohmann/json
5
- //
6
- // SPDX-FileCopyrightText: 2013-2023 Niels Lohmann <https://nlohmann.me>
7
- // SPDX-License-Identifier: MIT
8
-
9
- #pragma once
10
-
11
- #include <algorithm> // transform
12
- #include <array> // array
13
- #include <forward_list> // forward_list
14
- #include <iterator> // inserter, front_inserter, end
15
- #include <map> // map
16
- #include <string> // string
17
- #include <tuple> // tuple, make_tuple
18
- #include <type_traits> // is_arithmetic, is_same, is_enum, underlying_type, is_convertible
19
- #include <unordered_map> // unordered_map
20
- #include <utility> // pair, declval
21
- #include <valarray> // valarray
22
-
23
- #include <nlohmann/detail/exceptions.hpp>
24
- #include <nlohmann/detail/macro_scope.hpp>
25
- #include <nlohmann/detail/meta/cpp_future.hpp>
26
- #include <nlohmann/detail/meta/identity_tag.hpp>
27
- #include <nlohmann/detail/meta/std_fs.hpp>
28
- #include <nlohmann/detail/meta/type_traits.hpp>
29
- #include <nlohmann/detail/string_concat.hpp>
30
- #include <nlohmann/detail/value_t.hpp>
31
-
32
- NLOHMANN_JSON_NAMESPACE_BEGIN
33
- namespace detail
34
- {
35
-
36
- template<typename BasicJsonType>
37
- inline void from_json(const BasicJsonType& j, typename std::nullptr_t& n)
38
- {
39
- if (JSON_HEDLEY_UNLIKELY(!j.is_null()))
40
- {
41
- JSON_THROW(type_error::create(302, concat("type must be null, but is ", j.type_name()), &j));
42
- }
43
- n = nullptr;
44
- }
45
-
46
- // overloads for basic_json template parameters
47
- template < typename BasicJsonType, typename ArithmeticType,
48
- enable_if_t < std::is_arithmetic<ArithmeticType>::value&&
49
- !std::is_same<ArithmeticType, typename BasicJsonType::boolean_t>::value,
50
- int > = 0 >
51
- void get_arithmetic_value(const BasicJsonType& j, ArithmeticType& val)
52
- {
53
- switch (static_cast<value_t>(j))
54
- {
55
- case value_t::number_unsigned:
56
- {
57
- val = static_cast<ArithmeticType>(*j.template get_ptr<const typename BasicJsonType::number_unsigned_t*>());
58
- break;
59
- }
60
- case value_t::number_integer:
61
- {
62
- val = static_cast<ArithmeticType>(*j.template get_ptr<const typename BasicJsonType::number_integer_t*>());
63
- break;
64
- }
65
- case value_t::number_float:
66
- {
67
- val = static_cast<ArithmeticType>(*j.template get_ptr<const typename BasicJsonType::number_float_t*>());
68
- break;
69
- }
70
-
71
- case value_t::null:
72
- case value_t::object:
73
- case value_t::array:
74
- case value_t::string:
75
- case value_t::boolean:
76
- case value_t::binary:
77
- case value_t::discarded:
78
- default:
79
- JSON_THROW(type_error::create(302, concat("type must be number, but is ", j.type_name()), &j));
80
- }
81
- }
82
-
83
- template<typename BasicJsonType>
84
- inline void from_json(const BasicJsonType& j, typename BasicJsonType::boolean_t& b)
85
- {
86
- if (JSON_HEDLEY_UNLIKELY(!j.is_boolean()))
87
- {
88
- JSON_THROW(type_error::create(302, concat("type must be boolean, but is ", j.type_name()), &j));
89
- }
90
- b = *j.template get_ptr<const typename BasicJsonType::boolean_t*>();
91
- }
92
-
93
- template<typename BasicJsonType>
94
- inline void from_json(const BasicJsonType& j, typename BasicJsonType::string_t& s)
95
- {
96
- if (JSON_HEDLEY_UNLIKELY(!j.is_string()))
97
- {
98
- JSON_THROW(type_error::create(302, concat("type must be string, but is ", j.type_name()), &j));
99
- }
100
- s = *j.template get_ptr<const typename BasicJsonType::string_t*>();
101
- }
102
-
103
- template <
104
- typename BasicJsonType, typename StringType,
105
- enable_if_t <
106
- std::is_assignable<StringType&, const typename BasicJsonType::string_t>::value
107
- && is_detected_exact<typename BasicJsonType::string_t::value_type, value_type_t, StringType>::value
108
- && !std::is_same<typename BasicJsonType::string_t, StringType>::value
109
- && !is_json_ref<StringType>::value, int > = 0 >
110
- inline void from_json(const BasicJsonType& j, StringType& s)
111
- {
112
- if (JSON_HEDLEY_UNLIKELY(!j.is_string()))
113
- {
114
- JSON_THROW(type_error::create(302, concat("type must be string, but is ", j.type_name()), &j));
115
- }
116
-
117
- s = *j.template get_ptr<const typename BasicJsonType::string_t*>();
118
- }
119
-
120
- template<typename BasicJsonType>
121
- inline void from_json(const BasicJsonType& j, typename BasicJsonType::number_float_t& val)
122
- {
123
- get_arithmetic_value(j, val);
124
- }
125
-
126
- template<typename BasicJsonType>
127
- inline void from_json(const BasicJsonType& j, typename BasicJsonType::number_unsigned_t& val)
128
- {
129
- get_arithmetic_value(j, val);
130
- }
131
-
132
- template<typename BasicJsonType>
133
- inline void from_json(const BasicJsonType& j, typename BasicJsonType::number_integer_t& val)
134
- {
135
- get_arithmetic_value(j, val);
136
- }
137
-
138
- #if !JSON_DISABLE_ENUM_SERIALIZATION
139
- template<typename BasicJsonType, typename EnumType,
140
- enable_if_t<std::is_enum<EnumType>::value, int> = 0>
141
- inline void from_json(const BasicJsonType& j, EnumType& e)
142
- {
143
- typename std::underlying_type<EnumType>::type val;
144
- get_arithmetic_value(j, val);
145
- e = static_cast<EnumType>(val);
146
- }
147
- #endif // JSON_DISABLE_ENUM_SERIALIZATION
148
-
149
- // forward_list doesn't have an insert method
150
- template<typename BasicJsonType, typename T, typename Allocator,
151
- enable_if_t<is_getable<BasicJsonType, T>::value, int> = 0>
152
- inline void from_json(const BasicJsonType& j, std::forward_list<T, Allocator>& l)
153
- {
154
- if (JSON_HEDLEY_UNLIKELY(!j.is_array()))
155
- {
156
- JSON_THROW(type_error::create(302, concat("type must be array, but is ", j.type_name()), &j));
157
- }
158
- l.clear();
159
- std::transform(j.rbegin(), j.rend(),
160
- std::front_inserter(l), [](const BasicJsonType & i)
161
- {
162
- return i.template get<T>();
163
- });
164
- }
165
-
166
- // valarray doesn't have an insert method
167
- template<typename BasicJsonType, typename T,
168
- enable_if_t<is_getable<BasicJsonType, T>::value, int> = 0>
169
- inline void from_json(const BasicJsonType& j, std::valarray<T>& l)
170
- {
171
- if (JSON_HEDLEY_UNLIKELY(!j.is_array()))
172
- {
173
- JSON_THROW(type_error::create(302, concat("type must be array, but is ", j.type_name()), &j));
174
- }
175
- l.resize(j.size());
176
- std::transform(j.begin(), j.end(), std::begin(l),
177
- [](const BasicJsonType & elem)
178
- {
179
- return elem.template get<T>();
180
- });
181
- }
182
-
183
- template<typename BasicJsonType, typename T, std::size_t N>
184
- auto from_json(const BasicJsonType& j, T (&arr)[N]) // NOLINT(cppcoreguidelines-avoid-c-arrays,hicpp-avoid-c-arrays,modernize-avoid-c-arrays)
185
- -> decltype(j.template get<T>(), void())
186
- {
187
- for (std::size_t i = 0; i < N; ++i)
188
- {
189
- arr[i] = j.at(i).template get<T>();
190
- }
191
- }
192
-
193
- template<typename BasicJsonType>
194
- inline void from_json_array_impl(const BasicJsonType& j, typename BasicJsonType::array_t& arr, priority_tag<3> /*unused*/)
195
- {
196
- arr = *j.template get_ptr<const typename BasicJsonType::array_t*>();
197
- }
198
-
199
- template<typename BasicJsonType, typename T, std::size_t N>
200
- auto from_json_array_impl(const BasicJsonType& j, std::array<T, N>& arr,
201
- priority_tag<2> /*unused*/)
202
- -> decltype(j.template get<T>(), void())
203
- {
204
- for (std::size_t i = 0; i < N; ++i)
205
- {
206
- arr[i] = j.at(i).template get<T>();
207
- }
208
- }
209
-
210
- template<typename BasicJsonType, typename ConstructibleArrayType,
211
- enable_if_t<
212
- std::is_assignable<ConstructibleArrayType&, ConstructibleArrayType>::value,
213
- int> = 0>
214
- auto from_json_array_impl(const BasicJsonType& j, ConstructibleArrayType& arr, priority_tag<1> /*unused*/)
215
- -> decltype(
216
- arr.reserve(std::declval<typename ConstructibleArrayType::size_type>()),
217
- j.template get<typename ConstructibleArrayType::value_type>(),
218
- void())
219
- {
220
- using std::end;
221
-
222
- ConstructibleArrayType ret;
223
- ret.reserve(j.size());
224
- std::transform(j.begin(), j.end(),
225
- std::inserter(ret, end(ret)), [](const BasicJsonType & i)
226
- {
227
- // get<BasicJsonType>() returns *this, this won't call a from_json
228
- // method when value_type is BasicJsonType
229
- return i.template get<typename ConstructibleArrayType::value_type>();
230
- });
231
- arr = std::move(ret);
232
- }
233
-
234
- template<typename BasicJsonType, typename ConstructibleArrayType,
235
- enable_if_t<
236
- std::is_assignable<ConstructibleArrayType&, ConstructibleArrayType>::value,
237
- int> = 0>
238
- inline void from_json_array_impl(const BasicJsonType& j, ConstructibleArrayType& arr,
239
- priority_tag<0> /*unused*/)
240
- {
241
- using std::end;
242
-
243
- ConstructibleArrayType ret;
244
- std::transform(
245
- j.begin(), j.end(), std::inserter(ret, end(ret)),
246
- [](const BasicJsonType & i)
247
- {
248
- // get<BasicJsonType>() returns *this, this won't call a from_json
249
- // method when value_type is BasicJsonType
250
- return i.template get<typename ConstructibleArrayType::value_type>();
251
- });
252
- arr = std::move(ret);
253
- }
254
-
255
- template < typename BasicJsonType, typename ConstructibleArrayType,
256
- enable_if_t <
257
- is_constructible_array_type<BasicJsonType, ConstructibleArrayType>::value&&
258
- !is_constructible_object_type<BasicJsonType, ConstructibleArrayType>::value&&
259
- !is_constructible_string_type<BasicJsonType, ConstructibleArrayType>::value&&
260
- !std::is_same<ConstructibleArrayType, typename BasicJsonType::binary_t>::value&&
261
- !is_basic_json<ConstructibleArrayType>::value,
262
- int > = 0 >
263
- auto from_json(const BasicJsonType& j, ConstructibleArrayType& arr)
264
- -> decltype(from_json_array_impl(j, arr, priority_tag<3> {}),
265
- j.template get<typename ConstructibleArrayType::value_type>(),
266
- void())
267
- {
268
- if (JSON_HEDLEY_UNLIKELY(!j.is_array()))
269
- {
270
- JSON_THROW(type_error::create(302, concat("type must be array, but is ", j.type_name()), &j));
271
- }
272
-
273
- from_json_array_impl(j, arr, priority_tag<3> {});
274
- }
275
-
276
- template < typename BasicJsonType, typename T, std::size_t... Idx >
277
- std::array<T, sizeof...(Idx)> from_json_inplace_array_impl(BasicJsonType&& j,
278
- identity_tag<std::array<T, sizeof...(Idx)>> /*unused*/, index_sequence<Idx...> /*unused*/)
279
- {
280
- return { { std::forward<BasicJsonType>(j).at(Idx).template get<T>()... } };
281
- }
282
-
283
- template < typename BasicJsonType, typename T, std::size_t N >
284
- auto from_json(BasicJsonType&& j, identity_tag<std::array<T, N>> tag)
285
- -> decltype(from_json_inplace_array_impl(std::forward<BasicJsonType>(j), tag, make_index_sequence<N> {}))
286
- {
287
- if (JSON_HEDLEY_UNLIKELY(!j.is_array()))
288
- {
289
- JSON_THROW(type_error::create(302, concat("type must be array, but is ", j.type_name()), &j));
290
- }
291
-
292
- return from_json_inplace_array_impl(std::forward<BasicJsonType>(j), tag, make_index_sequence<N> {});
293
- }
294
-
295
- template<typename BasicJsonType>
296
- inline void from_json(const BasicJsonType& j, typename BasicJsonType::binary_t& bin)
297
- {
298
- if (JSON_HEDLEY_UNLIKELY(!j.is_binary()))
299
- {
300
- JSON_THROW(type_error::create(302, concat("type must be binary, but is ", j.type_name()), &j));
301
- }
302
-
303
- bin = *j.template get_ptr<const typename BasicJsonType::binary_t*>();
304
- }
305
-
306
- template<typename BasicJsonType, typename ConstructibleObjectType,
307
- enable_if_t<is_constructible_object_type<BasicJsonType, ConstructibleObjectType>::value, int> = 0>
308
- inline void from_json(const BasicJsonType& j, ConstructibleObjectType& obj)
309
- {
310
- if (JSON_HEDLEY_UNLIKELY(!j.is_object()))
311
- {
312
- JSON_THROW(type_error::create(302, concat("type must be object, but is ", j.type_name()), &j));
313
- }
314
-
315
- ConstructibleObjectType ret;
316
- const auto* inner_object = j.template get_ptr<const typename BasicJsonType::object_t*>();
317
- using value_type = typename ConstructibleObjectType::value_type;
318
- std::transform(
319
- inner_object->begin(), inner_object->end(),
320
- std::inserter(ret, ret.begin()),
321
- [](typename BasicJsonType::object_t::value_type const & p)
322
- {
323
- return value_type(p.first, p.second.template get<typename ConstructibleObjectType::mapped_type>());
324
- });
325
- obj = std::move(ret);
326
- }
327
-
328
- // overload for arithmetic types, not chosen for basic_json template arguments
329
- // (BooleanType, etc..); note: Is it really necessary to provide explicit
330
- // overloads for boolean_t etc. in case of a custom BooleanType which is not
331
- // an arithmetic type?
332
- template < typename BasicJsonType, typename ArithmeticType,
333
- enable_if_t <
334
- std::is_arithmetic<ArithmeticType>::value&&
335
- !std::is_same<ArithmeticType, typename BasicJsonType::number_unsigned_t>::value&&
336
- !std::is_same<ArithmeticType, typename BasicJsonType::number_integer_t>::value&&
337
- !std::is_same<ArithmeticType, typename BasicJsonType::number_float_t>::value&&
338
- !std::is_same<ArithmeticType, typename BasicJsonType::boolean_t>::value,
339
- int > = 0 >
340
- inline void from_json(const BasicJsonType& j, ArithmeticType& val)
341
- {
342
- switch (static_cast<value_t>(j))
343
- {
344
- case value_t::number_unsigned:
345
- {
346
- val = static_cast<ArithmeticType>(*j.template get_ptr<const typename BasicJsonType::number_unsigned_t*>());
347
- break;
348
- }
349
- case value_t::number_integer:
350
- {
351
- val = static_cast<ArithmeticType>(*j.template get_ptr<const typename BasicJsonType::number_integer_t*>());
352
- break;
353
- }
354
- case value_t::number_float:
355
- {
356
- val = static_cast<ArithmeticType>(*j.template get_ptr<const typename BasicJsonType::number_float_t*>());
357
- break;
358
- }
359
- case value_t::boolean:
360
- {
361
- val = static_cast<ArithmeticType>(*j.template get_ptr<const typename BasicJsonType::boolean_t*>());
362
- break;
363
- }
364
-
365
- case value_t::null:
366
- case value_t::object:
367
- case value_t::array:
368
- case value_t::string:
369
- case value_t::binary:
370
- case value_t::discarded:
371
- default:
372
- JSON_THROW(type_error::create(302, concat("type must be number, but is ", j.type_name()), &j));
373
- }
374
- }
375
-
376
- template<typename BasicJsonType, typename... Args, std::size_t... Idx>
377
- std::tuple<Args...> from_json_tuple_impl_base(BasicJsonType&& j, index_sequence<Idx...> /*unused*/)
378
- {
379
- return std::make_tuple(std::forward<BasicJsonType>(j).at(Idx).template get<Args>()...);
380
- }
381
-
382
- template < typename BasicJsonType, class A1, class A2 >
383
- std::pair<A1, A2> from_json_tuple_impl(BasicJsonType&& j, identity_tag<std::pair<A1, A2>> /*unused*/, priority_tag<0> /*unused*/)
384
- {
385
- return {std::forward<BasicJsonType>(j).at(0).template get<A1>(),
386
- std::forward<BasicJsonType>(j).at(1).template get<A2>()};
387
- }
388
-
389
- template<typename BasicJsonType, typename A1, typename A2>
390
- inline void from_json_tuple_impl(BasicJsonType&& j, std::pair<A1, A2>& p, priority_tag<1> /*unused*/)
391
- {
392
- p = from_json_tuple_impl(std::forward<BasicJsonType>(j), identity_tag<std::pair<A1, A2>> {}, priority_tag<0> {});
393
- }
394
-
395
- template<typename BasicJsonType, typename... Args>
396
- std::tuple<Args...> from_json_tuple_impl(BasicJsonType&& j, identity_tag<std::tuple<Args...>> /*unused*/, priority_tag<2> /*unused*/)
397
- {
398
- return from_json_tuple_impl_base<BasicJsonType, Args...>(std::forward<BasicJsonType>(j), index_sequence_for<Args...> {});
399
- }
400
-
401
- template<typename BasicJsonType, typename... Args>
402
- inline void from_json_tuple_impl(BasicJsonType&& j, std::tuple<Args...>& t, priority_tag<3> /*unused*/)
403
- {
404
- t = from_json_tuple_impl_base<BasicJsonType, Args...>(std::forward<BasicJsonType>(j), index_sequence_for<Args...> {});
405
- }
406
-
407
- template<typename BasicJsonType, typename TupleRelated>
408
- auto from_json(BasicJsonType&& j, TupleRelated&& t)
409
- -> decltype(from_json_tuple_impl(std::forward<BasicJsonType>(j), std::forward<TupleRelated>(t), priority_tag<3> {}))
410
- {
411
- if (JSON_HEDLEY_UNLIKELY(!j.is_array()))
412
- {
413
- JSON_THROW(type_error::create(302, concat("type must be array, but is ", j.type_name()), &j));
414
- }
415
-
416
- return from_json_tuple_impl(std::forward<BasicJsonType>(j), std::forward<TupleRelated>(t), priority_tag<3> {});
417
- }
418
-
419
- template < typename BasicJsonType, typename Key, typename Value, typename Compare, typename Allocator,
420
- typename = enable_if_t < !std::is_constructible <
421
- typename BasicJsonType::string_t, Key >::value >>
422
- inline void from_json(const BasicJsonType& j, std::map<Key, Value, Compare, Allocator>& m)
423
- {
424
- if (JSON_HEDLEY_UNLIKELY(!j.is_array()))
425
- {
426
- JSON_THROW(type_error::create(302, concat("type must be array, but is ", j.type_name()), &j));
427
- }
428
- m.clear();
429
- for (const auto& p : j)
430
- {
431
- if (JSON_HEDLEY_UNLIKELY(!p.is_array()))
432
- {
433
- JSON_THROW(type_error::create(302, concat("type must be array, but is ", p.type_name()), &j));
434
- }
435
- m.emplace(p.at(0).template get<Key>(), p.at(1).template get<Value>());
436
- }
437
- }
438
-
439
- template < typename BasicJsonType, typename Key, typename Value, typename Hash, typename KeyEqual, typename Allocator,
440
- typename = enable_if_t < !std::is_constructible <
441
- typename BasicJsonType::string_t, Key >::value >>
442
- inline void from_json(const BasicJsonType& j, std::unordered_map<Key, Value, Hash, KeyEqual, Allocator>& m)
443
- {
444
- if (JSON_HEDLEY_UNLIKELY(!j.is_array()))
445
- {
446
- JSON_THROW(type_error::create(302, concat("type must be array, but is ", j.type_name()), &j));
447
- }
448
- m.clear();
449
- for (const auto& p : j)
450
- {
451
- if (JSON_HEDLEY_UNLIKELY(!p.is_array()))
452
- {
453
- JSON_THROW(type_error::create(302, concat("type must be array, but is ", p.type_name()), &j));
454
- }
455
- m.emplace(p.at(0).template get<Key>(), p.at(1).template get<Value>());
456
- }
457
- }
458
-
459
- #if JSON_HAS_FILESYSTEM || JSON_HAS_EXPERIMENTAL_FILESYSTEM
460
- template<typename BasicJsonType>
461
- inline void from_json(const BasicJsonType& j, std_fs::path& p)
462
- {
463
- if (JSON_HEDLEY_UNLIKELY(!j.is_string()))
464
- {
465
- JSON_THROW(type_error::create(302, concat("type must be string, but is ", j.type_name()), &j));
466
- }
467
- p = *j.template get_ptr<const typename BasicJsonType::string_t*>();
468
- }
469
- #endif
470
-
471
- struct from_json_fn
472
- {
473
- template<typename BasicJsonType, typename T>
474
- auto operator()(const BasicJsonType& j, T&& val) const
475
- noexcept(noexcept(from_json(j, std::forward<T>(val))))
476
- -> decltype(from_json(j, std::forward<T>(val)))
477
- {
478
- return from_json(j, std::forward<T>(val));
479
- }
480
- };
481
-
482
- } // namespace detail
483
-
484
- #ifndef JSON_HAS_CPP_17
485
- /// namespace to hold default `from_json` function
486
- /// to see why this is required:
487
- /// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/n4381.html
488
- namespace // NOLINT(cert-dcl59-cpp,fuchsia-header-anon-namespaces,google-build-namespaces)
489
- {
490
- #endif
491
- JSON_INLINE_VARIABLE constexpr const auto& from_json = // NOLINT(misc-definitions-in-headers)
492
- detail::static_const<detail::from_json_fn>::value;
493
- #ifndef JSON_HAS_CPP_17
494
- } // namespace
495
- #endif
496
-
497
- NLOHMANN_JSON_NAMESPACE_END