/src/cryptofuzz/third_party/json/json.hpp
Line | Count | Source |
1 | | // __ _____ _____ _____ |
2 | | // __| | __| | | | JSON for Modern C++ |
3 | | // | | |__ | | | | | | version 3.12.0 |
4 | | // |_____|_____|_____|_|___| https://github.com/nlohmann/json |
5 | | // |
6 | | // SPDX-FileCopyrightText: 2013-2026 Niels Lohmann <https://nlohmann.me> |
7 | | // SPDX-License-Identifier: MIT |
8 | | |
9 | | /****************************************************************************\ |
10 | | * Note on documentation: The source files contain links to the online * |
11 | | * documentation of the public API at https://json.nlohmann.me. This URL * |
12 | | * contains the most recent documentation and should also be applicable to * |
13 | | * previous versions; documentation for deprecated functions is not * |
14 | | * removed, but marked deprecated. See "Generate documentation" section in * |
15 | | * file docs/README.md. * |
16 | | \****************************************************************************/ |
17 | | |
18 | | #ifndef INCLUDE_NLOHMANN_JSON_HPP_ |
19 | | #define INCLUDE_NLOHMANN_JSON_HPP_ |
20 | | |
21 | | #include <algorithm> // all_of, find, for_each |
22 | | #include <cstddef> // nullptr_t, ptrdiff_t, size_t |
23 | | #include <functional> // hash, less |
24 | | #include <initializer_list> // initializer_list |
25 | | #ifndef JSON_NO_IO |
26 | | #include <iosfwd> // istream, ostream |
27 | | #endif // JSON_NO_IO |
28 | | #include <iterator> // random_access_iterator_tag |
29 | | #include <memory> // unique_ptr |
30 | | #include <string> // string, stoi, to_string |
31 | | #include <utility> // declval, forward, move, pair, swap |
32 | | #include <vector> // vector |
33 | | |
34 | | // #include <nlohmann/adl_serializer.hpp> |
35 | | // __ _____ _____ _____ |
36 | | // __| | __| | | | JSON for Modern C++ |
37 | | // | | |__ | | | | | | version 3.12.0 |
38 | | // |_____|_____|_____|_|___| https://github.com/nlohmann/json |
39 | | // |
40 | | // SPDX-FileCopyrightText: 2013-2026 Niels Lohmann <https://nlohmann.me> |
41 | | // SPDX-License-Identifier: MIT |
42 | | |
43 | | |
44 | | |
45 | | #include <utility> |
46 | | |
47 | | // #include <nlohmann/detail/abi_macros.hpp> |
48 | | // __ _____ _____ _____ |
49 | | // __| | __| | | | JSON for Modern C++ |
50 | | // | | |__ | | | | | | version 3.12.0 |
51 | | // |_____|_____|_____|_|___| https://github.com/nlohmann/json |
52 | | // |
53 | | // SPDX-FileCopyrightText: 2013-2026 Niels Lohmann <https://nlohmann.me> |
54 | | // SPDX-License-Identifier: MIT |
55 | | |
56 | | |
57 | | |
58 | | // This file contains all macro definitions affecting or depending on the ABI |
59 | | |
60 | | #ifndef JSON_SKIP_LIBRARY_VERSION_CHECK |
61 | | #if defined(NLOHMANN_JSON_VERSION_MAJOR) && defined(NLOHMANN_JSON_VERSION_MINOR) && defined(NLOHMANN_JSON_VERSION_PATCH) |
62 | | #if NLOHMANN_JSON_VERSION_MAJOR != 3 || NLOHMANN_JSON_VERSION_MINOR != 12 || NLOHMANN_JSON_VERSION_PATCH != 0 |
63 | | #warning "Already included a different version of the library!" |
64 | | #endif |
65 | | #endif |
66 | | #endif |
67 | | |
68 | | #define NLOHMANN_JSON_VERSION_MAJOR 3 // NOLINT(modernize-macro-to-enum) |
69 | | #define NLOHMANN_JSON_VERSION_MINOR 12 // NOLINT(modernize-macro-to-enum) |
70 | | #define NLOHMANN_JSON_VERSION_PATCH 0 // NOLINT(modernize-macro-to-enum) |
71 | | |
72 | | #ifndef JSON_DIAGNOSTICS |
73 | | #define JSON_DIAGNOSTICS 0 |
74 | | #endif |
75 | | |
76 | | #ifndef JSON_DIAGNOSTIC_POSITIONS |
77 | | #define JSON_DIAGNOSTIC_POSITIONS 0 |
78 | | #endif |
79 | | |
80 | | #ifndef JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON |
81 | | #define JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON 0 |
82 | | #endif |
83 | | |
84 | | #if JSON_DIAGNOSTICS |
85 | | #define NLOHMANN_JSON_ABI_TAG_DIAGNOSTICS _diag |
86 | | #else |
87 | | #define NLOHMANN_JSON_ABI_TAG_DIAGNOSTICS |
88 | | #endif |
89 | | |
90 | | #if JSON_DIAGNOSTIC_POSITIONS |
91 | | #define NLOHMANN_JSON_ABI_TAG_DIAGNOSTIC_POSITIONS _dp |
92 | | #else |
93 | | #define NLOHMANN_JSON_ABI_TAG_DIAGNOSTIC_POSITIONS |
94 | | #endif |
95 | | |
96 | | #if JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON |
97 | | #define NLOHMANN_JSON_ABI_TAG_LEGACY_DISCARDED_VALUE_COMPARISON _ldvcmp |
98 | | #else |
99 | | #define NLOHMANN_JSON_ABI_TAG_LEGACY_DISCARDED_VALUE_COMPARISON |
100 | | #endif |
101 | | |
102 | | #ifndef NLOHMANN_JSON_NAMESPACE_NO_VERSION |
103 | | #define NLOHMANN_JSON_NAMESPACE_NO_VERSION 0 |
104 | | #endif |
105 | | |
106 | | // Construct the namespace ABI tags component |
107 | | #define NLOHMANN_JSON_ABI_TAGS_CONCAT_EX(a, b, c) json_abi ## a ## b ## c |
108 | | #define NLOHMANN_JSON_ABI_TAGS_CONCAT(a, b, c) \ |
109 | | NLOHMANN_JSON_ABI_TAGS_CONCAT_EX(a, b, c) |
110 | | |
111 | | #define NLOHMANN_JSON_ABI_TAGS \ |
112 | | NLOHMANN_JSON_ABI_TAGS_CONCAT( \ |
113 | | NLOHMANN_JSON_ABI_TAG_DIAGNOSTICS, \ |
114 | | NLOHMANN_JSON_ABI_TAG_LEGACY_DISCARDED_VALUE_COMPARISON, \ |
115 | | NLOHMANN_JSON_ABI_TAG_DIAGNOSTIC_POSITIONS) |
116 | | |
117 | | // Construct the namespace version component |
118 | | #define NLOHMANN_JSON_NAMESPACE_VERSION_CONCAT_EX(major, minor, patch) \ |
119 | | _v ## major ## _ ## minor ## _ ## patch |
120 | | #define NLOHMANN_JSON_NAMESPACE_VERSION_CONCAT(major, minor, patch) \ |
121 | | NLOHMANN_JSON_NAMESPACE_VERSION_CONCAT_EX(major, minor, patch) |
122 | | |
123 | | #if NLOHMANN_JSON_NAMESPACE_NO_VERSION |
124 | | #define NLOHMANN_JSON_NAMESPACE_VERSION |
125 | | #else |
126 | | #define NLOHMANN_JSON_NAMESPACE_VERSION \ |
127 | | NLOHMANN_JSON_NAMESPACE_VERSION_CONCAT(NLOHMANN_JSON_VERSION_MAJOR, \ |
128 | | NLOHMANN_JSON_VERSION_MINOR, \ |
129 | | NLOHMANN_JSON_VERSION_PATCH) |
130 | | #endif |
131 | | |
132 | | // Combine namespace components |
133 | | #define NLOHMANN_JSON_NAMESPACE_CONCAT_EX(a, b) a ## b |
134 | | #define NLOHMANN_JSON_NAMESPACE_CONCAT(a, b) \ |
135 | | NLOHMANN_JSON_NAMESPACE_CONCAT_EX(a, b) |
136 | | |
137 | | #ifndef NLOHMANN_JSON_NAMESPACE |
138 | | #define NLOHMANN_JSON_NAMESPACE \ |
139 | | nlohmann::NLOHMANN_JSON_NAMESPACE_CONCAT( \ |
140 | | NLOHMANN_JSON_ABI_TAGS, \ |
141 | | NLOHMANN_JSON_NAMESPACE_VERSION) |
142 | | #endif |
143 | | |
144 | | #ifndef NLOHMANN_JSON_NAMESPACE_BEGIN |
145 | | #define NLOHMANN_JSON_NAMESPACE_BEGIN \ |
146 | | namespace nlohmann \ |
147 | | { \ |
148 | | inline namespace NLOHMANN_JSON_NAMESPACE_CONCAT( \ |
149 | | NLOHMANN_JSON_ABI_TAGS, \ |
150 | | NLOHMANN_JSON_NAMESPACE_VERSION) \ |
151 | | { |
152 | | #endif |
153 | | |
154 | | #ifndef NLOHMANN_JSON_NAMESPACE_END |
155 | | #define NLOHMANN_JSON_NAMESPACE_END \ |
156 | | } /* namespace (inline namespace) NOLINT(readability/namespace) */ \ |
157 | | } // namespace nlohmann |
158 | | #endif |
159 | | |
160 | | // #include <nlohmann/detail/conversions/from_json.hpp> |
161 | | // __ _____ _____ _____ |
162 | | // __| | __| | | | JSON for Modern C++ |
163 | | // | | |__ | | | | | | version 3.12.0 |
164 | | // |_____|_____|_____|_|___| https://github.com/nlohmann/json |
165 | | // |
166 | | // SPDX-FileCopyrightText: 2013-2026 Niels Lohmann <https://nlohmann.me> |
167 | | // SPDX-License-Identifier: MIT |
168 | | |
169 | | |
170 | | |
171 | | #include <algorithm> // transform |
172 | | #include <array> // array |
173 | | #include <forward_list> // forward_list |
174 | | #include <iterator> // inserter, front_inserter, end |
175 | | #include <map> // map |
176 | | #include <string> // string |
177 | | #include <tuple> // tuple, make_tuple |
178 | | #include <type_traits> // is_arithmetic, is_same, is_enum, underlying_type, is_convertible |
179 | | #include <unordered_map> // unordered_map |
180 | | #include <utility> // pair, declval |
181 | | #include <valarray> // valarray |
182 | | |
183 | | // #include <nlohmann/detail/exceptions.hpp> |
184 | | // __ _____ _____ _____ |
185 | | // __| | __| | | | JSON for Modern C++ |
186 | | // | | |__ | | | | | | version 3.12.0 |
187 | | // |_____|_____|_____|_|___| https://github.com/nlohmann/json |
188 | | // |
189 | | // SPDX-FileCopyrightText: 2013-2026 Niels Lohmann <https://nlohmann.me> |
190 | | // SPDX-License-Identifier: MIT |
191 | | |
192 | | |
193 | | |
194 | | #include <cstddef> // nullptr_t |
195 | | #include <exception> // exception |
196 | | #if JSON_DIAGNOSTICS |
197 | | #include <numeric> // accumulate |
198 | | #endif |
199 | | #include <stdexcept> // runtime_error |
200 | | #include <string> // to_string |
201 | | #include <vector> // vector |
202 | | |
203 | | // #include <nlohmann/detail/value_t.hpp> |
204 | | // __ _____ _____ _____ |
205 | | // __| | __| | | | JSON for Modern C++ |
206 | | // | | |__ | | | | | | version 3.12.0 |
207 | | // |_____|_____|_____|_|___| https://github.com/nlohmann/json |
208 | | // |
209 | | // SPDX-FileCopyrightText: 2013-2026 Niels Lohmann <https://nlohmann.me> |
210 | | // SPDX-License-Identifier: MIT |
211 | | |
212 | | |
213 | | |
214 | | #include <array> // array |
215 | | #include <cstddef> // size_t |
216 | | #include <cstdint> // uint8_t |
217 | | #include <string> // string |
218 | | |
219 | | // #include <nlohmann/detail/macro_scope.hpp> |
220 | | // __ _____ _____ _____ |
221 | | // __| | __| | | | JSON for Modern C++ |
222 | | // | | |__ | | | | | | version 3.12.0 |
223 | | // |_____|_____|_____|_|___| https://github.com/nlohmann/json |
224 | | // |
225 | | // SPDX-FileCopyrightText: 2013-2026 Niels Lohmann <https://nlohmann.me> |
226 | | // SPDX-License-Identifier: MIT |
227 | | |
228 | | |
229 | | |
230 | | #include <utility> // declval, pair |
231 | | // #include <nlohmann/detail/meta/detected.hpp> |
232 | | // __ _____ _____ _____ |
233 | | // __| | __| | | | JSON for Modern C++ |
234 | | // | | |__ | | | | | | version 3.12.0 |
235 | | // |_____|_____|_____|_|___| https://github.com/nlohmann/json |
236 | | // |
237 | | // SPDX-FileCopyrightText: 2013-2026 Niels Lohmann <https://nlohmann.me> |
238 | | // SPDX-License-Identifier: MIT |
239 | | |
240 | | |
241 | | |
242 | | #include <type_traits> |
243 | | |
244 | | // #include <nlohmann/detail/meta/void_t.hpp> |
245 | | // __ _____ _____ _____ |
246 | | // __| | __| | | | JSON for Modern C++ |
247 | | // | | |__ | | | | | | version 3.12.0 |
248 | | // |_____|_____|_____|_|___| https://github.com/nlohmann/json |
249 | | // |
250 | | // SPDX-FileCopyrightText: 2013-2026 Niels Lohmann <https://nlohmann.me> |
251 | | // SPDX-License-Identifier: MIT |
252 | | |
253 | | |
254 | | |
255 | | // #include <nlohmann/detail/abi_macros.hpp> |
256 | | |
257 | | |
258 | | NLOHMANN_JSON_NAMESPACE_BEGIN |
259 | | namespace detail |
260 | | { |
261 | | |
262 | | template<typename ...Ts> struct make_void |
263 | | { |
264 | | using type = void; |
265 | | }; |
266 | | template<typename ...Ts> using void_t = typename make_void<Ts...>::type; |
267 | | |
268 | | } // namespace detail |
269 | | NLOHMANN_JSON_NAMESPACE_END |
270 | | |
271 | | |
272 | | NLOHMANN_JSON_NAMESPACE_BEGIN |
273 | | namespace detail |
274 | | { |
275 | | |
276 | | // https://en.cppreference.com/w/cpp/experimental/is_detected |
277 | | struct nonesuch |
278 | | { |
279 | | nonesuch() = delete; |
280 | | ~nonesuch() = delete; |
281 | | nonesuch(nonesuch const&) = delete; |
282 | | nonesuch(nonesuch const&&) = delete; |
283 | | void operator=(nonesuch const&) = delete; |
284 | | void operator=(nonesuch&&) = delete; |
285 | | }; |
286 | | |
287 | | template<class Default, |
288 | | class AlwaysVoid, |
289 | | template<class...> class Op, |
290 | | class... Args> |
291 | | struct detector |
292 | | { |
293 | | using value_t = std::false_type; |
294 | | using type = Default; |
295 | | }; |
296 | | |
297 | | template<class Default, template<class...> class Op, class... Args> |
298 | | struct detector<Default, void_t<Op<Args...>>, Op, Args...> |
299 | | { |
300 | | using value_t = std::true_type; |
301 | | using type = Op<Args...>; |
302 | | }; |
303 | | |
304 | | template<template<class...> class Op, class... Args> |
305 | | using is_detected = typename detector<nonesuch, void, Op, Args...>::value_t; |
306 | | |
307 | | template<template<class...> class Op, class... Args> |
308 | | struct is_detected_lazy : is_detected<Op, Args...> { }; |
309 | | |
310 | | template<template<class...> class Op, class... Args> |
311 | | using detected_t = typename detector<nonesuch, void, Op, Args...>::type; |
312 | | |
313 | | template<class Default, template<class...> class Op, class... Args> |
314 | | using detected_or = detector<Default, void, Op, Args...>; |
315 | | |
316 | | template<class Default, template<class...> class Op, class... Args> |
317 | | using detected_or_t = typename detected_or<Default, Op, Args...>::type; |
318 | | |
319 | | template<class Expected, template<class...> class Op, class... Args> |
320 | | using is_detected_exact = std::is_same<Expected, detected_t<Op, Args...>>; |
321 | | |
322 | | template<class To, template<class...> class Op, class... Args> |
323 | | using is_detected_convertible = |
324 | | std::is_convertible<detected_t<Op, Args...>, To>; |
325 | | |
326 | | } // namespace detail |
327 | | NLOHMANN_JSON_NAMESPACE_END |
328 | | |
329 | | // #include <nlohmann/thirdparty/hedley/hedley.hpp> |
330 | | |
331 | | |
332 | | // __ _____ _____ _____ |
333 | | // __| | __| | | | JSON for Modern C++ |
334 | | // | | |__ | | | | | | version 3.12.0 |
335 | | // |_____|_____|_____|_|___| https://github.com/nlohmann/json |
336 | | // |
337 | | // SPDX-FileCopyrightText: 2013-2026 Niels Lohmann <https://nlohmann.me> |
338 | | // SPDX-FileCopyrightText: 2016-2021 Evan Nemerson <evan@nemerson.com> |
339 | | // SPDX-License-Identifier: MIT |
340 | | |
341 | | /* Hedley - https://nemequ.github.io/hedley |
342 | | * Created by Evan Nemerson <evan@nemerson.com> |
343 | | * SPDX-License-Identifier: CC0-1.0 |
344 | | */ |
345 | | |
346 | | #if !defined(JSON_HEDLEY_VERSION) || (JSON_HEDLEY_VERSION < 15) |
347 | | #if defined(JSON_HEDLEY_VERSION) |
348 | | #undef JSON_HEDLEY_VERSION |
349 | | #endif |
350 | | #define JSON_HEDLEY_VERSION 15 |
351 | | |
352 | | #if defined(JSON_HEDLEY_STRINGIFY_EX) |
353 | | #undef JSON_HEDLEY_STRINGIFY_EX |
354 | | #endif |
355 | | #define JSON_HEDLEY_STRINGIFY_EX(x) #x |
356 | | |
357 | | #if defined(JSON_HEDLEY_STRINGIFY) |
358 | | #undef JSON_HEDLEY_STRINGIFY |
359 | | #endif |
360 | | #define JSON_HEDLEY_STRINGIFY(x) JSON_HEDLEY_STRINGIFY_EX(x) |
361 | | |
362 | | #if defined(JSON_HEDLEY_CONCAT_EX) |
363 | | #undef JSON_HEDLEY_CONCAT_EX |
364 | | #endif |
365 | | #define JSON_HEDLEY_CONCAT_EX(a,b) a##b |
366 | | |
367 | | #if defined(JSON_HEDLEY_CONCAT) |
368 | | #undef JSON_HEDLEY_CONCAT |
369 | | #endif |
370 | | #define JSON_HEDLEY_CONCAT(a,b) JSON_HEDLEY_CONCAT_EX(a,b) |
371 | | |
372 | | #if defined(JSON_HEDLEY_CONCAT3_EX) |
373 | | #undef JSON_HEDLEY_CONCAT3_EX |
374 | | #endif |
375 | | #define JSON_HEDLEY_CONCAT3_EX(a,b,c) a##b##c |
376 | | |
377 | | #if defined(JSON_HEDLEY_CONCAT3) |
378 | | #undef JSON_HEDLEY_CONCAT3 |
379 | | #endif |
380 | | #define JSON_HEDLEY_CONCAT3(a,b,c) JSON_HEDLEY_CONCAT3_EX(a,b,c) |
381 | | |
382 | | #if defined(JSON_HEDLEY_VERSION_ENCODE) |
383 | | #undef JSON_HEDLEY_VERSION_ENCODE |
384 | | #endif |
385 | | #define JSON_HEDLEY_VERSION_ENCODE(major,minor,revision) (((major) * 1000000) + ((minor) * 1000) + (revision)) |
386 | | |
387 | | #if defined(JSON_HEDLEY_VERSION_DECODE_MAJOR) |
388 | | #undef JSON_HEDLEY_VERSION_DECODE_MAJOR |
389 | | #endif |
390 | | #define JSON_HEDLEY_VERSION_DECODE_MAJOR(version) ((version) / 1000000) |
391 | | |
392 | | #if defined(JSON_HEDLEY_VERSION_DECODE_MINOR) |
393 | | #undef JSON_HEDLEY_VERSION_DECODE_MINOR |
394 | | #endif |
395 | | #define JSON_HEDLEY_VERSION_DECODE_MINOR(version) (((version) % 1000000) / 1000) |
396 | | |
397 | | #if defined(JSON_HEDLEY_VERSION_DECODE_REVISION) |
398 | | #undef JSON_HEDLEY_VERSION_DECODE_REVISION |
399 | | #endif |
400 | | #define JSON_HEDLEY_VERSION_DECODE_REVISION(version) ((version) % 1000) |
401 | | |
402 | | #if defined(JSON_HEDLEY_GNUC_VERSION) |
403 | | #undef JSON_HEDLEY_GNUC_VERSION |
404 | | #endif |
405 | | #if defined(__GNUC__) && defined(__GNUC_PATCHLEVEL__) |
406 | | #define JSON_HEDLEY_GNUC_VERSION JSON_HEDLEY_VERSION_ENCODE(__GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__) |
407 | | #elif defined(__GNUC__) |
408 | | #define JSON_HEDLEY_GNUC_VERSION JSON_HEDLEY_VERSION_ENCODE(__GNUC__, __GNUC_MINOR__, 0) |
409 | | #endif |
410 | | |
411 | | #if defined(JSON_HEDLEY_GNUC_VERSION_CHECK) |
412 | | #undef JSON_HEDLEY_GNUC_VERSION_CHECK |
413 | | #endif |
414 | | #if defined(JSON_HEDLEY_GNUC_VERSION) |
415 | | #define JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_GNUC_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) |
416 | | #else |
417 | | #define JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) (0) |
418 | | #endif |
419 | | |
420 | | #if defined(JSON_HEDLEY_MSVC_VERSION) |
421 | | #undef JSON_HEDLEY_MSVC_VERSION |
422 | | #endif |
423 | | #if defined(_MSC_FULL_VER) && (_MSC_FULL_VER >= 140000000) && !defined(__ICL) |
424 | | #define JSON_HEDLEY_MSVC_VERSION JSON_HEDLEY_VERSION_ENCODE(_MSC_FULL_VER / 10000000, (_MSC_FULL_VER % 10000000) / 100000, (_MSC_FULL_VER % 100000) / 100) |
425 | | #elif defined(_MSC_FULL_VER) && !defined(__ICL) |
426 | | #define JSON_HEDLEY_MSVC_VERSION JSON_HEDLEY_VERSION_ENCODE(_MSC_FULL_VER / 1000000, (_MSC_FULL_VER % 1000000) / 10000, (_MSC_FULL_VER % 10000) / 10) |
427 | | #elif defined(_MSC_VER) && !defined(__ICL) |
428 | | #define JSON_HEDLEY_MSVC_VERSION JSON_HEDLEY_VERSION_ENCODE(_MSC_VER / 100, _MSC_VER % 100, 0) |
429 | | #endif |
430 | | |
431 | | #if defined(JSON_HEDLEY_MSVC_VERSION_CHECK) |
432 | | #undef JSON_HEDLEY_MSVC_VERSION_CHECK |
433 | | #endif |
434 | | #if !defined(JSON_HEDLEY_MSVC_VERSION) |
435 | | #define JSON_HEDLEY_MSVC_VERSION_CHECK(major,minor,patch) (0) |
436 | | #elif defined(_MSC_VER) && (_MSC_VER >= 1400) |
437 | | #define JSON_HEDLEY_MSVC_VERSION_CHECK(major,minor,patch) (_MSC_FULL_VER >= ((major * 10000000) + (minor * 100000) + (patch))) |
438 | | #elif defined(_MSC_VER) && (_MSC_VER >= 1200) |
439 | | #define JSON_HEDLEY_MSVC_VERSION_CHECK(major,minor,patch) (_MSC_FULL_VER >= ((major * 1000000) + (minor * 10000) + (patch))) |
440 | | #else |
441 | | #define JSON_HEDLEY_MSVC_VERSION_CHECK(major,minor,patch) (_MSC_VER >= ((major * 100) + (minor))) |
442 | | #endif |
443 | | |
444 | | #if defined(JSON_HEDLEY_INTEL_VERSION) |
445 | | #undef JSON_HEDLEY_INTEL_VERSION |
446 | | #endif |
447 | | #if defined(__INTEL_COMPILER) && defined(__INTEL_COMPILER_UPDATE) && !defined(__ICL) |
448 | | #define JSON_HEDLEY_INTEL_VERSION JSON_HEDLEY_VERSION_ENCODE(__INTEL_COMPILER / 100, __INTEL_COMPILER % 100, __INTEL_COMPILER_UPDATE) |
449 | | #elif defined(__INTEL_COMPILER) && !defined(__ICL) |
450 | | #define JSON_HEDLEY_INTEL_VERSION JSON_HEDLEY_VERSION_ENCODE(__INTEL_COMPILER / 100, __INTEL_COMPILER % 100, 0) |
451 | | #endif |
452 | | |
453 | | #if defined(JSON_HEDLEY_INTEL_VERSION_CHECK) |
454 | | #undef JSON_HEDLEY_INTEL_VERSION_CHECK |
455 | | #endif |
456 | | #if defined(JSON_HEDLEY_INTEL_VERSION) |
457 | | #define JSON_HEDLEY_INTEL_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_INTEL_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) |
458 | | #else |
459 | | #define JSON_HEDLEY_INTEL_VERSION_CHECK(major,minor,patch) (0) |
460 | | #endif |
461 | | |
462 | | #if defined(JSON_HEDLEY_INTEL_CL_VERSION) |
463 | | #undef JSON_HEDLEY_INTEL_CL_VERSION |
464 | | #endif |
465 | | #if defined(__INTEL_COMPILER) && defined(__INTEL_COMPILER_UPDATE) && defined(__ICL) |
466 | | #define JSON_HEDLEY_INTEL_CL_VERSION JSON_HEDLEY_VERSION_ENCODE(__INTEL_COMPILER, __INTEL_COMPILER_UPDATE, 0) |
467 | | #endif |
468 | | |
469 | | #if defined(JSON_HEDLEY_INTEL_CL_VERSION_CHECK) |
470 | | #undef JSON_HEDLEY_INTEL_CL_VERSION_CHECK |
471 | | #endif |
472 | | #if defined(JSON_HEDLEY_INTEL_CL_VERSION) |
473 | | #define JSON_HEDLEY_INTEL_CL_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_INTEL_CL_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) |
474 | | #else |
475 | | #define JSON_HEDLEY_INTEL_CL_VERSION_CHECK(major,minor,patch) (0) |
476 | | #endif |
477 | | |
478 | | #if defined(JSON_HEDLEY_PGI_VERSION) |
479 | | #undef JSON_HEDLEY_PGI_VERSION |
480 | | #endif |
481 | | #if defined(__PGI) && defined(__PGIC__) && defined(__PGIC_MINOR__) && defined(__PGIC_PATCHLEVEL__) |
482 | | #define JSON_HEDLEY_PGI_VERSION JSON_HEDLEY_VERSION_ENCODE(__PGIC__, __PGIC_MINOR__, __PGIC_PATCHLEVEL__) |
483 | | #endif |
484 | | |
485 | | #if defined(JSON_HEDLEY_PGI_VERSION_CHECK) |
486 | | #undef JSON_HEDLEY_PGI_VERSION_CHECK |
487 | | #endif |
488 | | #if defined(JSON_HEDLEY_PGI_VERSION) |
489 | | #define JSON_HEDLEY_PGI_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_PGI_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) |
490 | | #else |
491 | | #define JSON_HEDLEY_PGI_VERSION_CHECK(major,minor,patch) (0) |
492 | | #endif |
493 | | |
494 | | #if defined(JSON_HEDLEY_SUNPRO_VERSION) |
495 | | #undef JSON_HEDLEY_SUNPRO_VERSION |
496 | | #endif |
497 | | #if defined(__SUNPRO_C) && (__SUNPRO_C > 0x1000) |
498 | | #define JSON_HEDLEY_SUNPRO_VERSION JSON_HEDLEY_VERSION_ENCODE((((__SUNPRO_C >> 16) & 0xf) * 10) + ((__SUNPRO_C >> 12) & 0xf), (((__SUNPRO_C >> 8) & 0xf) * 10) + ((__SUNPRO_C >> 4) & 0xf), (__SUNPRO_C & 0xf) * 10) |
499 | | #elif defined(__SUNPRO_C) |
500 | | #define JSON_HEDLEY_SUNPRO_VERSION JSON_HEDLEY_VERSION_ENCODE((__SUNPRO_C >> 8) & 0xf, (__SUNPRO_C >> 4) & 0xf, (__SUNPRO_C) & 0xf) |
501 | | #elif defined(__SUNPRO_CC) && (__SUNPRO_CC > 0x1000) |
502 | | #define JSON_HEDLEY_SUNPRO_VERSION JSON_HEDLEY_VERSION_ENCODE((((__SUNPRO_CC >> 16) & 0xf) * 10) + ((__SUNPRO_CC >> 12) & 0xf), (((__SUNPRO_CC >> 8) & 0xf) * 10) + ((__SUNPRO_CC >> 4) & 0xf), (__SUNPRO_CC & 0xf) * 10) |
503 | | #elif defined(__SUNPRO_CC) |
504 | | #define JSON_HEDLEY_SUNPRO_VERSION JSON_HEDLEY_VERSION_ENCODE((__SUNPRO_CC >> 8) & 0xf, (__SUNPRO_CC >> 4) & 0xf, (__SUNPRO_CC) & 0xf) |
505 | | #endif |
506 | | |
507 | | #if defined(JSON_HEDLEY_SUNPRO_VERSION_CHECK) |
508 | | #undef JSON_HEDLEY_SUNPRO_VERSION_CHECK |
509 | | #endif |
510 | | #if defined(JSON_HEDLEY_SUNPRO_VERSION) |
511 | | #define JSON_HEDLEY_SUNPRO_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_SUNPRO_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) |
512 | | #else |
513 | | #define JSON_HEDLEY_SUNPRO_VERSION_CHECK(major,minor,patch) (0) |
514 | | #endif |
515 | | |
516 | | #if defined(JSON_HEDLEY_EMSCRIPTEN_VERSION) |
517 | | #undef JSON_HEDLEY_EMSCRIPTEN_VERSION |
518 | | #endif |
519 | | #if defined(__EMSCRIPTEN__) |
520 | | #define JSON_HEDLEY_EMSCRIPTEN_VERSION JSON_HEDLEY_VERSION_ENCODE(__EMSCRIPTEN_major__, __EMSCRIPTEN_minor__, __EMSCRIPTEN_tiny__) |
521 | | #endif |
522 | | |
523 | | #if defined(JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK) |
524 | | #undef JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK |
525 | | #endif |
526 | | #if defined(JSON_HEDLEY_EMSCRIPTEN_VERSION) |
527 | | #define JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_EMSCRIPTEN_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) |
528 | | #else |
529 | | #define JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK(major,minor,patch) (0) |
530 | | #endif |
531 | | |
532 | | #if defined(JSON_HEDLEY_ARM_VERSION) |
533 | | #undef JSON_HEDLEY_ARM_VERSION |
534 | | #endif |
535 | | #if defined(__CC_ARM) && defined(__ARMCOMPILER_VERSION) |
536 | | #define JSON_HEDLEY_ARM_VERSION JSON_HEDLEY_VERSION_ENCODE(__ARMCOMPILER_VERSION / 1000000, (__ARMCOMPILER_VERSION % 1000000) / 10000, (__ARMCOMPILER_VERSION % 10000) / 100) |
537 | | #elif defined(__CC_ARM) && defined(__ARMCC_VERSION) |
538 | | #define JSON_HEDLEY_ARM_VERSION JSON_HEDLEY_VERSION_ENCODE(__ARMCC_VERSION / 1000000, (__ARMCC_VERSION % 1000000) / 10000, (__ARMCC_VERSION % 10000) / 100) |
539 | | #endif |
540 | | |
541 | | #if defined(JSON_HEDLEY_ARM_VERSION_CHECK) |
542 | | #undef JSON_HEDLEY_ARM_VERSION_CHECK |
543 | | #endif |
544 | | #if defined(JSON_HEDLEY_ARM_VERSION) |
545 | | #define JSON_HEDLEY_ARM_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_ARM_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) |
546 | | #else |
547 | | #define JSON_HEDLEY_ARM_VERSION_CHECK(major,minor,patch) (0) |
548 | | #endif |
549 | | |
550 | | #if defined(JSON_HEDLEY_IBM_VERSION) |
551 | | #undef JSON_HEDLEY_IBM_VERSION |
552 | | #endif |
553 | | #if defined(__ibmxl__) |
554 | | #define JSON_HEDLEY_IBM_VERSION JSON_HEDLEY_VERSION_ENCODE(__ibmxl_version__, __ibmxl_release__, __ibmxl_modification__) |
555 | | #elif defined(__xlC__) && defined(__xlC_ver__) |
556 | | #define JSON_HEDLEY_IBM_VERSION JSON_HEDLEY_VERSION_ENCODE(__xlC__ >> 8, __xlC__ & 0xff, (__xlC_ver__ >> 8) & 0xff) |
557 | | #elif defined(__xlC__) |
558 | | #define JSON_HEDLEY_IBM_VERSION JSON_HEDLEY_VERSION_ENCODE(__xlC__ >> 8, __xlC__ & 0xff, 0) |
559 | | #endif |
560 | | |
561 | | #if defined(JSON_HEDLEY_IBM_VERSION_CHECK) |
562 | | #undef JSON_HEDLEY_IBM_VERSION_CHECK |
563 | | #endif |
564 | | #if defined(JSON_HEDLEY_IBM_VERSION) |
565 | | #define JSON_HEDLEY_IBM_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_IBM_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) |
566 | | #else |
567 | | #define JSON_HEDLEY_IBM_VERSION_CHECK(major,minor,patch) (0) |
568 | | #endif |
569 | | |
570 | | #if defined(JSON_HEDLEY_TI_VERSION) |
571 | | #undef JSON_HEDLEY_TI_VERSION |
572 | | #endif |
573 | | #if \ |
574 | | defined(__TI_COMPILER_VERSION__) && \ |
575 | | ( \ |
576 | | defined(__TMS470__) || defined(__TI_ARM__) || \ |
577 | | defined(__MSP430__) || \ |
578 | | defined(__TMS320C2000__) \ |
579 | | ) |
580 | | #if (__TI_COMPILER_VERSION__ >= 16000000) |
581 | | #define JSON_HEDLEY_TI_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000)) |
582 | | #endif |
583 | | #endif |
584 | | |
585 | | #if defined(JSON_HEDLEY_TI_VERSION_CHECK) |
586 | | #undef JSON_HEDLEY_TI_VERSION_CHECK |
587 | | #endif |
588 | | #if defined(JSON_HEDLEY_TI_VERSION) |
589 | | #define JSON_HEDLEY_TI_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) |
590 | | #else |
591 | | #define JSON_HEDLEY_TI_VERSION_CHECK(major,minor,patch) (0) |
592 | | #endif |
593 | | |
594 | | #if defined(JSON_HEDLEY_TI_CL2000_VERSION) |
595 | | #undef JSON_HEDLEY_TI_CL2000_VERSION |
596 | | #endif |
597 | | #if defined(__TI_COMPILER_VERSION__) && defined(__TMS320C2000__) |
598 | | #define JSON_HEDLEY_TI_CL2000_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000)) |
599 | | #endif |
600 | | |
601 | | #if defined(JSON_HEDLEY_TI_CL2000_VERSION_CHECK) |
602 | | #undef JSON_HEDLEY_TI_CL2000_VERSION_CHECK |
603 | | #endif |
604 | | #if defined(JSON_HEDLEY_TI_CL2000_VERSION) |
605 | | #define JSON_HEDLEY_TI_CL2000_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_CL2000_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) |
606 | | #else |
607 | | #define JSON_HEDLEY_TI_CL2000_VERSION_CHECK(major,minor,patch) (0) |
608 | | #endif |
609 | | |
610 | | #if defined(JSON_HEDLEY_TI_CL430_VERSION) |
611 | | #undef JSON_HEDLEY_TI_CL430_VERSION |
612 | | #endif |
613 | | #if defined(__TI_COMPILER_VERSION__) && defined(__MSP430__) |
614 | | #define JSON_HEDLEY_TI_CL430_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000)) |
615 | | #endif |
616 | | |
617 | | #if defined(JSON_HEDLEY_TI_CL430_VERSION_CHECK) |
618 | | #undef JSON_HEDLEY_TI_CL430_VERSION_CHECK |
619 | | #endif |
620 | | #if defined(JSON_HEDLEY_TI_CL430_VERSION) |
621 | | #define JSON_HEDLEY_TI_CL430_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_CL430_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) |
622 | | #else |
623 | | #define JSON_HEDLEY_TI_CL430_VERSION_CHECK(major,minor,patch) (0) |
624 | | #endif |
625 | | |
626 | | #if defined(JSON_HEDLEY_TI_ARMCL_VERSION) |
627 | | #undef JSON_HEDLEY_TI_ARMCL_VERSION |
628 | | #endif |
629 | | #if defined(__TI_COMPILER_VERSION__) && (defined(__TMS470__) || defined(__TI_ARM__)) |
630 | | #define JSON_HEDLEY_TI_ARMCL_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000)) |
631 | | #endif |
632 | | |
633 | | #if defined(JSON_HEDLEY_TI_ARMCL_VERSION_CHECK) |
634 | | #undef JSON_HEDLEY_TI_ARMCL_VERSION_CHECK |
635 | | #endif |
636 | | #if defined(JSON_HEDLEY_TI_ARMCL_VERSION) |
637 | | #define JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_ARMCL_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) |
638 | | #else |
639 | | #define JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(major,minor,patch) (0) |
640 | | #endif |
641 | | |
642 | | #if defined(JSON_HEDLEY_TI_CL6X_VERSION) |
643 | | #undef JSON_HEDLEY_TI_CL6X_VERSION |
644 | | #endif |
645 | | #if defined(__TI_COMPILER_VERSION__) && defined(__TMS320C6X__) |
646 | | #define JSON_HEDLEY_TI_CL6X_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000)) |
647 | | #endif |
648 | | |
649 | | #if defined(JSON_HEDLEY_TI_CL6X_VERSION_CHECK) |
650 | | #undef JSON_HEDLEY_TI_CL6X_VERSION_CHECK |
651 | | #endif |
652 | | #if defined(JSON_HEDLEY_TI_CL6X_VERSION) |
653 | | #define JSON_HEDLEY_TI_CL6X_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_CL6X_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) |
654 | | #else |
655 | | #define JSON_HEDLEY_TI_CL6X_VERSION_CHECK(major,minor,patch) (0) |
656 | | #endif |
657 | | |
658 | | #if defined(JSON_HEDLEY_TI_CL7X_VERSION) |
659 | | #undef JSON_HEDLEY_TI_CL7X_VERSION |
660 | | #endif |
661 | | #if defined(__TI_COMPILER_VERSION__) && defined(__C7000__) |
662 | | #define JSON_HEDLEY_TI_CL7X_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000)) |
663 | | #endif |
664 | | |
665 | | #if defined(JSON_HEDLEY_TI_CL7X_VERSION_CHECK) |
666 | | #undef JSON_HEDLEY_TI_CL7X_VERSION_CHECK |
667 | | #endif |
668 | | #if defined(JSON_HEDLEY_TI_CL7X_VERSION) |
669 | | #define JSON_HEDLEY_TI_CL7X_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_CL7X_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) |
670 | | #else |
671 | | #define JSON_HEDLEY_TI_CL7X_VERSION_CHECK(major,minor,patch) (0) |
672 | | #endif |
673 | | |
674 | | #if defined(JSON_HEDLEY_TI_CLPRU_VERSION) |
675 | | #undef JSON_HEDLEY_TI_CLPRU_VERSION |
676 | | #endif |
677 | | #if defined(__TI_COMPILER_VERSION__) && defined(__PRU__) |
678 | | #define JSON_HEDLEY_TI_CLPRU_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000)) |
679 | | #endif |
680 | | |
681 | | #if defined(JSON_HEDLEY_TI_CLPRU_VERSION_CHECK) |
682 | | #undef JSON_HEDLEY_TI_CLPRU_VERSION_CHECK |
683 | | #endif |
684 | | #if defined(JSON_HEDLEY_TI_CLPRU_VERSION) |
685 | | #define JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_CLPRU_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) |
686 | | #else |
687 | | #define JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(major,minor,patch) (0) |
688 | | #endif |
689 | | |
690 | | #if defined(JSON_HEDLEY_CRAY_VERSION) |
691 | | #undef JSON_HEDLEY_CRAY_VERSION |
692 | | #endif |
693 | | #if defined(_CRAYC) |
694 | | #if defined(_RELEASE_PATCHLEVEL) |
695 | | #define JSON_HEDLEY_CRAY_VERSION JSON_HEDLEY_VERSION_ENCODE(_RELEASE_MAJOR, _RELEASE_MINOR, _RELEASE_PATCHLEVEL) |
696 | | #else |
697 | | #define JSON_HEDLEY_CRAY_VERSION JSON_HEDLEY_VERSION_ENCODE(_RELEASE_MAJOR, _RELEASE_MINOR, 0) |
698 | | #endif |
699 | | #endif |
700 | | |
701 | | #if defined(JSON_HEDLEY_CRAY_VERSION_CHECK) |
702 | | #undef JSON_HEDLEY_CRAY_VERSION_CHECK |
703 | | #endif |
704 | | #if defined(JSON_HEDLEY_CRAY_VERSION) |
705 | | #define JSON_HEDLEY_CRAY_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_CRAY_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) |
706 | | #else |
707 | | #define JSON_HEDLEY_CRAY_VERSION_CHECK(major,minor,patch) (0) |
708 | | #endif |
709 | | |
710 | | #if defined(JSON_HEDLEY_IAR_VERSION) |
711 | | #undef JSON_HEDLEY_IAR_VERSION |
712 | | #endif |
713 | | #if defined(__IAR_SYSTEMS_ICC__) |
714 | | #if __VER__ > 1000 |
715 | | #define JSON_HEDLEY_IAR_VERSION JSON_HEDLEY_VERSION_ENCODE((__VER__ / 1000000), ((__VER__ / 1000) % 1000), (__VER__ % 1000)) |
716 | | #else |
717 | | #define JSON_HEDLEY_IAR_VERSION JSON_HEDLEY_VERSION_ENCODE(__VER__ / 100, __VER__ % 100, 0) |
718 | | #endif |
719 | | #endif |
720 | | |
721 | | #if defined(JSON_HEDLEY_IAR_VERSION_CHECK) |
722 | | #undef JSON_HEDLEY_IAR_VERSION_CHECK |
723 | | #endif |
724 | | #if defined(JSON_HEDLEY_IAR_VERSION) |
725 | | #define JSON_HEDLEY_IAR_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_IAR_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) |
726 | | #else |
727 | | #define JSON_HEDLEY_IAR_VERSION_CHECK(major,minor,patch) (0) |
728 | | #endif |
729 | | |
730 | | #if defined(JSON_HEDLEY_TINYC_VERSION) |
731 | | #undef JSON_HEDLEY_TINYC_VERSION |
732 | | #endif |
733 | | #if defined(__TINYC__) |
734 | | #define JSON_HEDLEY_TINYC_VERSION JSON_HEDLEY_VERSION_ENCODE(__TINYC__ / 1000, (__TINYC__ / 100) % 10, __TINYC__ % 100) |
735 | | #endif |
736 | | |
737 | | #if defined(JSON_HEDLEY_TINYC_VERSION_CHECK) |
738 | | #undef JSON_HEDLEY_TINYC_VERSION_CHECK |
739 | | #endif |
740 | | #if defined(JSON_HEDLEY_TINYC_VERSION) |
741 | | #define JSON_HEDLEY_TINYC_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TINYC_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) |
742 | | #else |
743 | | #define JSON_HEDLEY_TINYC_VERSION_CHECK(major,minor,patch) (0) |
744 | | #endif |
745 | | |
746 | | #if defined(JSON_HEDLEY_DMC_VERSION) |
747 | | #undef JSON_HEDLEY_DMC_VERSION |
748 | | #endif |
749 | | #if defined(__DMC__) |
750 | | #define JSON_HEDLEY_DMC_VERSION JSON_HEDLEY_VERSION_ENCODE(__DMC__ >> 8, (__DMC__ >> 4) & 0xf, __DMC__ & 0xf) |
751 | | #endif |
752 | | |
753 | | #if defined(JSON_HEDLEY_DMC_VERSION_CHECK) |
754 | | #undef JSON_HEDLEY_DMC_VERSION_CHECK |
755 | | #endif |
756 | | #if defined(JSON_HEDLEY_DMC_VERSION) |
757 | | #define JSON_HEDLEY_DMC_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_DMC_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) |
758 | | #else |
759 | | #define JSON_HEDLEY_DMC_VERSION_CHECK(major,minor,patch) (0) |
760 | | #endif |
761 | | |
762 | | #if defined(JSON_HEDLEY_COMPCERT_VERSION) |
763 | | #undef JSON_HEDLEY_COMPCERT_VERSION |
764 | | #endif |
765 | | #if defined(__COMPCERT_VERSION__) |
766 | | #define JSON_HEDLEY_COMPCERT_VERSION JSON_HEDLEY_VERSION_ENCODE(__COMPCERT_VERSION__ / 10000, (__COMPCERT_VERSION__ / 100) % 100, __COMPCERT_VERSION__ % 100) |
767 | | #endif |
768 | | |
769 | | #if defined(JSON_HEDLEY_COMPCERT_VERSION_CHECK) |
770 | | #undef JSON_HEDLEY_COMPCERT_VERSION_CHECK |
771 | | #endif |
772 | | #if defined(JSON_HEDLEY_COMPCERT_VERSION) |
773 | | #define JSON_HEDLEY_COMPCERT_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_COMPCERT_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) |
774 | | #else |
775 | | #define JSON_HEDLEY_COMPCERT_VERSION_CHECK(major,minor,patch) (0) |
776 | | #endif |
777 | | |
778 | | #if defined(JSON_HEDLEY_PELLES_VERSION) |
779 | | #undef JSON_HEDLEY_PELLES_VERSION |
780 | | #endif |
781 | | #if defined(__POCC__) |
782 | | #define JSON_HEDLEY_PELLES_VERSION JSON_HEDLEY_VERSION_ENCODE(__POCC__ / 100, __POCC__ % 100, 0) |
783 | | #endif |
784 | | |
785 | | #if defined(JSON_HEDLEY_PELLES_VERSION_CHECK) |
786 | | #undef JSON_HEDLEY_PELLES_VERSION_CHECK |
787 | | #endif |
788 | | #if defined(JSON_HEDLEY_PELLES_VERSION) |
789 | | #define JSON_HEDLEY_PELLES_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_PELLES_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) |
790 | | #else |
791 | | #define JSON_HEDLEY_PELLES_VERSION_CHECK(major,minor,patch) (0) |
792 | | #endif |
793 | | |
794 | | #if defined(JSON_HEDLEY_MCST_LCC_VERSION) |
795 | | #undef JSON_HEDLEY_MCST_LCC_VERSION |
796 | | #endif |
797 | | #if defined(__LCC__) && defined(__LCC_MINOR__) |
798 | | #define JSON_HEDLEY_MCST_LCC_VERSION JSON_HEDLEY_VERSION_ENCODE(__LCC__ / 100, __LCC__ % 100, __LCC_MINOR__) |
799 | | #endif |
800 | | |
801 | | #if defined(JSON_HEDLEY_MCST_LCC_VERSION_CHECK) |
802 | | #undef JSON_HEDLEY_MCST_LCC_VERSION_CHECK |
803 | | #endif |
804 | | #if defined(JSON_HEDLEY_MCST_LCC_VERSION) |
805 | | #define JSON_HEDLEY_MCST_LCC_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_MCST_LCC_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) |
806 | | #else |
807 | | #define JSON_HEDLEY_MCST_LCC_VERSION_CHECK(major,minor,patch) (0) |
808 | | #endif |
809 | | |
810 | | #if defined(JSON_HEDLEY_GCC_VERSION) |
811 | | #undef JSON_HEDLEY_GCC_VERSION |
812 | | #endif |
813 | | #if \ |
814 | | defined(JSON_HEDLEY_GNUC_VERSION) && \ |
815 | | !defined(__clang__) && \ |
816 | | !defined(JSON_HEDLEY_INTEL_VERSION) && \ |
817 | | !defined(JSON_HEDLEY_PGI_VERSION) && \ |
818 | | !defined(JSON_HEDLEY_ARM_VERSION) && \ |
819 | | !defined(JSON_HEDLEY_CRAY_VERSION) && \ |
820 | | !defined(JSON_HEDLEY_TI_VERSION) && \ |
821 | | !defined(JSON_HEDLEY_TI_ARMCL_VERSION) && \ |
822 | | !defined(JSON_HEDLEY_TI_CL430_VERSION) && \ |
823 | | !defined(JSON_HEDLEY_TI_CL2000_VERSION) && \ |
824 | | !defined(JSON_HEDLEY_TI_CL6X_VERSION) && \ |
825 | | !defined(JSON_HEDLEY_TI_CL7X_VERSION) && \ |
826 | | !defined(JSON_HEDLEY_TI_CLPRU_VERSION) && \ |
827 | | !defined(__COMPCERT__) && \ |
828 | | !defined(JSON_HEDLEY_MCST_LCC_VERSION) |
829 | | #define JSON_HEDLEY_GCC_VERSION JSON_HEDLEY_GNUC_VERSION |
830 | | #endif |
831 | | |
832 | | #if defined(JSON_HEDLEY_GCC_VERSION_CHECK) |
833 | | #undef JSON_HEDLEY_GCC_VERSION_CHECK |
834 | | #endif |
835 | | #if defined(JSON_HEDLEY_GCC_VERSION) |
836 | | #define JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_GCC_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) |
837 | | #else |
838 | | #define JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) (0) |
839 | | #endif |
840 | | |
841 | | #if defined(JSON_HEDLEY_HAS_ATTRIBUTE) |
842 | | #undef JSON_HEDLEY_HAS_ATTRIBUTE |
843 | | #endif |
844 | | #if \ |
845 | | defined(__has_attribute) && \ |
846 | | ( \ |
847 | | (!defined(JSON_HEDLEY_IAR_VERSION) || JSON_HEDLEY_IAR_VERSION_CHECK(8,5,9)) \ |
848 | | ) |
849 | | # define JSON_HEDLEY_HAS_ATTRIBUTE(attribute) __has_attribute(attribute) |
850 | | #else |
851 | | # define JSON_HEDLEY_HAS_ATTRIBUTE(attribute) (0) |
852 | | #endif |
853 | | |
854 | | #if defined(JSON_HEDLEY_GNUC_HAS_ATTRIBUTE) |
855 | | #undef JSON_HEDLEY_GNUC_HAS_ATTRIBUTE |
856 | | #endif |
857 | | #if defined(__has_attribute) |
858 | | #define JSON_HEDLEY_GNUC_HAS_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_HAS_ATTRIBUTE(attribute) |
859 | | #else |
860 | | #define JSON_HEDLEY_GNUC_HAS_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) |
861 | | #endif |
862 | | |
863 | | #if defined(JSON_HEDLEY_GCC_HAS_ATTRIBUTE) |
864 | | #undef JSON_HEDLEY_GCC_HAS_ATTRIBUTE |
865 | | #endif |
866 | | #if defined(__has_attribute) |
867 | | #define JSON_HEDLEY_GCC_HAS_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_HAS_ATTRIBUTE(attribute) |
868 | | #else |
869 | | #define JSON_HEDLEY_GCC_HAS_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) |
870 | | #endif |
871 | | |
872 | | #if defined(JSON_HEDLEY_HAS_CPP_ATTRIBUTE) |
873 | | #undef JSON_HEDLEY_HAS_CPP_ATTRIBUTE |
874 | | #endif |
875 | | #if \ |
876 | | defined(__has_cpp_attribute) && \ |
877 | | defined(__cplusplus) && \ |
878 | | (!defined(JSON_HEDLEY_SUNPRO_VERSION) || JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,15,0)) |
879 | | #define JSON_HEDLEY_HAS_CPP_ATTRIBUTE(attribute) __has_cpp_attribute(attribute) |
880 | | #else |
881 | | #define JSON_HEDLEY_HAS_CPP_ATTRIBUTE(attribute) (0) |
882 | | #endif |
883 | | |
884 | | #if defined(JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS) |
885 | | #undef JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS |
886 | | #endif |
887 | | #if !defined(__cplusplus) || !defined(__has_cpp_attribute) |
888 | | #define JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS(ns,attribute) (0) |
889 | | #elif \ |
890 | | !defined(JSON_HEDLEY_PGI_VERSION) && \ |
891 | | !defined(JSON_HEDLEY_IAR_VERSION) && \ |
892 | | (!defined(JSON_HEDLEY_SUNPRO_VERSION) || JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,15,0)) && \ |
893 | | (!defined(JSON_HEDLEY_MSVC_VERSION) || JSON_HEDLEY_MSVC_VERSION_CHECK(19,20,0)) |
894 | | #define JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS(ns,attribute) JSON_HEDLEY_HAS_CPP_ATTRIBUTE(ns::attribute) |
895 | | #else |
896 | | #define JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS(ns,attribute) (0) |
897 | | #endif |
898 | | |
899 | | #if defined(JSON_HEDLEY_GNUC_HAS_CPP_ATTRIBUTE) |
900 | | #undef JSON_HEDLEY_GNUC_HAS_CPP_ATTRIBUTE |
901 | | #endif |
902 | | #if defined(__has_cpp_attribute) && defined(__cplusplus) |
903 | | #define JSON_HEDLEY_GNUC_HAS_CPP_ATTRIBUTE(attribute,major,minor,patch) __has_cpp_attribute(attribute) |
904 | | #else |
905 | | #define JSON_HEDLEY_GNUC_HAS_CPP_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) |
906 | | #endif |
907 | | |
908 | | #if defined(JSON_HEDLEY_GCC_HAS_CPP_ATTRIBUTE) |
909 | | #undef JSON_HEDLEY_GCC_HAS_CPP_ATTRIBUTE |
910 | | #endif |
911 | | #if defined(__has_cpp_attribute) && defined(__cplusplus) |
912 | | #define JSON_HEDLEY_GCC_HAS_CPP_ATTRIBUTE(attribute,major,minor,patch) __has_cpp_attribute(attribute) |
913 | | #else |
914 | | #define JSON_HEDLEY_GCC_HAS_CPP_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) |
915 | | #endif |
916 | | |
917 | | #if defined(JSON_HEDLEY_HAS_BUILTIN) |
918 | | #undef JSON_HEDLEY_HAS_BUILTIN |
919 | | #endif |
920 | | #if defined(__has_builtin) |
921 | | #define JSON_HEDLEY_HAS_BUILTIN(builtin) __has_builtin(builtin) |
922 | | #else |
923 | | #define JSON_HEDLEY_HAS_BUILTIN(builtin) (0) |
924 | | #endif |
925 | | |
926 | | #if defined(JSON_HEDLEY_GNUC_HAS_BUILTIN) |
927 | | #undef JSON_HEDLEY_GNUC_HAS_BUILTIN |
928 | | #endif |
929 | | #if defined(__has_builtin) |
930 | | #define JSON_HEDLEY_GNUC_HAS_BUILTIN(builtin,major,minor,patch) __has_builtin(builtin) |
931 | | #else |
932 | | #define JSON_HEDLEY_GNUC_HAS_BUILTIN(builtin,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) |
933 | | #endif |
934 | | |
935 | | #if defined(JSON_HEDLEY_GCC_HAS_BUILTIN) |
936 | | #undef JSON_HEDLEY_GCC_HAS_BUILTIN |
937 | | #endif |
938 | | #if defined(__has_builtin) |
939 | | #define JSON_HEDLEY_GCC_HAS_BUILTIN(builtin,major,minor,patch) __has_builtin(builtin) |
940 | | #else |
941 | | #define JSON_HEDLEY_GCC_HAS_BUILTIN(builtin,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) |
942 | | #endif |
943 | | |
944 | | #if defined(JSON_HEDLEY_HAS_FEATURE) |
945 | | #undef JSON_HEDLEY_HAS_FEATURE |
946 | | #endif |
947 | | #if defined(__has_feature) |
948 | | #define JSON_HEDLEY_HAS_FEATURE(feature) __has_feature(feature) |
949 | | #else |
950 | | #define JSON_HEDLEY_HAS_FEATURE(feature) (0) |
951 | | #endif |
952 | | |
953 | | #if defined(JSON_HEDLEY_GNUC_HAS_FEATURE) |
954 | | #undef JSON_HEDLEY_GNUC_HAS_FEATURE |
955 | | #endif |
956 | | #if defined(__has_feature) |
957 | | #define JSON_HEDLEY_GNUC_HAS_FEATURE(feature,major,minor,patch) __has_feature(feature) |
958 | | #else |
959 | | #define JSON_HEDLEY_GNUC_HAS_FEATURE(feature,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) |
960 | | #endif |
961 | | |
962 | | #if defined(JSON_HEDLEY_GCC_HAS_FEATURE) |
963 | | #undef JSON_HEDLEY_GCC_HAS_FEATURE |
964 | | #endif |
965 | | #if defined(__has_feature) |
966 | | #define JSON_HEDLEY_GCC_HAS_FEATURE(feature,major,minor,patch) __has_feature(feature) |
967 | | #else |
968 | | #define JSON_HEDLEY_GCC_HAS_FEATURE(feature,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) |
969 | | #endif |
970 | | |
971 | | #if defined(JSON_HEDLEY_HAS_EXTENSION) |
972 | | #undef JSON_HEDLEY_HAS_EXTENSION |
973 | | #endif |
974 | | #if defined(__has_extension) |
975 | | #define JSON_HEDLEY_HAS_EXTENSION(extension) __has_extension(extension) |
976 | | #else |
977 | | #define JSON_HEDLEY_HAS_EXTENSION(extension) (0) |
978 | | #endif |
979 | | |
980 | | #if defined(JSON_HEDLEY_GNUC_HAS_EXTENSION) |
981 | | #undef JSON_HEDLEY_GNUC_HAS_EXTENSION |
982 | | #endif |
983 | | #if defined(__has_extension) |
984 | | #define JSON_HEDLEY_GNUC_HAS_EXTENSION(extension,major,minor,patch) __has_extension(extension) |
985 | | #else |
986 | | #define JSON_HEDLEY_GNUC_HAS_EXTENSION(extension,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) |
987 | | #endif |
988 | | |
989 | | #if defined(JSON_HEDLEY_GCC_HAS_EXTENSION) |
990 | | #undef JSON_HEDLEY_GCC_HAS_EXTENSION |
991 | | #endif |
992 | | #if defined(__has_extension) |
993 | | #define JSON_HEDLEY_GCC_HAS_EXTENSION(extension,major,minor,patch) __has_extension(extension) |
994 | | #else |
995 | | #define JSON_HEDLEY_GCC_HAS_EXTENSION(extension,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) |
996 | | #endif |
997 | | |
998 | | #if defined(JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE) |
999 | | #undef JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE |
1000 | | #endif |
1001 | | #if defined(__has_declspec_attribute) |
1002 | | #define JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE(attribute) __has_declspec_attribute(attribute) |
1003 | | #else |
1004 | | #define JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE(attribute) (0) |
1005 | | #endif |
1006 | | |
1007 | | #if defined(JSON_HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE) |
1008 | | #undef JSON_HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE |
1009 | | #endif |
1010 | | #if defined(__has_declspec_attribute) |
1011 | | #define JSON_HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE(attribute,major,minor,patch) __has_declspec_attribute(attribute) |
1012 | | #else |
1013 | | #define JSON_HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) |
1014 | | #endif |
1015 | | |
1016 | | #if defined(JSON_HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE) |
1017 | | #undef JSON_HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE |
1018 | | #endif |
1019 | | #if defined(__has_declspec_attribute) |
1020 | | #define JSON_HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE(attribute,major,minor,patch) __has_declspec_attribute(attribute) |
1021 | | #else |
1022 | | #define JSON_HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) |
1023 | | #endif |
1024 | | |
1025 | | #if defined(JSON_HEDLEY_HAS_WARNING) |
1026 | | #undef JSON_HEDLEY_HAS_WARNING |
1027 | | #endif |
1028 | | #if defined(__has_warning) |
1029 | | #define JSON_HEDLEY_HAS_WARNING(warning) __has_warning(warning) |
1030 | | #else |
1031 | | #define JSON_HEDLEY_HAS_WARNING(warning) (0) |
1032 | | #endif |
1033 | | |
1034 | | #if defined(JSON_HEDLEY_GNUC_HAS_WARNING) |
1035 | | #undef JSON_HEDLEY_GNUC_HAS_WARNING |
1036 | | #endif |
1037 | | #if defined(__has_warning) |
1038 | | #define JSON_HEDLEY_GNUC_HAS_WARNING(warning,major,minor,patch) __has_warning(warning) |
1039 | | #else |
1040 | | #define JSON_HEDLEY_GNUC_HAS_WARNING(warning,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) |
1041 | | #endif |
1042 | | |
1043 | | #if defined(JSON_HEDLEY_GCC_HAS_WARNING) |
1044 | | #undef JSON_HEDLEY_GCC_HAS_WARNING |
1045 | | #endif |
1046 | | #if defined(__has_warning) |
1047 | | #define JSON_HEDLEY_GCC_HAS_WARNING(warning,major,minor,patch) __has_warning(warning) |
1048 | | #else |
1049 | | #define JSON_HEDLEY_GCC_HAS_WARNING(warning,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) |
1050 | | #endif |
1051 | | |
1052 | | #if \ |
1053 | | (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)) || \ |
1054 | | defined(__clang__) || \ |
1055 | | JSON_HEDLEY_GCC_VERSION_CHECK(3,0,0) || \ |
1056 | | JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ |
1057 | | JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) || \ |
1058 | | JSON_HEDLEY_PGI_VERSION_CHECK(18,4,0) || \ |
1059 | | JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ |
1060 | | JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \ |
1061 | | JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,7,0) || \ |
1062 | | JSON_HEDLEY_TI_CL430_VERSION_CHECK(2,0,1) || \ |
1063 | | JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,1,0) || \ |
1064 | | JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,0,0) || \ |
1065 | | JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ |
1066 | | JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \ |
1067 | | JSON_HEDLEY_CRAY_VERSION_CHECK(5,0,0) || \ |
1068 | | JSON_HEDLEY_TINYC_VERSION_CHECK(0,9,17) || \ |
1069 | | JSON_HEDLEY_SUNPRO_VERSION_CHECK(8,0,0) || \ |
1070 | | (JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) && defined(__C99_PRAGMA_OPERATOR)) |
1071 | | #define JSON_HEDLEY_PRAGMA(value) _Pragma(#value) |
1072 | | #elif JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0) |
1073 | | #define JSON_HEDLEY_PRAGMA(value) __pragma(value) |
1074 | | #else |
1075 | | #define JSON_HEDLEY_PRAGMA(value) |
1076 | | #endif |
1077 | | |
1078 | | #if defined(JSON_HEDLEY_DIAGNOSTIC_PUSH) |
1079 | | #undef JSON_HEDLEY_DIAGNOSTIC_PUSH |
1080 | | #endif |
1081 | | #if defined(JSON_HEDLEY_DIAGNOSTIC_POP) |
1082 | | #undef JSON_HEDLEY_DIAGNOSTIC_POP |
1083 | | #endif |
1084 | | #if defined(__clang__) |
1085 | | #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("clang diagnostic push") |
1086 | | #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("clang diagnostic pop") |
1087 | | #elif JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) |
1088 | | #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("warning(push)") |
1089 | | #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("warning(pop)") |
1090 | | #elif JSON_HEDLEY_GCC_VERSION_CHECK(4,6,0) |
1091 | | #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("GCC diagnostic push") |
1092 | | #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("GCC diagnostic pop") |
1093 | | #elif \ |
1094 | | JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0) || \ |
1095 | | JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) |
1096 | | #define JSON_HEDLEY_DIAGNOSTIC_PUSH __pragma(warning(push)) |
1097 | | #define JSON_HEDLEY_DIAGNOSTIC_POP __pragma(warning(pop)) |
1098 | | #elif JSON_HEDLEY_ARM_VERSION_CHECK(5,6,0) |
1099 | | #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("push") |
1100 | | #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("pop") |
1101 | | #elif \ |
1102 | | JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \ |
1103 | | JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \ |
1104 | | JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,4,0) || \ |
1105 | | JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,1,0) || \ |
1106 | | JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ |
1107 | | JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) |
1108 | | #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("diag_push") |
1109 | | #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("diag_pop") |
1110 | | #elif JSON_HEDLEY_PELLES_VERSION_CHECK(2,90,0) |
1111 | | #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("warning(push)") |
1112 | | #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("warning(pop)") |
1113 | | #else |
1114 | | #define JSON_HEDLEY_DIAGNOSTIC_PUSH |
1115 | | #define JSON_HEDLEY_DIAGNOSTIC_POP |
1116 | | #endif |
1117 | | |
1118 | | /* JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_ is for |
1119 | | HEDLEY INTERNAL USE ONLY. API subject to change without notice. */ |
1120 | | #if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_) |
1121 | | #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_ |
1122 | | #endif |
1123 | | #if defined(__cplusplus) |
1124 | | # if JSON_HEDLEY_HAS_WARNING("-Wc++98-compat") |
1125 | | # if JSON_HEDLEY_HAS_WARNING("-Wc++17-extensions") |
1126 | | # if JSON_HEDLEY_HAS_WARNING("-Wc++1z-extensions") |
1127 | | # define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(xpr) \ |
1128 | | JSON_HEDLEY_DIAGNOSTIC_PUSH \ |
1129 | | _Pragma("clang diagnostic ignored \"-Wc++98-compat\"") \ |
1130 | | _Pragma("clang diagnostic ignored \"-Wc++17-extensions\"") \ |
1131 | | _Pragma("clang diagnostic ignored \"-Wc++1z-extensions\"") \ |
1132 | | xpr \ |
1133 | | JSON_HEDLEY_DIAGNOSTIC_POP |
1134 | | # else |
1135 | | # define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(xpr) \ |
1136 | | JSON_HEDLEY_DIAGNOSTIC_PUSH \ |
1137 | | _Pragma("clang diagnostic ignored \"-Wc++98-compat\"") \ |
1138 | | _Pragma("clang diagnostic ignored \"-Wc++17-extensions\"") \ |
1139 | | xpr \ |
1140 | | JSON_HEDLEY_DIAGNOSTIC_POP |
1141 | | # endif |
1142 | | # else |
1143 | | # define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(xpr) \ |
1144 | | JSON_HEDLEY_DIAGNOSTIC_PUSH \ |
1145 | | _Pragma("clang diagnostic ignored \"-Wc++98-compat\"") \ |
1146 | | xpr \ |
1147 | | JSON_HEDLEY_DIAGNOSTIC_POP |
1148 | | # endif |
1149 | | # endif |
1150 | | #endif |
1151 | | #if !defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_) |
1152 | | #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(x) x |
1153 | | #endif |
1154 | | |
1155 | | #if defined(JSON_HEDLEY_CONST_CAST) |
1156 | | #undef JSON_HEDLEY_CONST_CAST |
1157 | | #endif |
1158 | | #if defined(__cplusplus) |
1159 | | # define JSON_HEDLEY_CONST_CAST(T, expr) (const_cast<T>(expr)) |
1160 | | #elif \ |
1161 | | JSON_HEDLEY_HAS_WARNING("-Wcast-qual") || \ |
1162 | | JSON_HEDLEY_GCC_VERSION_CHECK(4,6,0) || \ |
1163 | | JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) |
1164 | | # define JSON_HEDLEY_CONST_CAST(T, expr) (__extension__ ({ \ |
1165 | | JSON_HEDLEY_DIAGNOSTIC_PUSH \ |
1166 | | JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL \ |
1167 | | ((T) (expr)); \ |
1168 | | JSON_HEDLEY_DIAGNOSTIC_POP \ |
1169 | | })) |
1170 | | #else |
1171 | | # define JSON_HEDLEY_CONST_CAST(T, expr) ((T) (expr)) |
1172 | | #endif |
1173 | | |
1174 | | #if defined(JSON_HEDLEY_REINTERPRET_CAST) |
1175 | | #undef JSON_HEDLEY_REINTERPRET_CAST |
1176 | | #endif |
1177 | | #if defined(__cplusplus) |
1178 | | #define JSON_HEDLEY_REINTERPRET_CAST(T, expr) (reinterpret_cast<T>(expr)) |
1179 | | #else |
1180 | | #define JSON_HEDLEY_REINTERPRET_CAST(T, expr) ((T) (expr)) |
1181 | | #endif |
1182 | | |
1183 | | #if defined(JSON_HEDLEY_STATIC_CAST) |
1184 | | #undef JSON_HEDLEY_STATIC_CAST |
1185 | | #endif |
1186 | | #if defined(__cplusplus) |
1187 | | #define JSON_HEDLEY_STATIC_CAST(T, expr) (static_cast<T>(expr)) |
1188 | | #else |
1189 | | #define JSON_HEDLEY_STATIC_CAST(T, expr) ((T) (expr)) |
1190 | | #endif |
1191 | | |
1192 | | #if defined(JSON_HEDLEY_CPP_CAST) |
1193 | | #undef JSON_HEDLEY_CPP_CAST |
1194 | | #endif |
1195 | | #if defined(__cplusplus) |
1196 | | # if JSON_HEDLEY_HAS_WARNING("-Wold-style-cast") |
1197 | | # define JSON_HEDLEY_CPP_CAST(T, expr) \ |
1198 | | JSON_HEDLEY_DIAGNOSTIC_PUSH \ |
1199 | | _Pragma("clang diagnostic ignored \"-Wold-style-cast\"") \ |
1200 | | ((T) (expr)) \ |
1201 | | JSON_HEDLEY_DIAGNOSTIC_POP |
1202 | | # elif JSON_HEDLEY_IAR_VERSION_CHECK(8,3,0) |
1203 | | # define JSON_HEDLEY_CPP_CAST(T, expr) \ |
1204 | | JSON_HEDLEY_DIAGNOSTIC_PUSH \ |
1205 | | _Pragma("diag_suppress=Pe137") \ |
1206 | | JSON_HEDLEY_DIAGNOSTIC_POP |
1207 | | # else |
1208 | | # define JSON_HEDLEY_CPP_CAST(T, expr) ((T) (expr)) |
1209 | | # endif |
1210 | | #else |
1211 | | # define JSON_HEDLEY_CPP_CAST(T, expr) (expr) |
1212 | | #endif |
1213 | | |
1214 | | #if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED) |
1215 | | #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED |
1216 | | #endif |
1217 | | #if JSON_HEDLEY_HAS_WARNING("-Wdeprecated-declarations") |
1218 | | #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("clang diagnostic ignored \"-Wdeprecated-declarations\"") |
1219 | | #elif JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) |
1220 | | #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("warning(disable:1478 1786)") |
1221 | | #elif JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) |
1222 | | #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED __pragma(warning(disable:1478 1786)) |
1223 | | #elif JSON_HEDLEY_PGI_VERSION_CHECK(20,7,0) |
1224 | | #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress 1215,1216,1444,1445") |
1225 | | #elif JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) |
1226 | | #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress 1215,1444") |
1227 | | #elif JSON_HEDLEY_GCC_VERSION_CHECK(4,3,0) |
1228 | | #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"") |
1229 | | #elif JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0) |
1230 | | #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED __pragma(warning(disable:4996)) |
1231 | | #elif JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) |
1232 | | #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress 1215,1444") |
1233 | | #elif \ |
1234 | | JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \ |
1235 | | (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ |
1236 | | JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \ |
1237 | | (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ |
1238 | | JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \ |
1239 | | (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ |
1240 | | JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \ |
1241 | | (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ |
1242 | | JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \ |
1243 | | JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ |
1244 | | JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) |
1245 | | #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress 1291,1718") |
1246 | | #elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,13,0) && !defined(__cplusplus) |
1247 | | #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("error_messages(off,E_DEPRECATED_ATT,E_DEPRECATED_ATT_MESS)") |
1248 | | #elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,13,0) && defined(__cplusplus) |
1249 | | #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("error_messages(off,symdeprecated,symdeprecated2)") |
1250 | | #elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) |
1251 | | #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress=Pe1444,Pe1215") |
1252 | | #elif JSON_HEDLEY_PELLES_VERSION_CHECK(2,90,0) |
1253 | | #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("warn(disable:2241)") |
1254 | | #else |
1255 | | #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED |
1256 | | #endif |
1257 | | |
1258 | | #if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS) |
1259 | | #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS |
1260 | | #endif |
1261 | | #if JSON_HEDLEY_HAS_WARNING("-Wunknown-pragmas") |
1262 | | #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("clang diagnostic ignored \"-Wunknown-pragmas\"") |
1263 | | #elif JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) |
1264 | | #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("warning(disable:161)") |
1265 | | #elif JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) |
1266 | | #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS __pragma(warning(disable:161)) |
1267 | | #elif JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) |
1268 | | #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress 1675") |
1269 | | #elif JSON_HEDLEY_GCC_VERSION_CHECK(4,3,0) |
1270 | | #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("GCC diagnostic ignored \"-Wunknown-pragmas\"") |
1271 | | #elif JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0) |
1272 | | #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS __pragma(warning(disable:4068)) |
1273 | | #elif \ |
1274 | | JSON_HEDLEY_TI_VERSION_CHECK(16,9,0) || \ |
1275 | | JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,0,0) || \ |
1276 | | JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ |
1277 | | JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,3,0) |
1278 | | #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress 163") |
1279 | | #elif JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,0,0) |
1280 | | #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress 163") |
1281 | | #elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) |
1282 | | #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress=Pe161") |
1283 | | #elif JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) |
1284 | | #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress 161") |
1285 | | #else |
1286 | | #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS |
1287 | | #endif |
1288 | | |
1289 | | #if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES) |
1290 | | #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES |
1291 | | #endif |
1292 | | #if JSON_HEDLEY_HAS_WARNING("-Wunknown-attributes") |
1293 | | #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("clang diagnostic ignored \"-Wunknown-attributes\"") |
1294 | | #elif JSON_HEDLEY_GCC_VERSION_CHECK(4,6,0) |
1295 | | #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"") |
1296 | | #elif JSON_HEDLEY_INTEL_VERSION_CHECK(17,0,0) |
1297 | | #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("warning(disable:1292)") |
1298 | | #elif JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) |
1299 | | #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES __pragma(warning(disable:1292)) |
1300 | | #elif JSON_HEDLEY_MSVC_VERSION_CHECK(19,0,0) |
1301 | | #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES __pragma(warning(disable:5030)) |
1302 | | #elif JSON_HEDLEY_PGI_VERSION_CHECK(20,7,0) |
1303 | | #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress 1097,1098") |
1304 | | #elif JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) |
1305 | | #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress 1097") |
1306 | | #elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,14,0) && defined(__cplusplus) |
1307 | | #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("error_messages(off,attrskipunsup)") |
1308 | | #elif \ |
1309 | | JSON_HEDLEY_TI_VERSION_CHECK(18,1,0) || \ |
1310 | | JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,3,0) || \ |
1311 | | JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) |
1312 | | #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress 1173") |
1313 | | #elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) |
1314 | | #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress=Pe1097") |
1315 | | #elif JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) |
1316 | | #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress 1097") |
1317 | | #else |
1318 | | #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES |
1319 | | #endif |
1320 | | |
1321 | | #if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL) |
1322 | | #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL |
1323 | | #endif |
1324 | | #if JSON_HEDLEY_HAS_WARNING("-Wcast-qual") |
1325 | | #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL _Pragma("clang diagnostic ignored \"-Wcast-qual\"") |
1326 | | #elif JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) |
1327 | | #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL _Pragma("warning(disable:2203 2331)") |
1328 | | #elif JSON_HEDLEY_GCC_VERSION_CHECK(3,0,0) |
1329 | | #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL _Pragma("GCC diagnostic ignored \"-Wcast-qual\"") |
1330 | | #else |
1331 | | #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL |
1332 | | #endif |
1333 | | |
1334 | | #if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION) |
1335 | | #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION |
1336 | | #endif |
1337 | | #if JSON_HEDLEY_HAS_WARNING("-Wunused-function") |
1338 | | #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION _Pragma("clang diagnostic ignored \"-Wunused-function\"") |
1339 | | #elif JSON_HEDLEY_GCC_VERSION_CHECK(3,4,0) |
1340 | | #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION _Pragma("GCC diagnostic ignored \"-Wunused-function\"") |
1341 | | #elif JSON_HEDLEY_MSVC_VERSION_CHECK(1,0,0) |
1342 | | #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION __pragma(warning(disable:4505)) |
1343 | | #elif JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) |
1344 | | #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION _Pragma("diag_suppress 3142") |
1345 | | #else |
1346 | | #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION |
1347 | | #endif |
1348 | | |
1349 | | #if defined(JSON_HEDLEY_DEPRECATED) |
1350 | | #undef JSON_HEDLEY_DEPRECATED |
1351 | | #endif |
1352 | | #if defined(JSON_HEDLEY_DEPRECATED_FOR) |
1353 | | #undef JSON_HEDLEY_DEPRECATED_FOR |
1354 | | #endif |
1355 | | #if \ |
1356 | | JSON_HEDLEY_MSVC_VERSION_CHECK(14,0,0) || \ |
1357 | | JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) |
1358 | | #define JSON_HEDLEY_DEPRECATED(since) __declspec(deprecated("Since " # since)) |
1359 | | #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) __declspec(deprecated("Since " #since "; use " #replacement)) |
1360 | | #elif \ |
1361 | | (JSON_HEDLEY_HAS_EXTENSION(attribute_deprecated_with_message) && !defined(JSON_HEDLEY_IAR_VERSION)) || \ |
1362 | | JSON_HEDLEY_GCC_VERSION_CHECK(4,5,0) || \ |
1363 | | JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ |
1364 | | JSON_HEDLEY_ARM_VERSION_CHECK(5,6,0) || \ |
1365 | | JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,13,0) || \ |
1366 | | JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) || \ |
1367 | | JSON_HEDLEY_TI_VERSION_CHECK(18,1,0) || \ |
1368 | | JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(18,1,0) || \ |
1369 | | JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,3,0) || \ |
1370 | | JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ |
1371 | | JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,3,0) || \ |
1372 | | JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) |
1373 | | #define JSON_HEDLEY_DEPRECATED(since) __attribute__((__deprecated__("Since " #since))) |
1374 | | #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) __attribute__((__deprecated__("Since " #since "; use " #replacement))) |
1375 | | #elif defined(__cplusplus) && (__cplusplus >= 201402L) |
1376 | | #define JSON_HEDLEY_DEPRECATED(since) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[deprecated("Since " #since)]]) |
1377 | | #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[deprecated("Since " #since "; use " #replacement)]]) |
1378 | | #elif \ |
1379 | | JSON_HEDLEY_HAS_ATTRIBUTE(deprecated) || \ |
1380 | | JSON_HEDLEY_GCC_VERSION_CHECK(3,1,0) || \ |
1381 | | JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ |
1382 | | JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \ |
1383 | | (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ |
1384 | | JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \ |
1385 | | (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ |
1386 | | JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \ |
1387 | | (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ |
1388 | | JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \ |
1389 | | (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ |
1390 | | JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \ |
1391 | | JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ |
1392 | | JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \ |
1393 | | JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) || \ |
1394 | | JSON_HEDLEY_IAR_VERSION_CHECK(8,10,0) |
1395 | | #define JSON_HEDLEY_DEPRECATED(since) __attribute__((__deprecated__)) |
1396 | | #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) __attribute__((__deprecated__)) |
1397 | | #elif \ |
1398 | | JSON_HEDLEY_MSVC_VERSION_CHECK(13,10,0) || \ |
1399 | | JSON_HEDLEY_PELLES_VERSION_CHECK(6,50,0) || \ |
1400 | | JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) |
1401 | | #define JSON_HEDLEY_DEPRECATED(since) __declspec(deprecated) |
1402 | | #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) __declspec(deprecated) |
1403 | | #elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) |
1404 | | #define JSON_HEDLEY_DEPRECATED(since) _Pragma("deprecated") |
1405 | | #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) _Pragma("deprecated") |
1406 | | #else |
1407 | | #define JSON_HEDLEY_DEPRECATED(since) |
1408 | | #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) |
1409 | | #endif |
1410 | | |
1411 | | #if defined(JSON_HEDLEY_UNAVAILABLE) |
1412 | | #undef JSON_HEDLEY_UNAVAILABLE |
1413 | | #endif |
1414 | | #if \ |
1415 | | JSON_HEDLEY_HAS_ATTRIBUTE(warning) || \ |
1416 | | JSON_HEDLEY_GCC_VERSION_CHECK(4,3,0) || \ |
1417 | | JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ |
1418 | | JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) |
1419 | | #define JSON_HEDLEY_UNAVAILABLE(available_since) __attribute__((__warning__("Not available until " #available_since))) |
1420 | | #else |
1421 | | #define JSON_HEDLEY_UNAVAILABLE(available_since) |
1422 | | #endif |
1423 | | |
1424 | | #if defined(JSON_HEDLEY_WARN_UNUSED_RESULT) |
1425 | | #undef JSON_HEDLEY_WARN_UNUSED_RESULT |
1426 | | #endif |
1427 | | #if defined(JSON_HEDLEY_WARN_UNUSED_RESULT_MSG) |
1428 | | #undef JSON_HEDLEY_WARN_UNUSED_RESULT_MSG |
1429 | | #endif |
1430 | | #if \ |
1431 | | JSON_HEDLEY_HAS_ATTRIBUTE(warn_unused_result) || \ |
1432 | | JSON_HEDLEY_GCC_VERSION_CHECK(3,4,0) || \ |
1433 | | JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ |
1434 | | JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \ |
1435 | | (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ |
1436 | | JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \ |
1437 | | (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ |
1438 | | JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \ |
1439 | | (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ |
1440 | | JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \ |
1441 | | (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ |
1442 | | JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \ |
1443 | | JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ |
1444 | | JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \ |
1445 | | (JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,15,0) && defined(__cplusplus)) || \ |
1446 | | JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) || \ |
1447 | | JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) |
1448 | | #define JSON_HEDLEY_WARN_UNUSED_RESULT __attribute__((__warn_unused_result__)) |
1449 | | #define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg) __attribute__((__warn_unused_result__)) |
1450 | | #elif (JSON_HEDLEY_HAS_CPP_ATTRIBUTE(nodiscard) >= 201907L) |
1451 | | #define JSON_HEDLEY_WARN_UNUSED_RESULT JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[nodiscard]]) |
1452 | | #define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[nodiscard(msg)]]) |
1453 | | #elif JSON_HEDLEY_HAS_CPP_ATTRIBUTE(nodiscard) |
1454 | | #define JSON_HEDLEY_WARN_UNUSED_RESULT JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[nodiscard]]) |
1455 | | #define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[nodiscard]]) |
1456 | | #elif defined(_Check_return_) /* SAL */ |
1457 | | #define JSON_HEDLEY_WARN_UNUSED_RESULT _Check_return_ |
1458 | | #define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg) _Check_return_ |
1459 | | #else |
1460 | | #define JSON_HEDLEY_WARN_UNUSED_RESULT |
1461 | | #define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg) |
1462 | | #endif |
1463 | | |
1464 | | #if defined(JSON_HEDLEY_SENTINEL) |
1465 | | #undef JSON_HEDLEY_SENTINEL |
1466 | | #endif |
1467 | | #if \ |
1468 | | JSON_HEDLEY_HAS_ATTRIBUTE(sentinel) || \ |
1469 | | JSON_HEDLEY_GCC_VERSION_CHECK(4,0,0) || \ |
1470 | | JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ |
1471 | | JSON_HEDLEY_ARM_VERSION_CHECK(5,4,0) || \ |
1472 | | JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) |
1473 | | #define JSON_HEDLEY_SENTINEL(position) __attribute__((__sentinel__(position))) |
1474 | | #else |
1475 | | #define JSON_HEDLEY_SENTINEL(position) |
1476 | | #endif |
1477 | | |
1478 | | #if defined(JSON_HEDLEY_NO_RETURN) |
1479 | | #undef JSON_HEDLEY_NO_RETURN |
1480 | | #endif |
1481 | | #if JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) |
1482 | | #define JSON_HEDLEY_NO_RETURN __noreturn |
1483 | | #elif \ |
1484 | | JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ |
1485 | | JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) |
1486 | | #define JSON_HEDLEY_NO_RETURN __attribute__((__noreturn__)) |
1487 | | #elif defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L |
1488 | | #define JSON_HEDLEY_NO_RETURN _Noreturn |
1489 | | #elif defined(__cplusplus) && (__cplusplus >= 201103L) |
1490 | | #define JSON_HEDLEY_NO_RETURN JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[noreturn]]) |
1491 | | #elif \ |
1492 | | JSON_HEDLEY_HAS_ATTRIBUTE(noreturn) || \ |
1493 | | JSON_HEDLEY_GCC_VERSION_CHECK(3,2,0) || \ |
1494 | | JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \ |
1495 | | JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ |
1496 | | JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \ |
1497 | | JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \ |
1498 | | (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ |
1499 | | JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \ |
1500 | | (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ |
1501 | | JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \ |
1502 | | (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ |
1503 | | JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \ |
1504 | | (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ |
1505 | | JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \ |
1506 | | JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ |
1507 | | JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \ |
1508 | | JSON_HEDLEY_IAR_VERSION_CHECK(8,10,0) |
1509 | | #define JSON_HEDLEY_NO_RETURN __attribute__((__noreturn__)) |
1510 | | #elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0) |
1511 | | #define JSON_HEDLEY_NO_RETURN _Pragma("does_not_return") |
1512 | | #elif \ |
1513 | | JSON_HEDLEY_MSVC_VERSION_CHECK(13,10,0) || \ |
1514 | | JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) |
1515 | | #define JSON_HEDLEY_NO_RETURN __declspec(noreturn) |
1516 | | #elif JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6,0,0) && defined(__cplusplus) |
1517 | | #define JSON_HEDLEY_NO_RETURN _Pragma("FUNC_NEVER_RETURNS;") |
1518 | | #elif JSON_HEDLEY_COMPCERT_VERSION_CHECK(3,2,0) |
1519 | | #define JSON_HEDLEY_NO_RETURN __attribute((noreturn)) |
1520 | | #elif JSON_HEDLEY_PELLES_VERSION_CHECK(9,0,0) |
1521 | | #define JSON_HEDLEY_NO_RETURN __declspec(noreturn) |
1522 | | #else |
1523 | | #define JSON_HEDLEY_NO_RETURN |
1524 | | #endif |
1525 | | |
1526 | | #if defined(JSON_HEDLEY_NO_ESCAPE) |
1527 | | #undef JSON_HEDLEY_NO_ESCAPE |
1528 | | #endif |
1529 | | #if JSON_HEDLEY_HAS_ATTRIBUTE(noescape) |
1530 | | #define JSON_HEDLEY_NO_ESCAPE __attribute__((__noescape__)) |
1531 | | #else |
1532 | | #define JSON_HEDLEY_NO_ESCAPE |
1533 | | #endif |
1534 | | |
1535 | | #if defined(JSON_HEDLEY_UNREACHABLE) |
1536 | | #undef JSON_HEDLEY_UNREACHABLE |
1537 | | #endif |
1538 | | #if defined(JSON_HEDLEY_UNREACHABLE_RETURN) |
1539 | | #undef JSON_HEDLEY_UNREACHABLE_RETURN |
1540 | | #endif |
1541 | | #if defined(JSON_HEDLEY_ASSUME) |
1542 | | #undef JSON_HEDLEY_ASSUME |
1543 | | #endif |
1544 | | #if \ |
1545 | | JSON_HEDLEY_MSVC_VERSION_CHECK(13,10,0) || \ |
1546 | | JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ |
1547 | | JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) |
1548 | | #define JSON_HEDLEY_ASSUME(expr) __assume(expr) |
1549 | | #elif JSON_HEDLEY_HAS_BUILTIN(__builtin_assume) |
1550 | | #define JSON_HEDLEY_ASSUME(expr) __builtin_assume(expr) |
1551 | | #elif \ |
1552 | | JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,2,0) || \ |
1553 | | JSON_HEDLEY_TI_CL6X_VERSION_CHECK(4,0,0) |
1554 | | #if defined(__cplusplus) |
1555 | | #define JSON_HEDLEY_ASSUME(expr) std::_nassert(expr) |
1556 | | #else |
1557 | | #define JSON_HEDLEY_ASSUME(expr) _nassert(expr) |
1558 | | #endif |
1559 | | #endif |
1560 | | #if \ |
1561 | | (JSON_HEDLEY_HAS_BUILTIN(__builtin_unreachable) && (!defined(JSON_HEDLEY_ARM_VERSION))) || \ |
1562 | | JSON_HEDLEY_GCC_VERSION_CHECK(4,5,0) || \ |
1563 | | JSON_HEDLEY_PGI_VERSION_CHECK(18,10,0) || \ |
1564 | | JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ |
1565 | | JSON_HEDLEY_IBM_VERSION_CHECK(13,1,5) || \ |
1566 | | JSON_HEDLEY_CRAY_VERSION_CHECK(10,0,0) || \ |
1567 | | JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) |
1568 | | #define JSON_HEDLEY_UNREACHABLE() __builtin_unreachable() |
1569 | | #elif defined(JSON_HEDLEY_ASSUME) |
1570 | | #define JSON_HEDLEY_UNREACHABLE() JSON_HEDLEY_ASSUME(0) |
1571 | | #endif |
1572 | | #if !defined(JSON_HEDLEY_ASSUME) |
1573 | | #if defined(JSON_HEDLEY_UNREACHABLE) |
1574 | | #define JSON_HEDLEY_ASSUME(expr) JSON_HEDLEY_STATIC_CAST(void, ((expr) ? 1 : (JSON_HEDLEY_UNREACHABLE(), 1))) |
1575 | | #else |
1576 | | #define JSON_HEDLEY_ASSUME(expr) JSON_HEDLEY_STATIC_CAST(void, expr) |
1577 | | #endif |
1578 | | #endif |
1579 | | #if defined(JSON_HEDLEY_UNREACHABLE) |
1580 | | #if \ |
1581 | | JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,2,0) || \ |
1582 | | JSON_HEDLEY_TI_CL6X_VERSION_CHECK(4,0,0) |
1583 | | #define JSON_HEDLEY_UNREACHABLE_RETURN(value) return (JSON_HEDLEY_STATIC_CAST(void, JSON_HEDLEY_ASSUME(0)), (value)) |
1584 | | #else |
1585 | | #define JSON_HEDLEY_UNREACHABLE_RETURN(value) JSON_HEDLEY_UNREACHABLE() |
1586 | | #endif |
1587 | | #else |
1588 | | #define JSON_HEDLEY_UNREACHABLE_RETURN(value) return (value) |
1589 | | #endif |
1590 | | #if !defined(JSON_HEDLEY_UNREACHABLE) |
1591 | | #define JSON_HEDLEY_UNREACHABLE() JSON_HEDLEY_ASSUME(0) |
1592 | | #endif |
1593 | | |
1594 | | JSON_HEDLEY_DIAGNOSTIC_PUSH |
1595 | | #if JSON_HEDLEY_HAS_WARNING("-Wpedantic") |
1596 | | #pragma clang diagnostic ignored "-Wpedantic" |
1597 | | #endif |
1598 | | #if JSON_HEDLEY_HAS_WARNING("-Wc++98-compat-pedantic") && defined(__cplusplus) |
1599 | | #pragma clang diagnostic ignored "-Wc++98-compat-pedantic" |
1600 | | #endif |
1601 | | #if JSON_HEDLEY_GCC_HAS_WARNING("-Wvariadic-macros",4,0,0) |
1602 | | #if defined(__clang__) |
1603 | | #pragma clang diagnostic ignored "-Wvariadic-macros" |
1604 | | #elif defined(JSON_HEDLEY_GCC_VERSION) |
1605 | | #pragma GCC diagnostic ignored "-Wvariadic-macros" |
1606 | | #endif |
1607 | | #endif |
1608 | | #if defined(JSON_HEDLEY_NON_NULL) |
1609 | | #undef JSON_HEDLEY_NON_NULL |
1610 | | #endif |
1611 | | #if \ |
1612 | | JSON_HEDLEY_HAS_ATTRIBUTE(nonnull) || \ |
1613 | | JSON_HEDLEY_GCC_VERSION_CHECK(3,3,0) || \ |
1614 | | JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ |
1615 | | JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) |
1616 | | #define JSON_HEDLEY_NON_NULL(...) __attribute__((__nonnull__(__VA_ARGS__))) |
1617 | | #else |
1618 | | #define JSON_HEDLEY_NON_NULL(...) |
1619 | | #endif |
1620 | | JSON_HEDLEY_DIAGNOSTIC_POP |
1621 | | |
1622 | | #if defined(JSON_HEDLEY_PRINTF_FORMAT) |
1623 | | #undef JSON_HEDLEY_PRINTF_FORMAT |
1624 | | #endif |
1625 | | #if defined(__MINGW32__) && JSON_HEDLEY_GCC_HAS_ATTRIBUTE(format,4,4,0) && !defined(__USE_MINGW_ANSI_STDIO) |
1626 | | #define JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) __attribute__((__format__(ms_printf, string_idx, first_to_check))) |
1627 | | #elif defined(__MINGW32__) && JSON_HEDLEY_GCC_HAS_ATTRIBUTE(format,4,4,0) && defined(__USE_MINGW_ANSI_STDIO) |
1628 | | #define JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) __attribute__((__format__(gnu_printf, string_idx, first_to_check))) |
1629 | | #elif \ |
1630 | | JSON_HEDLEY_HAS_ATTRIBUTE(format) || \ |
1631 | | JSON_HEDLEY_GCC_VERSION_CHECK(3,1,0) || \ |
1632 | | JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ |
1633 | | JSON_HEDLEY_ARM_VERSION_CHECK(5,6,0) || \ |
1634 | | JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \ |
1635 | | JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \ |
1636 | | (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ |
1637 | | JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \ |
1638 | | (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ |
1639 | | JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \ |
1640 | | (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ |
1641 | | JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \ |
1642 | | (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ |
1643 | | JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \ |
1644 | | JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ |
1645 | | JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \ |
1646 | | JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) |
1647 | | #define JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) __attribute__((__format__(__printf__, string_idx, first_to_check))) |
1648 | | #elif JSON_HEDLEY_PELLES_VERSION_CHECK(6,0,0) |
1649 | | #define JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) __declspec(vaformat(printf,string_idx,first_to_check)) |
1650 | | #else |
1651 | | #define JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) |
1652 | | #endif |
1653 | | |
1654 | | #if defined(JSON_HEDLEY_CONSTEXPR) |
1655 | | #undef JSON_HEDLEY_CONSTEXPR |
1656 | | #endif |
1657 | | #if defined(__cplusplus) |
1658 | | #if __cplusplus >= 201103L |
1659 | | #define JSON_HEDLEY_CONSTEXPR JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(constexpr) |
1660 | | #endif |
1661 | | #endif |
1662 | | #if !defined(JSON_HEDLEY_CONSTEXPR) |
1663 | | #define JSON_HEDLEY_CONSTEXPR |
1664 | | #endif |
1665 | | |
1666 | | #if defined(JSON_HEDLEY_PREDICT) |
1667 | | #undef JSON_HEDLEY_PREDICT |
1668 | | #endif |
1669 | | #if defined(JSON_HEDLEY_LIKELY) |
1670 | | #undef JSON_HEDLEY_LIKELY |
1671 | | #endif |
1672 | | #if defined(JSON_HEDLEY_UNLIKELY) |
1673 | | #undef JSON_HEDLEY_UNLIKELY |
1674 | | #endif |
1675 | | #if defined(JSON_HEDLEY_UNPREDICTABLE) |
1676 | | #undef JSON_HEDLEY_UNPREDICTABLE |
1677 | | #endif |
1678 | | #if JSON_HEDLEY_HAS_BUILTIN(__builtin_unpredictable) |
1679 | | #define JSON_HEDLEY_UNPREDICTABLE(expr) __builtin_unpredictable((expr)) |
1680 | | #endif |
1681 | | #if \ |
1682 | | (JSON_HEDLEY_HAS_BUILTIN(__builtin_expect_with_probability) && !defined(JSON_HEDLEY_PGI_VERSION)) || \ |
1683 | | JSON_HEDLEY_GCC_VERSION_CHECK(9,0,0) || \ |
1684 | | JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) |
1685 | | # define JSON_HEDLEY_PREDICT(expr, value, probability) __builtin_expect_with_probability( (expr), (value), (probability)) |
1686 | | # define JSON_HEDLEY_PREDICT_TRUE(expr, probability) __builtin_expect_with_probability(!!(expr), 1 , (probability)) |
1687 | | # define JSON_HEDLEY_PREDICT_FALSE(expr, probability) __builtin_expect_with_probability(!!(expr), 0 , (probability)) |
1688 | 0 | # define JSON_HEDLEY_LIKELY(expr) __builtin_expect (!!(expr), 1 ) |
1689 | 0 | # define JSON_HEDLEY_UNLIKELY(expr) __builtin_expect (!!(expr), 0 ) |
1690 | | #elif \ |
1691 | | (JSON_HEDLEY_HAS_BUILTIN(__builtin_expect) && !defined(JSON_HEDLEY_INTEL_CL_VERSION)) || \ |
1692 | | JSON_HEDLEY_GCC_VERSION_CHECK(3,0,0) || \ |
1693 | | JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ |
1694 | | (JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,15,0) && defined(__cplusplus)) || \ |
1695 | | JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ |
1696 | | JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \ |
1697 | | JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \ |
1698 | | JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,7,0) || \ |
1699 | | JSON_HEDLEY_TI_CL430_VERSION_CHECK(3,1,0) || \ |
1700 | | JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,1,0) || \ |
1701 | | JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6,1,0) || \ |
1702 | | JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ |
1703 | | JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \ |
1704 | | JSON_HEDLEY_TINYC_VERSION_CHECK(0,9,27) || \ |
1705 | | JSON_HEDLEY_CRAY_VERSION_CHECK(8,1,0) || \ |
1706 | | JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) |
1707 | | # define JSON_HEDLEY_PREDICT(expr, expected, probability) \ |
1708 | | (((probability) >= 0.9) ? __builtin_expect((expr), (expected)) : (JSON_HEDLEY_STATIC_CAST(void, expected), (expr))) |
1709 | | # define JSON_HEDLEY_PREDICT_TRUE(expr, probability) \ |
1710 | | (__extension__ ({ \ |
1711 | | double hedley_probability_ = (probability); \ |
1712 | | ((hedley_probability_ >= 0.9) ? __builtin_expect(!!(expr), 1) : ((hedley_probability_ <= 0.1) ? __builtin_expect(!!(expr), 0) : !!(expr))); \ |
1713 | | })) |
1714 | | # define JSON_HEDLEY_PREDICT_FALSE(expr, probability) \ |
1715 | | (__extension__ ({ \ |
1716 | | double hedley_probability_ = (probability); \ |
1717 | | ((hedley_probability_ >= 0.9) ? __builtin_expect(!!(expr), 0) : ((hedley_probability_ <= 0.1) ? __builtin_expect(!!(expr), 1) : !!(expr))); \ |
1718 | | })) |
1719 | | # define JSON_HEDLEY_LIKELY(expr) __builtin_expect(!!(expr), 1) |
1720 | | # define JSON_HEDLEY_UNLIKELY(expr) __builtin_expect(!!(expr), 0) |
1721 | | #else |
1722 | | # define JSON_HEDLEY_PREDICT(expr, expected, probability) (JSON_HEDLEY_STATIC_CAST(void, expected), (expr)) |
1723 | | # define JSON_HEDLEY_PREDICT_TRUE(expr, probability) (!!(expr)) |
1724 | | # define JSON_HEDLEY_PREDICT_FALSE(expr, probability) (!!(expr)) |
1725 | | # define JSON_HEDLEY_LIKELY(expr) (!!(expr)) |
1726 | | # define JSON_HEDLEY_UNLIKELY(expr) (!!(expr)) |
1727 | | #endif |
1728 | | #if !defined(JSON_HEDLEY_UNPREDICTABLE) |
1729 | | #define JSON_HEDLEY_UNPREDICTABLE(expr) JSON_HEDLEY_PREDICT(expr, 1, 0.5) |
1730 | | #endif |
1731 | | |
1732 | | #if defined(JSON_HEDLEY_MALLOC) |
1733 | | #undef JSON_HEDLEY_MALLOC |
1734 | | #endif |
1735 | | #if \ |
1736 | | JSON_HEDLEY_HAS_ATTRIBUTE(malloc) || \ |
1737 | | JSON_HEDLEY_GCC_VERSION_CHECK(3,1,0) || \ |
1738 | | JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ |
1739 | | JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \ |
1740 | | JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ |
1741 | | JSON_HEDLEY_IBM_VERSION_CHECK(12,1,0) || \ |
1742 | | JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \ |
1743 | | (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ |
1744 | | JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \ |
1745 | | (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ |
1746 | | JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \ |
1747 | | (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ |
1748 | | JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \ |
1749 | | (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ |
1750 | | JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \ |
1751 | | JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ |
1752 | | JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \ |
1753 | | JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) |
1754 | | #define JSON_HEDLEY_MALLOC __attribute__((__malloc__)) |
1755 | | #elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0) |
1756 | | #define JSON_HEDLEY_MALLOC _Pragma("returns_new_memory") |
1757 | | #elif \ |
1758 | | JSON_HEDLEY_MSVC_VERSION_CHECK(14,0,0) || \ |
1759 | | JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) |
1760 | | #define JSON_HEDLEY_MALLOC __declspec(restrict) |
1761 | | #else |
1762 | | #define JSON_HEDLEY_MALLOC |
1763 | | #endif |
1764 | | |
1765 | | #if defined(JSON_HEDLEY_PURE) |
1766 | | #undef JSON_HEDLEY_PURE |
1767 | | #endif |
1768 | | #if \ |
1769 | | JSON_HEDLEY_HAS_ATTRIBUTE(pure) || \ |
1770 | | JSON_HEDLEY_GCC_VERSION_CHECK(2,96,0) || \ |
1771 | | JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ |
1772 | | JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \ |
1773 | | JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ |
1774 | | JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \ |
1775 | | JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \ |
1776 | | (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ |
1777 | | JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \ |
1778 | | (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ |
1779 | | JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \ |
1780 | | (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ |
1781 | | JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \ |
1782 | | (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ |
1783 | | JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \ |
1784 | | JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ |
1785 | | JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \ |
1786 | | JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) || \ |
1787 | | JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) |
1788 | | # define JSON_HEDLEY_PURE __attribute__((__pure__)) |
1789 | | #elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0) |
1790 | | # define JSON_HEDLEY_PURE _Pragma("does_not_write_global_data") |
1791 | | #elif defined(__cplusplus) && \ |
1792 | | ( \ |
1793 | | JSON_HEDLEY_TI_CL430_VERSION_CHECK(2,0,1) || \ |
1794 | | JSON_HEDLEY_TI_CL6X_VERSION_CHECK(4,0,0) || \ |
1795 | | JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) \ |
1796 | | ) |
1797 | | # define JSON_HEDLEY_PURE _Pragma("FUNC_IS_PURE;") |
1798 | | #else |
1799 | | # define JSON_HEDLEY_PURE |
1800 | | #endif |
1801 | | |
1802 | | #if defined(JSON_HEDLEY_CONST) |
1803 | | #undef JSON_HEDLEY_CONST |
1804 | | #endif |
1805 | | #if \ |
1806 | | JSON_HEDLEY_HAS_ATTRIBUTE(const) || \ |
1807 | | JSON_HEDLEY_GCC_VERSION_CHECK(2,5,0) || \ |
1808 | | JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ |
1809 | | JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \ |
1810 | | JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ |
1811 | | JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \ |
1812 | | JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \ |
1813 | | (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ |
1814 | | JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \ |
1815 | | (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ |
1816 | | JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \ |
1817 | | (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ |
1818 | | JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \ |
1819 | | (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ |
1820 | | JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \ |
1821 | | JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ |
1822 | | JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \ |
1823 | | JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) || \ |
1824 | | JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) |
1825 | | #define JSON_HEDLEY_CONST __attribute__((__const__)) |
1826 | | #elif \ |
1827 | | JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0) |
1828 | | #define JSON_HEDLEY_CONST _Pragma("no_side_effect") |
1829 | | #else |
1830 | | #define JSON_HEDLEY_CONST JSON_HEDLEY_PURE |
1831 | | #endif |
1832 | | |
1833 | | #if defined(JSON_HEDLEY_RESTRICT) |
1834 | | #undef JSON_HEDLEY_RESTRICT |
1835 | | #endif |
1836 | | #if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) && !defined(__cplusplus) |
1837 | | #define JSON_HEDLEY_RESTRICT restrict |
1838 | | #elif \ |
1839 | | JSON_HEDLEY_GCC_VERSION_CHECK(3,1,0) || \ |
1840 | | JSON_HEDLEY_MSVC_VERSION_CHECK(14,0,0) || \ |
1841 | | JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ |
1842 | | JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) || \ |
1843 | | JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ |
1844 | | JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \ |
1845 | | JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) || \ |
1846 | | JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \ |
1847 | | JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,2,4) || \ |
1848 | | JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,1,0) || \ |
1849 | | JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ |
1850 | | (JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,14,0) && defined(__cplusplus)) || \ |
1851 | | JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) || \ |
1852 | | defined(__clang__) || \ |
1853 | | JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) |
1854 | | #define JSON_HEDLEY_RESTRICT __restrict |
1855 | | #elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,3,0) && !defined(__cplusplus) |
1856 | | #define JSON_HEDLEY_RESTRICT _Restrict |
1857 | | #else |
1858 | | #define JSON_HEDLEY_RESTRICT |
1859 | | #endif |
1860 | | |
1861 | | #if defined(JSON_HEDLEY_INLINE) |
1862 | | #undef JSON_HEDLEY_INLINE |
1863 | | #endif |
1864 | | #if \ |
1865 | | (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)) || \ |
1866 | | (defined(__cplusplus) && (__cplusplus >= 199711L)) |
1867 | | #define JSON_HEDLEY_INLINE inline |
1868 | | #elif \ |
1869 | | defined(JSON_HEDLEY_GCC_VERSION) || \ |
1870 | | JSON_HEDLEY_ARM_VERSION_CHECK(6,2,0) |
1871 | | #define JSON_HEDLEY_INLINE __inline__ |
1872 | | #elif \ |
1873 | | JSON_HEDLEY_MSVC_VERSION_CHECK(12,0,0) || \ |
1874 | | JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) || \ |
1875 | | JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ |
1876 | | JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,1,0) || \ |
1877 | | JSON_HEDLEY_TI_CL430_VERSION_CHECK(3,1,0) || \ |
1878 | | JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,2,0) || \ |
1879 | | JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,0,0) || \ |
1880 | | JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ |
1881 | | JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \ |
1882 | | JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) |
1883 | | #define JSON_HEDLEY_INLINE __inline |
1884 | | #else |
1885 | | #define JSON_HEDLEY_INLINE |
1886 | | #endif |
1887 | | |
1888 | | #if defined(JSON_HEDLEY_ALWAYS_INLINE) |
1889 | | #undef JSON_HEDLEY_ALWAYS_INLINE |
1890 | | #endif |
1891 | | #if \ |
1892 | | JSON_HEDLEY_HAS_ATTRIBUTE(always_inline) || \ |
1893 | | JSON_HEDLEY_GCC_VERSION_CHECK(4,0,0) || \ |
1894 | | JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ |
1895 | | JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \ |
1896 | | JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ |
1897 | | JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \ |
1898 | | JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \ |
1899 | | (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ |
1900 | | JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \ |
1901 | | (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ |
1902 | | JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \ |
1903 | | (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ |
1904 | | JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \ |
1905 | | (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ |
1906 | | JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \ |
1907 | | JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ |
1908 | | JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \ |
1909 | | JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) || \ |
1910 | | JSON_HEDLEY_IAR_VERSION_CHECK(8,10,0) |
1911 | | # define JSON_HEDLEY_ALWAYS_INLINE __attribute__((__always_inline__)) JSON_HEDLEY_INLINE |
1912 | | #elif \ |
1913 | | JSON_HEDLEY_MSVC_VERSION_CHECK(12,0,0) || \ |
1914 | | JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) |
1915 | | # define JSON_HEDLEY_ALWAYS_INLINE __forceinline |
1916 | | #elif defined(__cplusplus) && \ |
1917 | | ( \ |
1918 | | JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \ |
1919 | | JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \ |
1920 | | JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \ |
1921 | | JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6,1,0) || \ |
1922 | | JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ |
1923 | | JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) \ |
1924 | | ) |
1925 | | # define JSON_HEDLEY_ALWAYS_INLINE _Pragma("FUNC_ALWAYS_INLINE;") |
1926 | | #elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) |
1927 | | # define JSON_HEDLEY_ALWAYS_INLINE _Pragma("inline=forced") |
1928 | | #else |
1929 | | # define JSON_HEDLEY_ALWAYS_INLINE JSON_HEDLEY_INLINE |
1930 | | #endif |
1931 | | |
1932 | | #if defined(JSON_HEDLEY_NEVER_INLINE) |
1933 | | #undef JSON_HEDLEY_NEVER_INLINE |
1934 | | #endif |
1935 | | #if \ |
1936 | | JSON_HEDLEY_HAS_ATTRIBUTE(noinline) || \ |
1937 | | JSON_HEDLEY_GCC_VERSION_CHECK(4,0,0) || \ |
1938 | | JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ |
1939 | | JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \ |
1940 | | JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ |
1941 | | JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \ |
1942 | | JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \ |
1943 | | (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ |
1944 | | JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \ |
1945 | | (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ |
1946 | | JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \ |
1947 | | (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ |
1948 | | JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \ |
1949 | | (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ |
1950 | | JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \ |
1951 | | JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ |
1952 | | JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \ |
1953 | | JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) || \ |
1954 | | JSON_HEDLEY_IAR_VERSION_CHECK(8,10,0) |
1955 | | #define JSON_HEDLEY_NEVER_INLINE __attribute__((__noinline__)) |
1956 | | #elif \ |
1957 | | JSON_HEDLEY_MSVC_VERSION_CHECK(13,10,0) || \ |
1958 | | JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) |
1959 | | #define JSON_HEDLEY_NEVER_INLINE __declspec(noinline) |
1960 | | #elif JSON_HEDLEY_PGI_VERSION_CHECK(10,2,0) |
1961 | | #define JSON_HEDLEY_NEVER_INLINE _Pragma("noinline") |
1962 | | #elif JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6,0,0) && defined(__cplusplus) |
1963 | | #define JSON_HEDLEY_NEVER_INLINE _Pragma("FUNC_CANNOT_INLINE;") |
1964 | | #elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) |
1965 | | #define JSON_HEDLEY_NEVER_INLINE _Pragma("inline=never") |
1966 | | #elif JSON_HEDLEY_COMPCERT_VERSION_CHECK(3,2,0) |
1967 | | #define JSON_HEDLEY_NEVER_INLINE __attribute((noinline)) |
1968 | | #elif JSON_HEDLEY_PELLES_VERSION_CHECK(9,0,0) |
1969 | | #define JSON_HEDLEY_NEVER_INLINE __declspec(noinline) |
1970 | | #else |
1971 | | #define JSON_HEDLEY_NEVER_INLINE |
1972 | | #endif |
1973 | | |
1974 | | #if defined(JSON_HEDLEY_PRIVATE) |
1975 | | #undef JSON_HEDLEY_PRIVATE |
1976 | | #endif |
1977 | | #if defined(JSON_HEDLEY_PUBLIC) |
1978 | | #undef JSON_HEDLEY_PUBLIC |
1979 | | #endif |
1980 | | #if defined(JSON_HEDLEY_IMPORT) |
1981 | | #undef JSON_HEDLEY_IMPORT |
1982 | | #endif |
1983 | | #if defined(_WIN32) || defined(__CYGWIN__) |
1984 | | # define JSON_HEDLEY_PRIVATE |
1985 | | # define JSON_HEDLEY_PUBLIC __declspec(dllexport) |
1986 | | # define JSON_HEDLEY_IMPORT __declspec(dllimport) |
1987 | | #else |
1988 | | # if \ |
1989 | | JSON_HEDLEY_HAS_ATTRIBUTE(visibility) || \ |
1990 | | JSON_HEDLEY_GCC_VERSION_CHECK(3,3,0) || \ |
1991 | | JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \ |
1992 | | JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ |
1993 | | JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ |
1994 | | JSON_HEDLEY_IBM_VERSION_CHECK(13,1,0) || \ |
1995 | | ( \ |
1996 | | defined(__TI_EABI__) && \ |
1997 | | ( \ |
1998 | | (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ |
1999 | | JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) \ |
2000 | | ) \ |
2001 | | ) || \ |
2002 | | JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) |
2003 | | # define JSON_HEDLEY_PRIVATE __attribute__((__visibility__("hidden"))) |
2004 | | # define JSON_HEDLEY_PUBLIC __attribute__((__visibility__("default"))) |
2005 | | # else |
2006 | | # define JSON_HEDLEY_PRIVATE |
2007 | | # define JSON_HEDLEY_PUBLIC |
2008 | | # endif |
2009 | | # define JSON_HEDLEY_IMPORT extern |
2010 | | #endif |
2011 | | |
2012 | | #if defined(JSON_HEDLEY_NO_THROW) |
2013 | | #undef JSON_HEDLEY_NO_THROW |
2014 | | #endif |
2015 | | #if \ |
2016 | | JSON_HEDLEY_HAS_ATTRIBUTE(nothrow) || \ |
2017 | | JSON_HEDLEY_GCC_VERSION_CHECK(3,3,0) || \ |
2018 | | JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ |
2019 | | JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) |
2020 | | #define JSON_HEDLEY_NO_THROW __attribute__((__nothrow__)) |
2021 | | #elif \ |
2022 | | JSON_HEDLEY_MSVC_VERSION_CHECK(13,1,0) || \ |
2023 | | JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) || \ |
2024 | | JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) |
2025 | | #define JSON_HEDLEY_NO_THROW __declspec(nothrow) |
2026 | | #else |
2027 | | #define JSON_HEDLEY_NO_THROW |
2028 | | #endif |
2029 | | |
2030 | | #if defined(JSON_HEDLEY_FALL_THROUGH) |
2031 | | #undef JSON_HEDLEY_FALL_THROUGH |
2032 | | #endif |
2033 | | #if \ |
2034 | | JSON_HEDLEY_HAS_ATTRIBUTE(fallthrough) || \ |
2035 | | JSON_HEDLEY_GCC_VERSION_CHECK(7,0,0) || \ |
2036 | | JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) |
2037 | | #define JSON_HEDLEY_FALL_THROUGH __attribute__((__fallthrough__)) |
2038 | | #elif JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS(clang,fallthrough) |
2039 | | #define JSON_HEDLEY_FALL_THROUGH JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[clang::fallthrough]]) |
2040 | | #elif JSON_HEDLEY_HAS_CPP_ATTRIBUTE(fallthrough) |
2041 | | #define JSON_HEDLEY_FALL_THROUGH JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[fallthrough]]) |
2042 | | #elif defined(__fallthrough) /* SAL */ |
2043 | | #define JSON_HEDLEY_FALL_THROUGH __fallthrough |
2044 | | #else |
2045 | | #define JSON_HEDLEY_FALL_THROUGH |
2046 | | #endif |
2047 | | |
2048 | | #if defined(JSON_HEDLEY_RETURNS_NON_NULL) |
2049 | | #undef JSON_HEDLEY_RETURNS_NON_NULL |
2050 | | #endif |
2051 | | #if \ |
2052 | | JSON_HEDLEY_HAS_ATTRIBUTE(returns_nonnull) || \ |
2053 | | JSON_HEDLEY_GCC_VERSION_CHECK(4,9,0) || \ |
2054 | | JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) |
2055 | | #define JSON_HEDLEY_RETURNS_NON_NULL __attribute__((__returns_nonnull__)) |
2056 | | #elif defined(_Ret_notnull_) /* SAL */ |
2057 | | #define JSON_HEDLEY_RETURNS_NON_NULL _Ret_notnull_ |
2058 | | #else |
2059 | | #define JSON_HEDLEY_RETURNS_NON_NULL |
2060 | | #endif |
2061 | | |
2062 | | #if defined(JSON_HEDLEY_ARRAY_PARAM) |
2063 | | #undef JSON_HEDLEY_ARRAY_PARAM |
2064 | | #endif |
2065 | | #if \ |
2066 | | defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) && \ |
2067 | | !defined(__STDC_NO_VLA__) && \ |
2068 | | !defined(__cplusplus) && \ |
2069 | | !defined(JSON_HEDLEY_PGI_VERSION) && \ |
2070 | | !defined(JSON_HEDLEY_TINYC_VERSION) |
2071 | | #define JSON_HEDLEY_ARRAY_PARAM(name) (name) |
2072 | | #else |
2073 | | #define JSON_HEDLEY_ARRAY_PARAM(name) |
2074 | | #endif |
2075 | | |
2076 | | #if defined(JSON_HEDLEY_IS_CONSTANT) |
2077 | | #undef JSON_HEDLEY_IS_CONSTANT |
2078 | | #endif |
2079 | | #if defined(JSON_HEDLEY_REQUIRE_CONSTEXPR) |
2080 | | #undef JSON_HEDLEY_REQUIRE_CONSTEXPR |
2081 | | #endif |
2082 | | /* JSON_HEDLEY_IS_CONSTEXPR_ is for |
2083 | | HEDLEY INTERNAL USE ONLY. API subject to change without notice. */ |
2084 | | #if defined(JSON_HEDLEY_IS_CONSTEXPR_) |
2085 | | #undef JSON_HEDLEY_IS_CONSTEXPR_ |
2086 | | #endif |
2087 | | #if \ |
2088 | | JSON_HEDLEY_HAS_BUILTIN(__builtin_constant_p) || \ |
2089 | | JSON_HEDLEY_GCC_VERSION_CHECK(3,4,0) || \ |
2090 | | JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ |
2091 | | JSON_HEDLEY_TINYC_VERSION_CHECK(0,9,19) || \ |
2092 | | JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ |
2093 | | JSON_HEDLEY_IBM_VERSION_CHECK(13,1,0) || \ |
2094 | | JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6,1,0) || \ |
2095 | | (JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0) && !defined(__cplusplus)) || \ |
2096 | | JSON_HEDLEY_CRAY_VERSION_CHECK(8,1,0) || \ |
2097 | | JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) |
2098 | | #define JSON_HEDLEY_IS_CONSTANT(expr) __builtin_constant_p(expr) |
2099 | | #endif |
2100 | | #if !defined(__cplusplus) |
2101 | | # if \ |
2102 | | JSON_HEDLEY_HAS_BUILTIN(__builtin_types_compatible_p) || \ |
2103 | | JSON_HEDLEY_GCC_VERSION_CHECK(3,4,0) || \ |
2104 | | JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ |
2105 | | JSON_HEDLEY_IBM_VERSION_CHECK(13,1,0) || \ |
2106 | | JSON_HEDLEY_CRAY_VERSION_CHECK(8,1,0) || \ |
2107 | | JSON_HEDLEY_ARM_VERSION_CHECK(5,4,0) || \ |
2108 | | JSON_HEDLEY_TINYC_VERSION_CHECK(0,9,24) |
2109 | | #if defined(__INTPTR_TYPE__) |
2110 | | #define JSON_HEDLEY_IS_CONSTEXPR_(expr) __builtin_types_compatible_p(__typeof__((1 ? (void*) ((__INTPTR_TYPE__) ((expr) * 0)) : (int*) 0)), int*) |
2111 | | #else |
2112 | | #include <stdint.h> |
2113 | | #define JSON_HEDLEY_IS_CONSTEXPR_(expr) __builtin_types_compatible_p(__typeof__((1 ? (void*) ((intptr_t) ((expr) * 0)) : (int*) 0)), int*) |
2114 | | #endif |
2115 | | # elif \ |
2116 | | ( \ |
2117 | | defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L) && \ |
2118 | | !defined(JSON_HEDLEY_SUNPRO_VERSION) && \ |
2119 | | !defined(JSON_HEDLEY_PGI_VERSION) && \ |
2120 | | !defined(JSON_HEDLEY_IAR_VERSION)) || \ |
2121 | | (JSON_HEDLEY_HAS_EXTENSION(c_generic_selections) && !defined(JSON_HEDLEY_IAR_VERSION)) || \ |
2122 | | JSON_HEDLEY_GCC_VERSION_CHECK(4,9,0) || \ |
2123 | | JSON_HEDLEY_INTEL_VERSION_CHECK(17,0,0) || \ |
2124 | | JSON_HEDLEY_IBM_VERSION_CHECK(12,1,0) || \ |
2125 | | JSON_HEDLEY_ARM_VERSION_CHECK(5,3,0) |
2126 | | #if defined(__INTPTR_TYPE__) |
2127 | | #define JSON_HEDLEY_IS_CONSTEXPR_(expr) _Generic((1 ? (void*) ((__INTPTR_TYPE__) ((expr) * 0)) : (int*) 0), int*: 1, void*: 0) |
2128 | | #else |
2129 | | #include <stdint.h> |
2130 | | #define JSON_HEDLEY_IS_CONSTEXPR_(expr) _Generic((1 ? (void*) ((intptr_t) * 0) : (int*) 0), int*: 1, void*: 0) |
2131 | | #endif |
2132 | | # elif \ |
2133 | | defined(JSON_HEDLEY_GCC_VERSION) || \ |
2134 | | defined(JSON_HEDLEY_INTEL_VERSION) || \ |
2135 | | defined(JSON_HEDLEY_TINYC_VERSION) || \ |
2136 | | defined(JSON_HEDLEY_TI_ARMCL_VERSION) || \ |
2137 | | JSON_HEDLEY_TI_CL430_VERSION_CHECK(18,12,0) || \ |
2138 | | defined(JSON_HEDLEY_TI_CL2000_VERSION) || \ |
2139 | | defined(JSON_HEDLEY_TI_CL6X_VERSION) || \ |
2140 | | defined(JSON_HEDLEY_TI_CL7X_VERSION) || \ |
2141 | | defined(JSON_HEDLEY_TI_CLPRU_VERSION) || \ |
2142 | | defined(__clang__) |
2143 | | # define JSON_HEDLEY_IS_CONSTEXPR_(expr) ( \ |
2144 | | sizeof(void) != \ |
2145 | | sizeof(*( \ |
2146 | | 1 ? \ |
2147 | | ((void*) ((expr) * 0L) ) : \ |
2148 | | ((struct { char v[sizeof(void) * 2]; } *) 1) \ |
2149 | | ) \ |
2150 | | ) \ |
2151 | | ) |
2152 | | # endif |
2153 | | #endif |
2154 | | #if defined(JSON_HEDLEY_IS_CONSTEXPR_) |
2155 | | #if !defined(JSON_HEDLEY_IS_CONSTANT) |
2156 | | #define JSON_HEDLEY_IS_CONSTANT(expr) JSON_HEDLEY_IS_CONSTEXPR_(expr) |
2157 | | #endif |
2158 | | #define JSON_HEDLEY_REQUIRE_CONSTEXPR(expr) (JSON_HEDLEY_IS_CONSTEXPR_(expr) ? (expr) : (-1)) |
2159 | | #else |
2160 | | #if !defined(JSON_HEDLEY_IS_CONSTANT) |
2161 | | #define JSON_HEDLEY_IS_CONSTANT(expr) (0) |
2162 | | #endif |
2163 | | #define JSON_HEDLEY_REQUIRE_CONSTEXPR(expr) (expr) |
2164 | | #endif |
2165 | | |
2166 | | #if defined(JSON_HEDLEY_BEGIN_C_DECLS) |
2167 | | #undef JSON_HEDLEY_BEGIN_C_DECLS |
2168 | | #endif |
2169 | | #if defined(JSON_HEDLEY_END_C_DECLS) |
2170 | | #undef JSON_HEDLEY_END_C_DECLS |
2171 | | #endif |
2172 | | #if defined(JSON_HEDLEY_C_DECL) |
2173 | | #undef JSON_HEDLEY_C_DECL |
2174 | | #endif |
2175 | | #if defined(__cplusplus) |
2176 | | #define JSON_HEDLEY_BEGIN_C_DECLS extern "C" { |
2177 | | #define JSON_HEDLEY_END_C_DECLS } |
2178 | | #define JSON_HEDLEY_C_DECL extern "C" |
2179 | | #else |
2180 | | #define JSON_HEDLEY_BEGIN_C_DECLS |
2181 | | #define JSON_HEDLEY_END_C_DECLS |
2182 | | #define JSON_HEDLEY_C_DECL |
2183 | | #endif |
2184 | | |
2185 | | #if defined(JSON_HEDLEY_STATIC_ASSERT) |
2186 | | #undef JSON_HEDLEY_STATIC_ASSERT |
2187 | | #endif |
2188 | | #if \ |
2189 | | !defined(__cplusplus) && ( \ |
2190 | | (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L)) || \ |
2191 | | (JSON_HEDLEY_HAS_FEATURE(c_static_assert) && !defined(JSON_HEDLEY_INTEL_CL_VERSION)) || \ |
2192 | | JSON_HEDLEY_GCC_VERSION_CHECK(6,0,0) || \ |
2193 | | JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ |
2194 | | defined(_Static_assert) \ |
2195 | | ) |
2196 | | # define JSON_HEDLEY_STATIC_ASSERT(expr, message) _Static_assert(expr, message) |
2197 | | #elif \ |
2198 | | (defined(__cplusplus) && (__cplusplus >= 201103L)) || \ |
2199 | | JSON_HEDLEY_MSVC_VERSION_CHECK(16,0,0) || \ |
2200 | | JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) |
2201 | | # define JSON_HEDLEY_STATIC_ASSERT(expr, message) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(static_assert(expr, message)) |
2202 | | #else |
2203 | | # define JSON_HEDLEY_STATIC_ASSERT(expr, message) |
2204 | | #endif |
2205 | | |
2206 | | #if defined(JSON_HEDLEY_NULL) |
2207 | | #undef JSON_HEDLEY_NULL |
2208 | | #endif |
2209 | | #if defined(__cplusplus) |
2210 | | #if __cplusplus >= 201103L |
2211 | | #define JSON_HEDLEY_NULL JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(nullptr) |
2212 | | #elif defined(NULL) |
2213 | | #define JSON_HEDLEY_NULL NULL |
2214 | | #else |
2215 | | #define JSON_HEDLEY_NULL JSON_HEDLEY_STATIC_CAST(void*, 0) |
2216 | | #endif |
2217 | | #elif defined(NULL) |
2218 | | #define JSON_HEDLEY_NULL NULL |
2219 | | #else |
2220 | | #define JSON_HEDLEY_NULL ((void*) 0) |
2221 | | #endif |
2222 | | |
2223 | | #if defined(JSON_HEDLEY_MESSAGE) |
2224 | | #undef JSON_HEDLEY_MESSAGE |
2225 | | #endif |
2226 | | #if JSON_HEDLEY_HAS_WARNING("-Wunknown-pragmas") |
2227 | | # define JSON_HEDLEY_MESSAGE(msg) \ |
2228 | | JSON_HEDLEY_DIAGNOSTIC_PUSH \ |
2229 | | JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS \ |
2230 | | JSON_HEDLEY_PRAGMA(message msg) \ |
2231 | | JSON_HEDLEY_DIAGNOSTIC_POP |
2232 | | #elif \ |
2233 | | JSON_HEDLEY_GCC_VERSION_CHECK(4,4,0) || \ |
2234 | | JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) |
2235 | | # define JSON_HEDLEY_MESSAGE(msg) JSON_HEDLEY_PRAGMA(message msg) |
2236 | | #elif JSON_HEDLEY_CRAY_VERSION_CHECK(5,0,0) |
2237 | | # define JSON_HEDLEY_MESSAGE(msg) JSON_HEDLEY_PRAGMA(_CRI message msg) |
2238 | | #elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) |
2239 | | # define JSON_HEDLEY_MESSAGE(msg) JSON_HEDLEY_PRAGMA(message(msg)) |
2240 | | #elif JSON_HEDLEY_PELLES_VERSION_CHECK(2,0,0) |
2241 | | # define JSON_HEDLEY_MESSAGE(msg) JSON_HEDLEY_PRAGMA(message(msg)) |
2242 | | #else |
2243 | | # define JSON_HEDLEY_MESSAGE(msg) |
2244 | | #endif |
2245 | | |
2246 | | #if defined(JSON_HEDLEY_WARNING) |
2247 | | #undef JSON_HEDLEY_WARNING |
2248 | | #endif |
2249 | | #if JSON_HEDLEY_HAS_WARNING("-Wunknown-pragmas") |
2250 | | # define JSON_HEDLEY_WARNING(msg) \ |
2251 | | JSON_HEDLEY_DIAGNOSTIC_PUSH \ |
2252 | | JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS \ |
2253 | | JSON_HEDLEY_PRAGMA(clang warning msg) \ |
2254 | | JSON_HEDLEY_DIAGNOSTIC_POP |
2255 | | #elif \ |
2256 | | JSON_HEDLEY_GCC_VERSION_CHECK(4,8,0) || \ |
2257 | | JSON_HEDLEY_PGI_VERSION_CHECK(18,4,0) || \ |
2258 | | JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) |
2259 | | # define JSON_HEDLEY_WARNING(msg) JSON_HEDLEY_PRAGMA(GCC warning msg) |
2260 | | #elif \ |
2261 | | JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0) || \ |
2262 | | JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) |
2263 | | # define JSON_HEDLEY_WARNING(msg) JSON_HEDLEY_PRAGMA(message(msg)) |
2264 | | #else |
2265 | | # define JSON_HEDLEY_WARNING(msg) JSON_HEDLEY_MESSAGE(msg) |
2266 | | #endif |
2267 | | |
2268 | | #if defined(JSON_HEDLEY_REQUIRE) |
2269 | | #undef JSON_HEDLEY_REQUIRE |
2270 | | #endif |
2271 | | #if defined(JSON_HEDLEY_REQUIRE_MSG) |
2272 | | #undef JSON_HEDLEY_REQUIRE_MSG |
2273 | | #endif |
2274 | | #if JSON_HEDLEY_HAS_ATTRIBUTE(diagnose_if) |
2275 | | # if JSON_HEDLEY_HAS_WARNING("-Wgcc-compat") |
2276 | | # define JSON_HEDLEY_REQUIRE(expr) \ |
2277 | | JSON_HEDLEY_DIAGNOSTIC_PUSH \ |
2278 | | _Pragma("clang diagnostic ignored \"-Wgcc-compat\"") \ |
2279 | | __attribute__((diagnose_if(!(expr), #expr, "error"))) \ |
2280 | | JSON_HEDLEY_DIAGNOSTIC_POP |
2281 | | # define JSON_HEDLEY_REQUIRE_MSG(expr,msg) \ |
2282 | | JSON_HEDLEY_DIAGNOSTIC_PUSH \ |
2283 | | _Pragma("clang diagnostic ignored \"-Wgcc-compat\"") \ |
2284 | | __attribute__((diagnose_if(!(expr), msg, "error"))) \ |
2285 | | JSON_HEDLEY_DIAGNOSTIC_POP |
2286 | | # else |
2287 | | # define JSON_HEDLEY_REQUIRE(expr) __attribute__((diagnose_if(!(expr), #expr, "error"))) |
2288 | | # define JSON_HEDLEY_REQUIRE_MSG(expr,msg) __attribute__((diagnose_if(!(expr), msg, "error"))) |
2289 | | # endif |
2290 | | #else |
2291 | | # define JSON_HEDLEY_REQUIRE(expr) |
2292 | | # define JSON_HEDLEY_REQUIRE_MSG(expr,msg) |
2293 | | #endif |
2294 | | |
2295 | | #if defined(JSON_HEDLEY_FLAGS) |
2296 | | #undef JSON_HEDLEY_FLAGS |
2297 | | #endif |
2298 | | #if JSON_HEDLEY_HAS_ATTRIBUTE(flag_enum) && (!defined(__cplusplus) || JSON_HEDLEY_HAS_WARNING("-Wbitfield-enum-conversion")) |
2299 | | #define JSON_HEDLEY_FLAGS __attribute__((__flag_enum__)) |
2300 | | #else |
2301 | | #define JSON_HEDLEY_FLAGS |
2302 | | #endif |
2303 | | |
2304 | | #if defined(JSON_HEDLEY_FLAGS_CAST) |
2305 | | #undef JSON_HEDLEY_FLAGS_CAST |
2306 | | #endif |
2307 | | #if JSON_HEDLEY_INTEL_VERSION_CHECK(19,0,0) |
2308 | | # define JSON_HEDLEY_FLAGS_CAST(T, expr) (__extension__ ({ \ |
2309 | | JSON_HEDLEY_DIAGNOSTIC_PUSH \ |
2310 | | _Pragma("warning(disable:188)") \ |
2311 | | ((T) (expr)); \ |
2312 | | JSON_HEDLEY_DIAGNOSTIC_POP \ |
2313 | | })) |
2314 | | #else |
2315 | | # define JSON_HEDLEY_FLAGS_CAST(T, expr) JSON_HEDLEY_STATIC_CAST(T, expr) |
2316 | | #endif |
2317 | | |
2318 | | #if defined(JSON_HEDLEY_EMPTY_BASES) |
2319 | | #undef JSON_HEDLEY_EMPTY_BASES |
2320 | | #endif |
2321 | | #if \ |
2322 | | (JSON_HEDLEY_MSVC_VERSION_CHECK(19,0,23918) && !JSON_HEDLEY_MSVC_VERSION_CHECK(20,0,0)) || \ |
2323 | | JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) |
2324 | | #define JSON_HEDLEY_EMPTY_BASES __declspec(empty_bases) |
2325 | | #else |
2326 | | #define JSON_HEDLEY_EMPTY_BASES |
2327 | | #endif |
2328 | | |
2329 | | /* Remaining macros are deprecated. */ |
2330 | | |
2331 | | #if defined(JSON_HEDLEY_GCC_NOT_CLANG_VERSION_CHECK) |
2332 | | #undef JSON_HEDLEY_GCC_NOT_CLANG_VERSION_CHECK |
2333 | | #endif |
2334 | | #if defined(__clang__) |
2335 | | #define JSON_HEDLEY_GCC_NOT_CLANG_VERSION_CHECK(major,minor,patch) (0) |
2336 | | #else |
2337 | | #define JSON_HEDLEY_GCC_NOT_CLANG_VERSION_CHECK(major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) |
2338 | | #endif |
2339 | | |
2340 | | #if defined(JSON_HEDLEY_CLANG_HAS_ATTRIBUTE) |
2341 | | #undef JSON_HEDLEY_CLANG_HAS_ATTRIBUTE |
2342 | | #endif |
2343 | | #define JSON_HEDLEY_CLANG_HAS_ATTRIBUTE(attribute) JSON_HEDLEY_HAS_ATTRIBUTE(attribute) |
2344 | | |
2345 | | #if defined(JSON_HEDLEY_CLANG_HAS_CPP_ATTRIBUTE) |
2346 | | #undef JSON_HEDLEY_CLANG_HAS_CPP_ATTRIBUTE |
2347 | | #endif |
2348 | | #define JSON_HEDLEY_CLANG_HAS_CPP_ATTRIBUTE(attribute) JSON_HEDLEY_HAS_CPP_ATTRIBUTE(attribute) |
2349 | | |
2350 | | #if defined(JSON_HEDLEY_CLANG_HAS_BUILTIN) |
2351 | | #undef JSON_HEDLEY_CLANG_HAS_BUILTIN |
2352 | | #endif |
2353 | | #define JSON_HEDLEY_CLANG_HAS_BUILTIN(builtin) JSON_HEDLEY_HAS_BUILTIN(builtin) |
2354 | | |
2355 | | #if defined(JSON_HEDLEY_CLANG_HAS_FEATURE) |
2356 | | #undef JSON_HEDLEY_CLANG_HAS_FEATURE |
2357 | | #endif |
2358 | | #define JSON_HEDLEY_CLANG_HAS_FEATURE(feature) JSON_HEDLEY_HAS_FEATURE(feature) |
2359 | | |
2360 | | #if defined(JSON_HEDLEY_CLANG_HAS_EXTENSION) |
2361 | | #undef JSON_HEDLEY_CLANG_HAS_EXTENSION |
2362 | | #endif |
2363 | | #define JSON_HEDLEY_CLANG_HAS_EXTENSION(extension) JSON_HEDLEY_HAS_EXTENSION(extension) |
2364 | | |
2365 | | #if defined(JSON_HEDLEY_CLANG_HAS_DECLSPEC_DECLSPEC_ATTRIBUTE) |
2366 | | #undef JSON_HEDLEY_CLANG_HAS_DECLSPEC_DECLSPEC_ATTRIBUTE |
2367 | | #endif |
2368 | | #define JSON_HEDLEY_CLANG_HAS_DECLSPEC_ATTRIBUTE(attribute) JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE(attribute) |
2369 | | |
2370 | | #if defined(JSON_HEDLEY_CLANG_HAS_WARNING) |
2371 | | #undef JSON_HEDLEY_CLANG_HAS_WARNING |
2372 | | #endif |
2373 | | #define JSON_HEDLEY_CLANG_HAS_WARNING(warning) JSON_HEDLEY_HAS_WARNING(warning) |
2374 | | |
2375 | | #endif /* !defined(JSON_HEDLEY_VERSION) || (JSON_HEDLEY_VERSION < X) */ |
2376 | | |
2377 | | |
2378 | | // This file contains all internal macro definitions (except those affecting ABI) |
2379 | | // You MUST include macro_unscope.hpp at the end of json.hpp to undef all of them |
2380 | | |
2381 | | // #include <nlohmann/detail/abi_macros.hpp> |
2382 | | |
2383 | | |
2384 | | // exclude unsupported compilers |
2385 | | #if !defined(JSON_SKIP_UNSUPPORTED_COMPILER_CHECK) |
2386 | | #if defined(__clang__) |
2387 | | #if (__clang_major__ * 10000 + __clang_minor__ * 100 + __clang_patchlevel__) < 30400 |
2388 | | #error "unsupported Clang version - see https://github.com/nlohmann/json#supported-compilers" |
2389 | | #endif |
2390 | | #elif defined(__GNUC__) && !(defined(__ICC) || defined(__INTEL_COMPILER)) |
2391 | | #if (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) < 40800 |
2392 | | #error "unsupported GCC version - see https://github.com/nlohmann/json#supported-compilers" |
2393 | | #endif |
2394 | | #endif |
2395 | | #endif |
2396 | | |
2397 | | // C++ language standard detection |
2398 | | // if the user manually specified the used C++ version, this is skipped |
2399 | | #if !defined(JSON_HAS_CPP_26) && !defined(JSON_HAS_CPP_23) && !defined(JSON_HAS_CPP_20) && !defined(JSON_HAS_CPP_17) && !defined(JSON_HAS_CPP_14) && !defined(JSON_HAS_CPP_11) |
2400 | | #if (defined(__cplusplus) && __cplusplus > 202302L) || (defined(_MSVC_LANG) && _MSVC_LANG > 202302L) |
2401 | | #define JSON_HAS_CPP_26 |
2402 | | #define JSON_HAS_CPP_23 |
2403 | | #define JSON_HAS_CPP_20 |
2404 | | #define JSON_HAS_CPP_17 |
2405 | | #define JSON_HAS_CPP_14 |
2406 | | #elif (defined(__cplusplus) && __cplusplus > 202002L) || (defined(_MSVC_LANG) && _MSVC_LANG > 202002L) |
2407 | | #define JSON_HAS_CPP_23 |
2408 | | #define JSON_HAS_CPP_20 |
2409 | | #define JSON_HAS_CPP_17 |
2410 | | #define JSON_HAS_CPP_14 |
2411 | | #elif (defined(__cplusplus) && __cplusplus > 201703L) || (defined(_MSVC_LANG) && _MSVC_LANG > 201703L) |
2412 | | #define JSON_HAS_CPP_20 |
2413 | | #define JSON_HAS_CPP_17 |
2414 | | #define JSON_HAS_CPP_14 |
2415 | | #elif (defined(__cplusplus) && __cplusplus > 201402L) || (defined(_HAS_CXX17) && _HAS_CXX17 == 1) // fix for issue #464 |
2416 | | #define JSON_HAS_CPP_17 |
2417 | | #define JSON_HAS_CPP_14 |
2418 | | #elif (defined(__cplusplus) && __cplusplus > 201103L) || (defined(_HAS_CXX14) && _HAS_CXX14 == 1) |
2419 | | #define JSON_HAS_CPP_14 |
2420 | | #endif |
2421 | | // the cpp 11 flag is always specified because it is the minimal required version |
2422 | | #define JSON_HAS_CPP_11 |
2423 | | #endif |
2424 | | |
2425 | | #ifdef __has_include |
2426 | | #if __has_include(<version>) |
2427 | | #include <version> |
2428 | | #endif |
2429 | | #endif |
2430 | | |
2431 | | #if !defined(JSON_HAS_FILESYSTEM) && !defined(JSON_HAS_EXPERIMENTAL_FILESYSTEM) |
2432 | | #ifdef JSON_HAS_CPP_17 |
2433 | | #if defined(__cpp_lib_filesystem) |
2434 | | #define JSON_HAS_FILESYSTEM 1 |
2435 | | #elif defined(__cpp_lib_experimental_filesystem) |
2436 | | #define JSON_HAS_EXPERIMENTAL_FILESYSTEM 1 |
2437 | | #elif !defined(__has_include) |
2438 | | #define JSON_HAS_EXPERIMENTAL_FILESYSTEM 1 |
2439 | | #elif __has_include(<filesystem>) |
2440 | | #define JSON_HAS_FILESYSTEM 1 |
2441 | | #elif __has_include(<experimental/filesystem>) |
2442 | | #define JSON_HAS_EXPERIMENTAL_FILESYSTEM 1 |
2443 | | #endif |
2444 | | |
2445 | | // std::filesystem does not work on MinGW GCC 8: https://sourceforge.net/p/mingw-w64/bugs/737/ |
2446 | | #if defined(__MINGW32__) && defined(__GNUC__) && __GNUC__ == 8 |
2447 | | #undef JSON_HAS_FILESYSTEM |
2448 | | #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM |
2449 | | #endif |
2450 | | |
2451 | | // no filesystem support before GCC 8: https://en.cppreference.com/w/cpp/compiler_support |
2452 | | #if defined(__GNUC__) && !defined(__clang__) && __GNUC__ < 8 |
2453 | | #undef JSON_HAS_FILESYSTEM |
2454 | | #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM |
2455 | | #endif |
2456 | | |
2457 | | // no filesystem support before Clang 7: https://en.cppreference.com/w/cpp/compiler_support |
2458 | | #if defined(__clang_major__) && __clang_major__ < 7 |
2459 | | #undef JSON_HAS_FILESYSTEM |
2460 | | #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM |
2461 | | #endif |
2462 | | |
2463 | | // no filesystem support before MSVC 19.14: https://en.cppreference.com/w/cpp/compiler_support |
2464 | | #if defined(_MSC_VER) && _MSC_VER < 1914 |
2465 | | #undef JSON_HAS_FILESYSTEM |
2466 | | #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM |
2467 | | #endif |
2468 | | |
2469 | | // no filesystem support before iOS 13 |
2470 | | #if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) && __IPHONE_OS_VERSION_MIN_REQUIRED < 130000 |
2471 | | #undef JSON_HAS_FILESYSTEM |
2472 | | #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM |
2473 | | #endif |
2474 | | |
2475 | | // no filesystem support before macOS Catalina |
2476 | | #if defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && __MAC_OS_X_VERSION_MIN_REQUIRED < 101500 |
2477 | | #undef JSON_HAS_FILESYSTEM |
2478 | | #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM |
2479 | | #endif |
2480 | | #endif |
2481 | | #endif |
2482 | | |
2483 | | #ifndef JSON_HAS_EXPERIMENTAL_FILESYSTEM |
2484 | | #define JSON_HAS_EXPERIMENTAL_FILESYSTEM 0 |
2485 | | #endif |
2486 | | |
2487 | | #ifndef JSON_HAS_FILESYSTEM |
2488 | | #define JSON_HAS_FILESYSTEM 0 |
2489 | | #endif |
2490 | | |
2491 | | #ifndef JSON_HAS_THREE_WAY_COMPARISON |
2492 | | #if defined(__cpp_impl_three_way_comparison) && __cpp_impl_three_way_comparison >= 201907L \ |
2493 | | && defined(__cpp_lib_three_way_comparison) && __cpp_lib_three_way_comparison >= 201907L |
2494 | | #define JSON_HAS_THREE_WAY_COMPARISON 1 |
2495 | | #else |
2496 | | #define JSON_HAS_THREE_WAY_COMPARISON 0 |
2497 | | #endif |
2498 | | #endif |
2499 | | |
2500 | | #ifndef JSON_HAS_RANGES |
2501 | | // ranges header shipping in GCC 11.1.0 (released 2021-04-27) has a syntax error |
2502 | | #if defined(__GLIBCXX__) && __GLIBCXX__ == 20210427 |
2503 | | #define JSON_HAS_RANGES 0 |
2504 | | #elif defined(__cpp_lib_ranges) |
2505 | | #define JSON_HAS_RANGES 1 |
2506 | | #else |
2507 | | #define JSON_HAS_RANGES 0 |
2508 | | #endif |
2509 | | #endif |
2510 | | |
2511 | | #ifndef JSON_HAS_STATIC_RTTI |
2512 | | #if !defined(_HAS_STATIC_RTTI) || _HAS_STATIC_RTTI != 0 |
2513 | | #define JSON_HAS_STATIC_RTTI 1 |
2514 | | #else |
2515 | | #define JSON_HAS_STATIC_RTTI 0 |
2516 | | #endif |
2517 | | #endif |
2518 | | |
2519 | | #ifdef JSON_HAS_CPP_17 |
2520 | | #define JSON_INLINE_VARIABLE inline |
2521 | | #else |
2522 | | #define JSON_INLINE_VARIABLE |
2523 | | #endif |
2524 | | |
2525 | | #if JSON_HEDLEY_HAS_ATTRIBUTE(no_unique_address) |
2526 | | #define JSON_NO_UNIQUE_ADDRESS [[no_unique_address]] |
2527 | | #else |
2528 | | #define JSON_NO_UNIQUE_ADDRESS |
2529 | | #endif |
2530 | | |
2531 | | // disable documentation warnings on clang |
2532 | | #if defined(__clang__) |
2533 | | #pragma clang diagnostic push |
2534 | | #pragma clang diagnostic ignored "-Wdocumentation" |
2535 | | #pragma clang diagnostic ignored "-Wdocumentation-unknown-command" |
2536 | | #endif |
2537 | | |
2538 | | // allow disabling exceptions |
2539 | | #if (defined(__cpp_exceptions) || defined(__EXCEPTIONS) || defined(_CPPUNWIND)) && !defined(JSON_NOEXCEPTION) |
2540 | 0 | #define JSON_THROW(exception) throw exception |
2541 | | #define JSON_TRY try |
2542 | | #define JSON_CATCH(exception) catch(exception) |
2543 | | #define JSON_INTERNAL_CATCH(exception) catch(exception) |
2544 | | #else |
2545 | | #include <cstdlib> |
2546 | | #define JSON_THROW(exception) std::abort() |
2547 | | #define JSON_TRY if(true) |
2548 | | #define JSON_CATCH(exception) if(false) |
2549 | | #define JSON_INTERNAL_CATCH(exception) if(false) |
2550 | | #endif |
2551 | | |
2552 | | // override exception macros |
2553 | | #if defined(JSON_THROW_USER) |
2554 | | #undef JSON_THROW |
2555 | | #define JSON_THROW JSON_THROW_USER |
2556 | | #endif |
2557 | | #if defined(JSON_TRY_USER) |
2558 | | #undef JSON_TRY |
2559 | | #define JSON_TRY JSON_TRY_USER |
2560 | | #endif |
2561 | | #if defined(JSON_CATCH_USER) |
2562 | | #undef JSON_CATCH |
2563 | | #define JSON_CATCH JSON_CATCH_USER |
2564 | | #undef JSON_INTERNAL_CATCH |
2565 | | #define JSON_INTERNAL_CATCH JSON_CATCH_USER |
2566 | | #endif |
2567 | | #if defined(JSON_INTERNAL_CATCH_USER) |
2568 | | #undef JSON_INTERNAL_CATCH |
2569 | | #define JSON_INTERNAL_CATCH JSON_INTERNAL_CATCH_USER |
2570 | | #endif |
2571 | | |
2572 | | // allow overriding assert |
2573 | | #if !defined(JSON_ASSERT) |
2574 | | #include <cassert> // assert |
2575 | 0 | #define JSON_ASSERT(x) assert(x) |
2576 | | #endif |
2577 | | |
2578 | | // allow accessing some private functions (needed by the test suite) |
2579 | | #if defined(JSON_TESTS_PRIVATE) |
2580 | | #define JSON_PRIVATE_UNLESS_TESTED public |
2581 | | #else |
2582 | | #define JSON_PRIVATE_UNLESS_TESTED private |
2583 | | #endif |
2584 | | |
2585 | | /*! |
2586 | | @brief macro to briefly define a mapping between an enum and JSON |
2587 | | @def NLOHMANN_JSON_SERIALIZE_ENUM |
2588 | | @since version 3.4.0 |
2589 | | */ |
2590 | | #define NLOHMANN_JSON_SERIALIZE_ENUM(ENUM_TYPE, ...) \ |
2591 | | template<typename BasicJsonType> \ |
2592 | | inline void to_json(BasicJsonType& j, const ENUM_TYPE& e) \ |
2593 | | { \ |
2594 | | /* NOLINTNEXTLINE(modernize-type-traits) we use C++11 */ \ |
2595 | | static_assert(std::is_enum<ENUM_TYPE>::value, #ENUM_TYPE " must be an enum!"); \ |
2596 | | /* NOLINTNEXTLINE(modernize-avoid-c-arrays) we don't want to depend on <array> */ \ |
2597 | | static const std::pair<ENUM_TYPE, BasicJsonType> m[] = __VA_ARGS__; \ |
2598 | | auto it = std::find_if(std::begin(m), std::end(m), \ |
2599 | | [e](const std::pair<ENUM_TYPE, BasicJsonType>& ej_pair) -> bool \ |
2600 | | { \ |
2601 | | return ej_pair.first == e; \ |
2602 | | }); \ |
2603 | | j = ((it != std::end(m)) ? it : std::begin(m))->second; \ |
2604 | | } \ |
2605 | | template<typename BasicJsonType> \ |
2606 | | inline void from_json(const BasicJsonType& j, ENUM_TYPE& e) \ |
2607 | | { \ |
2608 | | /* NOLINTNEXTLINE(modernize-type-traits) we use C++11 */ \ |
2609 | | static_assert(std::is_enum<ENUM_TYPE>::value, #ENUM_TYPE " must be an enum!"); \ |
2610 | | /* NOLINTNEXTLINE(modernize-avoid-c-arrays) we don't want to depend on <array> */ \ |
2611 | | static const std::pair<ENUM_TYPE, BasicJsonType> m[] = __VA_ARGS__; \ |
2612 | | auto it = std::find_if(std::begin(m), std::end(m), \ |
2613 | | [&j](const std::pair<ENUM_TYPE, BasicJsonType>& ej_pair) -> bool \ |
2614 | | { \ |
2615 | | return ej_pair.second == j; \ |
2616 | | }); \ |
2617 | | e = ((it != std::end(m)) ? it : std::begin(m))->first; \ |
2618 | | } |
2619 | | |
2620 | | // Ugly macros to avoid uglier copy-paste when specializing basic_json. They |
2621 | | // may be removed in the future once the class is split. |
2622 | | |
2623 | | #define NLOHMANN_BASIC_JSON_TPL_DECLARATION \ |
2624 | | template<template<typename, typename, typename...> class ObjectType, \ |
2625 | | template<typename, typename...> class ArrayType, \ |
2626 | | class StringType, class BooleanType, class NumberIntegerType, \ |
2627 | | class NumberUnsignedType, class NumberFloatType, \ |
2628 | | template<typename> class AllocatorType, \ |
2629 | | template<typename, typename = void> class JSONSerializer, \ |
2630 | | class BinaryType, \ |
2631 | | class CustomBaseClass> |
2632 | | |
2633 | | #define NLOHMANN_BASIC_JSON_TPL \ |
2634 | | basic_json<ObjectType, ArrayType, StringType, BooleanType, \ |
2635 | | NumberIntegerType, NumberUnsignedType, NumberFloatType, \ |
2636 | | AllocatorType, JSONSerializer, BinaryType, CustomBaseClass> |
2637 | | |
2638 | | // Macros to simplify conversion from/to types |
2639 | | |
2640 | | #define NLOHMANN_JSON_EXPAND( x ) x |
2641 | | #define NLOHMANN_JSON_GET_MACRO(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, _31, _32, _33, _34, _35, _36, _37, _38, _39, _40, _41, _42, _43, _44, _45, _46, _47, _48, _49, _50, _51, _52, _53, _54, _55, _56, _57, _58, _59, _60, _61, _62, _63, _64, NAME,...) NAME |
2642 | | #define NLOHMANN_JSON_PASTE(...) NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_GET_MACRO(__VA_ARGS__, \ |
2643 | | NLOHMANN_JSON_PASTE64, \ |
2644 | | NLOHMANN_JSON_PASTE63, \ |
2645 | | NLOHMANN_JSON_PASTE62, \ |
2646 | | NLOHMANN_JSON_PASTE61, \ |
2647 | | NLOHMANN_JSON_PASTE60, \ |
2648 | | NLOHMANN_JSON_PASTE59, \ |
2649 | | NLOHMANN_JSON_PASTE58, \ |
2650 | | NLOHMANN_JSON_PASTE57, \ |
2651 | | NLOHMANN_JSON_PASTE56, \ |
2652 | | NLOHMANN_JSON_PASTE55, \ |
2653 | | NLOHMANN_JSON_PASTE54, \ |
2654 | | NLOHMANN_JSON_PASTE53, \ |
2655 | | NLOHMANN_JSON_PASTE52, \ |
2656 | | NLOHMANN_JSON_PASTE51, \ |
2657 | | NLOHMANN_JSON_PASTE50, \ |
2658 | | NLOHMANN_JSON_PASTE49, \ |
2659 | | NLOHMANN_JSON_PASTE48, \ |
2660 | | NLOHMANN_JSON_PASTE47, \ |
2661 | | NLOHMANN_JSON_PASTE46, \ |
2662 | | NLOHMANN_JSON_PASTE45, \ |
2663 | | NLOHMANN_JSON_PASTE44, \ |
2664 | | NLOHMANN_JSON_PASTE43, \ |
2665 | | NLOHMANN_JSON_PASTE42, \ |
2666 | | NLOHMANN_JSON_PASTE41, \ |
2667 | | NLOHMANN_JSON_PASTE40, \ |
2668 | | NLOHMANN_JSON_PASTE39, \ |
2669 | | NLOHMANN_JSON_PASTE38, \ |
2670 | | NLOHMANN_JSON_PASTE37, \ |
2671 | | NLOHMANN_JSON_PASTE36, \ |
2672 | | NLOHMANN_JSON_PASTE35, \ |
2673 | | NLOHMANN_JSON_PASTE34, \ |
2674 | | NLOHMANN_JSON_PASTE33, \ |
2675 | | NLOHMANN_JSON_PASTE32, \ |
2676 | | NLOHMANN_JSON_PASTE31, \ |
2677 | | NLOHMANN_JSON_PASTE30, \ |
2678 | | NLOHMANN_JSON_PASTE29, \ |
2679 | | NLOHMANN_JSON_PASTE28, \ |
2680 | | NLOHMANN_JSON_PASTE27, \ |
2681 | | NLOHMANN_JSON_PASTE26, \ |
2682 | | NLOHMANN_JSON_PASTE25, \ |
2683 | | NLOHMANN_JSON_PASTE24, \ |
2684 | | NLOHMANN_JSON_PASTE23, \ |
2685 | | NLOHMANN_JSON_PASTE22, \ |
2686 | | NLOHMANN_JSON_PASTE21, \ |
2687 | | NLOHMANN_JSON_PASTE20, \ |
2688 | | NLOHMANN_JSON_PASTE19, \ |
2689 | | NLOHMANN_JSON_PASTE18, \ |
2690 | | NLOHMANN_JSON_PASTE17, \ |
2691 | | NLOHMANN_JSON_PASTE16, \ |
2692 | | NLOHMANN_JSON_PASTE15, \ |
2693 | | NLOHMANN_JSON_PASTE14, \ |
2694 | | NLOHMANN_JSON_PASTE13, \ |
2695 | | NLOHMANN_JSON_PASTE12, \ |
2696 | | NLOHMANN_JSON_PASTE11, \ |
2697 | | NLOHMANN_JSON_PASTE10, \ |
2698 | | NLOHMANN_JSON_PASTE9, \ |
2699 | | NLOHMANN_JSON_PASTE8, \ |
2700 | | NLOHMANN_JSON_PASTE7, \ |
2701 | | NLOHMANN_JSON_PASTE6, \ |
2702 | | NLOHMANN_JSON_PASTE5, \ |
2703 | | NLOHMANN_JSON_PASTE4, \ |
2704 | | NLOHMANN_JSON_PASTE3, \ |
2705 | | NLOHMANN_JSON_PASTE2, \ |
2706 | | NLOHMANN_JSON_PASTE1)(__VA_ARGS__)) |
2707 | | #define NLOHMANN_JSON_PASTE2(func, v1) func(v1) |
2708 | | #define NLOHMANN_JSON_PASTE3(func, v1, v2) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE2(func, v2) |
2709 | | #define NLOHMANN_JSON_PASTE4(func, v1, v2, v3) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE3(func, v2, v3) |
2710 | | #define NLOHMANN_JSON_PASTE5(func, v1, v2, v3, v4) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE4(func, v2, v3, v4) |
2711 | | #define NLOHMANN_JSON_PASTE6(func, v1, v2, v3, v4, v5) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE5(func, v2, v3, v4, v5) |
2712 | | #define NLOHMANN_JSON_PASTE7(func, v1, v2, v3, v4, v5, v6) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE6(func, v2, v3, v4, v5, v6) |
2713 | | #define NLOHMANN_JSON_PASTE8(func, v1, v2, v3, v4, v5, v6, v7) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE7(func, v2, v3, v4, v5, v6, v7) |
2714 | | #define NLOHMANN_JSON_PASTE9(func, v1, v2, v3, v4, v5, v6, v7, v8) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE8(func, v2, v3, v4, v5, v6, v7, v8) |
2715 | | #define NLOHMANN_JSON_PASTE10(func, v1, v2, v3, v4, v5, v6, v7, v8, v9) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE9(func, v2, v3, v4, v5, v6, v7, v8, v9) |
2716 | | #define NLOHMANN_JSON_PASTE11(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE10(func, v2, v3, v4, v5, v6, v7, v8, v9, v10) |
2717 | | #define NLOHMANN_JSON_PASTE12(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE11(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11) |
2718 | | #define NLOHMANN_JSON_PASTE13(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE12(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12) |
2719 | | #define NLOHMANN_JSON_PASTE14(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE13(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13) |
2720 | | #define NLOHMANN_JSON_PASTE15(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE14(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14) |
2721 | | #define NLOHMANN_JSON_PASTE16(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE15(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15) |
2722 | | #define NLOHMANN_JSON_PASTE17(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE16(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16) |
2723 | | #define NLOHMANN_JSON_PASTE18(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE17(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17) |
2724 | | #define NLOHMANN_JSON_PASTE19(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE18(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18) |
2725 | | #define NLOHMANN_JSON_PASTE20(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE19(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19) |
2726 | | #define NLOHMANN_JSON_PASTE21(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE20(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20) |
2727 | | #define NLOHMANN_JSON_PASTE22(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE21(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21) |
2728 | | #define NLOHMANN_JSON_PASTE23(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE22(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22) |
2729 | | #define NLOHMANN_JSON_PASTE24(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE23(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23) |
2730 | | #define NLOHMANN_JSON_PASTE25(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE24(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24) |
2731 | | #define NLOHMANN_JSON_PASTE26(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE25(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25) |
2732 | | #define NLOHMANN_JSON_PASTE27(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE26(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26) |
2733 | | #define NLOHMANN_JSON_PASTE28(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE27(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27) |
2734 | | #define NLOHMANN_JSON_PASTE29(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE28(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28) |
2735 | | #define NLOHMANN_JSON_PASTE30(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE29(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29) |
2736 | | #define NLOHMANN_JSON_PASTE31(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE30(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30) |
2737 | | #define NLOHMANN_JSON_PASTE32(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE31(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31) |
2738 | | #define NLOHMANN_JSON_PASTE33(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE32(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32) |
2739 | | #define NLOHMANN_JSON_PASTE34(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE33(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33) |
2740 | | #define NLOHMANN_JSON_PASTE35(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE34(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34) |
2741 | | #define NLOHMANN_JSON_PASTE36(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE35(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35) |
2742 | | #define NLOHMANN_JSON_PASTE37(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE36(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36) |
2743 | | #define NLOHMANN_JSON_PASTE38(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE37(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37) |
2744 | | #define NLOHMANN_JSON_PASTE39(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE38(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38) |
2745 | | #define NLOHMANN_JSON_PASTE40(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE39(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39) |
2746 | | #define NLOHMANN_JSON_PASTE41(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE40(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40) |
2747 | | #define NLOHMANN_JSON_PASTE42(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE41(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41) |
2748 | | #define NLOHMANN_JSON_PASTE43(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE42(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42) |
2749 | | #define NLOHMANN_JSON_PASTE44(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE43(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43) |
2750 | | #define NLOHMANN_JSON_PASTE45(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE44(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44) |
2751 | | #define NLOHMANN_JSON_PASTE46(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE45(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45) |
2752 | | #define NLOHMANN_JSON_PASTE47(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE46(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46) |
2753 | | #define NLOHMANN_JSON_PASTE48(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE47(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47) |
2754 | | #define NLOHMANN_JSON_PASTE49(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE48(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48) |
2755 | | #define NLOHMANN_JSON_PASTE50(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE49(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49) |
2756 | | #define NLOHMANN_JSON_PASTE51(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE50(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50) |
2757 | | #define NLOHMANN_JSON_PASTE52(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE51(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51) |
2758 | | #define NLOHMANN_JSON_PASTE53(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE52(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52) |
2759 | | #define NLOHMANN_JSON_PASTE54(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE53(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53) |
2760 | | #define NLOHMANN_JSON_PASTE55(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE54(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54) |
2761 | | #define NLOHMANN_JSON_PASTE56(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE55(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55) |
2762 | | #define NLOHMANN_JSON_PASTE57(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE56(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56) |
2763 | | #define NLOHMANN_JSON_PASTE58(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE57(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57) |
2764 | | #define NLOHMANN_JSON_PASTE59(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE58(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58) |
2765 | | #define NLOHMANN_JSON_PASTE60(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE59(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59) |
2766 | | #define NLOHMANN_JSON_PASTE61(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE60(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60) |
2767 | | #define NLOHMANN_JSON_PASTE62(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60, v61) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE61(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60, v61) |
2768 | | #define NLOHMANN_JSON_PASTE63(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60, v61, v62) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE62(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60, v61, v62) |
2769 | | #define NLOHMANN_JSON_PASTE64(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60, v61, v62, v63) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE63(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60, v61, v62, v63) |
2770 | | |
2771 | | #define NLOHMANN_JSON_TO(v1) nlohmann_json_j[#v1] = nlohmann_json_t.v1; |
2772 | | #define NLOHMANN_JSON_FROM(v1) nlohmann_json_j.at(#v1).get_to(nlohmann_json_t.v1); |
2773 | | #define NLOHMANN_JSON_FROM_WITH_DEFAULT(v1) nlohmann_json_t.v1 = !nlohmann_json_j.is_null() ? nlohmann_json_j.value(#v1, nlohmann_json_default_obj.v1) : nlohmann_json_default_obj.v1; |
2774 | | |
2775 | | /*! |
2776 | | @brief macro |
2777 | | @def NLOHMANN_DEFINE_TYPE_INTRUSIVE |
2778 | | @since version 3.9.0 |
2779 | | @sa https://json.nlohmann.me/api/macros/nlohmann_define_type_intrusive/ |
2780 | | */ |
2781 | | #define NLOHMANN_DEFINE_TYPE_INTRUSIVE(Type, ...) \ |
2782 | | template<typename BasicJsonType, nlohmann::detail::enable_if_t<nlohmann::detail::is_basic_json<BasicJsonType>::value, int> = 0> \ |
2783 | | friend void to_json(BasicJsonType& nlohmann_json_j, const Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) } \ |
2784 | | template<typename BasicJsonType, nlohmann::detail::enable_if_t<nlohmann::detail::is_basic_json<BasicJsonType>::value, int> = 0> \ |
2785 | | friend void from_json(const BasicJsonType& nlohmann_json_j, Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM, __VA_ARGS__)) } |
2786 | | |
2787 | | /*! |
2788 | | @brief macro |
2789 | | @def NLOHMANN_DEFINE_TYPE_INTRUSIVE_WITH_DEFAULT |
2790 | | @since version 3.11.0 |
2791 | | @sa https://json.nlohmann.me/api/macros/nlohmann_define_type_intrusive/ |
2792 | | */ |
2793 | | #define NLOHMANN_DEFINE_TYPE_INTRUSIVE_WITH_DEFAULT(Type, ...) \ |
2794 | | template<typename BasicJsonType, nlohmann::detail::enable_if_t<nlohmann::detail::is_basic_json<BasicJsonType>::value, int> = 0> \ |
2795 | | friend void to_json(BasicJsonType& nlohmann_json_j, const Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) } \ |
2796 | | template<typename BasicJsonType, nlohmann::detail::enable_if_t<nlohmann::detail::is_basic_json<BasicJsonType>::value, int> = 0> \ |
2797 | | friend void from_json(const BasicJsonType& nlohmann_json_j, Type& nlohmann_json_t) { const Type nlohmann_json_default_obj{}; NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM_WITH_DEFAULT, __VA_ARGS__)) } |
2798 | | |
2799 | | /*! |
2800 | | @brief macro |
2801 | | @def NLOHMANN_DEFINE_TYPE_INTRUSIVE_ONLY_SERIALIZE |
2802 | | @since version 3.11.3 |
2803 | | @sa https://json.nlohmann.me/api/macros/nlohmann_define_type_intrusive/ |
2804 | | */ |
2805 | | #define NLOHMANN_DEFINE_TYPE_INTRUSIVE_ONLY_SERIALIZE(Type, ...) \ |
2806 | | template<typename BasicJsonType, nlohmann::detail::enable_if_t<nlohmann::detail::is_basic_json<BasicJsonType>::value, int> = 0> \ |
2807 | | friend void to_json(BasicJsonType& nlohmann_json_j, const Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) } |
2808 | | |
2809 | | /*! |
2810 | | @brief macro |
2811 | | @def NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE |
2812 | | @since version 3.9.0 |
2813 | | @sa https://json.nlohmann.me/api/macros/nlohmann_define_type_non_intrusive/ |
2814 | | */ |
2815 | | #define NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(Type, ...) \ |
2816 | | template<typename BasicJsonType, nlohmann::detail::enable_if_t<nlohmann::detail::is_basic_json<BasicJsonType>::value, int> = 0> \ |
2817 | | void to_json(BasicJsonType& nlohmann_json_j, const Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) } \ |
2818 | | template<typename BasicJsonType, nlohmann::detail::enable_if_t<nlohmann::detail::is_basic_json<BasicJsonType>::value, int> = 0> \ |
2819 | | void from_json(const BasicJsonType& nlohmann_json_j, Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM, __VA_ARGS__)) } |
2820 | | |
2821 | | /*! |
2822 | | @brief macro |
2823 | | @def NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_WITH_DEFAULT |
2824 | | @since version 3.11.0 |
2825 | | @sa https://json.nlohmann.me/api/macros/nlohmann_define_type_non_intrusive/ |
2826 | | */ |
2827 | | #define NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_WITH_DEFAULT(Type, ...) \ |
2828 | | template<typename BasicJsonType, nlohmann::detail::enable_if_t<nlohmann::detail::is_basic_json<BasicJsonType>::value, int> = 0> \ |
2829 | | void to_json(BasicJsonType& nlohmann_json_j, const Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) } \ |
2830 | | template<typename BasicJsonType, nlohmann::detail::enable_if_t<nlohmann::detail::is_basic_json<BasicJsonType>::value, int> = 0> \ |
2831 | | void from_json(const BasicJsonType& nlohmann_json_j, Type& nlohmann_json_t) { const Type nlohmann_json_default_obj{}; NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM_WITH_DEFAULT, __VA_ARGS__)) } |
2832 | | |
2833 | | /*! |
2834 | | @brief macro |
2835 | | @def NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_ONLY_SERIALIZE |
2836 | | @since version 3.11.3 |
2837 | | @sa https://json.nlohmann.me/api/macros/nlohmann_define_type_non_intrusive/ |
2838 | | */ |
2839 | | #define NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_ONLY_SERIALIZE(Type, ...) \ |
2840 | | template<typename BasicJsonType, nlohmann::detail::enable_if_t<nlohmann::detail::is_basic_json<BasicJsonType>::value, int> = 0> \ |
2841 | | void to_json(BasicJsonType& nlohmann_json_j, const Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) } |
2842 | | |
2843 | | /*! |
2844 | | @brief macro |
2845 | | @def NLOHMANN_DEFINE_DERIVED_TYPE_INTRUSIVE |
2846 | | @since version 3.12.0 |
2847 | | @sa https://json.nlohmann.me/api/macros/nlohmann_define_derived_type/ |
2848 | | */ |
2849 | | #define NLOHMANN_DEFINE_DERIVED_TYPE_INTRUSIVE(Type, BaseType, ...) \ |
2850 | | template<typename BasicJsonType, nlohmann::detail::enable_if_t<nlohmann::detail::is_basic_json<BasicJsonType>::value, int> = 0> \ |
2851 | | friend void to_json(BasicJsonType& nlohmann_json_j, const Type& nlohmann_json_t) { nlohmann::to_json(nlohmann_json_j, static_cast<const BaseType &>(nlohmann_json_t)); NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) } \ |
2852 | | template<typename BasicJsonType, nlohmann::detail::enable_if_t<nlohmann::detail::is_basic_json<BasicJsonType>::value, int> = 0> \ |
2853 | | friend void from_json(const BasicJsonType& nlohmann_json_j, Type& nlohmann_json_t) { nlohmann::from_json(nlohmann_json_j, static_cast<BaseType&>(nlohmann_json_t)); NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM, __VA_ARGS__)) } |
2854 | | |
2855 | | /*! |
2856 | | @brief macro |
2857 | | @def NLOHMANN_DEFINE_DERIVED_TYPE_INTRUSIVE_WITH_DEFAULT |
2858 | | @since version 3.12.0 |
2859 | | @sa https://json.nlohmann.me/api/macros/nlohmann_define_derived_type/ |
2860 | | */ |
2861 | | #define NLOHMANN_DEFINE_DERIVED_TYPE_INTRUSIVE_WITH_DEFAULT(Type, BaseType, ...) \ |
2862 | | template<typename BasicJsonType, nlohmann::detail::enable_if_t<nlohmann::detail::is_basic_json<BasicJsonType>::value, int> = 0> \ |
2863 | | friend void to_json(BasicJsonType& nlohmann_json_j, const Type& nlohmann_json_t) { nlohmann::to_json(nlohmann_json_j, static_cast<const BaseType&>(nlohmann_json_t)); NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) } \ |
2864 | | template<typename BasicJsonType, nlohmann::detail::enable_if_t<nlohmann::detail::is_basic_json<BasicJsonType>::value, int> = 0> \ |
2865 | | friend void from_json(const BasicJsonType& nlohmann_json_j, Type& nlohmann_json_t) { nlohmann::from_json(nlohmann_json_j, static_cast<BaseType&>(nlohmann_json_t)); const Type nlohmann_json_default_obj{}; NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM_WITH_DEFAULT, __VA_ARGS__)) } |
2866 | | |
2867 | | /*! |
2868 | | @brief macro |
2869 | | @def NLOHMANN_DEFINE_DERIVED_TYPE_INTRUSIVE_ONLY_SERIALIZE |
2870 | | @since version 3.12.0 |
2871 | | @sa https://json.nlohmann.me/api/macros/nlohmann_define_derived_type/ |
2872 | | */ |
2873 | | #define NLOHMANN_DEFINE_DERIVED_TYPE_INTRUSIVE_ONLY_SERIALIZE(Type, BaseType, ...) \ |
2874 | | template<typename BasicJsonType, nlohmann::detail::enable_if_t<nlohmann::detail::is_basic_json<BasicJsonType>::value, int> = 0> \ |
2875 | | friend void to_json(BasicJsonType& nlohmann_json_j, const Type& nlohmann_json_t) { nlohmann::to_json(nlohmann_json_j, static_cast<const BaseType &>(nlohmann_json_t)); NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) } |
2876 | | |
2877 | | /*! |
2878 | | @brief macro |
2879 | | @def NLOHMANN_DEFINE_DERIVED_TYPE_NON_INTRUSIVE |
2880 | | @since version 3.12.0 |
2881 | | @sa https://json.nlohmann.me/api/macros/nlohmann_define_derived_type/ |
2882 | | */ |
2883 | | #define NLOHMANN_DEFINE_DERIVED_TYPE_NON_INTRUSIVE(Type, BaseType, ...) \ |
2884 | | template<typename BasicJsonType, nlohmann::detail::enable_if_t<nlohmann::detail::is_basic_json<BasicJsonType>::value, int> = 0> \ |
2885 | | void to_json(BasicJsonType& nlohmann_json_j, const Type& nlohmann_json_t) { nlohmann::to_json(nlohmann_json_j, static_cast<const BaseType &>(nlohmann_json_t)); NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) } \ |
2886 | | template<typename BasicJsonType, nlohmann::detail::enable_if_t<nlohmann::detail::is_basic_json<BasicJsonType>::value, int> = 0> \ |
2887 | | void from_json(const BasicJsonType& nlohmann_json_j, Type& nlohmann_json_t) { nlohmann::from_json(nlohmann_json_j, static_cast<BaseType&>(nlohmann_json_t)); NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM, __VA_ARGS__)) } |
2888 | | |
2889 | | /*! |
2890 | | @brief macro |
2891 | | @def NLOHMANN_DEFINE_DERIVED_TYPE_NON_INTRUSIVE_WITH_DEFAULT |
2892 | | @since version 3.12.0 |
2893 | | @sa https://json.nlohmann.me/api/macros/nlohmann_define_derived_type/ |
2894 | | */ |
2895 | | #define NLOHMANN_DEFINE_DERIVED_TYPE_NON_INTRUSIVE_WITH_DEFAULT(Type, BaseType, ...) \ |
2896 | | template<typename BasicJsonType, nlohmann::detail::enable_if_t<nlohmann::detail::is_basic_json<BasicJsonType>::value, int> = 0> \ |
2897 | | void to_json(BasicJsonType& nlohmann_json_j, const Type& nlohmann_json_t) { nlohmann::to_json(nlohmann_json_j, static_cast<const BaseType &>(nlohmann_json_t)); NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) } \ |
2898 | | template<typename BasicJsonType, nlohmann::detail::enable_if_t<nlohmann::detail::is_basic_json<BasicJsonType>::value, int> = 0> \ |
2899 | | void from_json(const BasicJsonType& nlohmann_json_j, Type& nlohmann_json_t) { nlohmann::from_json(nlohmann_json_j, static_cast<BaseType&>(nlohmann_json_t)); const Type nlohmann_json_default_obj{}; NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM_WITH_DEFAULT, __VA_ARGS__)) } |
2900 | | |
2901 | | /*! |
2902 | | @brief macro |
2903 | | @def NLOHMANN_DEFINE_DERIVED_TYPE_NON_INTRUSIVE_ONLY_SERIALIZE |
2904 | | @since version 3.12.0 |
2905 | | @sa https://json.nlohmann.me/api/macros/nlohmann_define_derived_type/ |
2906 | | */ |
2907 | | #define NLOHMANN_DEFINE_DERIVED_TYPE_NON_INTRUSIVE_ONLY_SERIALIZE(Type, BaseType, ...) \ |
2908 | | template<typename BasicJsonType, nlohmann::detail::enable_if_t<nlohmann::detail::is_basic_json<BasicJsonType>::value, int> = 0> \ |
2909 | | void to_json(BasicJsonType& nlohmann_json_j, const Type& nlohmann_json_t) { nlohmann::to_json(nlohmann_json_j, static_cast<const BaseType &>(nlohmann_json_t)); NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) } |
2910 | | |
2911 | | // inspired from https://stackoverflow.com/a/26745591 |
2912 | | // allows calling any std function as if (e.g., with begin): |
2913 | | // using std::begin; begin(x); |
2914 | | // |
2915 | | // it allows using the detected idiom to retrieve the return type |
2916 | | // of such an expression |
2917 | | #define NLOHMANN_CAN_CALL_STD_FUNC_IMPL(std_name) \ |
2918 | | namespace detail { \ |
2919 | | using std::std_name; \ |
2920 | | \ |
2921 | | template<typename... T> \ |
2922 | | using result_of_##std_name = decltype(std_name(std::declval<T>()...)); \ |
2923 | | } \ |
2924 | | \ |
2925 | | namespace detail2 { \ |
2926 | | struct std_name##_tag \ |
2927 | | { \ |
2928 | | }; \ |
2929 | | \ |
2930 | | template<typename... T> \ |
2931 | | std_name##_tag std_name(T&&...); \ |
2932 | | \ |
2933 | | template<typename... T> \ |
2934 | | using result_of_##std_name = decltype(std_name(std::declval<T>()...)); \ |
2935 | | \ |
2936 | | template<typename... T> \ |
2937 | | struct would_call_std_##std_name \ |
2938 | | { \ |
2939 | | static constexpr auto const value = ::nlohmann::detail:: \ |
2940 | | is_detected_exact<std_name##_tag, result_of_##std_name, T...>::value; \ |
2941 | | }; \ |
2942 | | } /* namespace detail2 */ \ |
2943 | | \ |
2944 | | template<typename... T> \ |
2945 | | struct would_call_std_##std_name : detail2::would_call_std_##std_name<T...> \ |
2946 | | { \ |
2947 | | } |
2948 | | |
2949 | | #ifndef JSON_USE_IMPLICIT_CONVERSIONS |
2950 | | #define JSON_USE_IMPLICIT_CONVERSIONS 1 |
2951 | | #endif |
2952 | | |
2953 | | #if JSON_USE_IMPLICIT_CONVERSIONS |
2954 | | #define JSON_EXPLICIT |
2955 | | #else |
2956 | | #define JSON_EXPLICIT explicit |
2957 | | #endif |
2958 | | |
2959 | | #ifndef JSON_DISABLE_ENUM_SERIALIZATION |
2960 | | #define JSON_DISABLE_ENUM_SERIALIZATION 0 |
2961 | | #endif |
2962 | | |
2963 | | #ifndef JSON_USE_GLOBAL_UDLS |
2964 | | #define JSON_USE_GLOBAL_UDLS 1 |
2965 | | #endif |
2966 | | |
2967 | | #if JSON_HAS_THREE_WAY_COMPARISON |
2968 | | #include <compare> // partial_ordering |
2969 | | #endif |
2970 | | |
2971 | | NLOHMANN_JSON_NAMESPACE_BEGIN |
2972 | | namespace detail |
2973 | | { |
2974 | | |
2975 | | /////////////////////////// |
2976 | | // JSON type enumeration // |
2977 | | /////////////////////////// |
2978 | | |
2979 | | /*! |
2980 | | @brief the JSON type enumeration |
2981 | | |
2982 | | This enumeration collects the different JSON types. It is internally used to |
2983 | | distinguish the stored values, and the functions @ref basic_json::is_null(), |
2984 | | @ref basic_json::is_object(), @ref basic_json::is_array(), |
2985 | | @ref basic_json::is_string(), @ref basic_json::is_boolean(), |
2986 | | @ref basic_json::is_number() (with @ref basic_json::is_number_integer(), |
2987 | | @ref basic_json::is_number_unsigned(), and @ref basic_json::is_number_float()), |
2988 | | @ref basic_json::is_discarded(), @ref basic_json::is_primitive(), and |
2989 | | @ref basic_json::is_structured() rely on it. |
2990 | | |
2991 | | @note There are three enumeration entries (number_integer, number_unsigned, and |
2992 | | number_float), because the library distinguishes these three types for numbers: |
2993 | | @ref basic_json::number_unsigned_t is used for unsigned integers, |
2994 | | @ref basic_json::number_integer_t is used for signed integers, and |
2995 | | @ref basic_json::number_float_t is used for floating-point numbers or to |
2996 | | approximate integers which do not fit in the limits of their respective type. |
2997 | | |
2998 | | @sa see @ref basic_json::basic_json(const value_t value_type) -- create a JSON |
2999 | | value with the default value for a given type |
3000 | | |
3001 | | @since version 1.0.0 |
3002 | | */ |
3003 | | enum class value_t : std::uint8_t |
3004 | | { |
3005 | | null, ///< null value |
3006 | | object, ///< object (unordered set of name/value pairs) |
3007 | | array, ///< array (ordered collection of values) |
3008 | | string, ///< string value |
3009 | | boolean, ///< boolean value |
3010 | | number_integer, ///< number value (signed integer) |
3011 | | number_unsigned, ///< number value (unsigned integer) |
3012 | | number_float, ///< number value (floating-point) |
3013 | | binary, ///< binary array (ordered collection of bytes) |
3014 | | discarded ///< discarded by the parser callback function |
3015 | | }; |
3016 | | |
3017 | | /*! |
3018 | | @brief comparison operator for JSON types |
3019 | | |
3020 | | Returns an ordering that is similar to Python: |
3021 | | - order: null < boolean < number < object < array < string < binary |
3022 | | - furthermore, each type is not smaller than itself |
3023 | | - discarded values are not comparable |
3024 | | - binary is represented as a b"" string in python and directly comparable to a |
3025 | | string; however, making a binary array directly comparable with a string would |
3026 | | be surprising behavior in a JSON file. |
3027 | | |
3028 | | @since version 1.0.0 |
3029 | | */ |
3030 | | #if JSON_HAS_THREE_WAY_COMPARISON |
3031 | | inline std::partial_ordering operator<=>(const value_t lhs, const value_t rhs) noexcept // *NOPAD* |
3032 | | #else |
3033 | | inline bool operator<(const value_t lhs, const value_t rhs) noexcept |
3034 | | #endif |
3035 | 0 | { |
3036 | 0 | static constexpr std::array<std::uint8_t, 9> order = {{ |
3037 | 0 | 0 /* null */, 3 /* object */, 4 /* array */, 5 /* string */, |
3038 | 0 | 1 /* boolean */, 2 /* integer */, 2 /* unsigned */, 2 /* float */, |
3039 | 0 | 6 /* binary */ |
3040 | 0 | } |
3041 | 0 | }; |
3042 | 0 |
|
3043 | 0 | const auto l_index = static_cast<std::size_t>(lhs); |
3044 | 0 | const auto r_index = static_cast<std::size_t>(rhs); |
3045 | 0 | #if JSON_HAS_THREE_WAY_COMPARISON |
3046 | 0 | if (l_index < order.size() && r_index < order.size()) |
3047 | 0 | { |
3048 | 0 | return order[l_index] <=> order[r_index]; // *NOPAD* |
3049 | 0 | } |
3050 | 0 | return std::partial_ordering::unordered; |
3051 | 0 | #else |
3052 | 0 | return l_index < order.size() && r_index < order.size() && order[l_index] < order[r_index]; |
3053 | 0 | #endif |
3054 | 0 | } Unexecuted instantiation: nlohmann::json_abi_v3_12_0::detail::operator<(nlohmann::json_abi_v3_12_0::detail::value_t, nlohmann::json_abi_v3_12_0::detail::value_t) Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_06detailssENS1_7value_tES2_ |
3055 | | |
3056 | | // GCC selects the built-in operator< over an operator rewritten from |
3057 | | // a user-defined spaceship operator |
3058 | | // Clang, MSVC, and ICC select the rewritten candidate |
3059 | | // (see GCC bug https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105200) |
3060 | | #if JSON_HAS_THREE_WAY_COMPARISON && defined(__GNUC__) |
3061 | | inline bool operator<(const value_t lhs, const value_t rhs) noexcept |
3062 | | { |
3063 | | return std::is_lt(lhs <=> rhs); // *NOPAD* |
3064 | | } |
3065 | | #endif |
3066 | | |
3067 | | } // namespace detail |
3068 | | NLOHMANN_JSON_NAMESPACE_END |
3069 | | |
3070 | | // #include <nlohmann/detail/string_escape.hpp> |
3071 | | // __ _____ _____ _____ |
3072 | | // __| | __| | | | JSON for Modern C++ |
3073 | | // | | |__ | | | | | | version 3.12.0 |
3074 | | // |_____|_____|_____|_|___| https://github.com/nlohmann/json |
3075 | | // |
3076 | | // SPDX-FileCopyrightText: 2013-2026 Niels Lohmann <https://nlohmann.me> |
3077 | | // SPDX-License-Identifier: MIT |
3078 | | |
3079 | | |
3080 | | |
3081 | | // #include <nlohmann/detail/abi_macros.hpp> |
3082 | | |
3083 | | |
3084 | | NLOHMANN_JSON_NAMESPACE_BEGIN |
3085 | | namespace detail |
3086 | | { |
3087 | | |
3088 | | /*! |
3089 | | @brief replace all occurrences of a substring by another string |
3090 | | |
3091 | | @param[in,out] s the string to manipulate; changed so that all |
3092 | | occurrences of @a f are replaced with @a t |
3093 | | @param[in] f the substring to replace with @a t |
3094 | | @param[in] t the string to replace @a f |
3095 | | |
3096 | | @pre The search string @a f must not be empty. **This precondition is |
3097 | | enforced with an assertion.** |
3098 | | |
3099 | | @since version 2.0.0 |
3100 | | */ |
3101 | | template<typename StringType> |
3102 | | inline void replace_substring(StringType& s, const StringType& f, |
3103 | | const StringType& t) |
3104 | 0 | { |
3105 | 0 | JSON_ASSERT(!f.empty()); |
3106 | 0 | for (auto pos = s.find(f); // find the first occurrence of f |
3107 | 0 | pos != StringType::npos; // make sure f was found |
3108 | 0 | s.replace(pos, f.size(), t), // replace with t, and |
3109 | 0 | pos = s.find(f, pos + t.size())) // find the next occurrence of f |
3110 | 0 | {} |
3111 | 0 | } |
3112 | | |
3113 | | /*! |
3114 | | * @brief string escaping as described in RFC 6901 (Sect. 4) |
3115 | | * @param[in] s string to escape |
3116 | | * @return escaped string |
3117 | | * |
3118 | | * Note the order of escaping "~" to "~0" and "/" to "~1" is important. |
3119 | | */ |
3120 | | template<typename StringType> |
3121 | | inline StringType escape(StringType s) |
3122 | | { |
3123 | | replace_substring(s, StringType{"~"}, StringType{"~0"}); |
3124 | | replace_substring(s, StringType{"/"}, StringType{"~1"}); |
3125 | | return s; |
3126 | | } |
3127 | | |
3128 | | /*! |
3129 | | * @brief string unescaping as described in RFC 6901 (Sect. 4) |
3130 | | * @param[in] s string to unescape |
3131 | | * @return unescaped string |
3132 | | * |
3133 | | * Note the order of escaping "~1" to "/" and "~0" to "~" is important. |
3134 | | */ |
3135 | | template<typename StringType> |
3136 | | inline void unescape(StringType& s) |
3137 | 0 | { |
3138 | 0 | replace_substring(s, StringType{"~1"}, StringType{"/"}); |
3139 | 0 | replace_substring(s, StringType{"~0"}, StringType{"~"}); |
3140 | 0 | } |
3141 | | |
3142 | | } // namespace detail |
3143 | | NLOHMANN_JSON_NAMESPACE_END |
3144 | | |
3145 | | // #include <nlohmann/detail/input/position_t.hpp> |
3146 | | // __ _____ _____ _____ |
3147 | | // __| | __| | | | JSON for Modern C++ |
3148 | | // | | |__ | | | | | | version 3.12.0 |
3149 | | // |_____|_____|_____|_|___| https://github.com/nlohmann/json |
3150 | | // |
3151 | | // SPDX-FileCopyrightText: 2013-2026 Niels Lohmann <https://nlohmann.me> |
3152 | | // SPDX-License-Identifier: MIT |
3153 | | |
3154 | | |
3155 | | |
3156 | | #include <cstddef> // size_t |
3157 | | |
3158 | | // #include <nlohmann/detail/abi_macros.hpp> |
3159 | | |
3160 | | |
3161 | | NLOHMANN_JSON_NAMESPACE_BEGIN |
3162 | | namespace detail |
3163 | | { |
3164 | | |
3165 | | /// struct to capture the start position of the current token |
3166 | | struct position_t |
3167 | | { |
3168 | | /// the total number of characters read |
3169 | | std::size_t chars_read_total = 0; |
3170 | | /// the number of characters read in the current line |
3171 | | std::size_t chars_read_current_line = 0; |
3172 | | /// the number of lines read |
3173 | | std::size_t lines_read = 0; |
3174 | | |
3175 | | /// conversion to size_t to preserve SAX interface |
3176 | | constexpr operator size_t() const |
3177 | 0 | { |
3178 | 0 | return chars_read_total; |
3179 | 0 | } |
3180 | | }; |
3181 | | |
3182 | | } // namespace detail |
3183 | | NLOHMANN_JSON_NAMESPACE_END |
3184 | | |
3185 | | // #include <nlohmann/detail/macro_scope.hpp> |
3186 | | |
3187 | | // #include <nlohmann/detail/meta/cpp_future.hpp> |
3188 | | // __ _____ _____ _____ |
3189 | | // __| | __| | | | JSON for Modern C++ |
3190 | | // | | |__ | | | | | | version 3.12.0 |
3191 | | // |_____|_____|_____|_|___| https://github.com/nlohmann/json |
3192 | | // |
3193 | | // SPDX-FileCopyrightText: 2013-2026 Niels Lohmann <https://nlohmann.me> |
3194 | | // SPDX-FileCopyrightText: 2018 The Abseil Authors |
3195 | | // SPDX-License-Identifier: MIT |
3196 | | |
3197 | | |
3198 | | |
3199 | | #include <array> // array |
3200 | | #include <cstddef> // size_t |
3201 | | #include <type_traits> // conditional, enable_if, false_type, integral_constant, is_constructible, is_integral, is_same, remove_cv, remove_reference, true_type |
3202 | | #include <utility> // index_sequence, make_index_sequence, index_sequence_for |
3203 | | |
3204 | | // #include <nlohmann/detail/macro_scope.hpp> |
3205 | | |
3206 | | |
3207 | | NLOHMANN_JSON_NAMESPACE_BEGIN |
3208 | | namespace detail |
3209 | | { |
3210 | | |
3211 | | template<typename T> |
3212 | | using uncvref_t = typename std::remove_cv<typename std::remove_reference<T>::type>::type; |
3213 | | |
3214 | | #ifdef JSON_HAS_CPP_14 |
3215 | | |
3216 | | // the following utilities are natively available in C++14 |
3217 | | using std::enable_if_t; |
3218 | | using std::index_sequence; |
3219 | | using std::make_index_sequence; |
3220 | | using std::index_sequence_for; |
3221 | | |
3222 | | #else |
3223 | | |
3224 | | // alias templates to reduce boilerplate |
3225 | | template<bool B, typename T = void> |
3226 | | using enable_if_t = typename std::enable_if<B, T>::type; |
3227 | | |
3228 | | // The following code is taken from https://github.com/abseil/abseil-cpp/blob/10cb35e459f5ecca5b2ff107635da0bfa41011b4/absl/utility/utility.h |
3229 | | // which is part of Google Abseil (https://github.com/abseil/abseil-cpp), licensed under the Apache License 2.0. |
3230 | | |
3231 | | //// START OF CODE FROM GOOGLE ABSEIL |
3232 | | |
3233 | | // integer_sequence |
3234 | | // |
3235 | | // Class template representing a compile-time integer sequence. An instantiation |
3236 | | // of `integer_sequence<T, Ints...>` has a sequence of integers encoded in its |
3237 | | // type through its template arguments (which is a common need when |
3238 | | // working with C++11 variadic templates). `absl::integer_sequence` is designed |
3239 | | // to be a drop-in replacement for C++14's `std::integer_sequence`. |
3240 | | // |
3241 | | // Example: |
3242 | | // |
3243 | | // template< class T, T... Ints > |
3244 | | // void user_function(integer_sequence<T, Ints...>); |
3245 | | // |
3246 | | // int main() |
3247 | | // { |
3248 | | // // user_function's `T` will be deduced to `int` and `Ints...` |
3249 | | // // will be deduced to `0, 1, 2, 3, 4`. |
3250 | | // user_function(make_integer_sequence<int, 5>()); |
3251 | | // } |
3252 | | template <typename T, T... Ints> |
3253 | | struct integer_sequence |
3254 | | { |
3255 | | using value_type = T; |
3256 | | static constexpr std::size_t size() noexcept |
3257 | | { |
3258 | | return sizeof...(Ints); |
3259 | | } |
3260 | | }; |
3261 | | |
3262 | | // index_sequence |
3263 | | // |
3264 | | // A helper template for an `integer_sequence` of `size_t`, |
3265 | | // `absl::index_sequence` is designed to be a drop-in replacement for C++14's |
3266 | | // `std::index_sequence`. |
3267 | | template <size_t... Ints> |
3268 | | using index_sequence = integer_sequence<size_t, Ints...>; |
3269 | | |
3270 | | namespace utility_internal |
3271 | | { |
3272 | | |
3273 | | template <typename Seq, size_t SeqSize, size_t Rem> |
3274 | | struct Extend; |
3275 | | |
3276 | | // Note that SeqSize == sizeof...(Ints). It's passed explicitly for efficiency. |
3277 | | template <typename T, T... Ints, size_t SeqSize> |
3278 | | struct Extend<integer_sequence<T, Ints...>, SeqSize, 0> |
3279 | | { |
3280 | | using type = integer_sequence < T, Ints..., (Ints + SeqSize)... >; |
3281 | | }; |
3282 | | |
3283 | | template <typename T, T... Ints, size_t SeqSize> |
3284 | | struct Extend<integer_sequence<T, Ints...>, SeqSize, 1> |
3285 | | { |
3286 | | using type = integer_sequence < T, Ints..., (Ints + SeqSize)..., 2 * SeqSize >; |
3287 | | }; |
3288 | | |
3289 | | // Recursion helper for 'make_integer_sequence<T, N>'. |
3290 | | // 'Gen<T, N>::type' is an alias for 'integer_sequence<T, 0, 1, ... N-1>'. |
3291 | | template <typename T, size_t N> |
3292 | | struct Gen |
3293 | | { |
3294 | | using type = |
3295 | | typename Extend < typename Gen < T, N / 2 >::type, N / 2, N % 2 >::type; |
3296 | | }; |
3297 | | |
3298 | | template <typename T> |
3299 | | struct Gen<T, 0> |
3300 | | { |
3301 | | using type = integer_sequence<T>; |
3302 | | }; |
3303 | | |
3304 | | } // namespace utility_internal |
3305 | | |
3306 | | // Compile-time sequences of integers |
3307 | | |
3308 | | // make_integer_sequence |
3309 | | // |
3310 | | // This template alias is equivalent to |
3311 | | // `integer_sequence<int, 0, 1, ..., N-1>`, and is designed to be a drop-in |
3312 | | // replacement for C++14's `std::make_integer_sequence`. |
3313 | | template <typename T, T N> |
3314 | | using make_integer_sequence = typename utility_internal::Gen<T, N>::type; |
3315 | | |
3316 | | // make_index_sequence |
3317 | | // |
3318 | | // This template alias is equivalent to `index_sequence<0, 1, ..., N-1>`, |
3319 | | // and is designed to be a drop-in replacement for C++14's |
3320 | | // `std::make_index_sequence`. |
3321 | | template <size_t N> |
3322 | | using make_index_sequence = make_integer_sequence<size_t, N>; |
3323 | | |
3324 | | // index_sequence_for |
3325 | | // |
3326 | | // Converts a typename pack into an index sequence of the same length, and |
3327 | | // is designed to be a drop-in replacement for C++14's |
3328 | | // `std::index_sequence_for()` |
3329 | | template <typename... Ts> |
3330 | | using index_sequence_for = make_index_sequence<sizeof...(Ts)>; |
3331 | | |
3332 | | //// END OF CODE FROM GOOGLE ABSEIL |
3333 | | |
3334 | | #endif |
3335 | | |
3336 | | // dispatch utility (taken from ranges-v3) |
3337 | | template<unsigned N> struct priority_tag : priority_tag < N - 1 > {}; |
3338 | | template<> struct priority_tag<0> {}; |
3339 | | |
3340 | | // taken from ranges-v3 |
3341 | | template<typename T> |
3342 | | struct static_const |
3343 | | { |
3344 | | static JSON_INLINE_VARIABLE constexpr T value{}; |
3345 | | }; |
3346 | | |
3347 | | #ifndef JSON_HAS_CPP_17 |
3348 | | template<typename T> |
3349 | | constexpr T static_const<T>::value; |
3350 | | #endif |
3351 | | |
3352 | | template<typename T, typename... Args> |
3353 | | constexpr std::array<T, sizeof...(Args)> make_array(Args&& ... args) |
3354 | | { |
3355 | | return std::array<T, sizeof...(Args)> {{static_cast<T>(std::forward<Args>(args))...}}; |
3356 | | } |
3357 | | |
3358 | | } // namespace detail |
3359 | | NLOHMANN_JSON_NAMESPACE_END |
3360 | | |
3361 | | // #include <nlohmann/detail/meta/type_traits.hpp> |
3362 | | // __ _____ _____ _____ |
3363 | | // __| | __| | | | JSON for Modern C++ |
3364 | | // | | |__ | | | | | | version 3.12.0 |
3365 | | // |_____|_____|_____|_|___| https://github.com/nlohmann/json |
3366 | | // |
3367 | | // SPDX-FileCopyrightText: 2013-2026 Niels Lohmann <https://nlohmann.me> |
3368 | | // SPDX-License-Identifier: MIT |
3369 | | |
3370 | | |
3371 | | |
3372 | | #include <limits> // numeric_limits |
3373 | | #include <string> // char_traits |
3374 | | #include <tuple> // tuple |
3375 | | #include <type_traits> // false_type, is_constructible, is_integral, is_same, true_type |
3376 | | #include <utility> // declval |
3377 | | #if defined(__cpp_lib_byte) && __cpp_lib_byte >= 201603L |
3378 | | #include <cstddef> // byte |
3379 | | #endif |
3380 | | // #include <nlohmann/detail/iterators/iterator_traits.hpp> |
3381 | | // __ _____ _____ _____ |
3382 | | // __| | __| | | | JSON for Modern C++ |
3383 | | // | | |__ | | | | | | version 3.12.0 |
3384 | | // |_____|_____|_____|_|___| https://github.com/nlohmann/json |
3385 | | // |
3386 | | // SPDX-FileCopyrightText: 2013-2026 Niels Lohmann <https://nlohmann.me> |
3387 | | // SPDX-License-Identifier: MIT |
3388 | | |
3389 | | |
3390 | | |
3391 | | #include <iterator> // random_access_iterator_tag |
3392 | | |
3393 | | // #include <nlohmann/detail/abi_macros.hpp> |
3394 | | |
3395 | | // #include <nlohmann/detail/meta/void_t.hpp> |
3396 | | |
3397 | | // #include <nlohmann/detail/meta/cpp_future.hpp> |
3398 | | |
3399 | | |
3400 | | NLOHMANN_JSON_NAMESPACE_BEGIN |
3401 | | namespace detail |
3402 | | { |
3403 | | |
3404 | | template<typename It, typename = void> |
3405 | | struct iterator_types {}; |
3406 | | |
3407 | | template<typename It> |
3408 | | struct iterator_types < |
3409 | | It, |
3410 | | void_t<typename It::difference_type, typename It::value_type, typename It::pointer, |
3411 | | typename It::reference, typename It::iterator_category >> |
3412 | | { |
3413 | | using difference_type = typename It::difference_type; |
3414 | | using value_type = typename It::value_type; |
3415 | | using pointer = typename It::pointer; |
3416 | | using reference = typename It::reference; |
3417 | | using iterator_category = typename It::iterator_category; |
3418 | | }; |
3419 | | |
3420 | | // This is required as some compilers implement std::iterator_traits in a way that |
3421 | | // doesn't work with SFINAE. See https://github.com/nlohmann/json/issues/1341. |
3422 | | template<typename T, typename = void> |
3423 | | struct iterator_traits |
3424 | | { |
3425 | | }; |
3426 | | |
3427 | | template<typename T> |
3428 | | struct iterator_traits < T, enable_if_t < !std::is_pointer<T>::value >> |
3429 | | : iterator_types<T> |
3430 | | { |
3431 | | }; |
3432 | | |
3433 | | template<typename T> |
3434 | | struct iterator_traits<T*, enable_if_t<std::is_object<T>::value>> |
3435 | | { |
3436 | | using iterator_category = std::random_access_iterator_tag; |
3437 | | using value_type = T; |
3438 | | using difference_type = ptrdiff_t; |
3439 | | using pointer = T*; |
3440 | | using reference = T&; |
3441 | | }; |
3442 | | |
3443 | | } // namespace detail |
3444 | | NLOHMANN_JSON_NAMESPACE_END |
3445 | | |
3446 | | // #include <nlohmann/detail/macro_scope.hpp> |
3447 | | |
3448 | | // #include <nlohmann/detail/meta/call_std/begin.hpp> |
3449 | | // __ _____ _____ _____ |
3450 | | // __| | __| | | | JSON for Modern C++ |
3451 | | // | | |__ | | | | | | version 3.12.0 |
3452 | | // |_____|_____|_____|_|___| https://github.com/nlohmann/json |
3453 | | // |
3454 | | // SPDX-FileCopyrightText: 2013-2026 Niels Lohmann <https://nlohmann.me> |
3455 | | // SPDX-License-Identifier: MIT |
3456 | | |
3457 | | |
3458 | | |
3459 | | // #include <nlohmann/detail/macro_scope.hpp> |
3460 | | |
3461 | | |
3462 | | NLOHMANN_JSON_NAMESPACE_BEGIN |
3463 | | |
3464 | | NLOHMANN_CAN_CALL_STD_FUNC_IMPL(begin); |
3465 | | |
3466 | | NLOHMANN_JSON_NAMESPACE_END |
3467 | | |
3468 | | // #include <nlohmann/detail/meta/call_std/end.hpp> |
3469 | | // __ _____ _____ _____ |
3470 | | // __| | __| | | | JSON for Modern C++ |
3471 | | // | | |__ | | | | | | version 3.12.0 |
3472 | | // |_____|_____|_____|_|___| https://github.com/nlohmann/json |
3473 | | // |
3474 | | // SPDX-FileCopyrightText: 2013-2026 Niels Lohmann <https://nlohmann.me> |
3475 | | // SPDX-License-Identifier: MIT |
3476 | | |
3477 | | |
3478 | | |
3479 | | // #include <nlohmann/detail/macro_scope.hpp> |
3480 | | |
3481 | | |
3482 | | NLOHMANN_JSON_NAMESPACE_BEGIN |
3483 | | |
3484 | | NLOHMANN_CAN_CALL_STD_FUNC_IMPL(end); |
3485 | | |
3486 | | NLOHMANN_JSON_NAMESPACE_END |
3487 | | |
3488 | | // #include <nlohmann/detail/meta/cpp_future.hpp> |
3489 | | |
3490 | | // #include <nlohmann/detail/meta/detected.hpp> |
3491 | | |
3492 | | // #include <nlohmann/json_fwd.hpp> |
3493 | | // __ _____ _____ _____ |
3494 | | // __| | __| | | | JSON for Modern C++ |
3495 | | // | | |__ | | | | | | version 3.12.0 |
3496 | | // |_____|_____|_____|_|___| https://github.com/nlohmann/json |
3497 | | // |
3498 | | // SPDX-FileCopyrightText: 2013-2026 Niels Lohmann <https://nlohmann.me> |
3499 | | // SPDX-License-Identifier: MIT |
3500 | | |
3501 | | #ifndef INCLUDE_NLOHMANN_JSON_FWD_HPP_ |
3502 | | #define INCLUDE_NLOHMANN_JSON_FWD_HPP_ |
3503 | | |
3504 | | #include <cstdint> // int64_t, uint64_t |
3505 | | #include <map> // map |
3506 | | #include <memory> // allocator |
3507 | | #include <string> // string |
3508 | | #include <vector> // vector |
3509 | | |
3510 | | // #include <nlohmann/detail/abi_macros.hpp> |
3511 | | |
3512 | | |
3513 | | /*! |
3514 | | @brief namespace for Niels Lohmann |
3515 | | @see https://github.com/nlohmann |
3516 | | @since version 1.0.0 |
3517 | | */ |
3518 | | NLOHMANN_JSON_NAMESPACE_BEGIN |
3519 | | |
3520 | | /*! |
3521 | | @brief default JSONSerializer template argument |
3522 | | |
3523 | | This serializer ignores the template arguments and uses ADL |
3524 | | ([argument-dependent lookup](https://en.cppreference.com/w/cpp/language/adl)) |
3525 | | for serialization. |
3526 | | */ |
3527 | | template<typename T = void, typename SFINAE = void> |
3528 | | struct adl_serializer; |
3529 | | |
3530 | | /// a class to store JSON values |
3531 | | /// @sa https://json.nlohmann.me/api/basic_json/ |
3532 | | template<template<typename U, typename V, typename... Args> class ObjectType = |
3533 | | std::map, |
3534 | | template<typename U, typename... Args> class ArrayType = std::vector, |
3535 | | class StringType = std::string, class BooleanType = bool, |
3536 | | class NumberIntegerType = std::int64_t, |
3537 | | class NumberUnsignedType = std::uint64_t, |
3538 | | class NumberFloatType = double, |
3539 | | template<typename U> class AllocatorType = std::allocator, |
3540 | | template<typename T, typename SFINAE = void> class JSONSerializer = |
3541 | | adl_serializer, |
3542 | | class BinaryType = std::vector<std::uint8_t>, // cppcheck-suppress syntaxError |
3543 | | class CustomBaseClass = void> |
3544 | | class basic_json; |
3545 | | |
3546 | | /// @brief JSON Pointer defines a string syntax for identifying a specific value within a JSON document |
3547 | | /// @sa https://json.nlohmann.me/api/json_pointer/ |
3548 | | template<typename RefStringType> |
3549 | | class json_pointer; |
3550 | | |
3551 | | /*! |
3552 | | @brief default specialization |
3553 | | @sa https://json.nlohmann.me/api/json/ |
3554 | | */ |
3555 | | using json = basic_json<>; |
3556 | | |
3557 | | /// @brief a minimal map-like container that preserves insertion order |
3558 | | /// @sa https://json.nlohmann.me/api/ordered_map/ |
3559 | | template<class Key, class T, class IgnoredLess, class Allocator> |
3560 | | struct ordered_map; |
3561 | | |
3562 | | /// @brief specialization that maintains the insertion order of object keys |
3563 | | /// @sa https://json.nlohmann.me/api/ordered_json/ |
3564 | | using ordered_json = basic_json<nlohmann::ordered_map>; |
3565 | | |
3566 | | NLOHMANN_JSON_NAMESPACE_END |
3567 | | |
3568 | | #endif // INCLUDE_NLOHMANN_JSON_FWD_HPP_ |
3569 | | |
3570 | | |
3571 | | NLOHMANN_JSON_NAMESPACE_BEGIN |
3572 | | /*! |
3573 | | @brief detail namespace with internal helper functions |
3574 | | |
3575 | | This namespace collects functions that should not be exposed, |
3576 | | implementations of some @ref basic_json methods, and meta-programming helpers. |
3577 | | |
3578 | | @since version 2.1.0 |
3579 | | */ |
3580 | | namespace detail |
3581 | | { |
3582 | | |
3583 | | ///////////// |
3584 | | // helpers // |
3585 | | ///////////// |
3586 | | |
3587 | | // Note to maintainers: |
3588 | | // |
3589 | | // Every trait in this file expects a non-CV-qualified type. |
3590 | | // The only exceptions are in the 'aliases for detected' section |
3591 | | // (i.e., those of the form: decltype(T::member_function(std::declval<T>()))) |
3592 | | // |
3593 | | // In this case, T has to be properly CV-qualified to constraint the function arguments |
3594 | | // (e.g., to_json(BasicJsonType&, const T&)) |
3595 | | |
3596 | | template<typename> struct is_basic_json : std::false_type {}; |
3597 | | |
3598 | | NLOHMANN_BASIC_JSON_TPL_DECLARATION |
3599 | | struct is_basic_json<NLOHMANN_BASIC_JSON_TPL> : std::true_type {}; |
3600 | | |
3601 | | // used by exceptions create() member functions |
3602 | | // true_type for the pointer to possibly cv-qualified basic_json or std::nullptr_t |
3603 | | // false_type otherwise |
3604 | | template<typename BasicJsonContext> |
3605 | | struct is_basic_json_context : |
3606 | | std::integral_constant < bool, |
3607 | | is_basic_json<typename std::remove_cv<typename std::remove_pointer<BasicJsonContext>::type>::type>::value |
3608 | | || std::is_same<BasicJsonContext, std::nullptr_t>::value > |
3609 | | {}; |
3610 | | |
3611 | | ////////////////////// |
3612 | | // json_ref helpers // |
3613 | | ////////////////////// |
3614 | | |
3615 | | template<typename> |
3616 | | class json_ref; |
3617 | | |
3618 | | template<typename> |
3619 | | struct is_json_ref : std::false_type {}; |
3620 | | |
3621 | | template<typename T> |
3622 | | struct is_json_ref<json_ref<T>> : std::true_type {}; |
3623 | | |
3624 | | ////////////////////////// |
3625 | | // aliases for detected // |
3626 | | ////////////////////////// |
3627 | | |
3628 | | template<typename T> |
3629 | | using mapped_type_t = typename T::mapped_type; |
3630 | | |
3631 | | template<typename T> |
3632 | | using key_type_t = typename T::key_type; |
3633 | | |
3634 | | template<typename T> |
3635 | | using value_type_t = typename T::value_type; |
3636 | | |
3637 | | template<typename T> |
3638 | | using difference_type_t = typename T::difference_type; |
3639 | | |
3640 | | template<typename T> |
3641 | | using pointer_t = typename T::pointer; |
3642 | | |
3643 | | template<typename T> |
3644 | | using reference_t = typename T::reference; |
3645 | | |
3646 | | template<typename T> |
3647 | | using iterator_category_t = typename T::iterator_category; |
3648 | | |
3649 | | template<typename T, typename... Args> |
3650 | | using to_json_function = decltype(T::to_json(std::declval<Args>()...)); |
3651 | | |
3652 | | template<typename T, typename... Args> |
3653 | | using from_json_function = decltype(T::from_json(std::declval<Args>()...)); |
3654 | | |
3655 | | template<typename T, typename U> |
3656 | | using get_template_function = decltype(std::declval<T>().template get<U>()); |
3657 | | |
3658 | | // trait checking if JSONSerializer<T>::from_json(json const&, udt&) exists |
3659 | | template<typename BasicJsonType, typename T, typename = void> |
3660 | | struct has_from_json : std::false_type {}; |
3661 | | |
3662 | | // trait checking if j.get<T> is valid |
3663 | | // use this trait instead of std::is_constructible or std::is_convertible, |
3664 | | // both rely on, or make use of implicit conversions, and thus fail when T |
3665 | | // has several constructors/operator= (see https://github.com/nlohmann/json/issues/958) |
3666 | | template <typename BasicJsonType, typename T> |
3667 | | struct is_getable |
3668 | | { |
3669 | | static constexpr bool value = is_detected<get_template_function, const BasicJsonType&, T>::value; |
3670 | | }; |
3671 | | |
3672 | | template<typename BasicJsonType, typename T> |
3673 | | struct has_from_json < BasicJsonType, T, enable_if_t < !is_basic_json<T>::value >> |
3674 | | { |
3675 | | using serializer = typename BasicJsonType::template json_serializer<T, void>; |
3676 | | |
3677 | | static constexpr bool value = |
3678 | | is_detected_exact<void, from_json_function, serializer, |
3679 | | const BasicJsonType&, T&>::value; |
3680 | | }; |
3681 | | |
3682 | | // This trait checks if JSONSerializer<T>::from_json(json const&) exists |
3683 | | // this overload is used for non-default-constructible user-defined-types |
3684 | | template<typename BasicJsonType, typename T, typename = void> |
3685 | | struct has_non_default_from_json : std::false_type {}; |
3686 | | |
3687 | | template<typename BasicJsonType, typename T> |
3688 | | struct has_non_default_from_json < BasicJsonType, T, enable_if_t < !is_basic_json<T>::value >> |
3689 | | { |
3690 | | using serializer = typename BasicJsonType::template json_serializer<T, void>; |
3691 | | |
3692 | | static constexpr bool value = |
3693 | | is_detected_exact<T, from_json_function, serializer, |
3694 | | const BasicJsonType&>::value; |
3695 | | }; |
3696 | | |
3697 | | // This trait checks if BasicJsonType::json_serializer<T>::to_json exists |
3698 | | // Do not evaluate the trait when T is a basic_json type, to avoid template instantiation infinite recursion. |
3699 | | template<typename BasicJsonType, typename T, typename = void> |
3700 | | struct has_to_json : std::false_type {}; |
3701 | | |
3702 | | template<typename BasicJsonType, typename T> |
3703 | | struct has_to_json < BasicJsonType, T, enable_if_t < !is_basic_json<T>::value >> |
3704 | | { |
3705 | | using serializer = typename BasicJsonType::template json_serializer<T, void>; |
3706 | | |
3707 | | static constexpr bool value = |
3708 | | is_detected_exact<void, to_json_function, serializer, BasicJsonType&, |
3709 | | T>::value; |
3710 | | }; |
3711 | | |
3712 | | template<typename T> |
3713 | | using detect_key_compare = typename T::key_compare; |
3714 | | |
3715 | | template<typename T> |
3716 | | struct has_key_compare : std::integral_constant<bool, is_detected<detect_key_compare, T>::value> {}; |
3717 | | |
3718 | | // obtains the actual object key comparator |
3719 | | template<typename BasicJsonType> |
3720 | | struct actual_object_comparator |
3721 | | { |
3722 | | using object_t = typename BasicJsonType::object_t; |
3723 | | using object_comparator_t = typename BasicJsonType::default_object_comparator_t; |
3724 | | using type = typename std::conditional < has_key_compare<object_t>::value, |
3725 | | typename object_t::key_compare, object_comparator_t>::type; |
3726 | | }; |
3727 | | |
3728 | | template<typename BasicJsonType> |
3729 | | using actual_object_comparator_t = typename actual_object_comparator<BasicJsonType>::type; |
3730 | | |
3731 | | ///////////////// |
3732 | | // char_traits // |
3733 | | ///////////////// |
3734 | | |
3735 | | // Primary template of char_traits calls std char_traits |
3736 | | template<typename T> |
3737 | | struct char_traits : std::char_traits<T> |
3738 | | {}; |
3739 | | |
3740 | | // Explicitly define char traits for unsigned char since it is not standard |
3741 | | template<> |
3742 | | struct char_traits<unsigned char> : std::char_traits<char> |
3743 | | { |
3744 | | using char_type = unsigned char; |
3745 | | using int_type = uint64_t; |
3746 | | |
3747 | | // Redefine to_int_type function |
3748 | | static int_type to_int_type(char_type c) noexcept |
3749 | 0 | { |
3750 | 0 | return static_cast<int_type>(c); |
3751 | 0 | } |
3752 | | |
3753 | | static char_type to_char_type(int_type i) noexcept |
3754 | 0 | { |
3755 | 0 | return static_cast<char_type>(i); |
3756 | 0 | } |
3757 | | |
3758 | | static constexpr int_type eof() noexcept |
3759 | 0 | { |
3760 | 0 | return static_cast<int_type>(std::char_traits<char>::eof()); |
3761 | 0 | } |
3762 | | }; |
3763 | | |
3764 | | // Explicitly define char traits for signed char since it is not standard |
3765 | | template<> |
3766 | | struct char_traits<signed char> : std::char_traits<char> |
3767 | | { |
3768 | | using char_type = signed char; |
3769 | | using int_type = uint64_t; |
3770 | | |
3771 | | // Redefine to_int_type function |
3772 | | static int_type to_int_type(char_type c) noexcept |
3773 | 0 | { |
3774 | 0 | return static_cast<int_type>(c); |
3775 | 0 | } |
3776 | | |
3777 | | static char_type to_char_type(int_type i) noexcept |
3778 | 0 | { |
3779 | 0 | return static_cast<char_type>(i); |
3780 | 0 | } |
3781 | | |
3782 | | static constexpr int_type eof() noexcept |
3783 | 0 | { |
3784 | 0 | return static_cast<int_type>(std::char_traits<char>::eof()); |
3785 | 0 | } |
3786 | | }; |
3787 | | |
3788 | | #if defined(__cpp_lib_byte) && __cpp_lib_byte >= 201603L |
3789 | | template<> |
3790 | | struct char_traits<std::byte> : std::char_traits<char> |
3791 | | { |
3792 | | using char_type = std::byte; |
3793 | | using int_type = uint64_t; |
3794 | | |
3795 | | static int_type to_int_type(char_type c) noexcept |
3796 | 0 | { |
3797 | 0 | return static_cast<int_type>(std::to_integer<unsigned char>(c)); |
3798 | 0 | } |
3799 | | |
3800 | | static char_type to_char_type(int_type i) noexcept |
3801 | 0 | { |
3802 | 0 | return std::byte(static_cast<unsigned char>(i)); |
3803 | 0 | } |
3804 | | |
3805 | | static constexpr int_type eof() noexcept |
3806 | 0 | { |
3807 | 0 | return static_cast<int_type>(std::char_traits<char>::eof()); |
3808 | 0 | } |
3809 | | }; |
3810 | | #endif |
3811 | | |
3812 | | /////////////////// |
3813 | | // is_ functions // |
3814 | | /////////////////// |
3815 | | |
3816 | | // https://en.cppreference.com/w/cpp/types/conjunction |
3817 | | template<class...> struct conjunction : std::true_type { }; |
3818 | | template<class B> struct conjunction<B> : B { }; |
3819 | | template<class B, class... Bn> |
3820 | | struct conjunction<B, Bn...> |
3821 | | : std::conditional<static_cast<bool>(B::value), conjunction<Bn...>, B>::type {}; |
3822 | | |
3823 | | // https://en.cppreference.com/w/cpp/types/negation |
3824 | | template<class B> struct negation : std::integral_constant < bool, !B::value > { }; |
3825 | | |
3826 | | // Reimplementation of is_constructible and is_default_constructible, due to them being broken for |
3827 | | // std::pair and std::tuple until LWG 2367 fix (see https://cplusplus.github.io/LWG/lwg-defects.html#2367). |
3828 | | // This causes compile errors in e.g., Clang 3.5 or GCC 4.9. |
3829 | | template <typename T> |
3830 | | struct is_default_constructible : std::is_default_constructible<T> {}; |
3831 | | |
3832 | | template <typename T1, typename T2> |
3833 | | struct is_default_constructible<std::pair<T1, T2>> |
3834 | | : conjunction<is_default_constructible<T1>, is_default_constructible<T2>> {}; |
3835 | | |
3836 | | template <typename T1, typename T2> |
3837 | | struct is_default_constructible<const std::pair<T1, T2>> |
3838 | | : conjunction<is_default_constructible<T1>, is_default_constructible<T2>> {}; |
3839 | | |
3840 | | template <typename... Ts> |
3841 | | struct is_default_constructible<std::tuple<Ts...>> |
3842 | | : conjunction<is_default_constructible<Ts>...> {}; |
3843 | | |
3844 | | template <typename... Ts> |
3845 | | struct is_default_constructible<const std::tuple<Ts...>> |
3846 | | : conjunction<is_default_constructible<Ts>...> {}; |
3847 | | |
3848 | | template <typename T, typename... Args> |
3849 | | struct is_constructible : std::is_constructible<T, Args...> {}; |
3850 | | |
3851 | | template <typename T1, typename T2> |
3852 | | struct is_constructible<std::pair<T1, T2>> : is_default_constructible<std::pair<T1, T2>> {}; |
3853 | | |
3854 | | template <typename T1, typename T2> |
3855 | | struct is_constructible<const std::pair<T1, T2>> : is_default_constructible<const std::pair<T1, T2>> {}; |
3856 | | |
3857 | | template <typename... Ts> |
3858 | | struct is_constructible<std::tuple<Ts...>> : is_default_constructible<std::tuple<Ts...>> {}; |
3859 | | |
3860 | | template <typename... Ts> |
3861 | | struct is_constructible<const std::tuple<Ts...>> : is_default_constructible<const std::tuple<Ts...>> {}; |
3862 | | |
3863 | | template<typename T, typename = void> |
3864 | | struct is_iterator_traits : std::false_type {}; |
3865 | | |
3866 | | template<typename T> |
3867 | | struct is_iterator_traits<iterator_traits<T>> |
3868 | | { |
3869 | | private: |
3870 | | using traits = iterator_traits<T>; |
3871 | | |
3872 | | public: |
3873 | | static constexpr auto value = |
3874 | | is_detected<value_type_t, traits>::value && |
3875 | | is_detected<difference_type_t, traits>::value && |
3876 | | is_detected<pointer_t, traits>::value && |
3877 | | is_detected<iterator_category_t, traits>::value && |
3878 | | is_detected<reference_t, traits>::value; |
3879 | | }; |
3880 | | |
3881 | | template<typename T> |
3882 | | struct is_range |
3883 | | { |
3884 | | private: |
3885 | | using t_ref = typename std::add_lvalue_reference<T>::type; |
3886 | | |
3887 | | using iterator = detected_t<result_of_begin, t_ref>; |
3888 | | using sentinel = detected_t<result_of_end, t_ref>; |
3889 | | |
3890 | | // to be 100% correct, it should use https://en.cppreference.com/w/cpp/iterator/input_or_output_iterator |
3891 | | // and https://en.cppreference.com/w/cpp/iterator/sentinel_for |
3892 | | // but reimplementing these would be too much work, as a lot of other concepts are used underneath |
3893 | | static constexpr auto is_iterator_begin = |
3894 | | is_iterator_traits<iterator_traits<iterator>>::value; |
3895 | | |
3896 | | public: |
3897 | | static constexpr bool value = !std::is_same<iterator, nonesuch>::value && !std::is_same<sentinel, nonesuch>::value && is_iterator_begin; |
3898 | | }; |
3899 | | |
3900 | | template<typename R> |
3901 | | using iterator_t = enable_if_t<is_range<R>::value, result_of_begin<decltype(std::declval<R&>())>>; |
3902 | | |
3903 | | template<typename T> |
3904 | | using range_value_t = value_type_t<iterator_traits<iterator_t<T>>>; |
3905 | | |
3906 | | // The following implementation of is_complete_type is taken from |
3907 | | // https://blogs.msdn.microsoft.com/vcblog/2015/12/02/partial-support-for-expression-sfinae-in-vs-2015-update-1/ |
3908 | | // and is written by Xiang Fan who agreed to use it in this library. |
3909 | | |
3910 | | template<typename T, typename = void> |
3911 | | struct is_complete_type : std::false_type {}; |
3912 | | |
3913 | | template<typename T> |
3914 | | struct is_complete_type<T, decltype(void(sizeof(T)))> : std::true_type {}; |
3915 | | |
3916 | | template<typename BasicJsonType, typename CompatibleObjectType, |
3917 | | typename = void> |
3918 | | struct is_compatible_object_type_impl : std::false_type {}; |
3919 | | |
3920 | | template<typename BasicJsonType, typename CompatibleObjectType> |
3921 | | struct is_compatible_object_type_impl < |
3922 | | BasicJsonType, CompatibleObjectType, |
3923 | | enable_if_t < is_detected<mapped_type_t, CompatibleObjectType>::value&& |
3924 | | is_detected<key_type_t, CompatibleObjectType>::value >> |
3925 | | { |
3926 | | using object_t = typename BasicJsonType::object_t; |
3927 | | |
3928 | | // macOS's is_constructible does not play well with nonesuch... |
3929 | | static constexpr bool value = |
3930 | | is_constructible<typename object_t::key_type, |
3931 | | typename CompatibleObjectType::key_type>::value && |
3932 | | is_constructible<typename object_t::mapped_type, |
3933 | | typename CompatibleObjectType::mapped_type>::value; |
3934 | | }; |
3935 | | |
3936 | | template<typename BasicJsonType, typename CompatibleObjectType> |
3937 | | struct is_compatible_object_type |
3938 | | : is_compatible_object_type_impl<BasicJsonType, CompatibleObjectType> {}; |
3939 | | |
3940 | | template<typename BasicJsonType, typename ConstructibleObjectType, |
3941 | | typename = void> |
3942 | | struct is_constructible_object_type_impl : std::false_type {}; |
3943 | | |
3944 | | template<typename BasicJsonType, typename ConstructibleObjectType> |
3945 | | struct is_constructible_object_type_impl < |
3946 | | BasicJsonType, ConstructibleObjectType, |
3947 | | enable_if_t < is_detected<mapped_type_t, ConstructibleObjectType>::value&& |
3948 | | is_detected<key_type_t, ConstructibleObjectType>::value >> |
3949 | | { |
3950 | | using object_t = typename BasicJsonType::object_t; |
3951 | | |
3952 | | static constexpr bool value = |
3953 | | (is_default_constructible<ConstructibleObjectType>::value && |
3954 | | (std::is_move_assignable<ConstructibleObjectType>::value || |
3955 | | std::is_copy_assignable<ConstructibleObjectType>::value) && |
3956 | | (is_constructible<typename ConstructibleObjectType::key_type, |
3957 | | typename object_t::key_type>::value && |
3958 | | std::is_same < |
3959 | | typename object_t::mapped_type, |
3960 | | typename ConstructibleObjectType::mapped_type >::value)) || |
3961 | | (has_from_json<BasicJsonType, |
3962 | | typename ConstructibleObjectType::mapped_type>::value || |
3963 | | has_non_default_from_json < |
3964 | | BasicJsonType, |
3965 | | typename ConstructibleObjectType::mapped_type >::value); |
3966 | | }; |
3967 | | |
3968 | | template<typename BasicJsonType, typename ConstructibleObjectType> |
3969 | | struct is_constructible_object_type |
3970 | | : is_constructible_object_type_impl<BasicJsonType, |
3971 | | ConstructibleObjectType> {}; |
3972 | | |
3973 | | template<typename BasicJsonType, typename CompatibleStringType> |
3974 | | struct is_compatible_string_type |
3975 | | { |
3976 | | static constexpr auto value = |
3977 | | is_constructible<typename BasicJsonType::string_t, CompatibleStringType>::value; |
3978 | | }; |
3979 | | |
3980 | | template<typename BasicJsonType, typename ConstructibleStringType> |
3981 | | struct is_constructible_string_type |
3982 | | { |
3983 | | // launder type through decltype() to fix compilation failure on ICPC |
3984 | | #ifdef __INTEL_COMPILER |
3985 | | using laundered_type = decltype(std::declval<ConstructibleStringType>()); |
3986 | | #else |
3987 | | using laundered_type = ConstructibleStringType; |
3988 | | #endif |
3989 | | |
3990 | | static constexpr auto value = |
3991 | | conjunction < |
3992 | | is_constructible<laundered_type, typename BasicJsonType::string_t>, |
3993 | | is_detected_exact<typename BasicJsonType::string_t::value_type, |
3994 | | value_type_t, laundered_type >>::value; |
3995 | | }; |
3996 | | |
3997 | | template<typename BasicJsonType, typename CompatibleArrayType, typename = void> |
3998 | | struct is_compatible_array_type_impl : std::false_type {}; |
3999 | | |
4000 | | template<typename BasicJsonType, typename CompatibleArrayType> |
4001 | | struct is_compatible_array_type_impl < |
4002 | | BasicJsonType, CompatibleArrayType, |
4003 | | enable_if_t < |
4004 | | is_detected<iterator_t, CompatibleArrayType>::value&& |
4005 | | is_iterator_traits<iterator_traits<detected_t<iterator_t, CompatibleArrayType>>>::value&& |
4006 | | // special case for types like std::filesystem::path whose iterator's value_type are themselves |
4007 | | // c.f. https://github.com/nlohmann/json/pull/3073 |
4008 | | !std::is_same<CompatibleArrayType, detected_t<range_value_t, CompatibleArrayType>>::value >> |
4009 | | { |
4010 | | static constexpr bool value = |
4011 | | is_constructible<BasicJsonType, |
4012 | | range_value_t<CompatibleArrayType>>::value; |
4013 | | }; |
4014 | | |
4015 | | template<typename BasicJsonType, typename CompatibleArrayType> |
4016 | | struct is_compatible_array_type |
4017 | | : is_compatible_array_type_impl<BasicJsonType, CompatibleArrayType> {}; |
4018 | | |
4019 | | template<typename BasicJsonType, typename ConstructibleArrayType, typename = void> |
4020 | | struct is_constructible_array_type_impl : std::false_type {}; |
4021 | | |
4022 | | template<typename BasicJsonType, typename ConstructibleArrayType> |
4023 | | struct is_constructible_array_type_impl < |
4024 | | BasicJsonType, ConstructibleArrayType, |
4025 | | enable_if_t<std::is_same<ConstructibleArrayType, |
4026 | | typename BasicJsonType::value_type>::value >> |
4027 | | : std::true_type {}; |
4028 | | |
4029 | | template<typename BasicJsonType, typename ConstructibleArrayType> |
4030 | | struct is_constructible_array_type_impl < |
4031 | | BasicJsonType, ConstructibleArrayType, |
4032 | | enable_if_t < !std::is_same<ConstructibleArrayType, |
4033 | | typename BasicJsonType::value_type>::value&& |
4034 | | !is_compatible_string_type<BasicJsonType, ConstructibleArrayType>::value&& |
4035 | | is_default_constructible<ConstructibleArrayType>::value&& |
4036 | | (std::is_move_assignable<ConstructibleArrayType>::value || |
4037 | | std::is_copy_assignable<ConstructibleArrayType>::value)&& |
4038 | | is_detected<iterator_t, ConstructibleArrayType>::value&& |
4039 | | is_iterator_traits<iterator_traits<detected_t<iterator_t, ConstructibleArrayType>>>::value&& |
4040 | | is_detected<range_value_t, ConstructibleArrayType>::value&& |
4041 | | // special case for types like std::filesystem::path whose iterator's value_type are themselves |
4042 | | // c.f. https://github.com/nlohmann/json/pull/3073 |
4043 | | !std::is_same<ConstructibleArrayType, detected_t<range_value_t, ConstructibleArrayType>>::value&& |
4044 | | is_complete_type < |
4045 | | detected_t<range_value_t, ConstructibleArrayType >>::value >> |
4046 | | { |
4047 | | using value_type = range_value_t<ConstructibleArrayType>; |
4048 | | |
4049 | | static constexpr bool value = |
4050 | | std::is_same<value_type, |
4051 | | typename BasicJsonType::array_t::value_type>::value || |
4052 | | has_from_json<BasicJsonType, |
4053 | | value_type>::value || |
4054 | | has_non_default_from_json < |
4055 | | BasicJsonType, |
4056 | | value_type >::value; |
4057 | | }; |
4058 | | |
4059 | | template<typename BasicJsonType, typename ConstructibleArrayType> |
4060 | | struct is_constructible_array_type |
4061 | | : is_constructible_array_type_impl<BasicJsonType, ConstructibleArrayType> {}; |
4062 | | |
4063 | | template<typename RealIntegerType, typename CompatibleNumberIntegerType, |
4064 | | typename = void> |
4065 | | struct is_compatible_integer_type_impl : std::false_type {}; |
4066 | | |
4067 | | template<typename RealIntegerType, typename CompatibleNumberIntegerType> |
4068 | | struct is_compatible_integer_type_impl < |
4069 | | RealIntegerType, CompatibleNumberIntegerType, |
4070 | | enable_if_t < std::is_integral<RealIntegerType>::value&& |
4071 | | std::is_integral<CompatibleNumberIntegerType>::value&& |
4072 | | !std::is_same<bool, CompatibleNumberIntegerType>::value >> |
4073 | | { |
4074 | | // is there an assert somewhere on overflows? |
4075 | | using RealLimits = std::numeric_limits<RealIntegerType>; |
4076 | | using CompatibleLimits = std::numeric_limits<CompatibleNumberIntegerType>; |
4077 | | |
4078 | | static constexpr auto value = |
4079 | | is_constructible<RealIntegerType, |
4080 | | CompatibleNumberIntegerType>::value && |
4081 | | CompatibleLimits::is_integer && |
4082 | | RealLimits::is_signed == CompatibleLimits::is_signed; |
4083 | | }; |
4084 | | |
4085 | | template<typename RealIntegerType, typename CompatibleNumberIntegerType> |
4086 | | struct is_compatible_integer_type |
4087 | | : is_compatible_integer_type_impl<RealIntegerType, |
4088 | | CompatibleNumberIntegerType> {}; |
4089 | | |
4090 | | template<typename BasicJsonType, typename CompatibleType, typename = void> |
4091 | | struct is_compatible_type_impl: std::false_type {}; |
4092 | | |
4093 | | template<typename BasicJsonType, typename CompatibleType> |
4094 | | struct is_compatible_type_impl < |
4095 | | BasicJsonType, CompatibleType, |
4096 | | enable_if_t<is_complete_type<CompatibleType>::value >> |
4097 | | { |
4098 | | static constexpr bool value = |
4099 | | has_to_json<BasicJsonType, CompatibleType>::value; |
4100 | | }; |
4101 | | |
4102 | | template<typename BasicJsonType, typename CompatibleType> |
4103 | | struct is_compatible_type |
4104 | | : is_compatible_type_impl<BasicJsonType, CompatibleType> {}; |
4105 | | |
4106 | | template<typename T1, typename T2> |
4107 | | struct is_constructible_tuple : std::false_type {}; |
4108 | | |
4109 | | template<typename T1, typename... Args> |
4110 | | struct is_constructible_tuple<T1, std::tuple<Args...>> : conjunction<is_constructible<T1, Args>...> {}; |
4111 | | |
4112 | | template<typename BasicJsonType, typename T> |
4113 | | struct is_json_iterator_of : std::false_type {}; |
4114 | | |
4115 | | template<typename BasicJsonType> |
4116 | | struct is_json_iterator_of<BasicJsonType, typename BasicJsonType::iterator> : std::true_type {}; |
4117 | | |
4118 | | template<typename BasicJsonType> |
4119 | | struct is_json_iterator_of<BasicJsonType, typename BasicJsonType::const_iterator> : std::true_type |
4120 | | {}; |
4121 | | |
4122 | | // checks if a given type T is a template specialization of Primary |
4123 | | template<template <typename...> class Primary, typename T> |
4124 | | struct is_specialization_of : std::false_type {}; |
4125 | | |
4126 | | template<template <typename...> class Primary, typename... Args> |
4127 | | struct is_specialization_of<Primary, Primary<Args...>> : std::true_type {}; |
4128 | | |
4129 | | template<typename T> |
4130 | | using is_json_pointer = is_specialization_of<::nlohmann::json_pointer, uncvref_t<T>>; |
4131 | | |
4132 | | // checks if B is a json_pointer<A> |
4133 | | template <typename A, typename B> |
4134 | | struct is_json_pointer_of : std::false_type {}; |
4135 | | |
4136 | | template <typename A> |
4137 | | struct is_json_pointer_of<A, ::nlohmann::json_pointer<A>> : std::true_type {}; |
4138 | | |
4139 | | template <typename A> |
4140 | | struct is_json_pointer_of<A, ::nlohmann::json_pointer<A>&> : std::true_type {}; |
4141 | | |
4142 | | // checks if A and B are comparable using Compare functor |
4143 | | template<typename Compare, typename A, typename B, typename = void> |
4144 | | struct is_comparable : std::false_type {}; |
4145 | | |
4146 | | // We exclude json_pointer here, because the checks using Compare(A, B) will |
4147 | | // use json_pointer::operator string_t() which triggers a deprecation warning |
4148 | | // for GCC. See https://github.com/nlohmann/json/issues/4621. The call to |
4149 | | // is_json_pointer_of can be removed once the deprecated function has been |
4150 | | // removed. |
4151 | | template<typename Compare, typename A, typename B> |
4152 | | struct is_comparable < Compare, A, B, enable_if_t < !is_json_pointer_of<A, B>::value |
4153 | | && std::is_constructible <decltype(std::declval<Compare>()(std::declval<A>(), std::declval<B>()))>::value |
4154 | | && std::is_constructible <decltype(std::declval<Compare>()(std::declval<B>(), std::declval<A>()))>::value |
4155 | | >> : std::true_type {}; |
4156 | | |
4157 | | template<typename T> |
4158 | | using detect_is_transparent = typename T::is_transparent; |
4159 | | |
4160 | | // type trait to check if KeyType can be used as an object key (without a BasicJsonType) |
4161 | | // see is_usable_as_basic_json_key_type below |
4162 | | template<typename Comparator, typename ObjectKeyType, typename KeyTypeCVRef, bool RequireTransparentComparator = true, |
4163 | | bool ExcludeObjectKeyType = RequireTransparentComparator, typename KeyType = uncvref_t<KeyTypeCVRef>> |
4164 | | using is_usable_as_key_type = typename std::conditional < |
4165 | | is_comparable<Comparator, ObjectKeyType, KeyTypeCVRef>::value |
4166 | | && !(ExcludeObjectKeyType && std::is_same<KeyType, |
4167 | | ObjectKeyType>::value) |
4168 | | && (!RequireTransparentComparator |
4169 | | || is_detected <detect_is_transparent, Comparator>::value) |
4170 | | && !is_json_pointer<KeyType>::value, |
4171 | | std::true_type, |
4172 | | std::false_type >::type; |
4173 | | |
4174 | | // type trait to check if KeyType can be used as an object key |
4175 | | // true if: |
4176 | | // - KeyType is comparable with BasicJsonType::object_t::key_type |
4177 | | // - if ExcludeObjectKeyType is true, KeyType is not BasicJsonType::object_t::key_type |
4178 | | // - the comparator is transparent or RequireTransparentComparator is false |
4179 | | // - KeyType is not a JSON iterator or json_pointer |
4180 | | template<typename BasicJsonType, typename KeyTypeCVRef, bool RequireTransparentComparator = true, |
4181 | | bool ExcludeObjectKeyType = RequireTransparentComparator, typename KeyType = uncvref_t<KeyTypeCVRef>> |
4182 | | using is_usable_as_basic_json_key_type = typename std::conditional < |
4183 | | (is_usable_as_key_type<typename BasicJsonType::object_comparator_t, |
4184 | | typename BasicJsonType::object_t::key_type, KeyTypeCVRef, |
4185 | | RequireTransparentComparator, ExcludeObjectKeyType>::value |
4186 | | && !is_json_iterator_of<BasicJsonType, KeyType>::value) |
4187 | | #ifdef JSON_HAS_CPP_17 |
4188 | | || std::is_convertible<KeyType, std::string_view>::value |
4189 | | #endif |
4190 | | , std::true_type, |
4191 | | std::false_type >::type; |
4192 | | |
4193 | | template<typename ObjectType, typename KeyType> |
4194 | | using detect_erase_with_key_type = decltype(std::declval<ObjectType&>().erase(std::declval<KeyType>())); |
4195 | | |
4196 | | // type trait to check if object_t has an erase() member functions accepting KeyType |
4197 | | template<typename BasicJsonType, typename KeyType> |
4198 | | using has_erase_with_key_type = typename std::conditional < |
4199 | | is_detected < |
4200 | | detect_erase_with_key_type, |
4201 | | typename BasicJsonType::object_t, KeyType >::value, |
4202 | | std::true_type, |
4203 | | std::false_type >::type; |
4204 | | |
4205 | | // a naive helper to check if a type is an ordered_map (exploits the fact that |
4206 | | // ordered_map inherits capacity() from std::vector) |
4207 | | template <typename T> |
4208 | | struct is_ordered_map |
4209 | | { |
4210 | | using one = char; |
4211 | | |
4212 | | struct two |
4213 | | { |
4214 | | char x[2]; // NOLINT(cppcoreguidelines-avoid-c-arrays,hicpp-avoid-c-arrays,modernize-avoid-c-arrays) |
4215 | | }; |
4216 | | |
4217 | | template <typename C> static one test( decltype(&C::capacity) ) ; |
4218 | | template <typename C> static two test(...); |
4219 | | |
4220 | | enum { value = sizeof(test<T>(nullptr)) == sizeof(char) }; // NOLINT(cppcoreguidelines-pro-type-vararg,hicpp-vararg,cppcoreguidelines-use-enum-class) |
4221 | | }; |
4222 | | |
4223 | | // to avoid useless casts (see https://github.com/nlohmann/json/issues/2893#issuecomment-889152324) |
4224 | | template < typename T, typename U, enable_if_t < !std::is_same<T, U>::value, int > = 0 > |
4225 | | T conditional_static_cast(U value) |
4226 | | { |
4227 | | return static_cast<T>(value); |
4228 | | } |
4229 | | |
4230 | | template<typename T, typename U, enable_if_t<std::is_same<T, U>::value, int> = 0> |
4231 | | T conditional_static_cast(U value) |
4232 | | { |
4233 | | return value; |
4234 | | } |
4235 | | |
4236 | | template<typename... Types> |
4237 | | using all_integral = conjunction<std::is_integral<Types>...>; |
4238 | | |
4239 | | template<typename... Types> |
4240 | | using all_signed = conjunction<std::is_signed<Types>...>; |
4241 | | |
4242 | | template<typename... Types> |
4243 | | using all_unsigned = conjunction<std::is_unsigned<Types>...>; |
4244 | | |
4245 | | // there's a disjunction trait in another PR; replace when merged |
4246 | | template<typename... Types> |
4247 | | using same_sign = std::integral_constant < bool, |
4248 | | all_signed<Types...>::value || all_unsigned<Types...>::value >; |
4249 | | |
4250 | | template<typename OfType, typename T> |
4251 | | using never_out_of_range = std::integral_constant < bool, |
4252 | | (std::is_signed<OfType>::value && (sizeof(T) < sizeof(OfType))) |
4253 | | || (same_sign<OfType, T>::value && sizeof(OfType) == sizeof(T)) >; |
4254 | | |
4255 | | template<typename OfType, typename T, |
4256 | | bool OfTypeSigned = std::is_signed<OfType>::value, |
4257 | | bool TSigned = std::is_signed<T>::value> |
4258 | | struct value_in_range_of_impl2; |
4259 | | |
4260 | | template<typename OfType, typename T> |
4261 | | struct value_in_range_of_impl2<OfType, T, false, false> |
4262 | | { |
4263 | | static constexpr bool test(T val) |
4264 | | { |
4265 | | using CommonType = typename std::common_type<OfType, T>::type; |
4266 | | return static_cast<CommonType>(val) <= static_cast<CommonType>((std::numeric_limits<OfType>::max)()); |
4267 | | } |
4268 | | }; |
4269 | | |
4270 | | template<typename OfType, typename T> |
4271 | | struct value_in_range_of_impl2<OfType, T, true, false> |
4272 | | { |
4273 | | static constexpr bool test(T val) |
4274 | | { |
4275 | | using CommonType = typename std::common_type<OfType, T>::type; |
4276 | | return static_cast<CommonType>(val) <= static_cast<CommonType>((std::numeric_limits<OfType>::max)()); |
4277 | | } |
4278 | | }; |
4279 | | |
4280 | | template<typename OfType, typename T> |
4281 | | struct value_in_range_of_impl2<OfType, T, false, true> |
4282 | | { |
4283 | | static constexpr bool test(T val) |
4284 | 0 | { |
4285 | 0 | using CommonType = typename std::common_type<OfType, T>::type; |
4286 | 0 | return val >= 0 && static_cast<CommonType>(val) <= static_cast<CommonType>((std::numeric_limits<OfType>::max)()); |
4287 | 0 | } |
4288 | | }; |
4289 | | |
4290 | | template<typename OfType, typename T> |
4291 | | struct value_in_range_of_impl2<OfType, T, true, true> |
4292 | | { |
4293 | | static constexpr bool test(T val) |
4294 | | { |
4295 | | using CommonType = typename std::common_type<OfType, T>::type; |
4296 | | return static_cast<CommonType>(val) >= static_cast<CommonType>((std::numeric_limits<OfType>::min)()) |
4297 | | && static_cast<CommonType>(val) <= static_cast<CommonType>((std::numeric_limits<OfType>::max)()); |
4298 | | } |
4299 | | }; |
4300 | | |
4301 | | template<typename OfType, typename T, |
4302 | | bool NeverOutOfRange = never_out_of_range<OfType, T>::value, |
4303 | | typename = detail::enable_if_t<all_integral<OfType, T>::value>> |
4304 | | struct value_in_range_of_impl1; |
4305 | | |
4306 | | template<typename OfType, typename T> |
4307 | | struct value_in_range_of_impl1<OfType, T, false> |
4308 | | { |
4309 | | static constexpr bool test(T val) |
4310 | 0 | { |
4311 | 0 | return value_in_range_of_impl2<OfType, T>::test(val); |
4312 | 0 | } |
4313 | | }; |
4314 | | |
4315 | | template<typename OfType, typename T> |
4316 | | struct value_in_range_of_impl1<OfType, T, true> |
4317 | | { |
4318 | | static constexpr bool test(T /*val*/) |
4319 | 0 | { |
4320 | 0 | return true; |
4321 | 0 | } |
4322 | | }; |
4323 | | |
4324 | | template<typename OfType, typename T> |
4325 | | constexpr bool value_in_range_of(T val) |
4326 | 0 | { |
4327 | 0 | return value_in_range_of_impl1<OfType, T>::test(val); |
4328 | 0 | } Unexecuted instantiation: bool nlohmann::json_abi_v3_12_0::detail::value_in_range_of<unsigned long, long>(long) Unexecuted instantiation: bool nlohmann::json_abi_v3_12_0::detail::value_in_range_of<unsigned long, unsigned long>(unsigned long) |
4329 | | |
4330 | | template<bool Value> |
4331 | | using bool_constant = std::integral_constant<bool, Value>; |
4332 | | |
4333 | | /////////////////////////////////////////////////////////////////////////////// |
4334 | | // is_c_string |
4335 | | /////////////////////////////////////////////////////////////////////////////// |
4336 | | |
4337 | | namespace impl |
4338 | | { |
4339 | | |
4340 | | template<typename T> |
4341 | | constexpr bool is_c_string() |
4342 | | { |
4343 | | using TUnExt = typename std::remove_extent<T>::type; |
4344 | | using TUnCVExt = typename std::remove_cv<TUnExt>::type; |
4345 | | using TUnPtr = typename std::remove_pointer<T>::type; |
4346 | | using TUnCVPtr = typename std::remove_cv<TUnPtr>::type; |
4347 | | return |
4348 | | (std::is_array<T>::value && std::is_same<TUnCVExt, char>::value) |
4349 | | || (std::is_pointer<T>::value && std::is_same<TUnCVPtr, char>::value); |
4350 | | } |
4351 | | |
4352 | | } // namespace impl |
4353 | | |
4354 | | // checks whether T is a [cv] char */[cv] char[] C string |
4355 | | template<typename T> |
4356 | | struct is_c_string : bool_constant<impl::is_c_string<T>()> {}; |
4357 | | |
4358 | | template<typename T> |
4359 | | using is_c_string_uncvref = is_c_string<uncvref_t<T>>; |
4360 | | |
4361 | | /////////////////////////////////////////////////////////////////////////////// |
4362 | | // is_transparent |
4363 | | /////////////////////////////////////////////////////////////////////////////// |
4364 | | |
4365 | | namespace impl |
4366 | | { |
4367 | | |
4368 | | template<typename T> |
4369 | | constexpr bool is_transparent() |
4370 | 0 | { |
4371 | 0 | return is_detected<detect_is_transparent, T>::value; |
4372 | 0 | } |
4373 | | |
4374 | | } // namespace impl |
4375 | | |
4376 | | // checks whether T has a member named is_transparent |
4377 | | template<typename T> |
4378 | | struct is_transparent : bool_constant<impl::is_transparent<T>()> {}; |
4379 | | |
4380 | | /////////////////////////////////////////////////////////////////////////////// |
4381 | | |
4382 | | } // namespace detail |
4383 | | NLOHMANN_JSON_NAMESPACE_END |
4384 | | |
4385 | | // #include <nlohmann/detail/string_concat.hpp> |
4386 | | // __ _____ _____ _____ |
4387 | | // __| | __| | | | JSON for Modern C++ |
4388 | | // | | |__ | | | | | | version 3.12.0 |
4389 | | // |_____|_____|_____|_|___| https://github.com/nlohmann/json |
4390 | | // |
4391 | | // SPDX-FileCopyrightText: 2013-2026 Niels Lohmann <https://nlohmann.me> |
4392 | | // SPDX-License-Identifier: MIT |
4393 | | |
4394 | | |
4395 | | |
4396 | | #include <cstring> // strlen |
4397 | | #include <string> // string |
4398 | | #include <utility> // forward |
4399 | | |
4400 | | // #include <nlohmann/detail/meta/cpp_future.hpp> |
4401 | | |
4402 | | // #include <nlohmann/detail/meta/detected.hpp> |
4403 | | |
4404 | | |
4405 | | NLOHMANN_JSON_NAMESPACE_BEGIN |
4406 | | namespace detail |
4407 | | { |
4408 | | |
4409 | | inline std::size_t concat_length() |
4410 | 0 | { |
4411 | 0 | return 0; |
4412 | 0 | } |
4413 | | |
4414 | | template<typename... Args> |
4415 | | inline std::size_t concat_length(const char* cstr, const Args& ... rest); |
4416 | | |
4417 | | template<typename StringType, typename... Args> |
4418 | | inline std::size_t concat_length(const StringType& str, const Args& ... rest); |
4419 | | |
4420 | | template<typename... Args> |
4421 | | inline std::size_t concat_length(const char /*c*/, const Args& ... rest) |
4422 | 0 | { |
4423 | 0 | return 1 + concat_length(rest...); |
4424 | 0 | } Unexecuted instantiation: unsigned long nlohmann::json_abi_v3_12_0::detail::concat_length<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, char [3]>(char, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, char const (&) [3]) Unexecuted instantiation: unsigned long nlohmann::json_abi_v3_12_0::detail::concat_length<>(char) |
4425 | | |
4426 | | template<typename... Args> |
4427 | | inline std::size_t concat_length(const char* cstr, const Args& ... rest) |
4428 | 0 | { |
4429 | | // cppcheck-suppress ignoredReturnValue |
4430 | 0 | return ::strlen(cstr) + concat_length(rest...); |
4431 | 0 | } Unexecuted instantiation: unsigned long nlohmann::json_abi_v3_12_0::detail::concat_length<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, char, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, char [3]>(char const*, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, char const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, char const (&) [3]) Unexecuted instantiation: unsigned long nlohmann::json_abi_v3_12_0::detail::concat_length<>(char const*) Unexecuted instantiation: unsigned long nlohmann::json_abi_v3_12_0::detail::concat_length<char const*>(char const*, char const* const&) Unexecuted instantiation: unsigned long nlohmann::json_abi_v3_12_0::detail::concat_length<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, char [10], std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >(char const*, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, char const (&) [10], std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) Unexecuted instantiation: unsigned long nlohmann::json_abi_v3_12_0::detail::concat_length<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >(char const*, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) Unexecuted instantiation: unsigned long nlohmann::json_abi_v3_12_0::detail::concat_length<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, char [3], std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >(char const*, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, char const (&) [3], std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) Unexecuted instantiation: unsigned long nlohmann::json_abi_v3_12_0::detail::concat_length<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >(char const*, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) Unexecuted instantiation: unsigned long nlohmann::json_abi_v3_12_0::detail::concat_length<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, char>(char const*, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, char const&) Unexecuted instantiation: unsigned long nlohmann::json_abi_v3_12_0::detail::concat_length<char [15], std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, char>(char const*, char const (&) [15], std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, char const&) Unexecuted instantiation: unsigned long nlohmann::json_abi_v3_12_0::detail::concat_length<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, char [2]>(char const*, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, char const (&) [2]) Unexecuted instantiation: unsigned long nlohmann::json_abi_v3_12_0::detail::concat_length<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, char [5], std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >(char const*, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, char const (&) [5], std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) |
4432 | | |
4433 | | template<typename StringType, typename... Args> |
4434 | | inline std::size_t concat_length(const StringType& str, const Args& ... rest) |
4435 | 0 | { |
4436 | 0 | return str.size() + concat_length(rest...); |
4437 | 0 | } Unexecuted instantiation: unsigned long nlohmann::json_abi_v3_12_0::detail::concat_length<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) Unexecuted instantiation: unsigned long nlohmann::json_abi_v3_12_0::detail::concat_length<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) Unexecuted instantiation: unsigned long nlohmann::json_abi_v3_12_0::detail::concat_length<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >>(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) Unexecuted instantiation: unsigned long nlohmann::json_abi_v3_12_0::detail::concat_length<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, char, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, char [3]>(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, char const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, char const (&) [3]) Unexecuted instantiation: unsigned long nlohmann::json_abi_v3_12_0::detail::concat_length<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, char [3]>(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, char const (&) [3]) Unexecuted instantiation: unsigned long nlohmann::json_abi_v3_12_0::detail::concat_length<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, char [10], std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, char const (&) [10], std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) Unexecuted instantiation: unsigned long nlohmann::json_abi_v3_12_0::detail::concat_length<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, char [12], std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, char [3], std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, char const (&) [12], std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, char const (&) [3], std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) Unexecuted instantiation: unsigned long nlohmann::json_abi_v3_12_0::detail::concat_length<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, char [3], std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, char const (&) [3], std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) Unexecuted instantiation: unsigned long nlohmann::json_abi_v3_12_0::detail::concat_length<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, char>(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, char const&) Unexecuted instantiation: unsigned long nlohmann::json_abi_v3_12_0::detail::concat_length<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, char [2]>(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, char const (&) [2]) Unexecuted instantiation: unsigned long nlohmann::json_abi_v3_12_0::detail::concat_length<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, char [5], std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, char const (&) [5], std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) |
4438 | | |
4439 | | template<typename OutStringType> |
4440 | | inline void concat_into(OutStringType& /*out*/) |
4441 | 0 | {} |
4442 | | |
4443 | | template<typename StringType, typename Arg> |
4444 | | using string_can_append = decltype(std::declval<StringType&>().append(std::declval < Arg && > ())); |
4445 | | |
4446 | | template<typename StringType, typename Arg> |
4447 | | using detect_string_can_append = is_detected<string_can_append, StringType, Arg>; |
4448 | | |
4449 | | template<typename StringType, typename Arg> |
4450 | | using string_can_append_op = decltype(std::declval<StringType&>() += std::declval < Arg && > ()); |
4451 | | |
4452 | | template<typename StringType, typename Arg> |
4453 | | using detect_string_can_append_op = is_detected<string_can_append_op, StringType, Arg>; |
4454 | | |
4455 | | template<typename StringType, typename Arg> |
4456 | | using string_can_append_iter = decltype(std::declval<StringType&>().append(std::declval<const Arg&>().begin(), std::declval<const Arg&>().end())); |
4457 | | |
4458 | | template<typename StringType, typename Arg> |
4459 | | using detect_string_can_append_iter = is_detected<string_can_append_iter, StringType, Arg>; |
4460 | | |
4461 | | template<typename StringType, typename Arg> |
4462 | | using string_can_append_data = decltype(std::declval<StringType&>().append(std::declval<const Arg&>().data(), std::declval<const Arg&>().size())); |
4463 | | |
4464 | | template<typename StringType, typename Arg> |
4465 | | using detect_string_can_append_data = is_detected<string_can_append_data, StringType, Arg>; |
4466 | | |
4467 | | template < typename OutStringType, typename Arg, typename... Args, |
4468 | | enable_if_t < !detect_string_can_append<OutStringType, Arg>::value |
4469 | | && detect_string_can_append_op<OutStringType, Arg>::value, int > = 0 > |
4470 | | inline void concat_into(OutStringType& out, Arg && arg, Args && ... rest); |
4471 | | |
4472 | | template < typename OutStringType, typename Arg, typename... Args, |
4473 | | enable_if_t < !detect_string_can_append<OutStringType, Arg>::value |
4474 | | && !detect_string_can_append_op<OutStringType, Arg>::value |
4475 | | && detect_string_can_append_iter<OutStringType, Arg>::value, int > = 0 > |
4476 | | inline void concat_into(OutStringType& out, const Arg& arg, Args && ... rest); |
4477 | | |
4478 | | template < typename OutStringType, typename Arg, typename... Args, |
4479 | | enable_if_t < !detect_string_can_append<OutStringType, Arg>::value |
4480 | | && !detect_string_can_append_op<OutStringType, Arg>::value |
4481 | | && !detect_string_can_append_iter<OutStringType, Arg>::value |
4482 | | && detect_string_can_append_data<OutStringType, Arg>::value, int > = 0 > |
4483 | | inline void concat_into(OutStringType& out, const Arg& arg, Args && ... rest); |
4484 | | |
4485 | | template<typename OutStringType, typename Arg, typename... Args, |
4486 | | enable_if_t<detect_string_can_append<OutStringType, Arg>::value, int> = 0> |
4487 | | inline void concat_into(OutStringType& out, Arg && arg, Args && ... rest) |
4488 | 0 | { |
4489 | 0 | out.append(std::forward<Arg>(arg)); |
4490 | 0 | concat_into(out, std::forward<Args>(rest)...); |
4491 | 0 | } Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_06detail11concat_intoINSt3__112basic_stringIcNS3_11char_traitsIcEENS3_9allocatorIcEEEES9_JS9_RKS9_ETnNS3_9enable_ifIXsr24detect_string_can_appendIT_T0_EE5valueEiE4typeELi0EEEvRSD_OSE_DpOT1_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_06detail11concat_intoINSt3__112basic_stringIcNS3_11char_traitsIcEENS3_9allocatorIcEEEES9_JRKS9_ETnNS3_9enable_ifIXsr24detect_string_can_appendIT_T0_EE5valueEiE4typeELi0EEEvRSD_OSE_DpOT1_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_06detail11concat_intoINSt3__112basic_stringIcNS3_11char_traitsIcEENS3_9allocatorIcEEEERKS9_JETnNS3_9enable_ifIXsr24detect_string_can_appendIT_T0_EE5valueEiE4typeELi0EEEvRSD_OSE_DpOT1_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_06detail11concat_intoINSt3__112basic_stringIcNS3_11char_traitsIcEENS3_9allocatorIcEEEERA17_KcJRKS9_cS9_RA3_SA_ETnNS3_9enable_ifIXsr24detect_string_can_appendIT_T0_EE5valueEiE4typeELi0EEEvRSI_OSJ_DpOT1_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_06detail11concat_intoINSt3__112basic_stringIcNS3_11char_traitsIcEENS3_9allocatorIcEEEERKS9_JcS9_RA3_KcETnNS3_9enable_ifIXsr24detect_string_can_appendIT_T0_EE5valueEiE4typeELi0EEEvRSG_OSH_DpOT1_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_06detail11concat_intoINSt3__112basic_stringIcNS3_11char_traitsIcEENS3_9allocatorIcEEEES9_JRA3_KcETnNS3_9enable_ifIXsr24detect_string_can_appendIT_T0_EE5valueEiE4typeELi0EEEvRSE_OSF_DpOT1_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_06detail11concat_intoINSt3__112basic_stringIcNS3_11char_traitsIcEENS3_9allocatorIcEEEERA3_KcJETnNS3_9enable_ifIXsr24detect_string_can_appendIT_T0_EE5valueEiE4typeELi0EEEvRSE_OSF_DpOT1_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_06detail11concat_intoINSt3__112basic_stringIcNS3_11char_traitsIcEENS3_9allocatorIcEEEERA51_KcJPSA_ETnNS3_9enable_ifIXsr24detect_string_can_appendIT_T0_EE5valueEiE4typeELi0EEEvRSF_OSG_DpOT1_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_06detail11concat_intoINSt3__112basic_stringIcNS3_11char_traitsIcEENS3_9allocatorIcEEEEPKcJETnNS3_9enable_ifIXsr24detect_string_can_appendIT_T0_EE5valueEiE4typeELi0EEEvRSD_OSE_DpOT1_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_06detail11concat_intoINSt3__112basic_stringIcNS3_11char_traitsIcEENS3_9allocatorIcEEEERA10_KcJS9_SC_S9_ETnNS3_9enable_ifIXsr24detect_string_can_appendIT_T0_EE5valueEiE4typeELi0EEEvRSE_OSF_DpOT1_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_06detail11concat_intoINSt3__112basic_stringIcNS3_11char_traitsIcEENS3_9allocatorIcEEEES9_JRA10_KcS9_ETnNS3_9enable_ifIXsr24detect_string_can_appendIT_T0_EE5valueEiE4typeELi0EEEvRSE_OSF_DpOT1_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_06detail11concat_intoINSt3__112basic_stringIcNS3_11char_traitsIcEENS3_9allocatorIcEEEERA10_KcJS9_ETnNS3_9enable_ifIXsr24detect_string_can_appendIT_T0_EE5valueEiE4typeELi0EEEvRSE_OSF_DpOT1_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_06detail11concat_intoINSt3__112basic_stringIcNS3_11char_traitsIcEENS3_9allocatorIcEEEES9_JETnNS3_9enable_ifIXsr24detect_string_can_appendIT_T0_EE5valueEiE4typeELi0EEEvRSB_OSC_DpOT1_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_06detail11concat_intoINSt3__112basic_stringIcNS3_11char_traitsIcEENS3_9allocatorIcEEEES9_JRA12_KcS9_RA3_SA_S9_RKS9_ETnNS3_9enable_ifIXsr24detect_string_can_appendIT_T0_EE5valueEiE4typeELi0EEEvRSI_OSJ_DpOT1_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_06detail11concat_intoINSt3__112basic_stringIcNS3_11char_traitsIcEENS3_9allocatorIcEEEERA12_KcJS9_RA3_SA_S9_RKS9_ETnNS3_9enable_ifIXsr24detect_string_can_appendIT_T0_EE5valueEiE4typeELi0EEEvRSI_OSJ_DpOT1_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_06detail11concat_intoINSt3__112basic_stringIcNS3_11char_traitsIcEENS3_9allocatorIcEEEES9_JRA3_KcS9_RKS9_ETnNS3_9enable_ifIXsr24detect_string_can_appendIT_T0_EE5valueEiE4typeELi0EEEvRSG_OSH_DpOT1_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_06detail11concat_intoINSt3__112basic_stringIcNS3_11char_traitsIcEENS3_9allocatorIcEEEERA3_KcJS9_RKS9_ETnNS3_9enable_ifIXsr24detect_string_can_appendIT_T0_EE5valueEiE4typeELi0EEEvRSG_OSH_DpOT1_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_06detail11concat_intoINSt3__112basic_stringIcNS3_11char_traitsIcEENS3_9allocatorIcEEEERA24_KcJS9_ETnNS3_9enable_ifIXsr24detect_string_can_appendIT_T0_EE5valueEiE4typeELi0EEEvRSE_OSF_DpOT1_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_06detail11concat_intoINSt3__112basic_stringIcNS3_11char_traitsIcEENS3_9allocatorIcEEEERA25_KcJPSA_ETnNS3_9enable_ifIXsr24detect_string_can_appendIT_T0_EE5valueEiE4typeELi0EEEvRSF_OSG_DpOT1_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_06detail11concat_intoINSt3__112basic_stringIcNS3_11char_traitsIcEENS3_9allocatorIcEEEERA23_KcJS9_ETnNS3_9enable_ifIXsr24detect_string_can_appendIT_T0_EE5valueEiE4typeELi0EEEvRSE_OSF_DpOT1_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_06detail11concat_intoINSt3__112basic_stringIcNS3_11char_traitsIcEENS3_9allocatorIcEEEERA26_KcJS9_cETnNS3_9enable_ifIXsr24detect_string_can_appendIT_T0_EE5valueEiE4typeELi0EEEvRSE_OSF_DpOT1_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_06detail11concat_intoINSt3__112basic_stringIcNS3_11char_traitsIcEENS3_9allocatorIcEEEES9_JcETnNS3_9enable_ifIXsr24detect_string_can_appendIT_T0_EE5valueEiE4typeELi0EEEvRSB_OSC_DpOT1_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_06detail11concat_intoINSt3__112basic_stringIcNS3_11char_traitsIcEENS3_9allocatorIcEEEERA15_KcJRKS9_cETnNS3_9enable_ifIXsr24detect_string_can_appendIT_T0_EE5valueEiE4typeELi0EEEvRSG_OSH_DpOT1_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_06detail11concat_intoINSt3__112basic_stringIcNS3_11char_traitsIcEENS3_9allocatorIcEEEERKS9_JcETnNS3_9enable_ifIXsr24detect_string_can_appendIT_T0_EE5valueEiE4typeELi0EEEvRSD_OSE_DpOT1_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_06detail11concat_intoINSt3__112basic_stringIcNS3_11char_traitsIcEENS3_9allocatorIcEEEEPKcJRA15_SA_S9_cETnNS3_9enable_ifIXsr24detect_string_can_appendIT_T0_EE5valueEiE4typeELi0EEEvRSF_OSG_DpOT1_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_06detail11concat_intoINSt3__112basic_stringIcNS3_11char_traitsIcEENS3_9allocatorIcEEEERA15_KcJS9_cETnNS3_9enable_ifIXsr24detect_string_can_appendIT_T0_EE5valueEiE4typeELi0EEEvRSE_OSF_DpOT1_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_06detail11concat_intoINSt3__112basic_stringIcNS3_11char_traitsIcEENS3_9allocatorIcEEEERA12_KcJPSA_ETnNS3_9enable_ifIXsr24detect_string_can_appendIT_T0_EE5valueEiE4typeELi0EEEvRSF_OSG_DpOT1_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_06detail11concat_intoINSt3__112basic_stringIcNS3_11char_traitsIcEENS3_9allocatorIcEEEERA54_KcJRKS9_RA2_SA_ETnNS3_9enable_ifIXsr24detect_string_can_appendIT_T0_EE5valueEiE4typeELi0EEEvRSI_OSJ_DpOT1_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_06detail11concat_intoINSt3__112basic_stringIcNS3_11char_traitsIcEENS3_9allocatorIcEEEERKS9_JRA2_KcETnNS3_9enable_ifIXsr24detect_string_can_appendIT_T0_EE5valueEiE4typeELi0EEEvRSG_OSH_DpOT1_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_06detail11concat_intoINSt3__112basic_stringIcNS3_11char_traitsIcEENS3_9allocatorIcEEEERA2_KcJETnNS3_9enable_ifIXsr24detect_string_can_appendIT_T0_EE5valueEiE4typeELi0EEEvRSE_OSF_DpOT1_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_06detail11concat_intoINSt3__112basic_stringIcNS3_11char_traitsIcEENS3_9allocatorIcEEEERA29_KcJPSA_ETnNS3_9enable_ifIXsr24detect_string_can_appendIT_T0_EE5valueEiE4typeELi0EEEvRSF_OSG_DpOT1_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_06detail11concat_intoINSt3__112basic_stringIcNS3_11char_traitsIcEENS3_9allocatorIcEEEERA30_KcJPSA_ETnNS3_9enable_ifIXsr24detect_string_can_appendIT_T0_EE5valueEiE4typeELi0EEEvRSF_OSG_DpOT1_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_06detail11concat_intoINSt3__112basic_stringIcNS3_11char_traitsIcEENS3_9allocatorIcEEEERA52_KcJPSA_ETnNS3_9enable_ifIXsr24detect_string_can_appendIT_T0_EE5valueEiE4typeELi0EEEvRSF_OSG_DpOT1_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_06detail11concat_intoINSt3__112basic_stringIcNS3_11char_traitsIcEENS3_9allocatorIcEEEERA29_KcJS9_RA5_SA_S9_ETnNS3_9enable_ifIXsr24detect_string_can_appendIT_T0_EE5valueEiE4typeELi0EEEvRSG_OSH_DpOT1_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_06detail11concat_intoINSt3__112basic_stringIcNS3_11char_traitsIcEENS3_9allocatorIcEEEES9_JRA5_KcS9_ETnNS3_9enable_ifIXsr24detect_string_can_appendIT_T0_EE5valueEiE4typeELi0EEEvRSE_OSF_DpOT1_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_06detail11concat_intoINSt3__112basic_stringIcNS3_11char_traitsIcEENS3_9allocatorIcEEEERA5_KcJS9_ETnNS3_9enable_ifIXsr24detect_string_can_appendIT_T0_EE5valueEiE4typeELi0EEEvRSE_OSF_DpOT1_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_06detail11concat_intoINSt3__112basic_stringIcNS3_11char_traitsIcEENS3_9allocatorIcEEEERA39_KcJS9_ETnNS3_9enable_ifIXsr24detect_string_can_appendIT_T0_EE5valueEiE4typeELi0EEEvRSE_OSF_DpOT1_ |
4492 | | |
4493 | | template < typename OutStringType, typename Arg, typename... Args, |
4494 | | enable_if_t < !detect_string_can_append<OutStringType, Arg>::value |
4495 | | && detect_string_can_append_op<OutStringType, Arg>::value, int > > |
4496 | | inline void concat_into(OutStringType& out, Arg&& arg, Args&& ... rest) |
4497 | 0 | { |
4498 | 0 | out += std::forward<Arg>(arg); |
4499 | 0 | concat_into(out, std::forward<Args>(rest)...); |
4500 | 0 | } Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_06detail11concat_intoINSt3__112basic_stringIcNS3_11char_traitsIcEENS3_9allocatorIcEEEEcJS9_RA3_KcETnNS3_9enable_ifIXaantsr24detect_string_can_appendIT_T0_EE5valuesr27detect_string_can_append_opISE_SF_EE5valueEiE4typeELi0EEEvRSE_OSF_DpOT1_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_06detail11concat_intoINSt3__112basic_stringIcNS3_11char_traitsIcEENS3_9allocatorIcEEEEcJETnNS3_9enable_ifIXaantsr24detect_string_can_appendIT_T0_EE5valuesr27detect_string_can_append_opISB_SC_EE5valueEiE4typeELi0EEEvRSB_OSC_DpOT1_ |
4501 | | |
4502 | | template < typename OutStringType, typename Arg, typename... Args, |
4503 | | enable_if_t < !detect_string_can_append<OutStringType, Arg>::value |
4504 | | && !detect_string_can_append_op<OutStringType, Arg>::value |
4505 | | && detect_string_can_append_iter<OutStringType, Arg>::value, int > > |
4506 | | inline void concat_into(OutStringType& out, const Arg& arg, Args&& ... rest) |
4507 | | { |
4508 | | out.append(arg.begin(), arg.end()); |
4509 | | concat_into(out, std::forward<Args>(rest)...); |
4510 | | } |
4511 | | |
4512 | | template < typename OutStringType, typename Arg, typename... Args, |
4513 | | enable_if_t < !detect_string_can_append<OutStringType, Arg>::value |
4514 | | && !detect_string_can_append_op<OutStringType, Arg>::value |
4515 | | && !detect_string_can_append_iter<OutStringType, Arg>::value |
4516 | | && detect_string_can_append_data<OutStringType, Arg>::value, int > > |
4517 | | inline void concat_into(OutStringType& out, const Arg& arg, Args&& ... rest) |
4518 | | { |
4519 | | out.append(arg.data(), arg.size()); |
4520 | | concat_into(out, std::forward<Args>(rest)...); |
4521 | | } |
4522 | | |
4523 | | template<typename OutStringType = std::string, typename... Args> |
4524 | | inline OutStringType concat(Args && ... args) |
4525 | 0 | { |
4526 | 0 | OutStringType str; |
4527 | 0 | str.reserve(concat_length(args...)); |
4528 | 0 | concat_into(str, std::forward<Args>(args)...); |
4529 | 0 | return str; |
4530 | 0 | } Unexecuted instantiation: std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > nlohmann::json_abi_v3_12_0::detail::concat<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&>(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) Unexecuted instantiation: std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > nlohmann::json_abi_v3_12_0::detail::concat<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, char const (&) [17], std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, char, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, char const (&) [3]>(char const (&) [17], std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, char&&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&&, char const (&) [3]) Unexecuted instantiation: std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > nlohmann::json_abi_v3_12_0::detail::concat<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, char const (&) [51], char const*>(char const (&) [51], char const*&&) Unexecuted instantiation: std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > nlohmann::json_abi_v3_12_0::detail::concat<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, char const (&) [10], std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, char const (&) [10], std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >(char const (&) [10], std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&&, char const (&) [10], std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&&) Unexecuted instantiation: std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > nlohmann::json_abi_v3_12_0::detail::concat<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, char const (&) [10], std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >(char const (&) [10], std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&&) Unexecuted instantiation: std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > nlohmann::json_abi_v3_12_0::detail::concat<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, char const (&) [12], std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, char const (&) [3], std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&>(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&&, char const (&) [12], std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&&, char const (&) [3], std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) Unexecuted instantiation: std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > nlohmann::json_abi_v3_12_0::detail::concat<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, char const (&) [24], std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >(char const (&) [24], std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&&) Unexecuted instantiation: std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > nlohmann::json_abi_v3_12_0::detail::concat<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, char const (&) [25], char const*>(char const (&) [25], char const*&&) Unexecuted instantiation: std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > nlohmann::json_abi_v3_12_0::detail::concat<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, char const (&) [23], std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >(char const (&) [23], std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&&) Unexecuted instantiation: std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > nlohmann::json_abi_v3_12_0::detail::concat<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, char const (&) [26], std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, char>(char const (&) [26], std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&&, char&&) Unexecuted instantiation: std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > nlohmann::json_abi_v3_12_0::detail::concat<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, char const (&) [15], std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, char>(char const (&) [15], std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, char&&) Unexecuted instantiation: std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > nlohmann::json_abi_v3_12_0::detail::concat<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, char const*, char const (&) [15], std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, char>(char const*&&, char const (&) [15], std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&&, char&&) Unexecuted instantiation: std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > nlohmann::json_abi_v3_12_0::detail::concat<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, char const (&) [12], char const*>(char const (&) [12], char const*&&) Unexecuted instantiation: std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > nlohmann::json_abi_v3_12_0::detail::concat<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, char const (&) [54], std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, char const (&) [2]>(char const (&) [54], std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, char const (&) [2]) Unexecuted instantiation: std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > nlohmann::json_abi_v3_12_0::detail::concat<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, char const (&) [29], char const*>(char const (&) [29], char const*&&) Unexecuted instantiation: std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > nlohmann::json_abi_v3_12_0::detail::concat<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, char const (&) [30], char const*>(char const (&) [30], char const*&&) Unexecuted instantiation: std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > nlohmann::json_abi_v3_12_0::detail::concat<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, char const (&) [52], char const*>(char const (&) [52], char const*&&) Unexecuted instantiation: std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > nlohmann::json_abi_v3_12_0::detail::concat<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, char const (&) [29], std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, char const (&) [5], std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >(char const (&) [29], std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&&, char const (&) [5], std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&&) Unexecuted instantiation: std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > nlohmann::json_abi_v3_12_0::detail::concat<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, char const (&) [39], std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >(char const (&) [39], std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&&) |
4531 | | |
4532 | | } // namespace detail |
4533 | | NLOHMANN_JSON_NAMESPACE_END |
4534 | | |
4535 | | |
4536 | | // With -Wweak-vtables, Clang will complain about the exception classes as they |
4537 | | // have no out-of-line virtual method definitions and their vtable will be |
4538 | | // emitted in every translation unit. This issue cannot be fixed with a |
4539 | | // header-only library as there is no implementation file to move these |
4540 | | // functions to. As a result, we suppress this warning here to avoid client |
4541 | | // code stumbling over this. See https://github.com/nlohmann/json/issues/4087 |
4542 | | // for a discussion. |
4543 | | #if defined(__clang__) |
4544 | | #pragma clang diagnostic push |
4545 | | #pragma clang diagnostic ignored "-Wweak-vtables" |
4546 | | #endif |
4547 | | |
4548 | | NLOHMANN_JSON_NAMESPACE_BEGIN |
4549 | | namespace detail |
4550 | | { |
4551 | | |
4552 | | //////////////// |
4553 | | // exceptions // |
4554 | | //////////////// |
4555 | | |
4556 | | /// @brief general exception of the @ref basic_json class |
4557 | | /// @sa https://json.nlohmann.me/api/basic_json/exception/ |
4558 | | class exception : public std::exception |
4559 | | { |
4560 | | public: |
4561 | | /// returns the explanatory string |
4562 | | const char* what() const noexcept override |
4563 | 0 | { |
4564 | 0 | return m.what(); |
4565 | 0 | } |
4566 | | |
4567 | | /// the id of the exception |
4568 | | const int id; // NOLINT(cppcoreguidelines-non-private-member-variables-in-classes) |
4569 | | |
4570 | | protected: |
4571 | | JSON_HEDLEY_NON_NULL(3) |
4572 | 0 | exception(int id_, const char* what_arg) : id(id_), m(what_arg) {} // NOLINT(bugprone-throw-keyword-missing) |
4573 | | |
4574 | | static std::string name(const std::string& ename, int id_) |
4575 | 0 | { |
4576 | 0 | return concat("[json.exception.", ename, '.', std::to_string(id_), "] "); |
4577 | 0 | } |
4578 | | |
4579 | | static std::string diagnostics(std::nullptr_t /*leaf_element*/) |
4580 | 0 | { |
4581 | 0 | return ""; |
4582 | 0 | } |
4583 | | |
4584 | | template<typename BasicJsonType> |
4585 | | static std::string diagnostics(const BasicJsonType* leaf_element) |
4586 | 0 | { |
4587 | | #if JSON_DIAGNOSTICS |
4588 | | std::vector<std::string> tokens; |
4589 | | for (const auto* current = leaf_element; current != nullptr && current->m_parent != nullptr; current = current->m_parent) |
4590 | | { |
4591 | | switch (current->m_parent->type()) |
4592 | | { |
4593 | | case value_t::array: |
4594 | | { |
4595 | | for (std::size_t i = 0; i < current->m_parent->m_data.m_value.array->size(); ++i) |
4596 | | { |
4597 | | if (¤t->m_parent->m_data.m_value.array->operator[](i) == current) |
4598 | | { |
4599 | | tokens.emplace_back(std::to_string(i)); |
4600 | | break; |
4601 | | } |
4602 | | } |
4603 | | break; |
4604 | | } |
4605 | | |
4606 | | case value_t::object: |
4607 | | { |
4608 | | for (const auto& element : *current->m_parent->m_data.m_value.object) |
4609 | | { |
4610 | | if (&element.second == current) |
4611 | | { |
4612 | | tokens.emplace_back(element.first.c_str()); |
4613 | | break; |
4614 | | } |
4615 | | } |
4616 | | break; |
4617 | | } |
4618 | | |
4619 | | case value_t::null: // LCOV_EXCL_LINE |
4620 | | case value_t::string: // LCOV_EXCL_LINE |
4621 | | case value_t::boolean: // LCOV_EXCL_LINE |
4622 | | case value_t::number_integer: // LCOV_EXCL_LINE |
4623 | | case value_t::number_unsigned: // LCOV_EXCL_LINE |
4624 | | case value_t::number_float: // LCOV_EXCL_LINE |
4625 | | case value_t::binary: // LCOV_EXCL_LINE |
4626 | | case value_t::discarded: // LCOV_EXCL_LINE |
4627 | | default: // LCOV_EXCL_LINE |
4628 | | break; // LCOV_EXCL_LINE |
4629 | | } |
4630 | | } |
4631 | | |
4632 | | if (tokens.empty()) |
4633 | | { |
4634 | | return ""; |
4635 | | } |
4636 | | |
4637 | | auto str = std::accumulate(tokens.rbegin(), tokens.rend(), std::string{}, |
4638 | | [](const std::string & a, const std::string & b) |
4639 | | { |
4640 | | return concat(a, '/', detail::escape(b)); |
4641 | | }); |
4642 | | |
4643 | | return concat('(', str, ") ", get_byte_positions(leaf_element)); |
4644 | | #else |
4645 | 0 | return get_byte_positions(leaf_element); |
4646 | 0 | #endif |
4647 | 0 | } |
4648 | | |
4649 | | private: |
4650 | | /// an exception object as storage for error messages |
4651 | | std::runtime_error m; |
4652 | | #if JSON_DIAGNOSTIC_POSITIONS |
4653 | | template<typename BasicJsonType> |
4654 | | static std::string get_byte_positions(const BasicJsonType* leaf_element) |
4655 | | { |
4656 | | if ((leaf_element->start_pos() != std::string::npos) && (leaf_element->end_pos() != std::string::npos)) |
4657 | | { |
4658 | | return concat("(bytes ", std::to_string(leaf_element->start_pos()), "-", std::to_string(leaf_element->end_pos()), ") "); |
4659 | | } |
4660 | | return ""; |
4661 | | } |
4662 | | #else |
4663 | | template<typename BasicJsonType> |
4664 | | static std::string get_byte_positions(const BasicJsonType* leaf_element) |
4665 | 0 | { |
4666 | 0 | static_cast<void>(leaf_element); |
4667 | 0 | return ""; |
4668 | 0 | } |
4669 | | #endif |
4670 | | }; |
4671 | | |
4672 | | /// @brief exception indicating a parse error |
4673 | | /// @sa https://json.nlohmann.me/api/basic_json/parse_error/ |
4674 | | class parse_error : public exception |
4675 | | { |
4676 | | public: |
4677 | | /*! |
4678 | | @brief create a parse error exception |
4679 | | @param[in] id_ the id of the exception |
4680 | | @param[in] pos the position where the error occurred (or with |
4681 | | chars_read_total=0 if the position cannot be |
4682 | | determined) |
4683 | | @param[in] what_arg the explanatory string |
4684 | | @return parse_error object |
4685 | | */ |
4686 | | template<typename BasicJsonContext, enable_if_t<is_basic_json_context<BasicJsonContext>::value, int> = 0> |
4687 | | static parse_error create(int id_, const position_t& pos, const std::string& what_arg, BasicJsonContext context) |
4688 | 0 | { |
4689 | 0 | const std::string w = concat(exception::name("parse_error", id_), "parse error", |
4690 | 0 | position_string(pos), ": ", exception::diagnostics(context), what_arg); |
4691 | 0 | return {id_, pos.chars_read_total, w.c_str()}; |
4692 | 0 | } |
4693 | | |
4694 | | template<typename BasicJsonContext, enable_if_t<is_basic_json_context<BasicJsonContext>::value, int> = 0> |
4695 | | static parse_error create(int id_, std::size_t byte_, const std::string& what_arg, BasicJsonContext context) |
4696 | 0 | { |
4697 | 0 | const std::string w = concat(exception::name("parse_error", id_), "parse error", |
4698 | 0 | (byte_ != 0 ? (concat(" at byte ", std::to_string(byte_))) : ""), |
4699 | 0 | ": ", exception::diagnostics(context), what_arg); |
4700 | 0 | return {id_, byte_, w.c_str()}; |
4701 | 0 | } |
4702 | | |
4703 | | /*! |
4704 | | @brief byte index of the parse error |
4705 | | |
4706 | | The byte index of the last read character in the input file. |
4707 | | |
4708 | | @note For an input with n bytes, 1 is the index of the first character and |
4709 | | n+1 is the index of the terminating null byte or the end of file. |
4710 | | This also holds true when reading a byte vector (CBOR or MessagePack). |
4711 | | */ |
4712 | | const std::size_t byte; |
4713 | | |
4714 | | private: |
4715 | | parse_error(int id_, std::size_t byte_, const char* what_arg) |
4716 | 0 | : exception(id_, what_arg), byte(byte_) {} |
4717 | | |
4718 | | static std::string position_string(const position_t& pos) |
4719 | 0 | { |
4720 | 0 | return concat(" at line ", std::to_string(pos.lines_read + 1), |
4721 | 0 | ", column ", std::to_string(pos.chars_read_current_line)); |
4722 | 0 | } |
4723 | | }; |
4724 | | |
4725 | | /// @brief exception indicating errors with iterators |
4726 | | /// @sa https://json.nlohmann.me/api/basic_json/invalid_iterator/ |
4727 | | class invalid_iterator : public exception |
4728 | | { |
4729 | | public: |
4730 | | template<typename BasicJsonContext, enable_if_t<is_basic_json_context<BasicJsonContext>::value, int> = 0> |
4731 | | static invalid_iterator create(int id_, const std::string& what_arg, BasicJsonContext context) |
4732 | 0 | { |
4733 | 0 | const std::string w = concat(exception::name("invalid_iterator", id_), exception::diagnostics(context), what_arg); |
4734 | 0 | return {id_, w.c_str()}; |
4735 | 0 | } Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_06detail16invalid_iterator6createIPNS0_10basic_jsonINSt3__13mapENS5_6vectorENS5_12basic_stringIcNS5_11char_traitsIcEENS5_9allocatorIcEEEEblmdSB_NS0_14adl_serializerENS7_IhNSB_IhEEEEvEETnNS5_9enable_ifIXsr21is_basic_json_contextIT_EE5valueEiE4typeELi0EEES2_iRKSD_SK_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_06detail16invalid_iterator6createIPKNS0_10basic_jsonINSt3__13mapENS5_6vectorENS5_12basic_stringIcNS5_11char_traitsIcEENS5_9allocatorIcEEEEblmdSB_NS0_14adl_serializerENS7_IhNSB_IhEEEEvEETnNS5_9enable_ifIXsr21is_basic_json_contextIT_EE5valueEiE4typeELi0EEES2_iRKSD_SL_ |
4736 | | |
4737 | | private: |
4738 | | JSON_HEDLEY_NON_NULL(3) |
4739 | | invalid_iterator(int id_, const char* what_arg) |
4740 | 0 | : exception(id_, what_arg) {} |
4741 | | }; |
4742 | | |
4743 | | /// @brief exception indicating executing a member function with a wrong type |
4744 | | /// @sa https://json.nlohmann.me/api/basic_json/type_error/ |
4745 | | class type_error : public exception |
4746 | | { |
4747 | | public: |
4748 | | template<typename BasicJsonContext, enable_if_t<is_basic_json_context<BasicJsonContext>::value, int> = 0> |
4749 | | static type_error create(int id_, const std::string& what_arg, BasicJsonContext context) |
4750 | 0 | { |
4751 | 0 | const std::string w = concat(exception::name("type_error", id_), exception::diagnostics(context), what_arg); |
4752 | 0 | return {id_, w.c_str()}; |
4753 | 0 | } Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_06detail10type_error6createIPNS0_10basic_jsonINSt3__13mapENS5_6vectorENS5_12basic_stringIcNS5_11char_traitsIcEENS5_9allocatorIcEEEEblmdSB_NS0_14adl_serializerENS7_IhNSB_IhEEEEvEETnNS5_9enable_ifIXsr21is_basic_json_contextIT_EE5valueEiE4typeELi0EEES2_iRKSD_SK_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_06detail10type_error6createIPKNS0_10basic_jsonINSt3__13mapENS5_6vectorENS5_12basic_stringIcNS5_11char_traitsIcEENS5_9allocatorIcEEEEblmdSB_NS0_14adl_serializerENS7_IhNSB_IhEEEEvEETnNS5_9enable_ifIXsr21is_basic_json_contextIT_EE5valueEiE4typeELi0EEES2_iRKSD_SL_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_06detail10type_error6createIDnTnNSt3__19enable_ifIXsr21is_basic_json_contextIT_EE5valueEiE4typeELi0EEES2_iRKNS4_12basic_stringIcNS4_11char_traitsIcEENS4_9allocatorIcEEEES6_ |
4754 | | |
4755 | | private: |
4756 | | JSON_HEDLEY_NON_NULL(3) |
4757 | 0 | type_error(int id_, const char* what_arg) : exception(id_, what_arg) {} |
4758 | | }; |
4759 | | |
4760 | | /// @brief exception indicating access out of the defined range |
4761 | | /// @sa https://json.nlohmann.me/api/basic_json/out_of_range/ |
4762 | | class out_of_range : public exception |
4763 | | { |
4764 | | public: |
4765 | | template<typename BasicJsonContext, enable_if_t<is_basic_json_context<BasicJsonContext>::value, int> = 0> |
4766 | | static out_of_range create(int id_, const std::string& what_arg, BasicJsonContext context) |
4767 | 0 | { |
4768 | 0 | const std::string w = concat(exception::name("out_of_range", id_), exception::diagnostics(context), what_arg); |
4769 | 0 | return {id_, w.c_str()}; |
4770 | 0 | } Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_06detail12out_of_range6createIPNS0_10basic_jsonINSt3__13mapENS5_6vectorENS5_12basic_stringIcNS5_11char_traitsIcEENS5_9allocatorIcEEEEblmdSB_NS0_14adl_serializerENS7_IhNSB_IhEEEEvEETnNS5_9enable_ifIXsr21is_basic_json_contextIT_EE5valueEiE4typeELi0EEES2_iRKSD_SK_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_06detail12out_of_range6createIDnTnNSt3__19enable_ifIXsr21is_basic_json_contextIT_EE5valueEiE4typeELi0EEES2_iRKNS4_12basic_stringIcNS4_11char_traitsIcEENS4_9allocatorIcEEEES6_ |
4771 | | |
4772 | | private: |
4773 | | JSON_HEDLEY_NON_NULL(3) |
4774 | 0 | out_of_range(int id_, const char* what_arg) : exception(id_, what_arg) {} |
4775 | | }; |
4776 | | |
4777 | | /// @brief exception indicating other library errors |
4778 | | /// @sa https://json.nlohmann.me/api/basic_json/other_error/ |
4779 | | class other_error : public exception |
4780 | | { |
4781 | | public: |
4782 | | template<typename BasicJsonContext, enable_if_t<is_basic_json_context<BasicJsonContext>::value, int> = 0> |
4783 | | static other_error create(int id_, const std::string& what_arg, BasicJsonContext context) |
4784 | 0 | { |
4785 | 0 | const std::string w = concat(exception::name("other_error", id_), exception::diagnostics(context), what_arg); |
4786 | 0 | return {id_, w.c_str()}; |
4787 | 0 | } |
4788 | | |
4789 | | private: |
4790 | | JSON_HEDLEY_NON_NULL(3) |
4791 | 0 | other_error(int id_, const char* what_arg) : exception(id_, what_arg) {} |
4792 | | }; |
4793 | | |
4794 | | } // namespace detail |
4795 | | NLOHMANN_JSON_NAMESPACE_END |
4796 | | |
4797 | | #if defined(__clang__) |
4798 | | #pragma clang diagnostic pop |
4799 | | #endif |
4800 | | |
4801 | | // #include <nlohmann/detail/macro_scope.hpp> |
4802 | | |
4803 | | // #include <nlohmann/detail/meta/cpp_future.hpp> |
4804 | | |
4805 | | // #include <nlohmann/detail/meta/identity_tag.hpp> |
4806 | | // __ _____ _____ _____ |
4807 | | // __| | __| | | | JSON for Modern C++ |
4808 | | // | | |__ | | | | | | version 3.12.0 |
4809 | | // |_____|_____|_____|_|___| https://github.com/nlohmann/json |
4810 | | // |
4811 | | // SPDX-FileCopyrightText: 2013-2026 Niels Lohmann <https://nlohmann.me> |
4812 | | // SPDX-License-Identifier: MIT |
4813 | | |
4814 | | |
4815 | | |
4816 | | // #include <nlohmann/detail/abi_macros.hpp> |
4817 | | |
4818 | | |
4819 | | NLOHMANN_JSON_NAMESPACE_BEGIN |
4820 | | namespace detail |
4821 | | { |
4822 | | |
4823 | | // dispatching helper struct |
4824 | | template <class T> struct identity_tag {}; |
4825 | | |
4826 | | } // namespace detail |
4827 | | NLOHMANN_JSON_NAMESPACE_END |
4828 | | |
4829 | | // #include <nlohmann/detail/meta/std_fs.hpp> |
4830 | | // __ _____ _____ _____ |
4831 | | // __| | __| | | | JSON for Modern C++ |
4832 | | // | | |__ | | | | | | version 3.12.0 |
4833 | | // |_____|_____|_____|_|___| https://github.com/nlohmann/json |
4834 | | // |
4835 | | // SPDX-FileCopyrightText: 2013-2026 Niels Lohmann <https://nlohmann.me> |
4836 | | // SPDX-License-Identifier: MIT |
4837 | | |
4838 | | |
4839 | | |
4840 | | // #include <nlohmann/detail/macro_scope.hpp> |
4841 | | |
4842 | | |
4843 | | #if JSON_HAS_EXPERIMENTAL_FILESYSTEM |
4844 | | #include <experimental/filesystem> |
4845 | | NLOHMANN_JSON_NAMESPACE_BEGIN |
4846 | | namespace detail |
4847 | | { |
4848 | | namespace std_fs = std::experimental::filesystem; |
4849 | | } // namespace detail |
4850 | | NLOHMANN_JSON_NAMESPACE_END |
4851 | | #elif JSON_HAS_FILESYSTEM |
4852 | | #include <filesystem> // NOLINT(build/c++17) |
4853 | | NLOHMANN_JSON_NAMESPACE_BEGIN |
4854 | | namespace detail |
4855 | | { |
4856 | | namespace std_fs = std::filesystem; |
4857 | | } // namespace detail |
4858 | | NLOHMANN_JSON_NAMESPACE_END |
4859 | | #endif |
4860 | | |
4861 | | // #include <nlohmann/detail/meta/type_traits.hpp> |
4862 | | |
4863 | | // #include <nlohmann/detail/string_concat.hpp> |
4864 | | |
4865 | | // #include <nlohmann/detail/value_t.hpp> |
4866 | | |
4867 | | |
4868 | | // include after macro_scope.hpp |
4869 | | #ifdef JSON_HAS_CPP_17 |
4870 | | #include <optional> // optional |
4871 | | #endif |
4872 | | |
4873 | | #if JSON_HAS_FILESYSTEM || JSON_HAS_EXPERIMENTAL_FILESYSTEM |
4874 | | #include <string_view> // u8string_view |
4875 | | #endif |
4876 | | |
4877 | | NLOHMANN_JSON_NAMESPACE_BEGIN |
4878 | | namespace detail |
4879 | | { |
4880 | | |
4881 | | template<typename BasicJsonType> |
4882 | | inline void from_json(const BasicJsonType& j, typename std::nullptr_t& n) |
4883 | | { |
4884 | | if (JSON_HEDLEY_UNLIKELY(!j.is_null())) |
4885 | | { |
4886 | | JSON_THROW(type_error::create(302, concat("type must be null, but is ", j.type_name()), &j)); |
4887 | | } |
4888 | | n = nullptr; |
4889 | | } |
4890 | | |
4891 | | #ifdef JSON_HAS_CPP_17 |
4892 | | template < typename BasicJsonType, typename T, |
4893 | | typename std::enable_if < !nlohmann::detail::is_basic_json<T>::value, int >::type = 0 > |
4894 | | void from_json(const BasicJsonType& j, std::optional<T>& opt) |
4895 | | { |
4896 | | if (j.is_null()) |
4897 | | { |
4898 | | opt = std::nullopt; |
4899 | | } |
4900 | | else |
4901 | | { |
4902 | | opt.emplace(j.template get<T>()); |
4903 | | } |
4904 | | } |
4905 | | #endif // JSON_HAS_CPP_17 |
4906 | | |
4907 | | // overloads for basic_json template parameters |
4908 | | template < typename BasicJsonType, typename ArithmeticType, |
4909 | | enable_if_t < std::is_arithmetic<ArithmeticType>::value&& |
4910 | | !std::is_same<ArithmeticType, typename BasicJsonType::boolean_t>::value, |
4911 | | int > = 0 > |
4912 | | void get_arithmetic_value(const BasicJsonType& j, ArithmeticType& val) |
4913 | 0 | { |
4914 | 0 | switch (static_cast<value_t>(j)) |
4915 | 0 | { |
4916 | 0 | case value_t::number_unsigned: |
4917 | 0 | { |
4918 | 0 | val = static_cast<ArithmeticType>(*j.template get_ptr<const typename BasicJsonType::number_unsigned_t*>()); |
4919 | 0 | break; |
4920 | 0 | } |
4921 | 0 | case value_t::number_integer: |
4922 | 0 | { |
4923 | 0 | val = static_cast<ArithmeticType>(*j.template get_ptr<const typename BasicJsonType::number_integer_t*>()); |
4924 | 0 | break; |
4925 | 0 | } |
4926 | 0 | case value_t::number_float: |
4927 | 0 | { |
4928 | 0 | val = static_cast<ArithmeticType>(*j.template get_ptr<const typename BasicJsonType::number_float_t*>()); |
4929 | 0 | break; |
4930 | 0 | } |
4931 | | |
4932 | 0 | case value_t::null: |
4933 | 0 | case value_t::object: |
4934 | 0 | case value_t::array: |
4935 | 0 | case value_t::string: |
4936 | 0 | case value_t::boolean: |
4937 | 0 | case value_t::binary: |
4938 | 0 | case value_t::discarded: |
4939 | 0 | default: |
4940 | 0 | JSON_THROW(type_error::create(302, concat("type must be number, but is ", j.type_name()), &j)); |
4941 | 0 | } |
4942 | 0 | } |
4943 | | |
4944 | | template<typename BasicJsonType> |
4945 | | inline void from_json(const BasicJsonType& j, typename BasicJsonType::boolean_t& b) |
4946 | 0 | { |
4947 | 0 | if (JSON_HEDLEY_UNLIKELY(!j.is_boolean())) |
4948 | 0 | { |
4949 | 0 | JSON_THROW(type_error::create(302, concat("type must be boolean, but is ", j.type_name()), &j)); |
4950 | 0 | } |
4951 | 0 | b = *j.template get_ptr<const typename BasicJsonType::boolean_t*>(); |
4952 | 0 | } |
4953 | | |
4954 | | template<typename BasicJsonType> |
4955 | | inline void from_json(const BasicJsonType& j, typename BasicJsonType::string_t& s) |
4956 | 0 | { |
4957 | 0 | if (JSON_HEDLEY_UNLIKELY(!j.is_string())) |
4958 | 0 | { |
4959 | 0 | JSON_THROW(type_error::create(302, concat("type must be string, but is ", j.type_name()), &j)); |
4960 | 0 | } |
4961 | 0 | s = *j.template get_ptr<const typename BasicJsonType::string_t*>(); |
4962 | 0 | } |
4963 | | |
4964 | | template < |
4965 | | typename BasicJsonType, typename StringType, |
4966 | | enable_if_t < |
4967 | | std::is_assignable<StringType&, const typename BasicJsonType::string_t>::value |
4968 | | && is_detected_exact<typename BasicJsonType::string_t::value_type, value_type_t, StringType>::value |
4969 | | && !std::is_same<typename BasicJsonType::string_t, StringType>::value |
4970 | | && !is_json_ref<StringType>::value, int > = 0 > |
4971 | | inline void from_json(const BasicJsonType& j, StringType& s) |
4972 | | { |
4973 | | if (JSON_HEDLEY_UNLIKELY(!j.is_string())) |
4974 | | { |
4975 | | JSON_THROW(type_error::create(302, concat("type must be string, but is ", j.type_name()), &j)); |
4976 | | } |
4977 | | |
4978 | | s = *j.template get_ptr<const typename BasicJsonType::string_t*>(); |
4979 | | } |
4980 | | |
4981 | | template<typename BasicJsonType> |
4982 | | inline void from_json(const BasicJsonType& j, typename BasicJsonType::number_float_t& val) |
4983 | | { |
4984 | | get_arithmetic_value(j, val); |
4985 | | } |
4986 | | |
4987 | | template<typename BasicJsonType> |
4988 | | inline void from_json(const BasicJsonType& j, typename BasicJsonType::number_unsigned_t& val) |
4989 | 0 | { |
4990 | 0 | get_arithmetic_value(j, val); |
4991 | 0 | } |
4992 | | |
4993 | | template<typename BasicJsonType> |
4994 | | inline void from_json(const BasicJsonType& j, typename BasicJsonType::number_integer_t& val) |
4995 | | { |
4996 | | get_arithmetic_value(j, val); |
4997 | | } |
4998 | | |
4999 | | #if !JSON_DISABLE_ENUM_SERIALIZATION |
5000 | | template<typename BasicJsonType, typename EnumType, |
5001 | | enable_if_t<std::is_enum<EnumType>::value, int> = 0> |
5002 | | inline void from_json(const BasicJsonType& j, EnumType& e) |
5003 | | { |
5004 | | typename std::underlying_type<EnumType>::type val; |
5005 | | get_arithmetic_value(j, val); |
5006 | | e = static_cast<EnumType>(val); |
5007 | | } |
5008 | | #endif // JSON_DISABLE_ENUM_SERIALIZATION |
5009 | | |
5010 | | // forward_list doesn't have an insert method |
5011 | | template<typename BasicJsonType, typename T, typename Allocator, |
5012 | | enable_if_t<is_getable<BasicJsonType, T>::value, int> = 0> |
5013 | | inline void from_json(const BasicJsonType& j, std::forward_list<T, Allocator>& l) |
5014 | | { |
5015 | | if (JSON_HEDLEY_UNLIKELY(!j.is_array())) |
5016 | | { |
5017 | | JSON_THROW(type_error::create(302, concat("type must be array, but is ", j.type_name()), &j)); |
5018 | | } |
5019 | | l.clear(); |
5020 | | std::transform(j.rbegin(), j.rend(), |
5021 | | std::front_inserter(l), [](const BasicJsonType & i) |
5022 | | { |
5023 | | return i.template get<T>(); |
5024 | | }); |
5025 | | } |
5026 | | |
5027 | | // valarray doesn't have an insert method |
5028 | | template<typename BasicJsonType, typename T, |
5029 | | enable_if_t<is_getable<BasicJsonType, T>::value, int> = 0> |
5030 | | inline void from_json(const BasicJsonType& j, std::valarray<T>& l) |
5031 | | { |
5032 | | if (JSON_HEDLEY_UNLIKELY(!j.is_array())) |
5033 | | { |
5034 | | JSON_THROW(type_error::create(302, concat("type must be array, but is ", j.type_name()), &j)); |
5035 | | } |
5036 | | l.resize(j.size()); |
5037 | | std::transform(j.begin(), j.end(), std::begin(l), |
5038 | | [](const BasicJsonType & elem) |
5039 | | { |
5040 | | return elem.template get<T>(); |
5041 | | }); |
5042 | | } |
5043 | | |
5044 | | template<typename BasicJsonType, typename T, std::size_t N> |
5045 | | auto from_json(const BasicJsonType& j, T (&arr)[N]) // NOLINT(cppcoreguidelines-avoid-c-arrays,hicpp-avoid-c-arrays,modernize-avoid-c-arrays) |
5046 | | -> decltype(j.template get<T>(), void()) |
5047 | | { |
5048 | | for (std::size_t i = 0; i < N; ++i) |
5049 | | { |
5050 | | arr[i] = j.at(i).template get<T>(); |
5051 | | } |
5052 | | } |
5053 | | |
5054 | | template<typename BasicJsonType, typename T, std::size_t N1, std::size_t N2> |
5055 | | auto from_json(const BasicJsonType& j, T (&arr)[N1][N2]) // NOLINT(cppcoreguidelines-avoid-c-arrays,hicpp-avoid-c-arrays,modernize-avoid-c-arrays) |
5056 | | -> decltype(j.template get<T>(), void()) |
5057 | | { |
5058 | | for (std::size_t i1 = 0; i1 < N1; ++i1) |
5059 | | { |
5060 | | for (std::size_t i2 = 0; i2 < N2; ++i2) |
5061 | | { |
5062 | | arr[i1][i2] = j.at(i1).at(i2).template get<T>(); |
5063 | | } |
5064 | | } |
5065 | | } |
5066 | | |
5067 | | template<typename BasicJsonType, typename T, std::size_t N1, std::size_t N2, std::size_t N3> |
5068 | | auto from_json(const BasicJsonType& j, T (&arr)[N1][N2][N3]) // NOLINT(cppcoreguidelines-avoid-c-arrays,hicpp-avoid-c-arrays,modernize-avoid-c-arrays) |
5069 | | -> decltype(j.template get<T>(), void()) |
5070 | | { |
5071 | | for (std::size_t i1 = 0; i1 < N1; ++i1) |
5072 | | { |
5073 | | for (std::size_t i2 = 0; i2 < N2; ++i2) |
5074 | | { |
5075 | | for (std::size_t i3 = 0; i3 < N3; ++i3) |
5076 | | { |
5077 | | arr[i1][i2][i3] = j.at(i1).at(i2).at(i3).template get<T>(); |
5078 | | } |
5079 | | } |
5080 | | } |
5081 | | } |
5082 | | |
5083 | | template<typename BasicJsonType, typename T, std::size_t N1, std::size_t N2, std::size_t N3, std::size_t N4> |
5084 | | auto from_json(const BasicJsonType& j, T (&arr)[N1][N2][N3][N4]) // NOLINT(cppcoreguidelines-avoid-c-arrays,hicpp-avoid-c-arrays,modernize-avoid-c-arrays) |
5085 | | -> decltype(j.template get<T>(), void()) |
5086 | | { |
5087 | | for (std::size_t i1 = 0; i1 < N1; ++i1) |
5088 | | { |
5089 | | for (std::size_t i2 = 0; i2 < N2; ++i2) |
5090 | | { |
5091 | | for (std::size_t i3 = 0; i3 < N3; ++i3) |
5092 | | { |
5093 | | for (std::size_t i4 = 0; i4 < N4; ++i4) |
5094 | | { |
5095 | | arr[i1][i2][i3][i4] = j.at(i1).at(i2).at(i3).at(i4).template get<T>(); |
5096 | | } |
5097 | | } |
5098 | | } |
5099 | | } |
5100 | | } |
5101 | | |
5102 | | template<typename BasicJsonType> |
5103 | | inline void from_json_array_impl(const BasicJsonType& j, typename BasicJsonType::array_t& arr, priority_tag<3> /*unused*/) |
5104 | | { |
5105 | | arr = *j.template get_ptr<const typename BasicJsonType::array_t*>(); |
5106 | | } |
5107 | | |
5108 | | template<typename BasicJsonType, typename T, std::size_t N> |
5109 | | auto from_json_array_impl(const BasicJsonType& j, std::array<T, N>& arr, |
5110 | | priority_tag<2> /*unused*/) |
5111 | | -> decltype(j.template get<T>(), void()) |
5112 | | { |
5113 | | for (std::size_t i = 0; i < N; ++i) |
5114 | | { |
5115 | | arr[i] = j.at(i).template get<T>(); |
5116 | | } |
5117 | | } |
5118 | | |
5119 | | template<typename BasicJsonType, typename ConstructibleArrayType, |
5120 | | enable_if_t< |
5121 | | std::is_assignable<ConstructibleArrayType&, ConstructibleArrayType>::value, |
5122 | | int> = 0> |
5123 | | auto from_json_array_impl(const BasicJsonType& j, ConstructibleArrayType& arr, priority_tag<1> /*unused*/) |
5124 | | -> decltype( |
5125 | | arr.reserve(std::declval<typename ConstructibleArrayType::size_type>()), |
5126 | | j.template get<typename ConstructibleArrayType::value_type>(), |
5127 | | void()) |
5128 | | { |
5129 | | using std::end; |
5130 | | |
5131 | | ConstructibleArrayType ret; |
5132 | | ret.reserve(j.size()); |
5133 | | std::transform(j.begin(), j.end(), |
5134 | | std::inserter(ret, end(ret)), [](const BasicJsonType & i) |
5135 | | { |
5136 | | // get<BasicJsonType>() returns *this, this won't call a from_json |
5137 | | // method when value_type is BasicJsonType |
5138 | | return i.template get<typename ConstructibleArrayType::value_type>(); |
5139 | | }); |
5140 | | arr = std::move(ret); |
5141 | | } |
5142 | | |
5143 | | template<typename BasicJsonType, typename ConstructibleArrayType, |
5144 | | enable_if_t< |
5145 | | std::is_assignable<ConstructibleArrayType&, ConstructibleArrayType>::value, |
5146 | | int> = 0> |
5147 | | inline void from_json_array_impl(const BasicJsonType& j, ConstructibleArrayType& arr, |
5148 | | priority_tag<0> /*unused*/) |
5149 | | { |
5150 | | using std::end; |
5151 | | |
5152 | | ConstructibleArrayType ret; |
5153 | | std::transform( |
5154 | | j.begin(), j.end(), std::inserter(ret, end(ret)), |
5155 | | [](const BasicJsonType & i) |
5156 | | { |
5157 | | // get<BasicJsonType>() returns *this, this won't call a from_json |
5158 | | // method when value_type is BasicJsonType |
5159 | | return i.template get<typename ConstructibleArrayType::value_type>(); |
5160 | | }); |
5161 | | arr = std::move(ret); |
5162 | | } |
5163 | | |
5164 | | template < typename BasicJsonType, typename ConstructibleArrayType, |
5165 | | enable_if_t < |
5166 | | is_constructible_array_type<BasicJsonType, ConstructibleArrayType>::value&& |
5167 | | !is_constructible_object_type<BasicJsonType, ConstructibleArrayType>::value&& |
5168 | | !is_constructible_string_type<BasicJsonType, ConstructibleArrayType>::value&& |
5169 | | !std::is_same<ConstructibleArrayType, typename BasicJsonType::binary_t>::value&& |
5170 | | !is_basic_json<ConstructibleArrayType>::value, |
5171 | | int > = 0 > |
5172 | | auto from_json(const BasicJsonType& j, ConstructibleArrayType& arr) |
5173 | | -> decltype(from_json_array_impl(j, arr, priority_tag<3> {}), |
5174 | | j.template get<typename ConstructibleArrayType::value_type>(), |
5175 | | void()) |
5176 | | { |
5177 | | if (JSON_HEDLEY_UNLIKELY(!j.is_array())) |
5178 | | { |
5179 | | JSON_THROW(type_error::create(302, concat("type must be array, but is ", j.type_name()), &j)); |
5180 | | } |
5181 | | |
5182 | | from_json_array_impl(j, arr, priority_tag<3> {}); |
5183 | | } |
5184 | | |
5185 | | template < typename BasicJsonType, typename T, std::size_t... Idx > |
5186 | | std::array<T, sizeof...(Idx)> from_json_inplace_array_impl(BasicJsonType&& j, |
5187 | | identity_tag<std::array<T, sizeof...(Idx)>> /*unused*/, index_sequence<Idx...> /*unused*/) |
5188 | | { |
5189 | | return { { std::forward<BasicJsonType>(j).at(Idx).template get<T>()... } }; |
5190 | | } |
5191 | | |
5192 | | template < typename BasicJsonType, typename T, std::size_t N > |
5193 | | auto from_json(BasicJsonType&& j, identity_tag<std::array<T, N>> tag) |
5194 | | -> decltype(from_json_inplace_array_impl(std::forward<BasicJsonType>(j), tag, make_index_sequence<N> {})) |
5195 | | { |
5196 | | if (JSON_HEDLEY_UNLIKELY(!j.is_array())) |
5197 | | { |
5198 | | JSON_THROW(type_error::create(302, concat("type must be array, but is ", j.type_name()), &j)); |
5199 | | } |
5200 | | |
5201 | | return from_json_inplace_array_impl(std::forward<BasicJsonType>(j), tag, make_index_sequence<N> {}); |
5202 | | } |
5203 | | |
5204 | | template<typename BasicJsonType> |
5205 | | inline void from_json(const BasicJsonType& j, typename BasicJsonType::binary_t& bin) |
5206 | | { |
5207 | | if (JSON_HEDLEY_UNLIKELY(!j.is_binary())) |
5208 | | { |
5209 | | JSON_THROW(type_error::create(302, concat("type must be binary, but is ", j.type_name()), &j)); |
5210 | | } |
5211 | | |
5212 | | bin = *j.template get_ptr<const typename BasicJsonType::binary_t*>(); |
5213 | | } |
5214 | | |
5215 | | template<typename BasicJsonType, typename ConstructibleObjectType, |
5216 | | enable_if_t<is_constructible_object_type<BasicJsonType, ConstructibleObjectType>::value, int> = 0> |
5217 | | inline void from_json(const BasicJsonType& j, ConstructibleObjectType& obj) |
5218 | | { |
5219 | | if (JSON_HEDLEY_UNLIKELY(!j.is_object())) |
5220 | | { |
5221 | | JSON_THROW(type_error::create(302, concat("type must be object, but is ", j.type_name()), &j)); |
5222 | | } |
5223 | | |
5224 | | ConstructibleObjectType ret; |
5225 | | const auto* inner_object = j.template get_ptr<const typename BasicJsonType::object_t*>(); |
5226 | | using value_type = typename ConstructibleObjectType::value_type; |
5227 | | std::transform( |
5228 | | inner_object->begin(), inner_object->end(), |
5229 | | std::inserter(ret, ret.begin()), |
5230 | | [](typename BasicJsonType::object_t::value_type const & p) |
5231 | | { |
5232 | | return value_type(p.first, p.second.template get<typename ConstructibleObjectType::mapped_type>()); |
5233 | | }); |
5234 | | obj = std::move(ret); |
5235 | | } |
5236 | | |
5237 | | // overload for arithmetic types, not chosen for basic_json template arguments |
5238 | | // (BooleanType, etc.); note: Is it really necessary to provide explicit |
5239 | | // overloads for boolean_t etc. in case of a custom BooleanType which is not |
5240 | | // an arithmetic type? |
5241 | | template < typename BasicJsonType, typename ArithmeticType, |
5242 | | enable_if_t < |
5243 | | std::is_arithmetic<ArithmeticType>::value&& |
5244 | | !std::is_same<ArithmeticType, typename BasicJsonType::number_unsigned_t>::value&& |
5245 | | !std::is_same<ArithmeticType, typename BasicJsonType::number_integer_t>::value&& |
5246 | | !std::is_same<ArithmeticType, typename BasicJsonType::number_float_t>::value&& |
5247 | | !std::is_same<ArithmeticType, typename BasicJsonType::boolean_t>::value, |
5248 | | int > = 0 > |
5249 | | inline void from_json(const BasicJsonType& j, ArithmeticType& val) |
5250 | 0 | { |
5251 | 0 | switch (static_cast<value_t>(j)) |
5252 | 0 | { |
5253 | 0 | case value_t::number_unsigned: |
5254 | 0 | { |
5255 | 0 | val = static_cast<ArithmeticType>(*j.template get_ptr<const typename BasicJsonType::number_unsigned_t*>()); |
5256 | 0 | break; |
5257 | 0 | } |
5258 | 0 | case value_t::number_integer: |
5259 | 0 | { |
5260 | 0 | val = static_cast<ArithmeticType>(*j.template get_ptr<const typename BasicJsonType::number_integer_t*>()); |
5261 | 0 | break; |
5262 | 0 | } |
5263 | 0 | case value_t::number_float: |
5264 | 0 | { |
5265 | 0 | val = static_cast<ArithmeticType>(*j.template get_ptr<const typename BasicJsonType::number_float_t*>()); |
5266 | 0 | break; |
5267 | 0 | } |
5268 | 0 | case value_t::boolean: |
5269 | 0 | { |
5270 | 0 | val = static_cast<ArithmeticType>(*j.template get_ptr<const typename BasicJsonType::boolean_t*>()); |
5271 | 0 | break; |
5272 | 0 | } |
5273 | | |
5274 | 0 | case value_t::null: |
5275 | 0 | case value_t::object: |
5276 | 0 | case value_t::array: |
5277 | 0 | case value_t::string: |
5278 | 0 | case value_t::binary: |
5279 | 0 | case value_t::discarded: |
5280 | 0 | default: |
5281 | 0 | JSON_THROW(type_error::create(302, concat("type must be number, but is ", j.type_name()), &j)); |
5282 | 0 | } |
5283 | 0 | } Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_06detail9from_jsonINS0_10basic_jsonINSt3__13mapENS4_6vectorENS4_12basic_stringIcNS4_11char_traitsIcEENS4_9allocatorIcEEEEblmdSA_NS0_14adl_serializerENS6_IhNSA_IhEEEEvEEhTnNS4_9enable_ifIXaaaaaaaasr3std13is_arithmeticIT0_EE5valuentsr3std7is_sameISI_NT_17number_unsigned_tEEE5valuentsr3std7is_sameISI_NSJ_16number_integer_tEEE5valuentsr3std7is_sameISI_NSJ_14number_float_tEEE5valuentsr3std7is_sameISI_NSJ_9boolean_tEEE5valueEiE4typeELi0EEEvRKSJ_RSI_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_06detail9from_jsonINS0_10basic_jsonINSt3__13mapENS4_6vectorENS4_12basic_stringIcNS4_11char_traitsIcEENS4_9allocatorIcEEEEblmdSA_NS0_14adl_serializerENS6_IhNSA_IhEEEEvEEjTnNS4_9enable_ifIXaaaaaaaasr3std13is_arithmeticIT0_EE5valuentsr3std7is_sameISI_NT_17number_unsigned_tEEE5valuentsr3std7is_sameISI_NSJ_16number_integer_tEEE5valuentsr3std7is_sameISI_NSJ_14number_float_tEEE5valuentsr3std7is_sameISI_NSJ_9boolean_tEEE5valueEiE4typeELi0EEEvRKSJ_RSI_ |
5284 | | |
5285 | | template<typename BasicJsonType, typename... Args, std::size_t... Idx> |
5286 | | std::tuple<Args...> from_json_tuple_impl_base(BasicJsonType&& j, index_sequence<Idx...> /*unused*/) |
5287 | | { |
5288 | | return std::make_tuple(std::forward<BasicJsonType>(j).at(Idx).template get<Args>()...); |
5289 | | } |
5290 | | |
5291 | | template<typename BasicJsonType> |
5292 | | std::tuple<> from_json_tuple_impl_base(BasicJsonType& /*unused*/, index_sequence<> /*unused*/) |
5293 | | { |
5294 | | return {}; |
5295 | | } |
5296 | | |
5297 | | template < typename BasicJsonType, class A1, class A2 > |
5298 | | std::pair<A1, A2> from_json_tuple_impl(BasicJsonType&& j, identity_tag<std::pair<A1, A2>> /*unused*/, priority_tag<0> /*unused*/) |
5299 | | { |
5300 | | return {std::forward<BasicJsonType>(j).at(0).template get<A1>(), |
5301 | | std::forward<BasicJsonType>(j).at(1).template get<A2>()}; |
5302 | | } |
5303 | | |
5304 | | template<typename BasicJsonType, typename A1, typename A2> |
5305 | | inline void from_json_tuple_impl(BasicJsonType&& j, std::pair<A1, A2>& p, priority_tag<1> /*unused*/) |
5306 | | { |
5307 | | p = from_json_tuple_impl(std::forward<BasicJsonType>(j), identity_tag<std::pair<A1, A2>> {}, priority_tag<0> {}); |
5308 | | } |
5309 | | |
5310 | | template<typename BasicJsonType, typename... Args> |
5311 | | std::tuple<Args...> from_json_tuple_impl(BasicJsonType&& j, identity_tag<std::tuple<Args...>> /*unused*/, priority_tag<2> /*unused*/) |
5312 | | { |
5313 | | return from_json_tuple_impl_base<BasicJsonType, Args...>(std::forward<BasicJsonType>(j), index_sequence_for<Args...> {}); |
5314 | | } |
5315 | | |
5316 | | template<typename BasicJsonType, typename... Args> |
5317 | | inline void from_json_tuple_impl(BasicJsonType&& j, std::tuple<Args...>& t, priority_tag<3> /*unused*/) |
5318 | | { |
5319 | | t = from_json_tuple_impl_base<BasicJsonType, Args...>(std::forward<BasicJsonType>(j), index_sequence_for<Args...> {}); |
5320 | | } |
5321 | | |
5322 | | template<typename BasicJsonType, typename TupleRelated> |
5323 | | auto from_json(BasicJsonType&& j, TupleRelated&& t) |
5324 | | -> decltype(from_json_tuple_impl(std::forward<BasicJsonType>(j), std::forward<TupleRelated>(t), priority_tag<3> {})) |
5325 | | { |
5326 | | if (JSON_HEDLEY_UNLIKELY(!j.is_array())) |
5327 | | { |
5328 | | JSON_THROW(type_error::create(302, concat("type must be array, but is ", j.type_name()), &j)); |
5329 | | } |
5330 | | |
5331 | | return from_json_tuple_impl(std::forward<BasicJsonType>(j), std::forward<TupleRelated>(t), priority_tag<3> {}); |
5332 | | } |
5333 | | |
5334 | | template < typename BasicJsonType, typename Key, typename Value, typename Compare, typename Allocator, |
5335 | | typename = enable_if_t < !std::is_constructible < |
5336 | | typename BasicJsonType::string_t, Key >::value >> |
5337 | | inline void from_json(const BasicJsonType& j, std::map<Key, Value, Compare, Allocator>& m) |
5338 | | { |
5339 | | if (JSON_HEDLEY_UNLIKELY(!j.is_array())) |
5340 | | { |
5341 | | JSON_THROW(type_error::create(302, concat("type must be array, but is ", j.type_name()), &j)); |
5342 | | } |
5343 | | m.clear(); |
5344 | | for (const auto& p : j) |
5345 | | { |
5346 | | if (JSON_HEDLEY_UNLIKELY(!p.is_array())) |
5347 | | { |
5348 | | JSON_THROW(type_error::create(302, concat("type must be array, but is ", p.type_name()), &j)); |
5349 | | } |
5350 | | m.emplace(p.at(0).template get<Key>(), p.at(1).template get<Value>()); |
5351 | | } |
5352 | | } |
5353 | | |
5354 | | template < typename BasicJsonType, typename Key, typename Value, typename Hash, typename KeyEqual, typename Allocator, |
5355 | | typename = enable_if_t < !std::is_constructible < |
5356 | | typename BasicJsonType::string_t, Key >::value >> |
5357 | | inline void from_json(const BasicJsonType& j, std::unordered_map<Key, Value, Hash, KeyEqual, Allocator>& m) |
5358 | | { |
5359 | | if (JSON_HEDLEY_UNLIKELY(!j.is_array())) |
5360 | | { |
5361 | | JSON_THROW(type_error::create(302, concat("type must be array, but is ", j.type_name()), &j)); |
5362 | | } |
5363 | | m.clear(); |
5364 | | for (const auto& p : j) |
5365 | | { |
5366 | | if (JSON_HEDLEY_UNLIKELY(!p.is_array())) |
5367 | | { |
5368 | | JSON_THROW(type_error::create(302, concat("type must be array, but is ", p.type_name()), &j)); |
5369 | | } |
5370 | | m.emplace(p.at(0).template get<Key>(), p.at(1).template get<Value>()); |
5371 | | } |
5372 | | } |
5373 | | |
5374 | | #if JSON_HAS_FILESYSTEM || JSON_HAS_EXPERIMENTAL_FILESYSTEM |
5375 | | template<typename BasicJsonType> |
5376 | | inline void from_json(const BasicJsonType& j, std_fs::path& p) |
5377 | | { |
5378 | | if (JSON_HEDLEY_UNLIKELY(!j.is_string())) |
5379 | | { |
5380 | | JSON_THROW(type_error::create(302, concat("type must be string, but is ", j.type_name()), &j)); |
5381 | | } |
5382 | | const auto& s = *j.template get_ptr<const typename BasicJsonType::string_t*>(); |
5383 | | // Checking for C++20 standard or later can be insufficient in case the |
5384 | | // library support for char8_t is either incomplete or was disabled |
5385 | | // altogether. Use the __cpp_lib_char8_t feature test instead. |
5386 | | #if defined(__cpp_lib_char8_t) && (__cpp_lib_char8_t >= 201907L) |
5387 | | p = std_fs::path(std::u8string_view(reinterpret_cast<const char8_t*>(s.data()), s.size())); |
5388 | | #else |
5389 | | p = std_fs::u8path(s); // accepts UTF-8 encoded std::string in C++17, deprecated in C++20 |
5390 | | #endif |
5391 | | } |
5392 | | #endif |
5393 | | |
5394 | | struct from_json_fn |
5395 | | { |
5396 | | template<typename BasicJsonType, typename T> |
5397 | | auto operator()(const BasicJsonType& j, T&& val) const |
5398 | | noexcept(noexcept(from_json(j, std::forward<T>(val)))) |
5399 | | -> decltype(from_json(j, std::forward<T>(val))) |
5400 | 0 | { |
5401 | 0 | return from_json(j, std::forward<T>(val)); |
5402 | 0 | } Unexecuted instantiation: _ZNK8nlohmann16json_abi_v3_12_06detail12from_json_fnclINS0_10basic_jsonINSt3__13mapENS5_6vectorENS5_12basic_stringIcNS5_11char_traitsIcEENS5_9allocatorIcEEEEblmdSB_NS0_14adl_serializerENS7_IhNSB_IhEEEEvEERmEEDTcl9from_jsonfp_clsr3stdE7forwardIT0_Efp0_EEERKT_OSJ_ Unexecuted instantiation: _ZNK8nlohmann16json_abi_v3_12_06detail12from_json_fnclINS0_10basic_jsonINSt3__13mapENS5_6vectorENS5_12basic_stringIcNS5_11char_traitsIcEENS5_9allocatorIcEEEEblmdSB_NS0_14adl_serializerENS7_IhNSB_IhEEEEvEERbEEDTcl9from_jsonfp_clsr3stdE7forwardIT0_Efp0_EEERKT_OSJ_ Unexecuted instantiation: _ZNK8nlohmann16json_abi_v3_12_06detail12from_json_fnclINS0_10basic_jsonINSt3__13mapENS5_6vectorENS5_12basic_stringIcNS5_11char_traitsIcEENS5_9allocatorIcEEEEblmdSB_NS0_14adl_serializerENS7_IhNSB_IhEEEEvEERhEEDTcl9from_jsonfp_clsr3stdE7forwardIT0_Efp0_EEERKT_OSJ_ Unexecuted instantiation: _ZNK8nlohmann16json_abi_v3_12_06detail12from_json_fnclINS0_10basic_jsonINSt3__13mapENS5_6vectorENS5_12basic_stringIcNS5_11char_traitsIcEENS5_9allocatorIcEEEEblmdSB_NS0_14adl_serializerENS7_IhNSB_IhEEEEvEERjEEDTcl9from_jsonfp_clsr3stdE7forwardIT0_Efp0_EEERKT_OSJ_ Unexecuted instantiation: _ZNK8nlohmann16json_abi_v3_12_06detail12from_json_fnclINS0_10basic_jsonINSt3__13mapENS5_6vectorENS5_12basic_stringIcNS5_11char_traitsIcEENS5_9allocatorIcEEEEblmdSB_NS0_14adl_serializerENS7_IhNSB_IhEEEEvEERSD_EEDTcl9from_jsonfp_clsr3stdE7forwardIT0_Efp0_EEERKT_OSJ_ |
5403 | | }; |
5404 | | |
5405 | | } // namespace detail |
5406 | | |
5407 | | #ifndef JSON_HAS_CPP_17 |
5408 | | /// namespace to hold default `from_json` function |
5409 | | /// to see why this is required: |
5410 | | /// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/n4381.html |
5411 | | namespace // NOLINT(cert-dcl59-cpp,fuchsia-header-anon-namespaces,google-build-namespaces) |
5412 | | { |
5413 | | #endif |
5414 | | JSON_INLINE_VARIABLE constexpr const auto& from_json = // NOLINT(misc-definitions-in-headers) |
5415 | | detail::static_const<detail::from_json_fn>::value; |
5416 | | #ifndef JSON_HAS_CPP_17 |
5417 | | } // namespace |
5418 | | #endif |
5419 | | |
5420 | | NLOHMANN_JSON_NAMESPACE_END |
5421 | | |
5422 | | // #include <nlohmann/detail/conversions/to_json.hpp> |
5423 | | // __ _____ _____ _____ |
5424 | | // __| | __| | | | JSON for Modern C++ |
5425 | | // | | |__ | | | | | | version 3.12.0 |
5426 | | // |_____|_____|_____|_|___| https://github.com/nlohmann/json |
5427 | | // |
5428 | | // SPDX-FileCopyrightText: 2013-2026 Niels Lohmann <https://nlohmann.me> |
5429 | | // SPDX-License-Identifier: MIT |
5430 | | |
5431 | | |
5432 | | |
5433 | | // #include <nlohmann/detail/macro_scope.hpp> |
5434 | | // JSON_HAS_CPP_17 |
5435 | | #ifdef JSON_HAS_CPP_17 |
5436 | | #include <optional> // optional |
5437 | | #endif |
5438 | | |
5439 | | #include <algorithm> // copy |
5440 | | #include <iterator> // begin, end |
5441 | | #include <memory> // allocator_traits |
5442 | | #include <string> // basic_string, char_traits |
5443 | | #include <tuple> // tuple, get |
5444 | | #include <type_traits> // is_same, is_constructible, is_floating_point, is_enum, underlying_type |
5445 | | #include <utility> // move, forward, declval, pair |
5446 | | #include <valarray> // valarray |
5447 | | #include <vector> // vector |
5448 | | |
5449 | | // #include <nlohmann/detail/iterators/iteration_proxy.hpp> |
5450 | | // __ _____ _____ _____ |
5451 | | // __| | __| | | | JSON for Modern C++ |
5452 | | // | | |__ | | | | | | version 3.12.0 |
5453 | | // |_____|_____|_____|_|___| https://github.com/nlohmann/json |
5454 | | // |
5455 | | // SPDX-FileCopyrightText: 2013-2026 Niels Lohmann <https://nlohmann.me> |
5456 | | // SPDX-License-Identifier: MIT |
5457 | | |
5458 | | |
5459 | | |
5460 | | #include <cstddef> // size_t |
5461 | | #include <iterator> // forward_iterator_tag |
5462 | | #include <tuple> // tuple_size, get, tuple_element |
5463 | | #include <utility> // move |
5464 | | |
5465 | | #if JSON_HAS_RANGES |
5466 | | #include <ranges> // enable_borrowed_range |
5467 | | #endif |
5468 | | |
5469 | | // #include <nlohmann/detail/abi_macros.hpp> |
5470 | | |
5471 | | // #include <nlohmann/detail/meta/type_traits.hpp> |
5472 | | |
5473 | | // #include <nlohmann/detail/string_utils.hpp> |
5474 | | // __ _____ _____ _____ |
5475 | | // __| | __| | | | JSON for Modern C++ |
5476 | | // | | |__ | | | | | | version 3.12.0 |
5477 | | // |_____|_____|_____|_|___| https://github.com/nlohmann/json |
5478 | | // |
5479 | | // SPDX-FileCopyrightText: 2013-2026 Niels Lohmann <https://nlohmann.me> |
5480 | | // SPDX-License-Identifier: MIT |
5481 | | |
5482 | | |
5483 | | |
5484 | | #include <cstddef> // size_t |
5485 | | #include <string> // string, to_string |
5486 | | |
5487 | | // #include <nlohmann/detail/abi_macros.hpp> |
5488 | | |
5489 | | |
5490 | | NLOHMANN_JSON_NAMESPACE_BEGIN |
5491 | | namespace detail |
5492 | | { |
5493 | | |
5494 | | template<typename StringType> |
5495 | | void int_to_string(StringType& target, std::size_t value) |
5496 | | { |
5497 | | // For ADL |
5498 | | using std::to_string; |
5499 | | target = to_string(value); |
5500 | | } |
5501 | | |
5502 | | template<typename StringType> |
5503 | | StringType to_string(std::size_t value) |
5504 | | { |
5505 | | StringType result; |
5506 | | int_to_string(result, value); |
5507 | | return result; |
5508 | | } |
5509 | | |
5510 | | } // namespace detail |
5511 | | NLOHMANN_JSON_NAMESPACE_END |
5512 | | |
5513 | | // #include <nlohmann/detail/value_t.hpp> |
5514 | | |
5515 | | |
5516 | | NLOHMANN_JSON_NAMESPACE_BEGIN |
5517 | | namespace detail |
5518 | | { |
5519 | | |
5520 | | template<typename IteratorType> class iteration_proxy_value |
5521 | | { |
5522 | | public: |
5523 | | using difference_type = std::ptrdiff_t; |
5524 | | using value_type = iteration_proxy_value; |
5525 | | using pointer = value_type *; |
5526 | | using reference = value_type &; |
5527 | | using iterator_category = std::forward_iterator_tag; |
5528 | | using string_type = typename std::remove_cv< typename std::remove_reference<decltype( std::declval<IteratorType>().key() ) >::type >::type; |
5529 | | |
5530 | | private: |
5531 | | /// the iterator |
5532 | | IteratorType anchor{}; |
5533 | | /// an index for arrays (used to create key names) |
5534 | | std::size_t array_index = 0; |
5535 | | /// last stringified array index |
5536 | | mutable std::size_t array_index_last = 0; |
5537 | | /// a string representation of the array index |
5538 | | mutable string_type array_index_str = "0"; |
5539 | | /// an empty string (to return a reference for primitive values) |
5540 | | string_type empty_str{}; |
5541 | | |
5542 | | public: |
5543 | | explicit iteration_proxy_value() = default; |
5544 | | explicit iteration_proxy_value(IteratorType it, std::size_t array_index_ = 0) |
5545 | | noexcept(std::is_nothrow_move_constructible<IteratorType>::value |
5546 | | && std::is_nothrow_default_constructible<string_type>::value) |
5547 | | : anchor(std::move(it)) |
5548 | | , array_index(array_index_) |
5549 | | {} |
5550 | | |
5551 | | iteration_proxy_value(iteration_proxy_value const&) = default; |
5552 | | iteration_proxy_value& operator=(iteration_proxy_value const&) = default; |
5553 | | // older GCCs are a bit fussy and require explicit noexcept specifiers on defaulted functions |
5554 | | iteration_proxy_value(iteration_proxy_value&&) |
5555 | | noexcept(std::is_nothrow_move_constructible<IteratorType>::value |
5556 | | && std::is_nothrow_move_constructible<string_type>::value) = default; // NOLINT(hicpp-noexcept-move,performance-noexcept-move-constructor,cppcoreguidelines-noexcept-move-operations) |
5557 | | iteration_proxy_value& operator=(iteration_proxy_value&&) |
5558 | | noexcept(std::is_nothrow_move_assignable<IteratorType>::value |
5559 | | && std::is_nothrow_move_assignable<string_type>::value) = default; // NOLINT(hicpp-noexcept-move,performance-noexcept-move-constructor,cppcoreguidelines-noexcept-move-operations) |
5560 | | ~iteration_proxy_value() = default; |
5561 | | |
5562 | | /// dereference operator (needed for range-based for) |
5563 | | const iteration_proxy_value& operator*() const |
5564 | | { |
5565 | | return *this; |
5566 | | } |
5567 | | |
5568 | | /// increment operator (needed for range-based for) |
5569 | | iteration_proxy_value& operator++() |
5570 | | { |
5571 | | ++anchor; |
5572 | | ++array_index; |
5573 | | |
5574 | | return *this; |
5575 | | } |
5576 | | |
5577 | | iteration_proxy_value operator++(int)& // NOLINT(cert-dcl21-cpp) |
5578 | | { |
5579 | | auto tmp = iteration_proxy_value(anchor, array_index); |
5580 | | ++anchor; |
5581 | | ++array_index; |
5582 | | return tmp; |
5583 | | } |
5584 | | |
5585 | | /// equality operator (needed for InputIterator) |
5586 | | bool operator==(const iteration_proxy_value& o) const |
5587 | | { |
5588 | | return anchor == o.anchor; |
5589 | | } |
5590 | | |
5591 | | /// inequality operator (needed for range-based for) |
5592 | | bool operator!=(const iteration_proxy_value& o) const |
5593 | | { |
5594 | | return anchor != o.anchor; |
5595 | | } |
5596 | | |
5597 | | /// return key of the iterator |
5598 | | const string_type& key() const |
5599 | | { |
5600 | | JSON_ASSERT(anchor.m_object != nullptr); |
5601 | | |
5602 | | switch (anchor.m_object->type()) |
5603 | | { |
5604 | | // use integer array index as key |
5605 | | case value_t::array: |
5606 | | { |
5607 | | if (array_index != array_index_last) |
5608 | | { |
5609 | | int_to_string( array_index_str, array_index ); |
5610 | | array_index_last = array_index; |
5611 | | } |
5612 | | return array_index_str; |
5613 | | } |
5614 | | |
5615 | | // use key from the object |
5616 | | case value_t::object: |
5617 | | return anchor.key(); |
5618 | | |
5619 | | // use an empty key for all primitive types |
5620 | | case value_t::null: |
5621 | | case value_t::string: |
5622 | | case value_t::boolean: |
5623 | | case value_t::number_integer: |
5624 | | case value_t::number_unsigned: |
5625 | | case value_t::number_float: |
5626 | | case value_t::binary: |
5627 | | case value_t::discarded: |
5628 | | default: |
5629 | | return empty_str; |
5630 | | } |
5631 | | } |
5632 | | |
5633 | | /// return value of the iterator |
5634 | | typename IteratorType::reference value() const |
5635 | | { |
5636 | | return anchor.value(); |
5637 | | } |
5638 | | }; |
5639 | | |
5640 | | /// proxy class for the items() function |
5641 | | template<typename IteratorType> class iteration_proxy |
5642 | | { |
5643 | | private: |
5644 | | /// the container to iterate |
5645 | | typename IteratorType::pointer container = nullptr; |
5646 | | |
5647 | | public: |
5648 | | explicit iteration_proxy() = default; |
5649 | | |
5650 | | /// construct iteration proxy from a container |
5651 | | explicit iteration_proxy(typename IteratorType::reference cont) noexcept |
5652 | | : container(&cont) {} |
5653 | | |
5654 | | iteration_proxy(iteration_proxy const&) = default; |
5655 | | iteration_proxy& operator=(iteration_proxy const&) = default; |
5656 | | iteration_proxy(iteration_proxy&&) noexcept = default; |
5657 | | iteration_proxy& operator=(iteration_proxy&&) noexcept = default; |
5658 | | ~iteration_proxy() = default; |
5659 | | |
5660 | | /// return iterator begin (needed for range-based for) |
5661 | | iteration_proxy_value<IteratorType> begin() const noexcept |
5662 | | { |
5663 | | return iteration_proxy_value<IteratorType>(container->begin()); |
5664 | | } |
5665 | | |
5666 | | /// return iterator end (needed for range-based for) |
5667 | | iteration_proxy_value<IteratorType> end() const noexcept |
5668 | | { |
5669 | | return iteration_proxy_value<IteratorType>(container->end()); |
5670 | | } |
5671 | | }; |
5672 | | |
5673 | | // Structured Bindings Support |
5674 | | // For further reference see https://blog.tartanllama.xyz/structured-bindings/ |
5675 | | // And see https://github.com/nlohmann/json/pull/1391 |
5676 | | template<std::size_t N, typename IteratorType, enable_if_t<N == 0, int> = 0> |
5677 | | auto get(const nlohmann::detail::iteration_proxy_value<IteratorType>& i) -> decltype(i.key()) |
5678 | | { |
5679 | | return i.key(); |
5680 | | } |
5681 | | // Structured Bindings Support |
5682 | | // For further reference see https://blog.tartanllama.xyz/structured-bindings/ |
5683 | | // And see https://github.com/nlohmann/json/pull/1391 |
5684 | | template<std::size_t N, typename IteratorType, enable_if_t<N == 1, int> = 0> |
5685 | | auto get(const nlohmann::detail::iteration_proxy_value<IteratorType>& i) -> decltype(i.value()) |
5686 | | { |
5687 | | return i.value(); |
5688 | | } |
5689 | | |
5690 | | } // namespace detail |
5691 | | NLOHMANN_JSON_NAMESPACE_END |
5692 | | |
5693 | | // The Addition to the STD Namespace is required to add |
5694 | | // Structured Bindings Support to the iteration_proxy_value class |
5695 | | // For further reference see https://blog.tartanllama.xyz/structured-bindings/ |
5696 | | // And see https://github.com/nlohmann/json/pull/1391 |
5697 | | namespace std |
5698 | | { |
5699 | | |
5700 | | #if defined(__clang__) |
5701 | | // Fix: https://github.com/nlohmann/json/issues/1401 |
5702 | | #pragma clang diagnostic push |
5703 | | #pragma clang diagnostic ignored "-Wmismatched-tags" |
5704 | | #endif |
5705 | | template<typename IteratorType> |
5706 | | class tuple_size<::nlohmann::detail::iteration_proxy_value<IteratorType>> // NOLINT(cert-dcl58-cpp) |
5707 | | : public std::integral_constant<std::size_t, 2> {}; |
5708 | | |
5709 | | template<std::size_t N, typename IteratorType> |
5710 | | class tuple_element<N, ::nlohmann::detail::iteration_proxy_value<IteratorType >> // NOLINT(cert-dcl58-cpp) |
5711 | | { |
5712 | | public: |
5713 | | using type = decltype( |
5714 | | get<N>(std::declval < |
5715 | | ::nlohmann::detail::iteration_proxy_value<IteratorType >> ())); |
5716 | | }; |
5717 | | #if defined(__clang__) |
5718 | | #pragma clang diagnostic pop |
5719 | | #endif |
5720 | | |
5721 | | } // namespace std |
5722 | | |
5723 | | #if JSON_HAS_RANGES |
5724 | | template <typename IteratorType> |
5725 | | inline constexpr bool ::std::ranges::enable_borrowed_range<::nlohmann::detail::iteration_proxy<IteratorType>> = true; |
5726 | | #endif |
5727 | | |
5728 | | // #include <nlohmann/detail/meta/cpp_future.hpp> |
5729 | | |
5730 | | // #include <nlohmann/detail/meta/std_fs.hpp> |
5731 | | |
5732 | | // #include <nlohmann/detail/meta/type_traits.hpp> |
5733 | | |
5734 | | // #include <nlohmann/detail/value_t.hpp> |
5735 | | |
5736 | | |
5737 | | NLOHMANN_JSON_NAMESPACE_BEGIN |
5738 | | namespace detail |
5739 | | { |
5740 | | |
5741 | | ////////////////// |
5742 | | // constructors // |
5743 | | ////////////////// |
5744 | | |
5745 | | /* |
5746 | | * Note all external_constructor<>::construct functions need to call |
5747 | | * j.m_data.m_value.destroy(j.m_data.m_type) to avoid a memory leak in case j contains an |
5748 | | * allocated value (e.g., a string). See bug issue |
5749 | | * https://github.com/nlohmann/json/issues/2865 for more information. |
5750 | | */ |
5751 | | |
5752 | | template<value_t> struct external_constructor; |
5753 | | |
5754 | | template<> |
5755 | | struct external_constructor<value_t::boolean> |
5756 | | { |
5757 | | template<typename BasicJsonType> |
5758 | | static void construct(BasicJsonType& j, typename BasicJsonType::boolean_t b) noexcept |
5759 | 0 | { |
5760 | 0 | j.m_data.m_value.destroy(j.m_data.m_type); |
5761 | 0 | j.m_data.m_type = value_t::boolean; |
5762 | 0 | j.m_data.m_value = b; |
5763 | 0 | j.assert_invariant(); |
5764 | 0 | } |
5765 | | }; |
5766 | | |
5767 | | template<> |
5768 | | struct external_constructor<value_t::string> |
5769 | | { |
5770 | | template<typename BasicJsonType> |
5771 | | static void construct(BasicJsonType& j, const typename BasicJsonType::string_t& s) |
5772 | 0 | { |
5773 | 0 | j.m_data.m_value.destroy(j.m_data.m_type); |
5774 | 0 | j.m_data.m_type = value_t::string; |
5775 | 0 | j.m_data.m_value = s; |
5776 | 0 | j.assert_invariant(); |
5777 | 0 | } |
5778 | | |
5779 | | template<typename BasicJsonType> |
5780 | | static void construct(BasicJsonType& j, typename BasicJsonType::string_t&& s) |
5781 | 0 | { |
5782 | 0 | j.m_data.m_value.destroy(j.m_data.m_type); |
5783 | 0 | j.m_data.m_type = value_t::string; |
5784 | 0 | j.m_data.m_value = std::move(s); |
5785 | 0 | j.assert_invariant(); |
5786 | 0 | } |
5787 | | |
5788 | | template < typename BasicJsonType, typename CompatibleStringType, |
5789 | | enable_if_t < !std::is_same<CompatibleStringType, typename BasicJsonType::string_t>::value, |
5790 | | int > = 0 > |
5791 | | static void construct(BasicJsonType& j, const CompatibleStringType& str) |
5792 | 0 | { |
5793 | 0 | j.m_data.m_value.destroy(j.m_data.m_type); |
5794 | 0 | j.m_data.m_type = value_t::string; |
5795 | 0 | j.m_data.m_value.string = j.template create<typename BasicJsonType::string_t>(str); |
5796 | 0 | j.assert_invariant(); |
5797 | 0 | } Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_06detail20external_constructorILNS1_7value_tE3EE9constructINS0_10basic_jsonINSt3__13mapENS7_6vectorENS7_12basic_stringIcNS7_11char_traitsIcEENS7_9allocatorIcEEEEblmdSD_NS0_14adl_serializerENS9_IhNSD_IhEEEEvEEA1_cTnNS7_9enable_ifIXntsr3std7is_sameIT0_NT_8string_tEEE5valueEiE4typeELi0EEEvRSN_RKSM_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_06detail20external_constructorILNS1_7value_tE3EE9constructINS0_10basic_jsonINSt3__13mapENS7_6vectorENS7_12basic_stringIcNS7_11char_traitsIcEENS7_9allocatorIcEEEEblmdSD_NS0_14adl_serializerENS9_IhNSD_IhEEEEvEEA2_cTnNS7_9enable_ifIXntsr3std7is_sameIT0_NT_8string_tEEE5valueEiE4typeELi0EEEvRSN_RKSM_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_06detail20external_constructorILNS1_7value_tE3EE9constructINS0_10basic_jsonINSt3__13mapENS7_6vectorENS7_12basic_stringIcNS7_11char_traitsIcEENS7_9allocatorIcEEEEblmdSD_NS0_14adl_serializerENS9_IhNSD_IhEEEEvEEA21_cTnNS7_9enable_ifIXntsr3std7is_sameIT0_NT_8string_tEEE5valueEiE4typeELi0EEEvRSN_RKSM_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_06detail20external_constructorILNS1_7value_tE3EE9constructINS0_10basic_jsonINSt3__13mapENS7_6vectorENS7_12basic_stringIcNS7_11char_traitsIcEENS7_9allocatorIcEEEEblmdSD_NS0_14adl_serializerENS9_IhNSD_IhEEEEvEEA40_cTnNS7_9enable_ifIXntsr3std7is_sameIT0_NT_8string_tEEE5valueEiE4typeELi0EEEvRSN_RKSM_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_06detail20external_constructorILNS1_7value_tE3EE9constructINS0_10basic_jsonINSt3__13mapENS7_6vectorENS7_12basic_stringIcNS7_11char_traitsIcEENS7_9allocatorIcEEEEblmdSD_NS0_14adl_serializerENS9_IhNSD_IhEEEEvEEA600_cTnNS7_9enable_ifIXntsr3std7is_sameIT0_NT_8string_tEEE5valueEiE4typeELi0EEEvRSN_RKSM_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_06detail20external_constructorILNS1_7value_tE3EE9constructINS0_10basic_jsonINSt3__13mapENS7_6vectorENS7_12basic_stringIcNS7_11char_traitsIcEENS7_9allocatorIcEEEEblmdSD_NS0_14adl_serializerENS9_IhNSD_IhEEEEvEEA137_cTnNS7_9enable_ifIXntsr3std7is_sameIT0_NT_8string_tEEE5valueEiE4typeELi0EEEvRSN_RKSM_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_06detail20external_constructorILNS1_7value_tE3EE9constructINS0_10basic_jsonINSt3__13mapENS7_6vectorENS7_12basic_stringIcNS7_11char_traitsIcEENS7_9allocatorIcEEEEblmdSD_NS0_14adl_serializerENS9_IhNSD_IhEEEEvEEA156_cTnNS7_9enable_ifIXntsr3std7is_sameIT0_NT_8string_tEEE5valueEiE4typeELi0EEEvRSN_RKSM_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_06detail20external_constructorILNS1_7value_tE3EE9constructINS0_10basic_jsonINSt3__13mapENS7_6vectorENS7_12basic_stringIcNS7_11char_traitsIcEENS7_9allocatorIcEEEEblmdSD_NS0_14adl_serializerENS9_IhNSD_IhEEEEvEEA78_cTnNS7_9enable_ifIXntsr3std7is_sameIT0_NT_8string_tEEE5valueEiE4typeELi0EEEvRSN_RKSM_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_06detail20external_constructorILNS1_7value_tE3EE9constructINS0_10basic_jsonINSt3__13mapENS7_6vectorENS7_12basic_stringIcNS7_11char_traitsIcEENS7_9allocatorIcEEEEblmdSD_NS0_14adl_serializerENS9_IhNSD_IhEEEEvEEA79_cTnNS7_9enable_ifIXntsr3std7is_sameIT0_NT_8string_tEEE5valueEiE4typeELi0EEEvRSN_RKSM_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_06detail20external_constructorILNS1_7value_tE3EE9constructINS0_10basic_jsonINSt3__13mapENS7_6vectorENS7_12basic_stringIcNS7_11char_traitsIcEENS7_9allocatorIcEEEEblmdSD_NS0_14adl_serializerENS9_IhNSD_IhEEEEvEEA65_cTnNS7_9enable_ifIXntsr3std7is_sameIT0_NT_8string_tEEE5valueEiE4typeELi0EEEvRSN_RKSM_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_06detail20external_constructorILNS1_7value_tE3EE9constructINS0_10basic_jsonINSt3__13mapENS7_6vectorENS7_12basic_stringIcNS7_11char_traitsIcEENS7_9allocatorIcEEEEblmdSD_NS0_14adl_serializerENS9_IhNSD_IhEEEEvEEA58_cTnNS7_9enable_ifIXntsr3std7is_sameIT0_NT_8string_tEEE5valueEiE4typeELi0EEEvRSN_RKSM_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_06detail20external_constructorILNS1_7value_tE3EE9constructINS0_10basic_jsonINSt3__13mapENS7_6vectorENS7_12basic_stringIcNS7_11char_traitsIcEENS7_9allocatorIcEEEEblmdSD_NS0_14adl_serializerENS9_IhNSD_IhEEEEvEEA56_cTnNS7_9enable_ifIXntsr3std7is_sameIT0_NT_8string_tEEE5valueEiE4typeELi0EEEvRSN_RKSM_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_06detail20external_constructorILNS1_7value_tE3EE9constructINS0_10basic_jsonINSt3__13mapENS7_6vectorENS7_12basic_stringIcNS7_11char_traitsIcEENS7_9allocatorIcEEEEblmdSD_NS0_14adl_serializerENS9_IhNSD_IhEEEEvEEA59_cTnNS7_9enable_ifIXntsr3std7is_sameIT0_NT_8string_tEEE5valueEiE4typeELi0EEEvRSN_RKSM_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_06detail20external_constructorILNS1_7value_tE3EE9constructINS0_10basic_jsonINSt3__13mapENS7_6vectorENS7_12basic_stringIcNS7_11char_traitsIcEENS7_9allocatorIcEEEEblmdSD_NS0_14adl_serializerENS9_IhNSD_IhEEEEvEEA1679_cTnNS7_9enable_ifIXntsr3std7is_sameIT0_NT_8string_tEEE5valueEiE4typeELi0EEEvRSN_RKSM_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_06detail20external_constructorILNS1_7value_tE3EE9constructINS0_10basic_jsonINSt3__13mapENS7_6vectorENS7_12basic_stringIcNS7_11char_traitsIcEENS7_9allocatorIcEEEEblmdSD_NS0_14adl_serializerENS9_IhNSD_IhEEEEvEEA1535_cTnNS7_9enable_ifIXntsr3std7is_sameIT0_NT_8string_tEEE5valueEiE4typeELi0EEEvRSN_RKSM_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_06detail20external_constructorILNS1_7value_tE3EE9constructINS0_10basic_jsonINSt3__13mapENS7_6vectorENS7_12basic_stringIcNS7_11char_traitsIcEENS7_9allocatorIcEEEEblmdSD_NS0_14adl_serializerENS9_IhNSD_IhEEEEvEEA714_cTnNS7_9enable_ifIXntsr3std7is_sameIT0_NT_8string_tEEE5valueEiE4typeELi0EEEvRSN_RKSM_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_06detail20external_constructorILNS1_7value_tE3EE9constructINS0_10basic_jsonINSt3__13mapENS7_6vectorENS7_12basic_stringIcNS7_11char_traitsIcEENS7_9allocatorIcEEEEblmdSD_NS0_14adl_serializerENS9_IhNSD_IhEEEEvEEA3238_cTnNS7_9enable_ifIXntsr3std7is_sameIT0_NT_8string_tEEE5valueEiE4typeELi0EEEvRSN_RKSM_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_06detail20external_constructorILNS1_7value_tE3EE9constructINS0_10basic_jsonINSt3__13mapENS7_6vectorENS7_12basic_stringIcNS7_11char_traitsIcEENS7_9allocatorIcEEEEblmdSD_NS0_14adl_serializerENS9_IhNSD_IhEEEEvEEA2159_cTnNS7_9enable_ifIXntsr3std7is_sameIT0_NT_8string_tEEE5valueEiE4typeELi0EEEvRSN_RKSM_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_06detail20external_constructorILNS1_7value_tE3EE9constructINS0_10basic_jsonINSt3__13mapENS7_6vectorENS7_12basic_stringIcNS7_11char_traitsIcEENS7_9allocatorIcEEEEblmdSD_NS0_14adl_serializerENS9_IhNSD_IhEEEEvEEA77_cTnNS7_9enable_ifIXntsr3std7is_sameIT0_NT_8string_tEEE5valueEiE4typeELi0EEEvRSN_RKSM_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_06detail20external_constructorILNS1_7value_tE3EE9constructINS0_10basic_jsonINSt3__13mapENS7_6vectorENS7_12basic_stringIcNS7_11char_traitsIcEENS7_9allocatorIcEEEEblmdSD_NS0_14adl_serializerENS9_IhNSD_IhEEEEvEEA16_cTnNS7_9enable_ifIXntsr3std7is_sameIT0_NT_8string_tEEE5valueEiE4typeELi0EEEvRSN_RKSM_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_06detail20external_constructorILNS1_7value_tE3EE9constructINS0_10basic_jsonINSt3__13mapENS7_6vectorENS7_12basic_stringIcNS7_11char_traitsIcEENS7_9allocatorIcEEEEblmdSD_NS0_14adl_serializerENS9_IhNSD_IhEEEEvEEA64_cTnNS7_9enable_ifIXntsr3std7is_sameIT0_NT_8string_tEEE5valueEiE4typeELi0EEEvRSN_RKSM_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_06detail20external_constructorILNS1_7value_tE3EE9constructINS0_10basic_jsonINSt3__13mapENS7_6vectorENS7_12basic_stringIcNS7_11char_traitsIcEENS7_9allocatorIcEEEEblmdSD_NS0_14adl_serializerENS9_IhNSD_IhEEEEvEEA923_cTnNS7_9enable_ifIXntsr3std7is_sameIT0_NT_8string_tEEE5valueEiE4typeELi0EEEvRSN_RKSM_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_06detail20external_constructorILNS1_7value_tE3EE9constructINS0_10basic_jsonINSt3__13mapENS7_6vectorENS7_12basic_stringIcNS7_11char_traitsIcEENS7_9allocatorIcEEEEblmdSD_NS0_14adl_serializerENS9_IhNSD_IhEEEEvEEA150_cTnNS7_9enable_ifIXntsr3std7is_sameIT0_NT_8string_tEEE5valueEiE4typeELi0EEEvRSN_RKSM_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_06detail20external_constructorILNS1_7value_tE3EE9constructINS0_10basic_jsonINSt3__13mapENS7_6vectorENS7_12basic_stringIcNS7_11char_traitsIcEENS7_9allocatorIcEEEEblmdSD_NS0_14adl_serializerENS9_IhNSD_IhEEEEvEEA309_cTnNS7_9enable_ifIXntsr3std7is_sameIT0_NT_8string_tEEE5valueEiE4typeELi0EEEvRSN_RKSM_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_06detail20external_constructorILNS1_7value_tE3EE9constructINS0_10basic_jsonINSt3__13mapENS7_6vectorENS7_12basic_stringIcNS7_11char_traitsIcEENS7_9allocatorIcEEEEblmdSD_NS0_14adl_serializerENS9_IhNSD_IhEEEEvEEA310_cTnNS7_9enable_ifIXntsr3std7is_sameIT0_NT_8string_tEEE5valueEiE4typeELi0EEEvRSN_RKSM_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_06detail20external_constructorILNS1_7value_tE3EE9constructINS0_10basic_jsonINSt3__13mapENS7_6vectorENS7_12basic_stringIcNS7_11char_traitsIcEENS7_9allocatorIcEEEEblmdSD_NS0_14adl_serializerENS9_IhNSD_IhEEEEvEEA155_cTnNS7_9enable_ifIXntsr3std7is_sameIT0_NT_8string_tEEE5valueEiE4typeELi0EEEvRSN_RKSM_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_06detail20external_constructorILNS1_7value_tE3EE9constructINS0_10basic_jsonINSt3__13mapENS7_6vectorENS7_12basic_stringIcNS7_11char_traitsIcEENS7_9allocatorIcEEEEblmdSD_NS0_14adl_serializerENS9_IhNSD_IhEEEEvEEA117_cTnNS7_9enable_ifIXntsr3std7is_sameIT0_NT_8string_tEEE5valueEiE4typeELi0EEEvRSN_RKSM_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_06detail20external_constructorILNS1_7value_tE3EE9constructINS0_10basic_jsonINSt3__13mapENS7_6vectorENS7_12basic_stringIcNS7_11char_traitsIcEENS7_9allocatorIcEEEEblmdSD_NS0_14adl_serializerENS9_IhNSD_IhEEEEvEEA50_cTnNS7_9enable_ifIXntsr3std7is_sameIT0_NT_8string_tEEE5valueEiE4typeELi0EEEvRSN_RKSM_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_06detail20external_constructorILNS1_7value_tE3EE9constructINS0_10basic_jsonINSt3__13mapENS7_6vectorENS7_12basic_stringIcNS7_11char_traitsIcEENS7_9allocatorIcEEEEblmdSD_NS0_14adl_serializerENS9_IhNSD_IhEEEEvEEA61_cTnNS7_9enable_ifIXntsr3std7is_sameIT0_NT_8string_tEEE5valueEiE4typeELi0EEEvRSN_RKSM_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_06detail20external_constructorILNS1_7value_tE3EE9constructINS0_10basic_jsonINSt3__13mapENS7_6vectorENS7_12basic_stringIcNS7_11char_traitsIcEENS7_9allocatorIcEEEEblmdSD_NS0_14adl_serializerENS9_IhNSD_IhEEEEvEEA158_cTnNS7_9enable_ifIXntsr3std7is_sameIT0_NT_8string_tEEE5valueEiE4typeELi0EEEvRSN_RKSM_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_06detail20external_constructorILNS1_7value_tE3EE9constructINS0_10basic_jsonINSt3__13mapENS7_6vectorENS7_12basic_stringIcNS7_11char_traitsIcEENS7_9allocatorIcEEEEblmdSD_NS0_14adl_serializerENS9_IhNSD_IhEEEEvEEA30_cTnNS7_9enable_ifIXntsr3std7is_sameIT0_NT_8string_tEEE5valueEiE4typeELi0EEEvRSN_RKSM_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_06detail20external_constructorILNS1_7value_tE3EE9constructINS0_10basic_jsonINSt3__13mapENS7_6vectorENS7_12basic_stringIcNS7_11char_traitsIcEENS7_9allocatorIcEEEEblmdSD_NS0_14adl_serializerENS9_IhNSD_IhEEEEvEEA69_cTnNS7_9enable_ifIXntsr3std7is_sameIT0_NT_8string_tEEE5valueEiE4typeELi0EEEvRSN_RKSM_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_06detail20external_constructorILNS1_7value_tE3EE9constructINS0_10basic_jsonINSt3__13mapENS7_6vectorENS7_12basic_stringIcNS7_11char_traitsIcEENS7_9allocatorIcEEEEblmdSD_NS0_14adl_serializerENS9_IhNSD_IhEEEEvEEA3_cTnNS7_9enable_ifIXntsr3std7is_sameIT0_NT_8string_tEEE5valueEiE4typeELi0EEEvRSN_RKSM_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_06detail20external_constructorILNS1_7value_tE3EE9constructINS0_10basic_jsonINSt3__13mapENS7_6vectorENS7_12basic_stringIcNS7_11char_traitsIcEENS7_9allocatorIcEEEEblmdSD_NS0_14adl_serializerENS9_IhNSD_IhEEEEvEEA114_cTnNS7_9enable_ifIXntsr3std7is_sameIT0_NT_8string_tEEE5valueEiE4typeELi0EEEvRSN_RKSM_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_06detail20external_constructorILNS1_7value_tE3EE9constructINS0_10basic_jsonINSt3__13mapENS7_6vectorENS7_12basic_stringIcNS7_11char_traitsIcEENS7_9allocatorIcEEEEblmdSD_NS0_14adl_serializerENS9_IhNSD_IhEEEEvEEA113_cTnNS7_9enable_ifIXntsr3std7is_sameIT0_NT_8string_tEEE5valueEiE4typeELi0EEEvRSN_RKSM_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_06detail20external_constructorILNS1_7value_tE3EE9constructINS0_10basic_jsonINSt3__13mapENS7_6vectorENS7_12basic_stringIcNS7_11char_traitsIcEENS7_9allocatorIcEEEEblmdSD_NS0_14adl_serializerENS9_IhNSD_IhEEEEvEEA39_cTnNS7_9enable_ifIXntsr3std7is_sameIT0_NT_8string_tEEE5valueEiE4typeELi0EEEvRSN_RKSM_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_06detail20external_constructorILNS1_7value_tE3EE9constructINS0_10basic_jsonINSt3__13mapENS7_6vectorENS7_12basic_stringIcNS7_11char_traitsIcEENS7_9allocatorIcEEEEblmdSD_NS0_14adl_serializerENS9_IhNSD_IhEEEEvEEA41_cTnNS7_9enable_ifIXntsr3std7is_sameIT0_NT_8string_tEEE5valueEiE4typeELi0EEEvRSN_RKSM_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_06detail20external_constructorILNS1_7value_tE3EE9constructINS0_10basic_jsonINSt3__13mapENS7_6vectorENS7_12basic_stringIcNS7_11char_traitsIcEENS7_9allocatorIcEEEEblmdSD_NS0_14adl_serializerENS9_IhNSD_IhEEEEvEEA86_cTnNS7_9enable_ifIXntsr3std7is_sameIT0_NT_8string_tEEE5valueEiE4typeELi0EEEvRSN_RKSM_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_06detail20external_constructorILNS1_7value_tE3EE9constructINS0_10basic_jsonINSt3__13mapENS7_6vectorENS7_12basic_stringIcNS7_11char_traitsIcEENS7_9allocatorIcEEEEblmdSD_NS0_14adl_serializerENS9_IhNSD_IhEEEEvEEA135_cTnNS7_9enable_ifIXntsr3std7is_sameIT0_NT_8string_tEEE5valueEiE4typeELi0EEEvRSN_RKSM_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_06detail20external_constructorILNS1_7value_tE3EE9constructINS0_10basic_jsonINSt3__13mapENS7_6vectorENS7_12basic_stringIcNS7_11char_traitsIcEENS7_9allocatorIcEEEEblmdSD_NS0_14adl_serializerENS9_IhNSD_IhEEEEvEEA20_cTnNS7_9enable_ifIXntsr3std7is_sameIT0_NT_8string_tEEE5valueEiE4typeELi0EEEvRSN_RKSM_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_06detail20external_constructorILNS1_7value_tE3EE9constructINS0_10basic_jsonINSt3__13mapENS7_6vectorENS7_12basic_stringIcNS7_11char_traitsIcEENS7_9allocatorIcEEEEblmdSD_NS0_14adl_serializerENS9_IhNSD_IhEEEEvEEA24_cTnNS7_9enable_ifIXntsr3std7is_sameIT0_NT_8string_tEEE5valueEiE4typeELi0EEEvRSN_RKSM_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_06detail20external_constructorILNS1_7value_tE3EE9constructINS0_10basic_jsonINSt3__13mapENS7_6vectorENS7_12basic_stringIcNS7_11char_traitsIcEENS7_9allocatorIcEEEEblmdSD_NS0_14adl_serializerENS9_IhNSD_IhEEEEvEEA11_cTnNS7_9enable_ifIXntsr3std7is_sameIT0_NT_8string_tEEE5valueEiE4typeELi0EEEvRSN_RKSM_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_06detail20external_constructorILNS1_7value_tE3EE9constructINS0_10basic_jsonINSt3__13mapENS7_6vectorENS7_12basic_stringIcNS7_11char_traitsIcEENS7_9allocatorIcEEEEblmdSD_NS0_14adl_serializerENS9_IhNSD_IhEEEEvEEA35_cTnNS7_9enable_ifIXntsr3std7is_sameIT0_NT_8string_tEEE5valueEiE4typeELi0EEEvRSN_RKSM_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_06detail20external_constructorILNS1_7value_tE3EE9constructINS0_10basic_jsonINSt3__13mapENS7_6vectorENS7_12basic_stringIcNS7_11char_traitsIcEENS7_9allocatorIcEEEEblmdSD_NS0_14adl_serializerENS9_IhNSD_IhEEEEvEEA4_cTnNS7_9enable_ifIXntsr3std7is_sameIT0_NT_8string_tEEE5valueEiE4typeELi0EEEvRSN_RKSM_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_06detail20external_constructorILNS1_7value_tE3EE9constructINS0_10basic_jsonINSt3__13mapENS7_6vectorENS7_12basic_stringIcNS7_11char_traitsIcEENS7_9allocatorIcEEEEblmdSD_NS0_14adl_serializerENS9_IhNSD_IhEEEEvEEA116_cTnNS7_9enable_ifIXntsr3std7is_sameIT0_NT_8string_tEEE5valueEiE4typeELi0EEEvRSN_RKSM_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_06detail20external_constructorILNS1_7value_tE3EE9constructINS0_10basic_jsonINSt3__13mapENS7_6vectorENS7_12basic_stringIcNS7_11char_traitsIcEENS7_9allocatorIcEEEEblmdSD_NS0_14adl_serializerENS9_IhNSD_IhEEEEvEEA115_cTnNS7_9enable_ifIXntsr3std7is_sameIT0_NT_8string_tEEE5valueEiE4typeELi0EEEvRSN_RKSM_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_06detail20external_constructorILNS1_7value_tE3EE9constructINS0_10basic_jsonINSt3__13mapENS7_6vectorENS7_12basic_stringIcNS7_11char_traitsIcEENS7_9allocatorIcEEEEblmdSD_NS0_14adl_serializerENS9_IhNSD_IhEEEEvEEA619_cTnNS7_9enable_ifIXntsr3std7is_sameIT0_NT_8string_tEEE5valueEiE4typeELi0EEEvRSN_RKSM_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_06detail20external_constructorILNS1_7value_tE3EE9constructINS0_10basic_jsonINSt3__13mapENS7_6vectorENS7_12basic_stringIcNS7_11char_traitsIcEENS7_9allocatorIcEEEEblmdSD_NS0_14adl_serializerENS9_IhNSD_IhEEEEvEEA9_cTnNS7_9enable_ifIXntsr3std7is_sameIT0_NT_8string_tEEE5valueEiE4typeELi0EEEvRSN_RKSM_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_06detail20external_constructorILNS1_7value_tE3EE9constructINS0_10basic_jsonINSt3__13mapENS7_6vectorENS7_12basic_stringIcNS7_11char_traitsIcEENS7_9allocatorIcEEEEblmdSD_NS0_14adl_serializerENS9_IhNSD_IhEEEEvEEA7_cTnNS7_9enable_ifIXntsr3std7is_sameIT0_NT_8string_tEEE5valueEiE4typeELi0EEEvRSN_RKSM_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_06detail20external_constructorILNS1_7value_tE3EE9constructINS0_10basic_jsonINSt3__13mapENS7_6vectorENS7_12basic_stringIcNS7_11char_traitsIcEENS7_9allocatorIcEEEEblmdSD_NS0_14adl_serializerENS9_IhNSD_IhEEEEvEEA5_cTnNS7_9enable_ifIXntsr3std7is_sameIT0_NT_8string_tEEE5valueEiE4typeELi0EEEvRSN_RKSM_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_06detail20external_constructorILNS1_7value_tE3EE9constructINS0_10basic_jsonINSt3__13mapENS7_6vectorENS7_12basic_stringIcNS7_11char_traitsIcEENS7_9allocatorIcEEEEblmdSD_NS0_14adl_serializerENS9_IhNSD_IhEEEEvEEA17_cTnNS7_9enable_ifIXntsr3std7is_sameIT0_NT_8string_tEEE5valueEiE4typeELi0EEEvRSN_RKSM_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_06detail20external_constructorILNS1_7value_tE3EE9constructINS0_10basic_jsonINSt3__13mapENS7_6vectorENS7_12basic_stringIcNS7_11char_traitsIcEENS7_9allocatorIcEEEEblmdSD_NS0_14adl_serializerENS9_IhNSD_IhEEEEvEEA13_cTnNS7_9enable_ifIXntsr3std7is_sameIT0_NT_8string_tEEE5valueEiE4typeELi0EEEvRSN_RKSM_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_06detail20external_constructorILNS1_7value_tE3EE9constructINS0_10basic_jsonINSt3__13mapENS7_6vectorENS7_12basic_stringIcNS7_11char_traitsIcEENS7_9allocatorIcEEEEblmdSD_NS0_14adl_serializerENS9_IhNSD_IhEEEEvEEA10_cTnNS7_9enable_ifIXntsr3std7is_sameIT0_NT_8string_tEEE5valueEiE4typeELi0EEEvRSN_RKSM_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_06detail20external_constructorILNS1_7value_tE3EE9constructINS0_10basic_jsonINSt3__13mapENS7_6vectorENS7_12basic_stringIcNS7_11char_traitsIcEENS7_9allocatorIcEEEEblmdSD_NS0_14adl_serializerENS9_IhNSD_IhEEEEvEEA8_cTnNS7_9enable_ifIXntsr3std7is_sameIT0_NT_8string_tEEE5valueEiE4typeELi0EEEvRSN_RKSM_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_06detail20external_constructorILNS1_7value_tE3EE9constructINS0_10basic_jsonINSt3__13mapENS7_6vectorENS7_12basic_stringIcNS7_11char_traitsIcEENS7_9allocatorIcEEEEblmdSD_NS0_14adl_serializerENS9_IhNSD_IhEEEEvEEA15_cTnNS7_9enable_ifIXntsr3std7is_sameIT0_NT_8string_tEEE5valueEiE4typeELi0EEEvRSN_RKSM_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_06detail20external_constructorILNS1_7value_tE3EE9constructINS0_10basic_jsonINSt3__13mapENS7_6vectorENS7_12basic_stringIcNS7_11char_traitsIcEENS7_9allocatorIcEEEEblmdSD_NS0_14adl_serializerENS9_IhNSD_IhEEEEvEEA19_cTnNS7_9enable_ifIXntsr3std7is_sameIT0_NT_8string_tEEE5valueEiE4typeELi0EEEvRSN_RKSM_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_06detail20external_constructorILNS1_7value_tE3EE9constructINS0_10basic_jsonINSt3__13mapENS7_6vectorENS7_12basic_stringIcNS7_11char_traitsIcEENS7_9allocatorIcEEEEblmdSD_NS0_14adl_serializerENS9_IhNSD_IhEEEEvEEA12_cTnNS7_9enable_ifIXntsr3std7is_sameIT0_NT_8string_tEEE5valueEiE4typeELi0EEEvRSN_RKSM_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_06detail20external_constructorILNS1_7value_tE3EE9constructINS0_10basic_jsonINSt3__13mapENS7_6vectorENS7_12basic_stringIcNS7_11char_traitsIcEENS7_9allocatorIcEEEEblmdSD_NS0_14adl_serializerENS9_IhNSD_IhEEEEvEEA14_cTnNS7_9enable_ifIXntsr3std7is_sameIT0_NT_8string_tEEE5valueEiE4typeELi0EEEvRSN_RKSM_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_06detail20external_constructorILNS1_7value_tE3EE9constructINS0_10basic_jsonINSt3__13mapENS7_6vectorENS7_12basic_stringIcNS7_11char_traitsIcEENS7_9allocatorIcEEEEblmdSD_NS0_14adl_serializerENS9_IhNSD_IhEEEEvEEA23_cTnNS7_9enable_ifIXntsr3std7is_sameIT0_NT_8string_tEEE5valueEiE4typeELi0EEEvRSN_RKSM_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_06detail20external_constructorILNS1_7value_tE3EE9constructINS0_10basic_jsonINSt3__13mapENS7_6vectorENS7_12basic_stringIcNS7_11char_traitsIcEENS7_9allocatorIcEEEEblmdSD_NS0_14adl_serializerENS9_IhNSD_IhEEEEvEEA18_cTnNS7_9enable_ifIXntsr3std7is_sameIT0_NT_8string_tEEE5valueEiE4typeELi0EEEvRSN_RKSM_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_06detail20external_constructorILNS1_7value_tE3EE9constructINS0_10basic_jsonINSt3__13mapENS7_6vectorENS7_12basic_stringIcNS7_11char_traitsIcEENS7_9allocatorIcEEEEblmdSD_NS0_14adl_serializerENS9_IhNSD_IhEEEEvEEPKcTnNS7_9enable_ifIXntsr3std7is_sameIT0_NT_8string_tEEE5valueEiE4typeELi0EEEvRSO_RKSN_ |
5798 | | }; |
5799 | | |
5800 | | template<> |
5801 | | struct external_constructor<value_t::binary> |
5802 | | { |
5803 | | template<typename BasicJsonType> |
5804 | | static void construct(BasicJsonType& j, const typename BasicJsonType::binary_t& b) |
5805 | | { |
5806 | | j.m_data.m_value.destroy(j.m_data.m_type); |
5807 | | j.m_data.m_type = value_t::binary; |
5808 | | j.m_data.m_value = typename BasicJsonType::binary_t(b); |
5809 | | j.assert_invariant(); |
5810 | | } |
5811 | | |
5812 | | template<typename BasicJsonType> |
5813 | | static void construct(BasicJsonType& j, typename BasicJsonType::binary_t&& b) |
5814 | | { |
5815 | | j.m_data.m_value.destroy(j.m_data.m_type); |
5816 | | j.m_data.m_type = value_t::binary; |
5817 | | j.m_data.m_value = typename BasicJsonType::binary_t(std::move(b)); |
5818 | | j.assert_invariant(); |
5819 | | } |
5820 | | }; |
5821 | | |
5822 | | template<> |
5823 | | struct external_constructor<value_t::number_float> |
5824 | | { |
5825 | | template<typename BasicJsonType> |
5826 | | static void construct(BasicJsonType& j, typename BasicJsonType::number_float_t val) noexcept |
5827 | 0 | { |
5828 | 0 | j.m_data.m_value.destroy(j.m_data.m_type); |
5829 | 0 | j.m_data.m_type = value_t::number_float; |
5830 | 0 | j.m_data.m_value = val; |
5831 | 0 | j.assert_invariant(); |
5832 | 0 | } |
5833 | | }; |
5834 | | |
5835 | | template<> |
5836 | | struct external_constructor<value_t::number_unsigned> |
5837 | | { |
5838 | | template<typename BasicJsonType> |
5839 | | static void construct(BasicJsonType& j, typename BasicJsonType::number_unsigned_t val) noexcept |
5840 | 0 | { |
5841 | 0 | j.m_data.m_value.destroy(j.m_data.m_type); |
5842 | 0 | j.m_data.m_type = value_t::number_unsigned; |
5843 | 0 | j.m_data.m_value = val; |
5844 | 0 | j.assert_invariant(); |
5845 | 0 | } |
5846 | | }; |
5847 | | |
5848 | | template<> |
5849 | | struct external_constructor<value_t::number_integer> |
5850 | | { |
5851 | | template<typename BasicJsonType> |
5852 | | static void construct(BasicJsonType& j, typename BasicJsonType::number_integer_t val) noexcept |
5853 | 0 | { |
5854 | 0 | j.m_data.m_value.destroy(j.m_data.m_type); |
5855 | 0 | j.m_data.m_type = value_t::number_integer; |
5856 | 0 | j.m_data.m_value = val; |
5857 | 0 | j.assert_invariant(); |
5858 | 0 | } |
5859 | | }; |
5860 | | |
5861 | | template<> |
5862 | | struct external_constructor<value_t::array> |
5863 | | { |
5864 | | template<typename BasicJsonType> |
5865 | | static void construct(BasicJsonType& j, const typename BasicJsonType::array_t& arr) |
5866 | | { |
5867 | | j.m_data.m_value.destroy(j.m_data.m_type); |
5868 | | j.m_data.m_type = value_t::array; |
5869 | | j.m_data.m_value = arr; |
5870 | | j.set_parents(); |
5871 | | j.assert_invariant(); |
5872 | | } |
5873 | | |
5874 | | template<typename BasicJsonType> |
5875 | | static void construct(BasicJsonType& j, typename BasicJsonType::array_t&& arr) |
5876 | 0 | { |
5877 | 0 | j.m_data.m_value.destroy(j.m_data.m_type); |
5878 | 0 | j.m_data.m_type = value_t::array; |
5879 | 0 | j.m_data.m_value = std::move(arr); |
5880 | 0 | j.set_parents(); |
5881 | 0 | j.assert_invariant(); |
5882 | 0 | } |
5883 | | |
5884 | | template < typename BasicJsonType, typename CompatibleArrayType, |
5885 | | enable_if_t < !std::is_same<CompatibleArrayType, typename BasicJsonType::array_t>::value, |
5886 | | int > = 0 > |
5887 | | static void construct(BasicJsonType& j, const CompatibleArrayType& arr) |
5888 | | { |
5889 | | using std::begin; |
5890 | | using std::end; |
5891 | | |
5892 | | j.m_data.m_value.destroy(j.m_data.m_type); |
5893 | | j.m_data.m_type = value_t::array; |
5894 | | j.m_data.m_value.array = j.template create<typename BasicJsonType::array_t>(begin(arr), end(arr)); |
5895 | | j.set_parents(); |
5896 | | j.assert_invariant(); |
5897 | | } |
5898 | | |
5899 | | template<typename BasicJsonType> |
5900 | | static void construct(BasicJsonType& j, const std::vector<bool>& arr) |
5901 | | { |
5902 | | j.m_data.m_value.destroy(j.m_data.m_type); |
5903 | | j.m_data.m_type = value_t::array; |
5904 | | j.m_data.m_value = value_t::array; |
5905 | | j.m_data.m_value.array->reserve(arr.size()); |
5906 | | for (const bool x : arr) |
5907 | | { |
5908 | | j.m_data.m_value.array->push_back(x); |
5909 | | j.set_parent(j.m_data.m_value.array->back()); |
5910 | | } |
5911 | | j.assert_invariant(); |
5912 | | } |
5913 | | |
5914 | | template<typename BasicJsonType, typename T, |
5915 | | enable_if_t<std::is_convertible<T, BasicJsonType>::value, int> = 0> |
5916 | | static void construct(BasicJsonType& j, const std::valarray<T>& arr) |
5917 | | { |
5918 | | j.m_data.m_value.destroy(j.m_data.m_type); |
5919 | | j.m_data.m_type = value_t::array; |
5920 | | j.m_data.m_value = value_t::array; |
5921 | | j.m_data.m_value.array->resize(arr.size()); |
5922 | | if (arr.size() > 0) |
5923 | | { |
5924 | | std::copy(std::begin(arr), std::end(arr), j.m_data.m_value.array->begin()); |
5925 | | } |
5926 | | j.set_parents(); |
5927 | | j.assert_invariant(); |
5928 | | } |
5929 | | }; |
5930 | | |
5931 | | template<> |
5932 | | struct external_constructor<value_t::object> |
5933 | | { |
5934 | | template<typename BasicJsonType> |
5935 | | static void construct(BasicJsonType& j, const typename BasicJsonType::object_t& obj) |
5936 | | { |
5937 | | j.m_data.m_value.destroy(j.m_data.m_type); |
5938 | | j.m_data.m_type = value_t::object; |
5939 | | j.m_data.m_value = obj; |
5940 | | j.set_parents(); |
5941 | | j.assert_invariant(); |
5942 | | } |
5943 | | |
5944 | | template<typename BasicJsonType> |
5945 | | static void construct(BasicJsonType& j, typename BasicJsonType::object_t&& obj) |
5946 | | { |
5947 | | j.m_data.m_value.destroy(j.m_data.m_type); |
5948 | | j.m_data.m_type = value_t::object; |
5949 | | j.m_data.m_value = std::move(obj); |
5950 | | j.set_parents(); |
5951 | | j.assert_invariant(); |
5952 | | } |
5953 | | |
5954 | | template < typename BasicJsonType, typename CompatibleObjectType, |
5955 | | enable_if_t < !std::is_same<CompatibleObjectType, typename BasicJsonType::object_t>::value, int > = 0 > |
5956 | | static void construct(BasicJsonType& j, const CompatibleObjectType& obj) |
5957 | | { |
5958 | | using std::begin; |
5959 | | using std::end; |
5960 | | |
5961 | | j.m_data.m_value.destroy(j.m_data.m_type); |
5962 | | j.m_data.m_type = value_t::object; |
5963 | | j.m_data.m_value.object = j.template create<typename BasicJsonType::object_t>(begin(obj), end(obj)); |
5964 | | j.set_parents(); |
5965 | | j.assert_invariant(); |
5966 | | } |
5967 | | }; |
5968 | | |
5969 | | ///////////// |
5970 | | // to_json // |
5971 | | ///////////// |
5972 | | |
5973 | | #ifdef JSON_HAS_CPP_17 |
5974 | | template<typename BasicJsonType, typename T, |
5975 | | enable_if_t<std::is_constructible<BasicJsonType, T>::value, int> = 0> |
5976 | | void to_json(BasicJsonType& j, const std::optional<T>& opt) noexcept |
5977 | | { |
5978 | | if (opt.has_value()) |
5979 | | { |
5980 | | j = *opt; |
5981 | | } |
5982 | | else |
5983 | | { |
5984 | | j = nullptr; |
5985 | | } |
5986 | | } |
5987 | | #endif |
5988 | | |
5989 | | template<typename BasicJsonType, typename T, |
5990 | | enable_if_t<std::is_same<T, typename BasicJsonType::boolean_t>::value, int> = 0> |
5991 | | inline void to_json(BasicJsonType& j, T b) noexcept |
5992 | 0 | { |
5993 | 0 | external_constructor<value_t::boolean>::construct(j, b); |
5994 | 0 | } |
5995 | | |
5996 | | template < typename BasicJsonType, typename BoolRef, |
5997 | | enable_if_t < |
5998 | | ((std::is_same<std::vector<bool>::reference, BoolRef>::value |
5999 | | && !std::is_same <std::vector<bool>::reference, typename BasicJsonType::boolean_t&>::value) |
6000 | | || (std::is_same<std::vector<bool>::const_reference, BoolRef>::value |
6001 | | && !std::is_same <detail::uncvref_t<std::vector<bool>::const_reference>, |
6002 | | typename BasicJsonType::boolean_t >::value)) |
6003 | | && std::is_convertible<const BoolRef&, typename BasicJsonType::boolean_t>::value, int > = 0 > |
6004 | | inline void to_json(BasicJsonType& j, const BoolRef& b) noexcept |
6005 | | { |
6006 | | external_constructor<value_t::boolean>::construct(j, static_cast<typename BasicJsonType::boolean_t>(b)); |
6007 | | } |
6008 | | |
6009 | | template<typename BasicJsonType, typename CompatibleString, |
6010 | | enable_if_t<std::is_constructible<typename BasicJsonType::string_t, CompatibleString>::value, int> = 0> |
6011 | | inline void to_json(BasicJsonType& j, const CompatibleString& s) |
6012 | 0 | { |
6013 | 0 | external_constructor<value_t::string>::construct(j, s); |
6014 | 0 | } Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_06detail7to_jsonINS0_10basic_jsonINSt3__13mapENS4_6vectorENS4_12basic_stringIcNS4_11char_traitsIcEENS4_9allocatorIcEEEEblmdSA_NS0_14adl_serializerENS6_IhNSA_IhEEEEvEEA1_cTnNS4_9enable_ifIXsr3std16is_constructibleINT_8string_tET0_EE5valueEiE4typeELi0EEEvRSJ_RKSL_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_06detail7to_jsonINS0_10basic_jsonINSt3__13mapENS4_6vectorENS4_12basic_stringIcNS4_11char_traitsIcEENS4_9allocatorIcEEEEblmdSA_NS0_14adl_serializerENS6_IhNSA_IhEEEEvEESC_TnNS4_9enable_ifIXsr3std16is_constructibleINT_8string_tET0_EE5valueEiE4typeELi0EEEvRSI_RKSK_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_06detail7to_jsonINS0_10basic_jsonINSt3__13mapENS4_6vectorENS4_12basic_stringIcNS4_11char_traitsIcEENS4_9allocatorIcEEEEblmdSA_NS0_14adl_serializerENS6_IhNSA_IhEEEEvEEA2_cTnNS4_9enable_ifIXsr3std16is_constructibleINT_8string_tET0_EE5valueEiE4typeELi0EEEvRSJ_RKSL_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_06detail7to_jsonINS0_10basic_jsonINSt3__13mapENS4_6vectorENS4_12basic_stringIcNS4_11char_traitsIcEENS4_9allocatorIcEEEEblmdSA_NS0_14adl_serializerENS6_IhNSA_IhEEEEvEEA21_cTnNS4_9enable_ifIXsr3std16is_constructibleINT_8string_tET0_EE5valueEiE4typeELi0EEEvRSJ_RKSL_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_06detail7to_jsonINS0_10basic_jsonINSt3__13mapENS4_6vectorENS4_12basic_stringIcNS4_11char_traitsIcEENS4_9allocatorIcEEEEblmdSA_NS0_14adl_serializerENS6_IhNSA_IhEEEEvEEA40_cTnNS4_9enable_ifIXsr3std16is_constructibleINT_8string_tET0_EE5valueEiE4typeELi0EEEvRSJ_RKSL_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_06detail7to_jsonINS0_10basic_jsonINSt3__13mapENS4_6vectorENS4_12basic_stringIcNS4_11char_traitsIcEENS4_9allocatorIcEEEEblmdSA_NS0_14adl_serializerENS6_IhNSA_IhEEEEvEEA600_cTnNS4_9enable_ifIXsr3std16is_constructibleINT_8string_tET0_EE5valueEiE4typeELi0EEEvRSJ_RKSL_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_06detail7to_jsonINS0_10basic_jsonINSt3__13mapENS4_6vectorENS4_12basic_stringIcNS4_11char_traitsIcEENS4_9allocatorIcEEEEblmdSA_NS0_14adl_serializerENS6_IhNSA_IhEEEEvEEA137_cTnNS4_9enable_ifIXsr3std16is_constructibleINT_8string_tET0_EE5valueEiE4typeELi0EEEvRSJ_RKSL_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_06detail7to_jsonINS0_10basic_jsonINSt3__13mapENS4_6vectorENS4_12basic_stringIcNS4_11char_traitsIcEENS4_9allocatorIcEEEEblmdSA_NS0_14adl_serializerENS6_IhNSA_IhEEEEvEEA156_cTnNS4_9enable_ifIXsr3std16is_constructibleINT_8string_tET0_EE5valueEiE4typeELi0EEEvRSJ_RKSL_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_06detail7to_jsonINS0_10basic_jsonINSt3__13mapENS4_6vectorENS4_12basic_stringIcNS4_11char_traitsIcEENS4_9allocatorIcEEEEblmdSA_NS0_14adl_serializerENS6_IhNSA_IhEEEEvEEA78_cTnNS4_9enable_ifIXsr3std16is_constructibleINT_8string_tET0_EE5valueEiE4typeELi0EEEvRSJ_RKSL_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_06detail7to_jsonINS0_10basic_jsonINSt3__13mapENS4_6vectorENS4_12basic_stringIcNS4_11char_traitsIcEENS4_9allocatorIcEEEEblmdSA_NS0_14adl_serializerENS6_IhNSA_IhEEEEvEEA79_cTnNS4_9enable_ifIXsr3std16is_constructibleINT_8string_tET0_EE5valueEiE4typeELi0EEEvRSJ_RKSL_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_06detail7to_jsonINS0_10basic_jsonINSt3__13mapENS4_6vectorENS4_12basic_stringIcNS4_11char_traitsIcEENS4_9allocatorIcEEEEblmdSA_NS0_14adl_serializerENS6_IhNSA_IhEEEEvEEA65_cTnNS4_9enable_ifIXsr3std16is_constructibleINT_8string_tET0_EE5valueEiE4typeELi0EEEvRSJ_RKSL_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_06detail7to_jsonINS0_10basic_jsonINSt3__13mapENS4_6vectorENS4_12basic_stringIcNS4_11char_traitsIcEENS4_9allocatorIcEEEEblmdSA_NS0_14adl_serializerENS6_IhNSA_IhEEEEvEEA58_cTnNS4_9enable_ifIXsr3std16is_constructibleINT_8string_tET0_EE5valueEiE4typeELi0EEEvRSJ_RKSL_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_06detail7to_jsonINS0_10basic_jsonINSt3__13mapENS4_6vectorENS4_12basic_stringIcNS4_11char_traitsIcEENS4_9allocatorIcEEEEblmdSA_NS0_14adl_serializerENS6_IhNSA_IhEEEEvEEA56_cTnNS4_9enable_ifIXsr3std16is_constructibleINT_8string_tET0_EE5valueEiE4typeELi0EEEvRSJ_RKSL_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_06detail7to_jsonINS0_10basic_jsonINSt3__13mapENS4_6vectorENS4_12basic_stringIcNS4_11char_traitsIcEENS4_9allocatorIcEEEEblmdSA_NS0_14adl_serializerENS6_IhNSA_IhEEEEvEEA59_cTnNS4_9enable_ifIXsr3std16is_constructibleINT_8string_tET0_EE5valueEiE4typeELi0EEEvRSJ_RKSL_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_06detail7to_jsonINS0_10basic_jsonINSt3__13mapENS4_6vectorENS4_12basic_stringIcNS4_11char_traitsIcEENS4_9allocatorIcEEEEblmdSA_NS0_14adl_serializerENS6_IhNSA_IhEEEEvEEA1679_cTnNS4_9enable_ifIXsr3std16is_constructibleINT_8string_tET0_EE5valueEiE4typeELi0EEEvRSJ_RKSL_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_06detail7to_jsonINS0_10basic_jsonINSt3__13mapENS4_6vectorENS4_12basic_stringIcNS4_11char_traitsIcEENS4_9allocatorIcEEEEblmdSA_NS0_14adl_serializerENS6_IhNSA_IhEEEEvEEA1535_cTnNS4_9enable_ifIXsr3std16is_constructibleINT_8string_tET0_EE5valueEiE4typeELi0EEEvRSJ_RKSL_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_06detail7to_jsonINS0_10basic_jsonINSt3__13mapENS4_6vectorENS4_12basic_stringIcNS4_11char_traitsIcEENS4_9allocatorIcEEEEblmdSA_NS0_14adl_serializerENS6_IhNSA_IhEEEEvEEA714_cTnNS4_9enable_ifIXsr3std16is_constructibleINT_8string_tET0_EE5valueEiE4typeELi0EEEvRSJ_RKSL_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_06detail7to_jsonINS0_10basic_jsonINSt3__13mapENS4_6vectorENS4_12basic_stringIcNS4_11char_traitsIcEENS4_9allocatorIcEEEEblmdSA_NS0_14adl_serializerENS6_IhNSA_IhEEEEvEEA3238_cTnNS4_9enable_ifIXsr3std16is_constructibleINT_8string_tET0_EE5valueEiE4typeELi0EEEvRSJ_RKSL_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_06detail7to_jsonINS0_10basic_jsonINSt3__13mapENS4_6vectorENS4_12basic_stringIcNS4_11char_traitsIcEENS4_9allocatorIcEEEEblmdSA_NS0_14adl_serializerENS6_IhNSA_IhEEEEvEEA2159_cTnNS4_9enable_ifIXsr3std16is_constructibleINT_8string_tET0_EE5valueEiE4typeELi0EEEvRSJ_RKSL_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_06detail7to_jsonINS0_10basic_jsonINSt3__13mapENS4_6vectorENS4_12basic_stringIcNS4_11char_traitsIcEENS4_9allocatorIcEEEEblmdSA_NS0_14adl_serializerENS6_IhNSA_IhEEEEvEEA77_cTnNS4_9enable_ifIXsr3std16is_constructibleINT_8string_tET0_EE5valueEiE4typeELi0EEEvRSJ_RKSL_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_06detail7to_jsonINS0_10basic_jsonINSt3__13mapENS4_6vectorENS4_12basic_stringIcNS4_11char_traitsIcEENS4_9allocatorIcEEEEblmdSA_NS0_14adl_serializerENS6_IhNSA_IhEEEEvEEA16_cTnNS4_9enable_ifIXsr3std16is_constructibleINT_8string_tET0_EE5valueEiE4typeELi0EEEvRSJ_RKSL_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_06detail7to_jsonINS0_10basic_jsonINSt3__13mapENS4_6vectorENS4_12basic_stringIcNS4_11char_traitsIcEENS4_9allocatorIcEEEEblmdSA_NS0_14adl_serializerENS6_IhNSA_IhEEEEvEEA64_cTnNS4_9enable_ifIXsr3std16is_constructibleINT_8string_tET0_EE5valueEiE4typeELi0EEEvRSJ_RKSL_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_06detail7to_jsonINS0_10basic_jsonINSt3__13mapENS4_6vectorENS4_12basic_stringIcNS4_11char_traitsIcEENS4_9allocatorIcEEEEblmdSA_NS0_14adl_serializerENS6_IhNSA_IhEEEEvEEA923_cTnNS4_9enable_ifIXsr3std16is_constructibleINT_8string_tET0_EE5valueEiE4typeELi0EEEvRSJ_RKSL_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_06detail7to_jsonINS0_10basic_jsonINSt3__13mapENS4_6vectorENS4_12basic_stringIcNS4_11char_traitsIcEENS4_9allocatorIcEEEEblmdSA_NS0_14adl_serializerENS6_IhNSA_IhEEEEvEEA150_cTnNS4_9enable_ifIXsr3std16is_constructibleINT_8string_tET0_EE5valueEiE4typeELi0EEEvRSJ_RKSL_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_06detail7to_jsonINS0_10basic_jsonINSt3__13mapENS4_6vectorENS4_12basic_stringIcNS4_11char_traitsIcEENS4_9allocatorIcEEEEblmdSA_NS0_14adl_serializerENS6_IhNSA_IhEEEEvEEA309_cTnNS4_9enable_ifIXsr3std16is_constructibleINT_8string_tET0_EE5valueEiE4typeELi0EEEvRSJ_RKSL_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_06detail7to_jsonINS0_10basic_jsonINSt3__13mapENS4_6vectorENS4_12basic_stringIcNS4_11char_traitsIcEENS4_9allocatorIcEEEEblmdSA_NS0_14adl_serializerENS6_IhNSA_IhEEEEvEEA310_cTnNS4_9enable_ifIXsr3std16is_constructibleINT_8string_tET0_EE5valueEiE4typeELi0EEEvRSJ_RKSL_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_06detail7to_jsonINS0_10basic_jsonINSt3__13mapENS4_6vectorENS4_12basic_stringIcNS4_11char_traitsIcEENS4_9allocatorIcEEEEblmdSA_NS0_14adl_serializerENS6_IhNSA_IhEEEEvEEA155_cTnNS4_9enable_ifIXsr3std16is_constructibleINT_8string_tET0_EE5valueEiE4typeELi0EEEvRSJ_RKSL_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_06detail7to_jsonINS0_10basic_jsonINSt3__13mapENS4_6vectorENS4_12basic_stringIcNS4_11char_traitsIcEENS4_9allocatorIcEEEEblmdSA_NS0_14adl_serializerENS6_IhNSA_IhEEEEvEEA117_cTnNS4_9enable_ifIXsr3std16is_constructibleINT_8string_tET0_EE5valueEiE4typeELi0EEEvRSJ_RKSL_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_06detail7to_jsonINS0_10basic_jsonINSt3__13mapENS4_6vectorENS4_12basic_stringIcNS4_11char_traitsIcEENS4_9allocatorIcEEEEblmdSA_NS0_14adl_serializerENS6_IhNSA_IhEEEEvEEA50_cTnNS4_9enable_ifIXsr3std16is_constructibleINT_8string_tET0_EE5valueEiE4typeELi0EEEvRSJ_RKSL_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_06detail7to_jsonINS0_10basic_jsonINSt3__13mapENS4_6vectorENS4_12basic_stringIcNS4_11char_traitsIcEENS4_9allocatorIcEEEEblmdSA_NS0_14adl_serializerENS6_IhNSA_IhEEEEvEEA61_cTnNS4_9enable_ifIXsr3std16is_constructibleINT_8string_tET0_EE5valueEiE4typeELi0EEEvRSJ_RKSL_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_06detail7to_jsonINS0_10basic_jsonINSt3__13mapENS4_6vectorENS4_12basic_stringIcNS4_11char_traitsIcEENS4_9allocatorIcEEEEblmdSA_NS0_14adl_serializerENS6_IhNSA_IhEEEEvEEA158_cTnNS4_9enable_ifIXsr3std16is_constructibleINT_8string_tET0_EE5valueEiE4typeELi0EEEvRSJ_RKSL_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_06detail7to_jsonINS0_10basic_jsonINSt3__13mapENS4_6vectorENS4_12basic_stringIcNS4_11char_traitsIcEENS4_9allocatorIcEEEEblmdSA_NS0_14adl_serializerENS6_IhNSA_IhEEEEvEEA30_cTnNS4_9enable_ifIXsr3std16is_constructibleINT_8string_tET0_EE5valueEiE4typeELi0EEEvRSJ_RKSL_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_06detail7to_jsonINS0_10basic_jsonINSt3__13mapENS4_6vectorENS4_12basic_stringIcNS4_11char_traitsIcEENS4_9allocatorIcEEEEblmdSA_NS0_14adl_serializerENS6_IhNSA_IhEEEEvEEA69_cTnNS4_9enable_ifIXsr3std16is_constructibleINT_8string_tET0_EE5valueEiE4typeELi0EEEvRSJ_RKSL_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_06detail7to_jsonINS0_10basic_jsonINSt3__13mapENS4_6vectorENS4_12basic_stringIcNS4_11char_traitsIcEENS4_9allocatorIcEEEEblmdSA_NS0_14adl_serializerENS6_IhNSA_IhEEEEvEEA3_cTnNS4_9enable_ifIXsr3std16is_constructibleINT_8string_tET0_EE5valueEiE4typeELi0EEEvRSJ_RKSL_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_06detail7to_jsonINS0_10basic_jsonINSt3__13mapENS4_6vectorENS4_12basic_stringIcNS4_11char_traitsIcEENS4_9allocatorIcEEEEblmdSA_NS0_14adl_serializerENS6_IhNSA_IhEEEEvEEA114_cTnNS4_9enable_ifIXsr3std16is_constructibleINT_8string_tET0_EE5valueEiE4typeELi0EEEvRSJ_RKSL_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_06detail7to_jsonINS0_10basic_jsonINSt3__13mapENS4_6vectorENS4_12basic_stringIcNS4_11char_traitsIcEENS4_9allocatorIcEEEEblmdSA_NS0_14adl_serializerENS6_IhNSA_IhEEEEvEEA113_cTnNS4_9enable_ifIXsr3std16is_constructibleINT_8string_tET0_EE5valueEiE4typeELi0EEEvRSJ_RKSL_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_06detail7to_jsonINS0_10basic_jsonINSt3__13mapENS4_6vectorENS4_12basic_stringIcNS4_11char_traitsIcEENS4_9allocatorIcEEEEblmdSA_NS0_14adl_serializerENS6_IhNSA_IhEEEEvEEA39_cTnNS4_9enable_ifIXsr3std16is_constructibleINT_8string_tET0_EE5valueEiE4typeELi0EEEvRSJ_RKSL_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_06detail7to_jsonINS0_10basic_jsonINSt3__13mapENS4_6vectorENS4_12basic_stringIcNS4_11char_traitsIcEENS4_9allocatorIcEEEEblmdSA_NS0_14adl_serializerENS6_IhNSA_IhEEEEvEEA41_cTnNS4_9enable_ifIXsr3std16is_constructibleINT_8string_tET0_EE5valueEiE4typeELi0EEEvRSJ_RKSL_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_06detail7to_jsonINS0_10basic_jsonINSt3__13mapENS4_6vectorENS4_12basic_stringIcNS4_11char_traitsIcEENS4_9allocatorIcEEEEblmdSA_NS0_14adl_serializerENS6_IhNSA_IhEEEEvEEA86_cTnNS4_9enable_ifIXsr3std16is_constructibleINT_8string_tET0_EE5valueEiE4typeELi0EEEvRSJ_RKSL_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_06detail7to_jsonINS0_10basic_jsonINSt3__13mapENS4_6vectorENS4_12basic_stringIcNS4_11char_traitsIcEENS4_9allocatorIcEEEEblmdSA_NS0_14adl_serializerENS6_IhNSA_IhEEEEvEEA135_cTnNS4_9enable_ifIXsr3std16is_constructibleINT_8string_tET0_EE5valueEiE4typeELi0EEEvRSJ_RKSL_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_06detail7to_jsonINS0_10basic_jsonINSt3__13mapENS4_6vectorENS4_12basic_stringIcNS4_11char_traitsIcEENS4_9allocatorIcEEEEblmdSA_NS0_14adl_serializerENS6_IhNSA_IhEEEEvEEA20_cTnNS4_9enable_ifIXsr3std16is_constructibleINT_8string_tET0_EE5valueEiE4typeELi0EEEvRSJ_RKSL_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_06detail7to_jsonINS0_10basic_jsonINSt3__13mapENS4_6vectorENS4_12basic_stringIcNS4_11char_traitsIcEENS4_9allocatorIcEEEEblmdSA_NS0_14adl_serializerENS6_IhNSA_IhEEEEvEEA24_cTnNS4_9enable_ifIXsr3std16is_constructibleINT_8string_tET0_EE5valueEiE4typeELi0EEEvRSJ_RKSL_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_06detail7to_jsonINS0_10basic_jsonINSt3__13mapENS4_6vectorENS4_12basic_stringIcNS4_11char_traitsIcEENS4_9allocatorIcEEEEblmdSA_NS0_14adl_serializerENS6_IhNSA_IhEEEEvEEA11_cTnNS4_9enable_ifIXsr3std16is_constructibleINT_8string_tET0_EE5valueEiE4typeELi0EEEvRSJ_RKSL_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_06detail7to_jsonINS0_10basic_jsonINSt3__13mapENS4_6vectorENS4_12basic_stringIcNS4_11char_traitsIcEENS4_9allocatorIcEEEEblmdSA_NS0_14adl_serializerENS6_IhNSA_IhEEEEvEEA35_cTnNS4_9enable_ifIXsr3std16is_constructibleINT_8string_tET0_EE5valueEiE4typeELi0EEEvRSJ_RKSL_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_06detail7to_jsonINS0_10basic_jsonINSt3__13mapENS4_6vectorENS4_12basic_stringIcNS4_11char_traitsIcEENS4_9allocatorIcEEEEblmdSA_NS0_14adl_serializerENS6_IhNSA_IhEEEEvEEA4_cTnNS4_9enable_ifIXsr3std16is_constructibleINT_8string_tET0_EE5valueEiE4typeELi0EEEvRSJ_RKSL_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_06detail7to_jsonINS0_10basic_jsonINSt3__13mapENS4_6vectorENS4_12basic_stringIcNS4_11char_traitsIcEENS4_9allocatorIcEEEEblmdSA_NS0_14adl_serializerENS6_IhNSA_IhEEEEvEEA116_cTnNS4_9enable_ifIXsr3std16is_constructibleINT_8string_tET0_EE5valueEiE4typeELi0EEEvRSJ_RKSL_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_06detail7to_jsonINS0_10basic_jsonINSt3__13mapENS4_6vectorENS4_12basic_stringIcNS4_11char_traitsIcEENS4_9allocatorIcEEEEblmdSA_NS0_14adl_serializerENS6_IhNSA_IhEEEEvEEA115_cTnNS4_9enable_ifIXsr3std16is_constructibleINT_8string_tET0_EE5valueEiE4typeELi0EEEvRSJ_RKSL_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_06detail7to_jsonINS0_10basic_jsonINSt3__13mapENS4_6vectorENS4_12basic_stringIcNS4_11char_traitsIcEENS4_9allocatorIcEEEEblmdSA_NS0_14adl_serializerENS6_IhNSA_IhEEEEvEEA619_cTnNS4_9enable_ifIXsr3std16is_constructibleINT_8string_tET0_EE5valueEiE4typeELi0EEEvRSJ_RKSL_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_06detail7to_jsonINS0_10basic_jsonINSt3__13mapENS4_6vectorENS4_12basic_stringIcNS4_11char_traitsIcEENS4_9allocatorIcEEEEblmdSA_NS0_14adl_serializerENS6_IhNSA_IhEEEEvEEA9_cTnNS4_9enable_ifIXsr3std16is_constructibleINT_8string_tET0_EE5valueEiE4typeELi0EEEvRSJ_RKSL_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_06detail7to_jsonINS0_10basic_jsonINSt3__13mapENS4_6vectorENS4_12basic_stringIcNS4_11char_traitsIcEENS4_9allocatorIcEEEEblmdSA_NS0_14adl_serializerENS6_IhNSA_IhEEEEvEEA7_cTnNS4_9enable_ifIXsr3std16is_constructibleINT_8string_tET0_EE5valueEiE4typeELi0EEEvRSJ_RKSL_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_06detail7to_jsonINS0_10basic_jsonINSt3__13mapENS4_6vectorENS4_12basic_stringIcNS4_11char_traitsIcEENS4_9allocatorIcEEEEblmdSA_NS0_14adl_serializerENS6_IhNSA_IhEEEEvEEA5_cTnNS4_9enable_ifIXsr3std16is_constructibleINT_8string_tET0_EE5valueEiE4typeELi0EEEvRSJ_RKSL_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_06detail7to_jsonINS0_10basic_jsonINSt3__13mapENS4_6vectorENS4_12basic_stringIcNS4_11char_traitsIcEENS4_9allocatorIcEEEEblmdSA_NS0_14adl_serializerENS6_IhNSA_IhEEEEvEEA17_cTnNS4_9enable_ifIXsr3std16is_constructibleINT_8string_tET0_EE5valueEiE4typeELi0EEEvRSJ_RKSL_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_06detail7to_jsonINS0_10basic_jsonINSt3__13mapENS4_6vectorENS4_12basic_stringIcNS4_11char_traitsIcEENS4_9allocatorIcEEEEblmdSA_NS0_14adl_serializerENS6_IhNSA_IhEEEEvEEA13_cTnNS4_9enable_ifIXsr3std16is_constructibleINT_8string_tET0_EE5valueEiE4typeELi0EEEvRSJ_RKSL_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_06detail7to_jsonINS0_10basic_jsonINSt3__13mapENS4_6vectorENS4_12basic_stringIcNS4_11char_traitsIcEENS4_9allocatorIcEEEEblmdSA_NS0_14adl_serializerENS6_IhNSA_IhEEEEvEEA10_cTnNS4_9enable_ifIXsr3std16is_constructibleINT_8string_tET0_EE5valueEiE4typeELi0EEEvRSJ_RKSL_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_06detail7to_jsonINS0_10basic_jsonINSt3__13mapENS4_6vectorENS4_12basic_stringIcNS4_11char_traitsIcEENS4_9allocatorIcEEEEblmdSA_NS0_14adl_serializerENS6_IhNSA_IhEEEEvEEA8_cTnNS4_9enable_ifIXsr3std16is_constructibleINT_8string_tET0_EE5valueEiE4typeELi0EEEvRSJ_RKSL_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_06detail7to_jsonINS0_10basic_jsonINSt3__13mapENS4_6vectorENS4_12basic_stringIcNS4_11char_traitsIcEENS4_9allocatorIcEEEEblmdSA_NS0_14adl_serializerENS6_IhNSA_IhEEEEvEEA15_cTnNS4_9enable_ifIXsr3std16is_constructibleINT_8string_tET0_EE5valueEiE4typeELi0EEEvRSJ_RKSL_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_06detail7to_jsonINS0_10basic_jsonINSt3__13mapENS4_6vectorENS4_12basic_stringIcNS4_11char_traitsIcEENS4_9allocatorIcEEEEblmdSA_NS0_14adl_serializerENS6_IhNSA_IhEEEEvEEA19_cTnNS4_9enable_ifIXsr3std16is_constructibleINT_8string_tET0_EE5valueEiE4typeELi0EEEvRSJ_RKSL_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_06detail7to_jsonINS0_10basic_jsonINSt3__13mapENS4_6vectorENS4_12basic_stringIcNS4_11char_traitsIcEENS4_9allocatorIcEEEEblmdSA_NS0_14adl_serializerENS6_IhNSA_IhEEEEvEEA12_cTnNS4_9enable_ifIXsr3std16is_constructibleINT_8string_tET0_EE5valueEiE4typeELi0EEEvRSJ_RKSL_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_06detail7to_jsonINS0_10basic_jsonINSt3__13mapENS4_6vectorENS4_12basic_stringIcNS4_11char_traitsIcEENS4_9allocatorIcEEEEblmdSA_NS0_14adl_serializerENS6_IhNSA_IhEEEEvEEA14_cTnNS4_9enable_ifIXsr3std16is_constructibleINT_8string_tET0_EE5valueEiE4typeELi0EEEvRSJ_RKSL_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_06detail7to_jsonINS0_10basic_jsonINSt3__13mapENS4_6vectorENS4_12basic_stringIcNS4_11char_traitsIcEENS4_9allocatorIcEEEEblmdSA_NS0_14adl_serializerENS6_IhNSA_IhEEEEvEEA23_cTnNS4_9enable_ifIXsr3std16is_constructibleINT_8string_tET0_EE5valueEiE4typeELi0EEEvRSJ_RKSL_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_06detail7to_jsonINS0_10basic_jsonINSt3__13mapENS4_6vectorENS4_12basic_stringIcNS4_11char_traitsIcEENS4_9allocatorIcEEEEblmdSA_NS0_14adl_serializerENS6_IhNSA_IhEEEEvEEA18_cTnNS4_9enable_ifIXsr3std16is_constructibleINT_8string_tET0_EE5valueEiE4typeELi0EEEvRSJ_RKSL_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_06detail7to_jsonINS0_10basic_jsonINSt3__13mapENS4_6vectorENS4_12basic_stringIcNS4_11char_traitsIcEENS4_9allocatorIcEEEEblmdSA_NS0_14adl_serializerENS6_IhNSA_IhEEEEvEEPKcTnNS4_9enable_ifIXsr3std16is_constructibleINT_8string_tET0_EE5valueEiE4typeELi0EEEvRSK_RKSM_ |
6015 | | |
6016 | | template<typename BasicJsonType> |
6017 | | inline void to_json(BasicJsonType& j, typename BasicJsonType::string_t&& s) |
6018 | 0 | { |
6019 | 0 | external_constructor<value_t::string>::construct(j, std::move(s)); |
6020 | 0 | } |
6021 | | |
6022 | | template<typename BasicJsonType, typename FloatType, |
6023 | | enable_if_t<std::is_floating_point<FloatType>::value, int> = 0> |
6024 | | inline void to_json(BasicJsonType& j, FloatType val) noexcept |
6025 | 0 | { |
6026 | 0 | external_constructor<value_t::number_float>::construct(j, static_cast<typename BasicJsonType::number_float_t>(val)); |
6027 | 0 | } |
6028 | | |
6029 | | template<typename BasicJsonType, typename CompatibleNumberUnsignedType, |
6030 | | enable_if_t<is_compatible_integer_type<typename BasicJsonType::number_unsigned_t, CompatibleNumberUnsignedType>::value, int> = 0> |
6031 | | inline void to_json(BasicJsonType& j, CompatibleNumberUnsignedType val) noexcept |
6032 | 0 | { |
6033 | 0 | external_constructor<value_t::number_unsigned>::construct(j, static_cast<typename BasicJsonType::number_unsigned_t>(val)); |
6034 | 0 | } Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_06detail7to_jsonINS0_10basic_jsonINSt3__13mapENS4_6vectorENS4_12basic_stringIcNS4_11char_traitsIcEENS4_9allocatorIcEEEEblmdSA_NS0_14adl_serializerENS6_IhNSA_IhEEEEvEEmTnNS4_9enable_ifIXsr26is_compatible_integer_typeINT_17number_unsigned_tET0_EE5valueEiE4typeELi0EEEvRSI_SK_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_06detail7to_jsonINS0_10basic_jsonINSt3__13mapENS4_6vectorENS4_12basic_stringIcNS4_11char_traitsIcEENS4_9allocatorIcEEEEblmdSA_NS0_14adl_serializerENS6_IhNSA_IhEEEEvEEjTnNS4_9enable_ifIXsr26is_compatible_integer_typeINT_17number_unsigned_tET0_EE5valueEiE4typeELi0EEEvRSI_SK_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_06detail7to_jsonINS0_10basic_jsonINSt3__13mapENS4_6vectorENS4_12basic_stringIcNS4_11char_traitsIcEENS4_9allocatorIcEEEEblmdSA_NS0_14adl_serializerENS6_IhNSA_IhEEEEvEEhTnNS4_9enable_ifIXsr26is_compatible_integer_typeINT_17number_unsigned_tET0_EE5valueEiE4typeELi0EEEvRSI_SK_ |
6035 | | |
6036 | | template<typename BasicJsonType, typename CompatibleNumberIntegerType, |
6037 | | enable_if_t<is_compatible_integer_type<typename BasicJsonType::number_integer_t, CompatibleNumberIntegerType>::value, int> = 0> |
6038 | | inline void to_json(BasicJsonType& j, CompatibleNumberIntegerType val) noexcept |
6039 | 0 | { |
6040 | 0 | external_constructor<value_t::number_integer>::construct(j, static_cast<typename BasicJsonType::number_integer_t>(val)); |
6041 | 0 | } Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_06detail7to_jsonINS0_10basic_jsonINSt3__13mapENS4_6vectorENS4_12basic_stringIcNS4_11char_traitsIcEENS4_9allocatorIcEEEEblmdSA_NS0_14adl_serializerENS6_IhNSA_IhEEEEvEElTnNS4_9enable_ifIXsr26is_compatible_integer_typeINT_16number_integer_tET0_EE5valueEiE4typeELi0EEEvRSI_SK_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_06detail7to_jsonINS0_10basic_jsonINSt3__13mapENS4_6vectorENS4_12basic_stringIcNS4_11char_traitsIcEENS4_9allocatorIcEEEEblmdSA_NS0_14adl_serializerENS6_IhNSA_IhEEEEvEEiTnNS4_9enable_ifIXsr26is_compatible_integer_typeINT_16number_integer_tET0_EE5valueEiE4typeELi0EEEvRSI_SK_ |
6042 | | |
6043 | | #if !JSON_DISABLE_ENUM_SERIALIZATION |
6044 | | template<typename BasicJsonType, typename EnumType, |
6045 | | enable_if_t<std::is_enum<EnumType>::value, int> = 0> |
6046 | | inline void to_json(BasicJsonType& j, EnumType e) noexcept |
6047 | | { |
6048 | | using underlying_type = typename std::underlying_type<EnumType>::type; |
6049 | | static constexpr value_t integral_value_t = std::is_unsigned<underlying_type>::value ? value_t::number_unsigned : value_t::number_integer; |
6050 | | external_constructor<integral_value_t>::construct(j, static_cast<underlying_type>(e)); |
6051 | | } |
6052 | | #endif // JSON_DISABLE_ENUM_SERIALIZATION |
6053 | | |
6054 | | template<typename BasicJsonType> |
6055 | | inline void to_json(BasicJsonType& j, const std::vector<bool>& e) |
6056 | | { |
6057 | | external_constructor<value_t::array>::construct(j, e); |
6058 | | } |
6059 | | |
6060 | | template < typename BasicJsonType, typename CompatibleArrayType, |
6061 | | enable_if_t < is_compatible_array_type<BasicJsonType, |
6062 | | CompatibleArrayType>::value&& |
6063 | | !is_compatible_object_type<BasicJsonType, CompatibleArrayType>::value&& |
6064 | | !is_compatible_string_type<BasicJsonType, CompatibleArrayType>::value&& |
6065 | | !std::is_same<typename BasicJsonType::binary_t, CompatibleArrayType>::value&& |
6066 | | !is_basic_json<CompatibleArrayType>::value, |
6067 | | int > = 0 > |
6068 | | inline void to_json(BasicJsonType& j, const CompatibleArrayType& arr) |
6069 | | { |
6070 | | external_constructor<value_t::array>::construct(j, arr); |
6071 | | } |
6072 | | |
6073 | | template<typename BasicJsonType> |
6074 | | inline void to_json(BasicJsonType& j, const typename BasicJsonType::binary_t& bin) |
6075 | | { |
6076 | | external_constructor<value_t::binary>::construct(j, bin); |
6077 | | } |
6078 | | |
6079 | | template<typename BasicJsonType, typename T, |
6080 | | enable_if_t<std::is_convertible<T, BasicJsonType>::value, int> = 0> |
6081 | | inline void to_json(BasicJsonType& j, const std::valarray<T>& arr) |
6082 | | { |
6083 | | external_constructor<value_t::array>::construct(j, std::move(arr)); |
6084 | | } |
6085 | | |
6086 | | template<typename BasicJsonType> |
6087 | | inline void to_json(BasicJsonType& j, typename BasicJsonType::array_t&& arr) |
6088 | 0 | { |
6089 | 0 | external_constructor<value_t::array>::construct(j, std::move(arr)); |
6090 | 0 | } |
6091 | | |
6092 | | template < typename BasicJsonType, typename CompatibleObjectType, |
6093 | | enable_if_t < is_compatible_object_type<BasicJsonType, CompatibleObjectType>::value&& !is_basic_json<CompatibleObjectType>::value, int > = 0 > |
6094 | | inline void to_json(BasicJsonType& j, const CompatibleObjectType& obj) |
6095 | | { |
6096 | | external_constructor<value_t::object>::construct(j, obj); |
6097 | | } |
6098 | | |
6099 | | template<typename BasicJsonType> |
6100 | | inline void to_json(BasicJsonType& j, typename BasicJsonType::object_t&& obj) |
6101 | | { |
6102 | | external_constructor<value_t::object>::construct(j, std::move(obj)); |
6103 | | } |
6104 | | |
6105 | | template < |
6106 | | typename BasicJsonType, typename T, std::size_t N, |
6107 | | enable_if_t < !std::is_constructible<typename BasicJsonType::string_t, |
6108 | | const T(&)[N]>::value, // NOLINT(cppcoreguidelines-avoid-c-arrays,hicpp-avoid-c-arrays,modernize-avoid-c-arrays) |
6109 | | int > = 0 > |
6110 | | inline void to_json(BasicJsonType& j, const T(&arr)[N]) // NOLINT(cppcoreguidelines-avoid-c-arrays,hicpp-avoid-c-arrays,modernize-avoid-c-arrays) |
6111 | | { |
6112 | | external_constructor<value_t::array>::construct(j, arr); |
6113 | | } |
6114 | | |
6115 | | template < typename BasicJsonType, typename T1, typename T2, enable_if_t < std::is_constructible<BasicJsonType, T1>::value&& std::is_constructible<BasicJsonType, T2>::value, int > = 0 > |
6116 | | inline void to_json(BasicJsonType& j, const std::pair<T1, T2>& p) |
6117 | | { |
6118 | | j = { p.first, p.second }; |
6119 | | } |
6120 | | |
6121 | | // for https://github.com/nlohmann/json/pull/1134 |
6122 | | template<typename BasicJsonType, typename T, |
6123 | | enable_if_t<std::is_same<T, iteration_proxy_value<typename BasicJsonType::iterator>>::value, int> = 0> |
6124 | | inline void to_json(BasicJsonType& j, const T& b) |
6125 | | { |
6126 | | j = { {b.key(), b.value()} }; |
6127 | | } |
6128 | | |
6129 | | template<typename BasicJsonType, typename Tuple, std::size_t... Idx> |
6130 | | inline void to_json_tuple_impl(BasicJsonType& j, const Tuple& t, index_sequence<Idx...> /*unused*/) |
6131 | | { |
6132 | | j = { std::get<Idx>(t)... }; |
6133 | | } |
6134 | | |
6135 | | template<typename BasicJsonType, typename Tuple> |
6136 | | inline void to_json_tuple_impl(BasicJsonType& j, const Tuple& /*unused*/, index_sequence<> /*unused*/) |
6137 | | { |
6138 | | using array_t = typename BasicJsonType::array_t; |
6139 | | j = array_t(); |
6140 | | } |
6141 | | |
6142 | | template<typename BasicJsonType, typename T, enable_if_t<is_constructible_tuple<BasicJsonType, T>::value, int > = 0> |
6143 | | inline void to_json(BasicJsonType& j, const T& t) |
6144 | | { |
6145 | | to_json_tuple_impl(j, t, make_index_sequence<std::tuple_size<T>::value> {}); |
6146 | | } |
6147 | | |
6148 | | #if JSON_HAS_FILESYSTEM || JSON_HAS_EXPERIMENTAL_FILESYSTEM |
6149 | | #if defined(__cpp_lib_char8_t) |
6150 | | template<typename BasicJsonType, typename Tr, typename Allocator> |
6151 | | inline void to_json(BasicJsonType& j, const std::basic_string<char8_t, Tr, Allocator>& s) |
6152 | | { |
6153 | | using OtherAllocator = typename std::allocator_traits<Allocator>::template rebind_alloc<char>; |
6154 | | j = std::basic_string<char, std::char_traits<char>, OtherAllocator>(s.begin(), s.end(), s.get_allocator()); |
6155 | | } |
6156 | | #endif |
6157 | | |
6158 | | template<typename BasicJsonType> |
6159 | | inline void to_json(BasicJsonType& j, const std_fs::path& p) |
6160 | | { |
6161 | | // Returns either a std::string or a std::u8string depending whether library |
6162 | | // support for char8_t is enabled. |
6163 | | j = p.u8string(); |
6164 | | } |
6165 | | #endif |
6166 | | |
6167 | | struct to_json_fn |
6168 | | { |
6169 | | template<typename BasicJsonType, typename T> |
6170 | | auto operator()(BasicJsonType& j, T&& val) const noexcept(noexcept(to_json(j, std::forward<T>(val)))) |
6171 | | -> decltype(to_json(j, std::forward<T>(val)), void()) |
6172 | 0 | { |
6173 | 0 | return to_json(j, std::forward<T>(val)); |
6174 | 0 | } Unexecuted instantiation: _ZNK8nlohmann16json_abi_v3_12_06detail10to_json_fnclINS0_10basic_jsonINSt3__13mapENS5_6vectorENS5_12basic_stringIcNS5_11char_traitsIcEENS5_9allocatorIcEEEEblmdSB_NS0_14adl_serializerENS7_IhNSB_IhEEEEvEERA1_KcEEDTcmcl7to_jsonfp_clsr3stdE7forwardIT0_Efp0_EEcvv_EERT_OSL_ Unexecuted instantiation: _ZNK8nlohmann16json_abi_v3_12_06detail10to_json_fnclINS0_10basic_jsonINSt3__13mapENS5_6vectorENS5_12basic_stringIcNS5_11char_traitsIcEENS5_9allocatorIcEEEEblmdSB_NS0_14adl_serializerENS7_IhNSB_IhEEEEvEERKmEEDTcmcl7to_jsonfp_clsr3stdE7forwardIT0_Efp0_EEcvv_EERT_OSK_ Unexecuted instantiation: _ZNK8nlohmann16json_abi_v3_12_06detail10to_json_fnclINS0_10basic_jsonINSt3__13mapENS5_6vectorENS5_12basic_stringIcNS5_11char_traitsIcEENS5_9allocatorIcEEEEblmdSB_NS0_14adl_serializerENS7_IhNSB_IhEEEEvEERKSD_EEDTcmcl7to_jsonfp_clsr3stdE7forwardIT0_Efp0_EEcvv_EERT_OSK_ Unexecuted instantiation: _ZNK8nlohmann16json_abi_v3_12_06detail10to_json_fnclINS0_10basic_jsonINSt3__13mapENS5_6vectorENS5_12basic_stringIcNS5_11char_traitsIcEENS5_9allocatorIcEEEEblmdSB_NS0_14adl_serializerENS7_IhNSB_IhEEEEvEERSD_EEDTcmcl7to_jsonfp_clsr3stdE7forwardIT0_Efp0_EEcvv_EERT_OSJ_ Unexecuted instantiation: _ZNK8nlohmann16json_abi_v3_12_06detail10to_json_fnclINS0_10basic_jsonINSt3__13mapENS5_6vectorENS5_12basic_stringIcNS5_11char_traitsIcEENS5_9allocatorIcEEEEblmdSB_NS0_14adl_serializerENS7_IhNSB_IhEEEEvEERdEEDTcmcl7to_jsonfp_clsr3stdE7forwardIT0_Efp0_EEcvv_EERT_OSJ_ Unexecuted instantiation: _ZNK8nlohmann16json_abi_v3_12_06detail10to_json_fnclINS0_10basic_jsonINSt3__13mapENS5_6vectorENS5_12basic_stringIcNS5_11char_traitsIcEENS5_9allocatorIcEEEEblmdSB_NS0_14adl_serializerENS7_IhNSB_IhEEEEvEERbEEDTcmcl7to_jsonfp_clsr3stdE7forwardIT0_Efp0_EEcvv_EERT_OSJ_ Unexecuted instantiation: _ZNK8nlohmann16json_abi_v3_12_06detail10to_json_fnclINS0_10basic_jsonINSt3__13mapENS5_6vectorENS5_12basic_stringIcNS5_11char_traitsIcEENS5_9allocatorIcEEEEblmdSB_NS0_14adl_serializerENS7_IhNSB_IhEEEEvEERlEEDTcmcl7to_jsonfp_clsr3stdE7forwardIT0_Efp0_EEcvv_EERT_OSJ_ Unexecuted instantiation: _ZNK8nlohmann16json_abi_v3_12_06detail10to_json_fnclINS0_10basic_jsonINSt3__13mapENS5_6vectorENS5_12basic_stringIcNS5_11char_traitsIcEENS5_9allocatorIcEEEEblmdSB_NS0_14adl_serializerENS7_IhNSB_IhEEEEvEERmEEDTcmcl7to_jsonfp_clsr3stdE7forwardIT0_Efp0_EEcvv_EERT_OSJ_ Unexecuted instantiation: _ZNK8nlohmann16json_abi_v3_12_06detail10to_json_fnclINS0_10basic_jsonINSt3__13mapENS5_6vectorENS5_12basic_stringIcNS5_11char_traitsIcEENS5_9allocatorIcEEEEblmdSB_NS0_14adl_serializerENS7_IhNSB_IhEEEEvEERA2_KcEEDTcmcl7to_jsonfp_clsr3stdE7forwardIT0_Efp0_EEcvv_EERT_OSL_ Unexecuted instantiation: _ZNK8nlohmann16json_abi_v3_12_06detail10to_json_fnclINS0_10basic_jsonINSt3__13mapENS5_6vectorENS5_12basic_stringIcNS5_11char_traitsIcEENS5_9allocatorIcEEEEblmdSB_NS0_14adl_serializerENS7_IhNSB_IhEEEEvEEmEEDTcmcl7to_jsonfp_clsr3stdE7forwardIT0_Efp0_EEcvv_EERT_OSI_ Unexecuted instantiation: _ZNK8nlohmann16json_abi_v3_12_06detail10to_json_fnclINS0_10basic_jsonINSt3__13mapENS5_6vectorENS5_12basic_stringIcNS5_11char_traitsIcEENS5_9allocatorIcEEEEblmdSB_NS0_14adl_serializerENS7_IhNSB_IhEEEEvEERA21_KcEEDTcmcl7to_jsonfp_clsr3stdE7forwardIT0_Efp0_EEcvv_EERT_OSL_ Unexecuted instantiation: _ZNK8nlohmann16json_abi_v3_12_06detail10to_json_fnclINS0_10basic_jsonINSt3__13mapENS5_6vectorENS5_12basic_stringIcNS5_11char_traitsIcEENS5_9allocatorIcEEEEblmdSB_NS0_14adl_serializerENS7_IhNSB_IhEEEEvEERA40_KcEEDTcmcl7to_jsonfp_clsr3stdE7forwardIT0_Efp0_EEcvv_EERT_OSL_ Unexecuted instantiation: _ZNK8nlohmann16json_abi_v3_12_06detail10to_json_fnclINS0_10basic_jsonINSt3__13mapENS5_6vectorENS5_12basic_stringIcNS5_11char_traitsIcEENS5_9allocatorIcEEEEblmdSB_NS0_14adl_serializerENS7_IhNSB_IhEEEEvEERA600_KcEEDTcmcl7to_jsonfp_clsr3stdE7forwardIT0_Efp0_EEcvv_EERT_OSL_ Unexecuted instantiation: _ZNK8nlohmann16json_abi_v3_12_06detail10to_json_fnclINS0_10basic_jsonINSt3__13mapENS5_6vectorENS5_12basic_stringIcNS5_11char_traitsIcEENS5_9allocatorIcEEEEblmdSB_NS0_14adl_serializerENS7_IhNSB_IhEEEEvEERA137_KcEEDTcmcl7to_jsonfp_clsr3stdE7forwardIT0_Efp0_EEcvv_EERT_OSL_ Unexecuted instantiation: _ZNK8nlohmann16json_abi_v3_12_06detail10to_json_fnclINS0_10basic_jsonINSt3__13mapENS5_6vectorENS5_12basic_stringIcNS5_11char_traitsIcEENS5_9allocatorIcEEEEblmdSB_NS0_14adl_serializerENS7_IhNSB_IhEEEEvEERA156_KcEEDTcmcl7to_jsonfp_clsr3stdE7forwardIT0_Efp0_EEcvv_EERT_OSL_ Unexecuted instantiation: _ZNK8nlohmann16json_abi_v3_12_06detail10to_json_fnclINS0_10basic_jsonINSt3__13mapENS5_6vectorENS5_12basic_stringIcNS5_11char_traitsIcEENS5_9allocatorIcEEEEblmdSB_NS0_14adl_serializerENS7_IhNSB_IhEEEEvEERA78_KcEEDTcmcl7to_jsonfp_clsr3stdE7forwardIT0_Efp0_EEcvv_EERT_OSL_ Unexecuted instantiation: _ZNK8nlohmann16json_abi_v3_12_06detail10to_json_fnclINS0_10basic_jsonINSt3__13mapENS5_6vectorENS5_12basic_stringIcNS5_11char_traitsIcEENS5_9allocatorIcEEEEblmdSB_NS0_14adl_serializerENS7_IhNSB_IhEEEEvEERA79_KcEEDTcmcl7to_jsonfp_clsr3stdE7forwardIT0_Efp0_EEcvv_EERT_OSL_ Unexecuted instantiation: _ZNK8nlohmann16json_abi_v3_12_06detail10to_json_fnclINS0_10basic_jsonINSt3__13mapENS5_6vectorENS5_12basic_stringIcNS5_11char_traitsIcEENS5_9allocatorIcEEEEblmdSB_NS0_14adl_serializerENS7_IhNSB_IhEEEEvEERA65_KcEEDTcmcl7to_jsonfp_clsr3stdE7forwardIT0_Efp0_EEcvv_EERT_OSL_ Unexecuted instantiation: _ZNK8nlohmann16json_abi_v3_12_06detail10to_json_fnclINS0_10basic_jsonINSt3__13mapENS5_6vectorENS5_12basic_stringIcNS5_11char_traitsIcEENS5_9allocatorIcEEEEblmdSB_NS0_14adl_serializerENS7_IhNSB_IhEEEEvEERA58_KcEEDTcmcl7to_jsonfp_clsr3stdE7forwardIT0_Efp0_EEcvv_EERT_OSL_ Unexecuted instantiation: _ZNK8nlohmann16json_abi_v3_12_06detail10to_json_fnclINS0_10basic_jsonINSt3__13mapENS5_6vectorENS5_12basic_stringIcNS5_11char_traitsIcEENS5_9allocatorIcEEEEblmdSB_NS0_14adl_serializerENS7_IhNSB_IhEEEEvEERA56_KcEEDTcmcl7to_jsonfp_clsr3stdE7forwardIT0_Efp0_EEcvv_EERT_OSL_ Unexecuted instantiation: _ZNK8nlohmann16json_abi_v3_12_06detail10to_json_fnclINS0_10basic_jsonINSt3__13mapENS5_6vectorENS5_12basic_stringIcNS5_11char_traitsIcEENS5_9allocatorIcEEEEblmdSB_NS0_14adl_serializerENS7_IhNSB_IhEEEEvEERA59_KcEEDTcmcl7to_jsonfp_clsr3stdE7forwardIT0_Efp0_EEcvv_EERT_OSL_ Unexecuted instantiation: _ZNK8nlohmann16json_abi_v3_12_06detail10to_json_fnclINS0_10basic_jsonINSt3__13mapENS5_6vectorENS5_12basic_stringIcNS5_11char_traitsIcEENS5_9allocatorIcEEEEblmdSB_NS0_14adl_serializerENS7_IhNSB_IhEEEEvEERA1679_KcEEDTcmcl7to_jsonfp_clsr3stdE7forwardIT0_Efp0_EEcvv_EERT_OSL_ Unexecuted instantiation: _ZNK8nlohmann16json_abi_v3_12_06detail10to_json_fnclINS0_10basic_jsonINSt3__13mapENS5_6vectorENS5_12basic_stringIcNS5_11char_traitsIcEENS5_9allocatorIcEEEEblmdSB_NS0_14adl_serializerENS7_IhNSB_IhEEEEvEERA1535_KcEEDTcmcl7to_jsonfp_clsr3stdE7forwardIT0_Efp0_EEcvv_EERT_OSL_ Unexecuted instantiation: _ZNK8nlohmann16json_abi_v3_12_06detail10to_json_fnclINS0_10basic_jsonINSt3__13mapENS5_6vectorENS5_12basic_stringIcNS5_11char_traitsIcEENS5_9allocatorIcEEEEblmdSB_NS0_14adl_serializerENS7_IhNSB_IhEEEEvEERA714_KcEEDTcmcl7to_jsonfp_clsr3stdE7forwardIT0_Efp0_EEcvv_EERT_OSL_ Unexecuted instantiation: _ZNK8nlohmann16json_abi_v3_12_06detail10to_json_fnclINS0_10basic_jsonINSt3__13mapENS5_6vectorENS5_12basic_stringIcNS5_11char_traitsIcEENS5_9allocatorIcEEEEblmdSB_NS0_14adl_serializerENS7_IhNSB_IhEEEEvEERA3238_KcEEDTcmcl7to_jsonfp_clsr3stdE7forwardIT0_Efp0_EEcvv_EERT_OSL_ Unexecuted instantiation: _ZNK8nlohmann16json_abi_v3_12_06detail10to_json_fnclINS0_10basic_jsonINSt3__13mapENS5_6vectorENS5_12basic_stringIcNS5_11char_traitsIcEENS5_9allocatorIcEEEEblmdSB_NS0_14adl_serializerENS7_IhNSB_IhEEEEvEERA2159_KcEEDTcmcl7to_jsonfp_clsr3stdE7forwardIT0_Efp0_EEcvv_EERT_OSL_ Unexecuted instantiation: _ZNK8nlohmann16json_abi_v3_12_06detail10to_json_fnclINS0_10basic_jsonINSt3__13mapENS5_6vectorENS5_12basic_stringIcNS5_11char_traitsIcEENS5_9allocatorIcEEEEblmdSB_NS0_14adl_serializerENS7_IhNSB_IhEEEEvEERA77_KcEEDTcmcl7to_jsonfp_clsr3stdE7forwardIT0_Efp0_EEcvv_EERT_OSL_ Unexecuted instantiation: _ZNK8nlohmann16json_abi_v3_12_06detail10to_json_fnclINS0_10basic_jsonINSt3__13mapENS5_6vectorENS5_12basic_stringIcNS5_11char_traitsIcEENS5_9allocatorIcEEEEblmdSB_NS0_14adl_serializerENS7_IhNSB_IhEEEEvEERA16_KcEEDTcmcl7to_jsonfp_clsr3stdE7forwardIT0_Efp0_EEcvv_EERT_OSL_ Unexecuted instantiation: _ZNK8nlohmann16json_abi_v3_12_06detail10to_json_fnclINS0_10basic_jsonINSt3__13mapENS5_6vectorENS5_12basic_stringIcNS5_11char_traitsIcEENS5_9allocatorIcEEEEblmdSB_NS0_14adl_serializerENS7_IhNSB_IhEEEEvEERA64_KcEEDTcmcl7to_jsonfp_clsr3stdE7forwardIT0_Efp0_EEcvv_EERT_OSL_ Unexecuted instantiation: _ZNK8nlohmann16json_abi_v3_12_06detail10to_json_fnclINS0_10basic_jsonINSt3__13mapENS5_6vectorENS5_12basic_stringIcNS5_11char_traitsIcEENS5_9allocatorIcEEEEblmdSB_NS0_14adl_serializerENS7_IhNSB_IhEEEEvEERA923_KcEEDTcmcl7to_jsonfp_clsr3stdE7forwardIT0_Efp0_EEcvv_EERT_OSL_ Unexecuted instantiation: _ZNK8nlohmann16json_abi_v3_12_06detail10to_json_fnclINS0_10basic_jsonINSt3__13mapENS5_6vectorENS5_12basic_stringIcNS5_11char_traitsIcEENS5_9allocatorIcEEEEblmdSB_NS0_14adl_serializerENS7_IhNSB_IhEEEEvEERA150_KcEEDTcmcl7to_jsonfp_clsr3stdE7forwardIT0_Efp0_EEcvv_EERT_OSL_ Unexecuted instantiation: _ZNK8nlohmann16json_abi_v3_12_06detail10to_json_fnclINS0_10basic_jsonINSt3__13mapENS5_6vectorENS5_12basic_stringIcNS5_11char_traitsIcEENS5_9allocatorIcEEEEblmdSB_NS0_14adl_serializerENS7_IhNSB_IhEEEEvEERA309_KcEEDTcmcl7to_jsonfp_clsr3stdE7forwardIT0_Efp0_EEcvv_EERT_OSL_ Unexecuted instantiation: _ZNK8nlohmann16json_abi_v3_12_06detail10to_json_fnclINS0_10basic_jsonINSt3__13mapENS5_6vectorENS5_12basic_stringIcNS5_11char_traitsIcEENS5_9allocatorIcEEEEblmdSB_NS0_14adl_serializerENS7_IhNSB_IhEEEEvEERA310_KcEEDTcmcl7to_jsonfp_clsr3stdE7forwardIT0_Efp0_EEcvv_EERT_OSL_ Unexecuted instantiation: _ZNK8nlohmann16json_abi_v3_12_06detail10to_json_fnclINS0_10basic_jsonINSt3__13mapENS5_6vectorENS5_12basic_stringIcNS5_11char_traitsIcEENS5_9allocatorIcEEEEblmdSB_NS0_14adl_serializerENS7_IhNSB_IhEEEEvEERA155_KcEEDTcmcl7to_jsonfp_clsr3stdE7forwardIT0_Efp0_EEcvv_EERT_OSL_ Unexecuted instantiation: _ZNK8nlohmann16json_abi_v3_12_06detail10to_json_fnclINS0_10basic_jsonINSt3__13mapENS5_6vectorENS5_12basic_stringIcNS5_11char_traitsIcEENS5_9allocatorIcEEEEblmdSB_NS0_14adl_serializerENS7_IhNSB_IhEEEEvEERA117_KcEEDTcmcl7to_jsonfp_clsr3stdE7forwardIT0_Efp0_EEcvv_EERT_OSL_ Unexecuted instantiation: _ZNK8nlohmann16json_abi_v3_12_06detail10to_json_fnclINS0_10basic_jsonINSt3__13mapENS5_6vectorENS5_12basic_stringIcNS5_11char_traitsIcEENS5_9allocatorIcEEEEblmdSB_NS0_14adl_serializerENS7_IhNSB_IhEEEEvEERA50_KcEEDTcmcl7to_jsonfp_clsr3stdE7forwardIT0_Efp0_EEcvv_EERT_OSL_ Unexecuted instantiation: _ZNK8nlohmann16json_abi_v3_12_06detail10to_json_fnclINS0_10basic_jsonINSt3__13mapENS5_6vectorENS5_12basic_stringIcNS5_11char_traitsIcEENS5_9allocatorIcEEEEblmdSB_NS0_14adl_serializerENS7_IhNSB_IhEEEEvEERA61_KcEEDTcmcl7to_jsonfp_clsr3stdE7forwardIT0_Efp0_EEcvv_EERT_OSL_ Unexecuted instantiation: _ZNK8nlohmann16json_abi_v3_12_06detail10to_json_fnclINS0_10basic_jsonINSt3__13mapENS5_6vectorENS5_12basic_stringIcNS5_11char_traitsIcEENS5_9allocatorIcEEEEblmdSB_NS0_14adl_serializerENS7_IhNSB_IhEEEEvEERA158_KcEEDTcmcl7to_jsonfp_clsr3stdE7forwardIT0_Efp0_EEcvv_EERT_OSL_ Unexecuted instantiation: _ZNK8nlohmann16json_abi_v3_12_06detail10to_json_fnclINS0_10basic_jsonINSt3__13mapENS5_6vectorENS5_12basic_stringIcNS5_11char_traitsIcEENS5_9allocatorIcEEEEblmdSB_NS0_14adl_serializerENS7_IhNSB_IhEEEEvEERA30_KcEEDTcmcl7to_jsonfp_clsr3stdE7forwardIT0_Efp0_EEcvv_EERT_OSL_ Unexecuted instantiation: _ZNK8nlohmann16json_abi_v3_12_06detail10to_json_fnclINS0_10basic_jsonINSt3__13mapENS5_6vectorENS5_12basic_stringIcNS5_11char_traitsIcEENS5_9allocatorIcEEEEblmdSB_NS0_14adl_serializerENS7_IhNSB_IhEEEEvEERA69_KcEEDTcmcl7to_jsonfp_clsr3stdE7forwardIT0_Efp0_EEcvv_EERT_OSL_ Unexecuted instantiation: _ZNK8nlohmann16json_abi_v3_12_06detail10to_json_fnclINS0_10basic_jsonINSt3__13mapENS5_6vectorENS5_12basic_stringIcNS5_11char_traitsIcEENS5_9allocatorIcEEEEblmdSB_NS0_14adl_serializerENS7_IhNSB_IhEEEEvEERA3_KcEEDTcmcl7to_jsonfp_clsr3stdE7forwardIT0_Efp0_EEcvv_EERT_OSL_ Unexecuted instantiation: _ZNK8nlohmann16json_abi_v3_12_06detail10to_json_fnclINS0_10basic_jsonINSt3__13mapENS5_6vectorENS5_12basic_stringIcNS5_11char_traitsIcEENS5_9allocatorIcEEEEblmdSB_NS0_14adl_serializerENS7_IhNSB_IhEEEEvEEiEEDTcmcl7to_jsonfp_clsr3stdE7forwardIT0_Efp0_EEcvv_EERT_OSI_ Unexecuted instantiation: _ZNK8nlohmann16json_abi_v3_12_06detail10to_json_fnclINS0_10basic_jsonINSt3__13mapENS5_6vectorENS5_12basic_stringIcNS5_11char_traitsIcEENS5_9allocatorIcEEEEblmdSB_NS0_14adl_serializerENS7_IhNSB_IhEEEEvEERA114_KcEEDTcmcl7to_jsonfp_clsr3stdE7forwardIT0_Efp0_EEcvv_EERT_OSL_ Unexecuted instantiation: _ZNK8nlohmann16json_abi_v3_12_06detail10to_json_fnclINS0_10basic_jsonINSt3__13mapENS5_6vectorENS5_12basic_stringIcNS5_11char_traitsIcEENS5_9allocatorIcEEEEblmdSB_NS0_14adl_serializerENS7_IhNSB_IhEEEEvEERA113_KcEEDTcmcl7to_jsonfp_clsr3stdE7forwardIT0_Efp0_EEcvv_EERT_OSL_ Unexecuted instantiation: _ZNK8nlohmann16json_abi_v3_12_06detail10to_json_fnclINS0_10basic_jsonINSt3__13mapENS5_6vectorENS5_12basic_stringIcNS5_11char_traitsIcEENS5_9allocatorIcEEEEblmdSB_NS0_14adl_serializerENS7_IhNSB_IhEEEEvEERA39_KcEEDTcmcl7to_jsonfp_clsr3stdE7forwardIT0_Efp0_EEcvv_EERT_OSL_ Unexecuted instantiation: _ZNK8nlohmann16json_abi_v3_12_06detail10to_json_fnclINS0_10basic_jsonINSt3__13mapENS5_6vectorENS5_12basic_stringIcNS5_11char_traitsIcEENS5_9allocatorIcEEEEblmdSB_NS0_14adl_serializerENS7_IhNSB_IhEEEEvEERA41_KcEEDTcmcl7to_jsonfp_clsr3stdE7forwardIT0_Efp0_EEcvv_EERT_OSL_ Unexecuted instantiation: _ZNK8nlohmann16json_abi_v3_12_06detail10to_json_fnclINS0_10basic_jsonINSt3__13mapENS5_6vectorENS5_12basic_stringIcNS5_11char_traitsIcEENS5_9allocatorIcEEEEblmdSB_NS0_14adl_serializerENS7_IhNSB_IhEEEEvEERA86_KcEEDTcmcl7to_jsonfp_clsr3stdE7forwardIT0_Efp0_EEcvv_EERT_OSL_ Unexecuted instantiation: _ZNK8nlohmann16json_abi_v3_12_06detail10to_json_fnclINS0_10basic_jsonINSt3__13mapENS5_6vectorENS5_12basic_stringIcNS5_11char_traitsIcEENS5_9allocatorIcEEEEblmdSB_NS0_14adl_serializerENS7_IhNSB_IhEEEEvEERA135_KcEEDTcmcl7to_jsonfp_clsr3stdE7forwardIT0_Efp0_EEcvv_EERT_OSL_ Unexecuted instantiation: _ZNK8nlohmann16json_abi_v3_12_06detail10to_json_fnclINS0_10basic_jsonINSt3__13mapENS5_6vectorENS5_12basic_stringIcNS5_11char_traitsIcEENS5_9allocatorIcEEEEblmdSB_NS0_14adl_serializerENS7_IhNSB_IhEEEEvEERA20_KcEEDTcmcl7to_jsonfp_clsr3stdE7forwardIT0_Efp0_EEcvv_EERT_OSL_ Unexecuted instantiation: _ZNK8nlohmann16json_abi_v3_12_06detail10to_json_fnclINS0_10basic_jsonINSt3__13mapENS5_6vectorENS5_12basic_stringIcNS5_11char_traitsIcEENS5_9allocatorIcEEEEblmdSB_NS0_14adl_serializerENS7_IhNSB_IhEEEEvEERA24_KcEEDTcmcl7to_jsonfp_clsr3stdE7forwardIT0_Efp0_EEcvv_EERT_OSL_ Unexecuted instantiation: _ZNK8nlohmann16json_abi_v3_12_06detail10to_json_fnclINS0_10basic_jsonINSt3__13mapENS5_6vectorENS5_12basic_stringIcNS5_11char_traitsIcEENS5_9allocatorIcEEEEblmdSB_NS0_14adl_serializerENS7_IhNSB_IhEEEEvEERA11_KcEEDTcmcl7to_jsonfp_clsr3stdE7forwardIT0_Efp0_EEcvv_EERT_OSL_ Unexecuted instantiation: _ZNK8nlohmann16json_abi_v3_12_06detail10to_json_fnclINS0_10basic_jsonINSt3__13mapENS5_6vectorENS5_12basic_stringIcNS5_11char_traitsIcEENS5_9allocatorIcEEEEblmdSB_NS0_14adl_serializerENS7_IhNSB_IhEEEEvEERA35_KcEEDTcmcl7to_jsonfp_clsr3stdE7forwardIT0_Efp0_EEcvv_EERT_OSL_ Unexecuted instantiation: _ZNK8nlohmann16json_abi_v3_12_06detail10to_json_fnclINS0_10basic_jsonINSt3__13mapENS5_6vectorENS5_12basic_stringIcNS5_11char_traitsIcEENS5_9allocatorIcEEEEblmdSB_NS0_14adl_serializerENS7_IhNSB_IhEEEEvEERA4_KcEEDTcmcl7to_jsonfp_clsr3stdE7forwardIT0_Efp0_EEcvv_EERT_OSL_ Unexecuted instantiation: _ZNK8nlohmann16json_abi_v3_12_06detail10to_json_fnclINS0_10basic_jsonINSt3__13mapENS5_6vectorENS5_12basic_stringIcNS5_11char_traitsIcEENS5_9allocatorIcEEEEblmdSB_NS0_14adl_serializerENS7_IhNSB_IhEEEEvEERA116_KcEEDTcmcl7to_jsonfp_clsr3stdE7forwardIT0_Efp0_EEcvv_EERT_OSL_ Unexecuted instantiation: _ZNK8nlohmann16json_abi_v3_12_06detail10to_json_fnclINS0_10basic_jsonINSt3__13mapENS5_6vectorENS5_12basic_stringIcNS5_11char_traitsIcEENS5_9allocatorIcEEEEblmdSB_NS0_14adl_serializerENS7_IhNSB_IhEEEEvEERA115_KcEEDTcmcl7to_jsonfp_clsr3stdE7forwardIT0_Efp0_EEcvv_EERT_OSL_ Unexecuted instantiation: _ZNK8nlohmann16json_abi_v3_12_06detail10to_json_fnclINS0_10basic_jsonINSt3__13mapENS5_6vectorENS5_12basic_stringIcNS5_11char_traitsIcEENS5_9allocatorIcEEEEblmdSB_NS0_14adl_serializerENS7_IhNSB_IhEEEEvEERA619_KcEEDTcmcl7to_jsonfp_clsr3stdE7forwardIT0_Efp0_EEcvv_EERT_OSL_ Unexecuted instantiation: _ZNK8nlohmann16json_abi_v3_12_06detail10to_json_fnclINS0_10basic_jsonINSt3__13mapENS5_6vectorENS5_12basic_stringIcNS5_11char_traitsIcEENS5_9allocatorIcEEEEblmdSB_NS0_14adl_serializerENS7_IhNSB_IhEEEEvEERA9_KcEEDTcmcl7to_jsonfp_clsr3stdE7forwardIT0_Efp0_EEcvv_EERT_OSL_ Unexecuted instantiation: _ZNK8nlohmann16json_abi_v3_12_06detail10to_json_fnclINS0_10basic_jsonINSt3__13mapENS5_6vectorENS5_12basic_stringIcNS5_11char_traitsIcEENS5_9allocatorIcEEEEblmdSB_NS0_14adl_serializerENS7_IhNSB_IhEEEEvEESD_EEDTcmcl7to_jsonfp_clsr3stdE7forwardIT0_Efp0_EEcvv_EERT_OSI_ Unexecuted instantiation: _ZNK8nlohmann16json_abi_v3_12_06detail10to_json_fnclINS0_10basic_jsonINSt3__13mapENS5_6vectorENS5_12basic_stringIcNS5_11char_traitsIcEENS5_9allocatorIcEEEEblmdSB_NS0_14adl_serializerENS7_IhNSB_IhEEEEvEENS7_ISH_NSB_ISH_EEEEEEDTcmcl7to_jsonfp_clsr3stdE7forwardIT0_Efp0_EEcvv_EERT_OSK_ Unexecuted instantiation: _ZNK8nlohmann16json_abi_v3_12_06detail10to_json_fnclINS0_10basic_jsonINSt3__13mapENS5_6vectorENS5_12basic_stringIcNS5_11char_traitsIcEENS5_9allocatorIcEEEEblmdSB_NS0_14adl_serializerENS7_IhNSB_IhEEEEvEERKbEEDTcmcl7to_jsonfp_clsr3stdE7forwardIT0_Efp0_EEcvv_EERT_OSK_ Unexecuted instantiation: _ZNK8nlohmann16json_abi_v3_12_06detail10to_json_fnclINS0_10basic_jsonINSt3__13mapENS5_6vectorENS5_12basic_stringIcNS5_11char_traitsIcEENS5_9allocatorIcEEEEblmdSB_NS0_14adl_serializerENS7_IhNSB_IhEEEEvEEjEEDTcmcl7to_jsonfp_clsr3stdE7forwardIT0_Efp0_EEcvv_EERT_OSI_ Unexecuted instantiation: _ZNK8nlohmann16json_abi_v3_12_06detail10to_json_fnclINS0_10basic_jsonINSt3__13mapENS5_6vectorENS5_12basic_stringIcNS5_11char_traitsIcEENS5_9allocatorIcEEEEblmdSB_NS0_14adl_serializerENS7_IhNSB_IhEEEEvEEbEEDTcmcl7to_jsonfp_clsr3stdE7forwardIT0_Efp0_EEcvv_EERT_OSI_ Unexecuted instantiation: _ZNK8nlohmann16json_abi_v3_12_06detail10to_json_fnclINS0_10basic_jsonINSt3__13mapENS5_6vectorENS5_12basic_stringIcNS5_11char_traitsIcEENS5_9allocatorIcEEEEblmdSB_NS0_14adl_serializerENS7_IhNSB_IhEEEEvEEKSD_EEDTcmcl7to_jsonfp_clsr3stdE7forwardIT0_Efp0_EEcvv_EERT_OSJ_ Unexecuted instantiation: _ZNK8nlohmann16json_abi_v3_12_06detail10to_json_fnclINS0_10basic_jsonINSt3__13mapENS5_6vectorENS5_12basic_stringIcNS5_11char_traitsIcEENS5_9allocatorIcEEEEblmdSB_NS0_14adl_serializerENS7_IhNSB_IhEEEEvEERA7_KcEEDTcmcl7to_jsonfp_clsr3stdE7forwardIT0_Efp0_EEcvv_EERT_OSL_ Unexecuted instantiation: _ZNK8nlohmann16json_abi_v3_12_06detail10to_json_fnclINS0_10basic_jsonINSt3__13mapENS5_6vectorENS5_12basic_stringIcNS5_11char_traitsIcEENS5_9allocatorIcEEEEblmdSB_NS0_14adl_serializerENS7_IhNSB_IhEEEEvEERA5_KcEEDTcmcl7to_jsonfp_clsr3stdE7forwardIT0_Efp0_EEcvv_EERT_OSL_ Unexecuted instantiation: _ZNK8nlohmann16json_abi_v3_12_06detail10to_json_fnclINS0_10basic_jsonINSt3__13mapENS5_6vectorENS5_12basic_stringIcNS5_11char_traitsIcEENS5_9allocatorIcEEEEblmdSB_NS0_14adl_serializerENS7_IhNSB_IhEEEEvEERKhEEDTcmcl7to_jsonfp_clsr3stdE7forwardIT0_Efp0_EEcvv_EERT_OSK_ Unexecuted instantiation: _ZNK8nlohmann16json_abi_v3_12_06detail10to_json_fnclINS0_10basic_jsonINSt3__13mapENS5_6vectorENS5_12basic_stringIcNS5_11char_traitsIcEENS5_9allocatorIcEEEEblmdSB_NS0_14adl_serializerENS7_IhNSB_IhEEEEvEERA17_KcEEDTcmcl7to_jsonfp_clsr3stdE7forwardIT0_Efp0_EEcvv_EERT_OSL_ Unexecuted instantiation: _ZNK8nlohmann16json_abi_v3_12_06detail10to_json_fnclINS0_10basic_jsonINSt3__13mapENS5_6vectorENS5_12basic_stringIcNS5_11char_traitsIcEENS5_9allocatorIcEEEEblmdSB_NS0_14adl_serializerENS7_IhNSB_IhEEEEvEERA13_KcEEDTcmcl7to_jsonfp_clsr3stdE7forwardIT0_Efp0_EEcvv_EERT_OSL_ Unexecuted instantiation: _ZNK8nlohmann16json_abi_v3_12_06detail10to_json_fnclINS0_10basic_jsonINSt3__13mapENS5_6vectorENS5_12basic_stringIcNS5_11char_traitsIcEENS5_9allocatorIcEEEEblmdSB_NS0_14adl_serializerENS7_IhNSB_IhEEEEvEERA10_KcEEDTcmcl7to_jsonfp_clsr3stdE7forwardIT0_Efp0_EEcvv_EERT_OSL_ Unexecuted instantiation: _ZNK8nlohmann16json_abi_v3_12_06detail10to_json_fnclINS0_10basic_jsonINSt3__13mapENS5_6vectorENS5_12basic_stringIcNS5_11char_traitsIcEENS5_9allocatorIcEEEEblmdSB_NS0_14adl_serializerENS7_IhNSB_IhEEEEvEERKjEEDTcmcl7to_jsonfp_clsr3stdE7forwardIT0_Efp0_EEcvv_EERT_OSK_ Unexecuted instantiation: _ZNK8nlohmann16json_abi_v3_12_06detail10to_json_fnclINS0_10basic_jsonINSt3__13mapENS5_6vectorENS5_12basic_stringIcNS5_11char_traitsIcEENS5_9allocatorIcEEEEblmdSB_NS0_14adl_serializerENS7_IhNSB_IhEEEEvEERA8_KcEEDTcmcl7to_jsonfp_clsr3stdE7forwardIT0_Efp0_EEcvv_EERT_OSL_ Unexecuted instantiation: _ZNK8nlohmann16json_abi_v3_12_06detail10to_json_fnclINS0_10basic_jsonINSt3__13mapENS5_6vectorENS5_12basic_stringIcNS5_11char_traitsIcEENS5_9allocatorIcEEEEblmdSB_NS0_14adl_serializerENS7_IhNSB_IhEEEEvEERA15_KcEEDTcmcl7to_jsonfp_clsr3stdE7forwardIT0_Efp0_EEcvv_EERT_OSL_ Unexecuted instantiation: _ZNK8nlohmann16json_abi_v3_12_06detail10to_json_fnclINS0_10basic_jsonINSt3__13mapENS5_6vectorENS5_12basic_stringIcNS5_11char_traitsIcEENS5_9allocatorIcEEEEblmdSB_NS0_14adl_serializerENS7_IhNSB_IhEEEEvEERA19_KcEEDTcmcl7to_jsonfp_clsr3stdE7forwardIT0_Efp0_EEcvv_EERT_OSL_ Unexecuted instantiation: _ZNK8nlohmann16json_abi_v3_12_06detail10to_json_fnclINS0_10basic_jsonINSt3__13mapENS5_6vectorENS5_12basic_stringIcNS5_11char_traitsIcEENS5_9allocatorIcEEEEblmdSB_NS0_14adl_serializerENS7_IhNSB_IhEEEEvEERA12_KcEEDTcmcl7to_jsonfp_clsr3stdE7forwardIT0_Efp0_EEcvv_EERT_OSL_ Unexecuted instantiation: _ZNK8nlohmann16json_abi_v3_12_06detail10to_json_fnclINS0_10basic_jsonINSt3__13mapENS5_6vectorENS5_12basic_stringIcNS5_11char_traitsIcEENS5_9allocatorIcEEEEblmdSB_NS0_14adl_serializerENS7_IhNSB_IhEEEEvEERA14_KcEEDTcmcl7to_jsonfp_clsr3stdE7forwardIT0_Efp0_EEcvv_EERT_OSL_ Unexecuted instantiation: _ZNK8nlohmann16json_abi_v3_12_06detail10to_json_fnclINS0_10basic_jsonINSt3__13mapENS5_6vectorENS5_12basic_stringIcNS5_11char_traitsIcEENS5_9allocatorIcEEEEblmdSB_NS0_14adl_serializerENS7_IhNSB_IhEEEEvEERA23_KcEEDTcmcl7to_jsonfp_clsr3stdE7forwardIT0_Efp0_EEcvv_EERT_OSL_ Unexecuted instantiation: _ZNK8nlohmann16json_abi_v3_12_06detail10to_json_fnclINS0_10basic_jsonINSt3__13mapENS5_6vectorENS5_12basic_stringIcNS5_11char_traitsIcEENS5_9allocatorIcEEEEblmdSB_NS0_14adl_serializerENS7_IhNSB_IhEEEEvEERA18_KcEEDTcmcl7to_jsonfp_clsr3stdE7forwardIT0_Efp0_EEcvv_EERT_OSL_ Unexecuted instantiation: _ZNK8nlohmann16json_abi_v3_12_06detail10to_json_fnclINS0_10basic_jsonINSt3__13mapENS5_6vectorENS5_12basic_stringIcNS5_11char_traitsIcEENS5_9allocatorIcEEEEblmdSB_NS0_14adl_serializerENS7_IhNSB_IhEEEEvEEKbEEDTcmcl7to_jsonfp_clsr3stdE7forwardIT0_Efp0_EEcvv_EERT_OSJ_ Unexecuted instantiation: _ZNK8nlohmann16json_abi_v3_12_06detail10to_json_fnclINS0_10basic_jsonINSt3__13mapENS5_6vectorENS5_12basic_stringIcNS5_11char_traitsIcEENS5_9allocatorIcEEEEblmdSB_NS0_14adl_serializerENS7_IhNSB_IhEEEEvEERPKcEEDTcmcl7to_jsonfp_clsr3stdE7forwardIT0_Efp0_EEcvv_EERT_OSL_ |
6175 | | }; |
6176 | | } // namespace detail |
6177 | | |
6178 | | #ifndef JSON_HAS_CPP_17 |
6179 | | /// namespace to hold default `to_json` function |
6180 | | /// to see why this is required: |
6181 | | /// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/n4381.html |
6182 | | namespace // NOLINT(cert-dcl59-cpp,fuchsia-header-anon-namespaces,google-build-namespaces) |
6183 | | { |
6184 | | #endif |
6185 | | JSON_INLINE_VARIABLE constexpr const auto& to_json = // NOLINT(misc-definitions-in-headers) |
6186 | | detail::static_const<detail::to_json_fn>::value; |
6187 | | #ifndef JSON_HAS_CPP_17 |
6188 | | } // namespace |
6189 | | #endif |
6190 | | |
6191 | | NLOHMANN_JSON_NAMESPACE_END |
6192 | | |
6193 | | // #include <nlohmann/detail/meta/identity_tag.hpp> |
6194 | | |
6195 | | |
6196 | | NLOHMANN_JSON_NAMESPACE_BEGIN |
6197 | | |
6198 | | /// @sa https://json.nlohmann.me/api/adl_serializer/ |
6199 | | template<typename ValueType, typename> |
6200 | | struct adl_serializer |
6201 | | { |
6202 | | /// @brief convert a JSON value to any value type |
6203 | | /// @sa https://json.nlohmann.me/api/adl_serializer/from_json/ |
6204 | | template<typename BasicJsonType, typename TargetType = ValueType> |
6205 | | static auto from_json(BasicJsonType && j, TargetType& val) noexcept( |
6206 | | noexcept(::nlohmann::from_json(std::forward<BasicJsonType>(j), val))) |
6207 | | -> decltype(::nlohmann::from_json(std::forward<BasicJsonType>(j), val), void()) |
6208 | 0 | { |
6209 | 0 | ::nlohmann::from_json(std::forward<BasicJsonType>(j), val); |
6210 | 0 | } Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_014adl_serializerImvE9from_jsonIRKNS0_10basic_jsonINSt3__13mapENS5_6vectorENS5_12basic_stringIcNS5_11char_traitsIcEENS5_9allocatorIcEEEEblmdSB_S1_NS7_IhNSB_IhEEEEvEEmEEDTcmclL_ZNS0_9from_jsonEEclsr3stdE7forwardIT_Efp_Efp0_Ecvv_EEOSJ_RT0_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_014adl_serializerIbvE9from_jsonIRKNS0_10basic_jsonINSt3__13mapENS5_6vectorENS5_12basic_stringIcNS5_11char_traitsIcEENS5_9allocatorIcEEEEblmdSB_S1_NS7_IhNSB_IhEEEEvEEbEEDTcmclL_ZNS0_9from_jsonEEclsr3stdE7forwardIT_Efp_Efp0_Ecvv_EEOSJ_RT0_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_014adl_serializerIhvE9from_jsonIRKNS0_10basic_jsonINSt3__13mapENS5_6vectorENS5_12basic_stringIcNS5_11char_traitsIcEENS5_9allocatorIcEEEEblmdSB_S1_NS7_IhNSB_IhEEEEvEEhEEDTcmclL_ZNS0_9from_jsonEEclsr3stdE7forwardIT_Efp_Efp0_Ecvv_EEOSJ_RT0_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_014adl_serializerIjvE9from_jsonIRKNS0_10basic_jsonINSt3__13mapENS5_6vectorENS5_12basic_stringIcNS5_11char_traitsIcEENS5_9allocatorIcEEEEblmdSB_S1_NS7_IhNSB_IhEEEEvEEjEEDTcmclL_ZNS0_9from_jsonEEclsr3stdE7forwardIT_Efp_Efp0_Ecvv_EEOSJ_RT0_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_014adl_serializerINSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEEvE9from_jsonIRKNS0_10basic_jsonINS2_3mapENS2_6vectorES8_blmdS6_S1_NSD_IhNS6_IhEEEEvEES8_EEDTcmclL_ZNS0_9from_jsonEEclsr3stdE7forwardIT_Efp_Efp0_Ecvv_EEOSJ_RT0_ |
6211 | | |
6212 | | /// @brief convert a JSON value to any value type |
6213 | | /// @sa https://json.nlohmann.me/api/adl_serializer/from_json/ |
6214 | | template<typename BasicJsonType, typename TargetType = ValueType> |
6215 | | static auto from_json(BasicJsonType && j) noexcept( |
6216 | | noexcept(::nlohmann::from_json(std::forward<BasicJsonType>(j), detail::identity_tag<TargetType> {}))) |
6217 | | -> decltype(::nlohmann::from_json(std::forward<BasicJsonType>(j), detail::identity_tag<TargetType> {})) |
6218 | | { |
6219 | | return ::nlohmann::from_json(std::forward<BasicJsonType>(j), detail::identity_tag<TargetType> {}); |
6220 | | } |
6221 | | |
6222 | | /// @brief convert any value type to a JSON value |
6223 | | /// @sa https://json.nlohmann.me/api/adl_serializer/to_json/ |
6224 | | template<typename BasicJsonType, typename TargetType = ValueType> |
6225 | | static auto to_json(BasicJsonType& j, TargetType && val) noexcept( |
6226 | | noexcept(::nlohmann::to_json(j, std::forward<TargetType>(val)))) |
6227 | | -> decltype(::nlohmann::to_json(j, std::forward<TargetType>(val)), void()) |
6228 | 0 | { |
6229 | 0 | ::nlohmann::to_json(j, std::forward<TargetType>(val)); |
6230 | 0 | } Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_014adl_serializerIA1_cvE7to_jsonINS0_10basic_jsonINSt3__13mapENS6_6vectorENS6_12basic_stringIcNS6_11char_traitsIcEENS6_9allocatorIcEEEEblmdSC_S1_NS8_IhNSC_IhEEEEvEERA1_KcEEDTcmclL_ZNS0_7to_jsonEEfp_clsr3stdE7forwardIT0_Efp0_EEcvv_EERT_OSL_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_014adl_serializerImvE7to_jsonINS0_10basic_jsonINSt3__13mapENS5_6vectorENS5_12basic_stringIcNS5_11char_traitsIcEENS5_9allocatorIcEEEEblmdSB_S1_NS7_IhNSB_IhEEEEvEERKmEEDTcmclL_ZNS0_7to_jsonEEfp_clsr3stdE7forwardIT0_Efp0_EEcvv_EERT_OSJ_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_014adl_serializerINSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEEvE7to_jsonINS0_10basic_jsonINS2_3mapENS2_6vectorES8_blmdS6_S1_NSD_IhNS6_IhEEEEvEERKS8_EEDTcmclL_ZNS0_7to_jsonEEfp_clsr3stdE7forwardIT0_Efp0_EEcvv_EERT_OSJ_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_014adl_serializerINSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEEvE7to_jsonINS0_10basic_jsonINS2_3mapENS2_6vectorES8_blmdS6_S1_NSD_IhNS6_IhEEEEvEERS8_EEDTcmclL_ZNS0_7to_jsonEEfp_clsr3stdE7forwardIT0_Efp0_EEcvv_EERT_OSI_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_014adl_serializerIdvE7to_jsonINS0_10basic_jsonINSt3__13mapENS5_6vectorENS5_12basic_stringIcNS5_11char_traitsIcEENS5_9allocatorIcEEEEblmdSB_S1_NS7_IhNSB_IhEEEEvEERdEEDTcmclL_ZNS0_7to_jsonEEfp_clsr3stdE7forwardIT0_Efp0_EEcvv_EERT_OSI_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_014adl_serializerIbvE7to_jsonINS0_10basic_jsonINSt3__13mapENS5_6vectorENS5_12basic_stringIcNS5_11char_traitsIcEENS5_9allocatorIcEEEEblmdSB_S1_NS7_IhNSB_IhEEEEvEERbEEDTcmclL_ZNS0_7to_jsonEEfp_clsr3stdE7forwardIT0_Efp0_EEcvv_EERT_OSI_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_014adl_serializerIlvE7to_jsonINS0_10basic_jsonINSt3__13mapENS5_6vectorENS5_12basic_stringIcNS5_11char_traitsIcEENS5_9allocatorIcEEEEblmdSB_S1_NS7_IhNSB_IhEEEEvEERlEEDTcmclL_ZNS0_7to_jsonEEfp_clsr3stdE7forwardIT0_Efp0_EEcvv_EERT_OSI_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_014adl_serializerImvE7to_jsonINS0_10basic_jsonINSt3__13mapENS5_6vectorENS5_12basic_stringIcNS5_11char_traitsIcEENS5_9allocatorIcEEEEblmdSB_S1_NS7_IhNSB_IhEEEEvEERmEEDTcmclL_ZNS0_7to_jsonEEfp_clsr3stdE7forwardIT0_Efp0_EEcvv_EERT_OSI_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_014adl_serializerIA2_cvE7to_jsonINS0_10basic_jsonINSt3__13mapENS6_6vectorENS6_12basic_stringIcNS6_11char_traitsIcEENS6_9allocatorIcEEEEblmdSC_S1_NS8_IhNSC_IhEEEEvEERA2_KcEEDTcmclL_ZNS0_7to_jsonEEfp_clsr3stdE7forwardIT0_Efp0_EEcvv_EERT_OSL_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_014adl_serializerImvE7to_jsonINS0_10basic_jsonINSt3__13mapENS5_6vectorENS5_12basic_stringIcNS5_11char_traitsIcEENS5_9allocatorIcEEEEblmdSB_S1_NS7_IhNSB_IhEEEEvEEmEEDTcmclL_ZNS0_7to_jsonEEfp_clsr3stdE7forwardIT0_Efp0_EEcvv_EERT_OSH_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_014adl_serializerIA21_cvE7to_jsonINS0_10basic_jsonINSt3__13mapENS6_6vectorENS6_12basic_stringIcNS6_11char_traitsIcEENS6_9allocatorIcEEEEblmdSC_S1_NS8_IhNSC_IhEEEEvEERA21_KcEEDTcmclL_ZNS0_7to_jsonEEfp_clsr3stdE7forwardIT0_Efp0_EEcvv_EERT_OSL_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_014adl_serializerIA40_cvE7to_jsonINS0_10basic_jsonINSt3__13mapENS6_6vectorENS6_12basic_stringIcNS6_11char_traitsIcEENS6_9allocatorIcEEEEblmdSC_S1_NS8_IhNSC_IhEEEEvEERA40_KcEEDTcmclL_ZNS0_7to_jsonEEfp_clsr3stdE7forwardIT0_Efp0_EEcvv_EERT_OSL_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_014adl_serializerIA600_cvE7to_jsonINS0_10basic_jsonINSt3__13mapENS6_6vectorENS6_12basic_stringIcNS6_11char_traitsIcEENS6_9allocatorIcEEEEblmdSC_S1_NS8_IhNSC_IhEEEEvEERA600_KcEEDTcmclL_ZNS0_7to_jsonEEfp_clsr3stdE7forwardIT0_Efp0_EEcvv_EERT_OSL_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_014adl_serializerIA137_cvE7to_jsonINS0_10basic_jsonINSt3__13mapENS6_6vectorENS6_12basic_stringIcNS6_11char_traitsIcEENS6_9allocatorIcEEEEblmdSC_S1_NS8_IhNSC_IhEEEEvEERA137_KcEEDTcmclL_ZNS0_7to_jsonEEfp_clsr3stdE7forwardIT0_Efp0_EEcvv_EERT_OSL_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_014adl_serializerIA156_cvE7to_jsonINS0_10basic_jsonINSt3__13mapENS6_6vectorENS6_12basic_stringIcNS6_11char_traitsIcEENS6_9allocatorIcEEEEblmdSC_S1_NS8_IhNSC_IhEEEEvEERA156_KcEEDTcmclL_ZNS0_7to_jsonEEfp_clsr3stdE7forwardIT0_Efp0_EEcvv_EERT_OSL_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_014adl_serializerIA78_cvE7to_jsonINS0_10basic_jsonINSt3__13mapENS6_6vectorENS6_12basic_stringIcNS6_11char_traitsIcEENS6_9allocatorIcEEEEblmdSC_S1_NS8_IhNSC_IhEEEEvEERA78_KcEEDTcmclL_ZNS0_7to_jsonEEfp_clsr3stdE7forwardIT0_Efp0_EEcvv_EERT_OSL_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_014adl_serializerIA79_cvE7to_jsonINS0_10basic_jsonINSt3__13mapENS6_6vectorENS6_12basic_stringIcNS6_11char_traitsIcEENS6_9allocatorIcEEEEblmdSC_S1_NS8_IhNSC_IhEEEEvEERA79_KcEEDTcmclL_ZNS0_7to_jsonEEfp_clsr3stdE7forwardIT0_Efp0_EEcvv_EERT_OSL_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_014adl_serializerIA65_cvE7to_jsonINS0_10basic_jsonINSt3__13mapENS6_6vectorENS6_12basic_stringIcNS6_11char_traitsIcEENS6_9allocatorIcEEEEblmdSC_S1_NS8_IhNSC_IhEEEEvEERA65_KcEEDTcmclL_ZNS0_7to_jsonEEfp_clsr3stdE7forwardIT0_Efp0_EEcvv_EERT_OSL_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_014adl_serializerIA58_cvE7to_jsonINS0_10basic_jsonINSt3__13mapENS6_6vectorENS6_12basic_stringIcNS6_11char_traitsIcEENS6_9allocatorIcEEEEblmdSC_S1_NS8_IhNSC_IhEEEEvEERA58_KcEEDTcmclL_ZNS0_7to_jsonEEfp_clsr3stdE7forwardIT0_Efp0_EEcvv_EERT_OSL_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_014adl_serializerIA56_cvE7to_jsonINS0_10basic_jsonINSt3__13mapENS6_6vectorENS6_12basic_stringIcNS6_11char_traitsIcEENS6_9allocatorIcEEEEblmdSC_S1_NS8_IhNSC_IhEEEEvEERA56_KcEEDTcmclL_ZNS0_7to_jsonEEfp_clsr3stdE7forwardIT0_Efp0_EEcvv_EERT_OSL_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_014adl_serializerIA59_cvE7to_jsonINS0_10basic_jsonINSt3__13mapENS6_6vectorENS6_12basic_stringIcNS6_11char_traitsIcEENS6_9allocatorIcEEEEblmdSC_S1_NS8_IhNSC_IhEEEEvEERA59_KcEEDTcmclL_ZNS0_7to_jsonEEfp_clsr3stdE7forwardIT0_Efp0_EEcvv_EERT_OSL_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_014adl_serializerIA1679_cvE7to_jsonINS0_10basic_jsonINSt3__13mapENS6_6vectorENS6_12basic_stringIcNS6_11char_traitsIcEENS6_9allocatorIcEEEEblmdSC_S1_NS8_IhNSC_IhEEEEvEERA1679_KcEEDTcmclL_ZNS0_7to_jsonEEfp_clsr3stdE7forwardIT0_Efp0_EEcvv_EERT_OSL_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_014adl_serializerIA1535_cvE7to_jsonINS0_10basic_jsonINSt3__13mapENS6_6vectorENS6_12basic_stringIcNS6_11char_traitsIcEENS6_9allocatorIcEEEEblmdSC_S1_NS8_IhNSC_IhEEEEvEERA1535_KcEEDTcmclL_ZNS0_7to_jsonEEfp_clsr3stdE7forwardIT0_Efp0_EEcvv_EERT_OSL_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_014adl_serializerIA714_cvE7to_jsonINS0_10basic_jsonINSt3__13mapENS6_6vectorENS6_12basic_stringIcNS6_11char_traitsIcEENS6_9allocatorIcEEEEblmdSC_S1_NS8_IhNSC_IhEEEEvEERA714_KcEEDTcmclL_ZNS0_7to_jsonEEfp_clsr3stdE7forwardIT0_Efp0_EEcvv_EERT_OSL_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_014adl_serializerIA3238_cvE7to_jsonINS0_10basic_jsonINSt3__13mapENS6_6vectorENS6_12basic_stringIcNS6_11char_traitsIcEENS6_9allocatorIcEEEEblmdSC_S1_NS8_IhNSC_IhEEEEvEERA3238_KcEEDTcmclL_ZNS0_7to_jsonEEfp_clsr3stdE7forwardIT0_Efp0_EEcvv_EERT_OSL_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_014adl_serializerIA2159_cvE7to_jsonINS0_10basic_jsonINSt3__13mapENS6_6vectorENS6_12basic_stringIcNS6_11char_traitsIcEENS6_9allocatorIcEEEEblmdSC_S1_NS8_IhNSC_IhEEEEvEERA2159_KcEEDTcmclL_ZNS0_7to_jsonEEfp_clsr3stdE7forwardIT0_Efp0_EEcvv_EERT_OSL_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_014adl_serializerIA77_cvE7to_jsonINS0_10basic_jsonINSt3__13mapENS6_6vectorENS6_12basic_stringIcNS6_11char_traitsIcEENS6_9allocatorIcEEEEblmdSC_S1_NS8_IhNSC_IhEEEEvEERA77_KcEEDTcmclL_ZNS0_7to_jsonEEfp_clsr3stdE7forwardIT0_Efp0_EEcvv_EERT_OSL_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_014adl_serializerIA16_cvE7to_jsonINS0_10basic_jsonINSt3__13mapENS6_6vectorENS6_12basic_stringIcNS6_11char_traitsIcEENS6_9allocatorIcEEEEblmdSC_S1_NS8_IhNSC_IhEEEEvEERA16_KcEEDTcmclL_ZNS0_7to_jsonEEfp_clsr3stdE7forwardIT0_Efp0_EEcvv_EERT_OSL_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_014adl_serializerIA64_cvE7to_jsonINS0_10basic_jsonINSt3__13mapENS6_6vectorENS6_12basic_stringIcNS6_11char_traitsIcEENS6_9allocatorIcEEEEblmdSC_S1_NS8_IhNSC_IhEEEEvEERA64_KcEEDTcmclL_ZNS0_7to_jsonEEfp_clsr3stdE7forwardIT0_Efp0_EEcvv_EERT_OSL_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_014adl_serializerIA923_cvE7to_jsonINS0_10basic_jsonINSt3__13mapENS6_6vectorENS6_12basic_stringIcNS6_11char_traitsIcEENS6_9allocatorIcEEEEblmdSC_S1_NS8_IhNSC_IhEEEEvEERA923_KcEEDTcmclL_ZNS0_7to_jsonEEfp_clsr3stdE7forwardIT0_Efp0_EEcvv_EERT_OSL_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_014adl_serializerIA150_cvE7to_jsonINS0_10basic_jsonINSt3__13mapENS6_6vectorENS6_12basic_stringIcNS6_11char_traitsIcEENS6_9allocatorIcEEEEblmdSC_S1_NS8_IhNSC_IhEEEEvEERA150_KcEEDTcmclL_ZNS0_7to_jsonEEfp_clsr3stdE7forwardIT0_Efp0_EEcvv_EERT_OSL_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_014adl_serializerIA309_cvE7to_jsonINS0_10basic_jsonINSt3__13mapENS6_6vectorENS6_12basic_stringIcNS6_11char_traitsIcEENS6_9allocatorIcEEEEblmdSC_S1_NS8_IhNSC_IhEEEEvEERA309_KcEEDTcmclL_ZNS0_7to_jsonEEfp_clsr3stdE7forwardIT0_Efp0_EEcvv_EERT_OSL_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_014adl_serializerIA310_cvE7to_jsonINS0_10basic_jsonINSt3__13mapENS6_6vectorENS6_12basic_stringIcNS6_11char_traitsIcEENS6_9allocatorIcEEEEblmdSC_S1_NS8_IhNSC_IhEEEEvEERA310_KcEEDTcmclL_ZNS0_7to_jsonEEfp_clsr3stdE7forwardIT0_Efp0_EEcvv_EERT_OSL_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_014adl_serializerIA155_cvE7to_jsonINS0_10basic_jsonINSt3__13mapENS6_6vectorENS6_12basic_stringIcNS6_11char_traitsIcEENS6_9allocatorIcEEEEblmdSC_S1_NS8_IhNSC_IhEEEEvEERA155_KcEEDTcmclL_ZNS0_7to_jsonEEfp_clsr3stdE7forwardIT0_Efp0_EEcvv_EERT_OSL_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_014adl_serializerIA117_cvE7to_jsonINS0_10basic_jsonINSt3__13mapENS6_6vectorENS6_12basic_stringIcNS6_11char_traitsIcEENS6_9allocatorIcEEEEblmdSC_S1_NS8_IhNSC_IhEEEEvEERA117_KcEEDTcmclL_ZNS0_7to_jsonEEfp_clsr3stdE7forwardIT0_Efp0_EEcvv_EERT_OSL_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_014adl_serializerIA50_cvE7to_jsonINS0_10basic_jsonINSt3__13mapENS6_6vectorENS6_12basic_stringIcNS6_11char_traitsIcEENS6_9allocatorIcEEEEblmdSC_S1_NS8_IhNSC_IhEEEEvEERA50_KcEEDTcmclL_ZNS0_7to_jsonEEfp_clsr3stdE7forwardIT0_Efp0_EEcvv_EERT_OSL_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_014adl_serializerIA61_cvE7to_jsonINS0_10basic_jsonINSt3__13mapENS6_6vectorENS6_12basic_stringIcNS6_11char_traitsIcEENS6_9allocatorIcEEEEblmdSC_S1_NS8_IhNSC_IhEEEEvEERA61_KcEEDTcmclL_ZNS0_7to_jsonEEfp_clsr3stdE7forwardIT0_Efp0_EEcvv_EERT_OSL_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_014adl_serializerIA158_cvE7to_jsonINS0_10basic_jsonINSt3__13mapENS6_6vectorENS6_12basic_stringIcNS6_11char_traitsIcEENS6_9allocatorIcEEEEblmdSC_S1_NS8_IhNSC_IhEEEEvEERA158_KcEEDTcmclL_ZNS0_7to_jsonEEfp_clsr3stdE7forwardIT0_Efp0_EEcvv_EERT_OSL_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_014adl_serializerIA30_cvE7to_jsonINS0_10basic_jsonINSt3__13mapENS6_6vectorENS6_12basic_stringIcNS6_11char_traitsIcEENS6_9allocatorIcEEEEblmdSC_S1_NS8_IhNSC_IhEEEEvEERA30_KcEEDTcmclL_ZNS0_7to_jsonEEfp_clsr3stdE7forwardIT0_Efp0_EEcvv_EERT_OSL_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_014adl_serializerIA69_cvE7to_jsonINS0_10basic_jsonINSt3__13mapENS6_6vectorENS6_12basic_stringIcNS6_11char_traitsIcEENS6_9allocatorIcEEEEblmdSC_S1_NS8_IhNSC_IhEEEEvEERA69_KcEEDTcmclL_ZNS0_7to_jsonEEfp_clsr3stdE7forwardIT0_Efp0_EEcvv_EERT_OSL_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_014adl_serializerIA3_cvE7to_jsonINS0_10basic_jsonINSt3__13mapENS6_6vectorENS6_12basic_stringIcNS6_11char_traitsIcEENS6_9allocatorIcEEEEblmdSC_S1_NS8_IhNSC_IhEEEEvEERA3_KcEEDTcmclL_ZNS0_7to_jsonEEfp_clsr3stdE7forwardIT0_Efp0_EEcvv_EERT_OSL_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_014adl_serializerIivE7to_jsonINS0_10basic_jsonINSt3__13mapENS5_6vectorENS5_12basic_stringIcNS5_11char_traitsIcEENS5_9allocatorIcEEEEblmdSB_S1_NS7_IhNSB_IhEEEEvEEiEEDTcmclL_ZNS0_7to_jsonEEfp_clsr3stdE7forwardIT0_Efp0_EEcvv_EERT_OSH_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_014adl_serializerIA114_cvE7to_jsonINS0_10basic_jsonINSt3__13mapENS6_6vectorENS6_12basic_stringIcNS6_11char_traitsIcEENS6_9allocatorIcEEEEblmdSC_S1_NS8_IhNSC_IhEEEEvEERA114_KcEEDTcmclL_ZNS0_7to_jsonEEfp_clsr3stdE7forwardIT0_Efp0_EEcvv_EERT_OSL_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_014adl_serializerIA113_cvE7to_jsonINS0_10basic_jsonINSt3__13mapENS6_6vectorENS6_12basic_stringIcNS6_11char_traitsIcEENS6_9allocatorIcEEEEblmdSC_S1_NS8_IhNSC_IhEEEEvEERA113_KcEEDTcmclL_ZNS0_7to_jsonEEfp_clsr3stdE7forwardIT0_Efp0_EEcvv_EERT_OSL_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_014adl_serializerIA39_cvE7to_jsonINS0_10basic_jsonINSt3__13mapENS6_6vectorENS6_12basic_stringIcNS6_11char_traitsIcEENS6_9allocatorIcEEEEblmdSC_S1_NS8_IhNSC_IhEEEEvEERA39_KcEEDTcmclL_ZNS0_7to_jsonEEfp_clsr3stdE7forwardIT0_Efp0_EEcvv_EERT_OSL_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_014adl_serializerIA41_cvE7to_jsonINS0_10basic_jsonINSt3__13mapENS6_6vectorENS6_12basic_stringIcNS6_11char_traitsIcEENS6_9allocatorIcEEEEblmdSC_S1_NS8_IhNSC_IhEEEEvEERA41_KcEEDTcmclL_ZNS0_7to_jsonEEfp_clsr3stdE7forwardIT0_Efp0_EEcvv_EERT_OSL_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_014adl_serializerIA86_cvE7to_jsonINS0_10basic_jsonINSt3__13mapENS6_6vectorENS6_12basic_stringIcNS6_11char_traitsIcEENS6_9allocatorIcEEEEblmdSC_S1_NS8_IhNSC_IhEEEEvEERA86_KcEEDTcmclL_ZNS0_7to_jsonEEfp_clsr3stdE7forwardIT0_Efp0_EEcvv_EERT_OSL_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_014adl_serializerIA135_cvE7to_jsonINS0_10basic_jsonINSt3__13mapENS6_6vectorENS6_12basic_stringIcNS6_11char_traitsIcEENS6_9allocatorIcEEEEblmdSC_S1_NS8_IhNSC_IhEEEEvEERA135_KcEEDTcmclL_ZNS0_7to_jsonEEfp_clsr3stdE7forwardIT0_Efp0_EEcvv_EERT_OSL_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_014adl_serializerIA20_cvE7to_jsonINS0_10basic_jsonINSt3__13mapENS6_6vectorENS6_12basic_stringIcNS6_11char_traitsIcEENS6_9allocatorIcEEEEblmdSC_S1_NS8_IhNSC_IhEEEEvEERA20_KcEEDTcmclL_ZNS0_7to_jsonEEfp_clsr3stdE7forwardIT0_Efp0_EEcvv_EERT_OSL_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_014adl_serializerIA24_cvE7to_jsonINS0_10basic_jsonINSt3__13mapENS6_6vectorENS6_12basic_stringIcNS6_11char_traitsIcEENS6_9allocatorIcEEEEblmdSC_S1_NS8_IhNSC_IhEEEEvEERA24_KcEEDTcmclL_ZNS0_7to_jsonEEfp_clsr3stdE7forwardIT0_Efp0_EEcvv_EERT_OSL_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_014adl_serializerIA11_cvE7to_jsonINS0_10basic_jsonINSt3__13mapENS6_6vectorENS6_12basic_stringIcNS6_11char_traitsIcEENS6_9allocatorIcEEEEblmdSC_S1_NS8_IhNSC_IhEEEEvEERA11_KcEEDTcmclL_ZNS0_7to_jsonEEfp_clsr3stdE7forwardIT0_Efp0_EEcvv_EERT_OSL_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_014adl_serializerIA35_cvE7to_jsonINS0_10basic_jsonINSt3__13mapENS6_6vectorENS6_12basic_stringIcNS6_11char_traitsIcEENS6_9allocatorIcEEEEblmdSC_S1_NS8_IhNSC_IhEEEEvEERA35_KcEEDTcmclL_ZNS0_7to_jsonEEfp_clsr3stdE7forwardIT0_Efp0_EEcvv_EERT_OSL_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_014adl_serializerIA4_cvE7to_jsonINS0_10basic_jsonINSt3__13mapENS6_6vectorENS6_12basic_stringIcNS6_11char_traitsIcEENS6_9allocatorIcEEEEblmdSC_S1_NS8_IhNSC_IhEEEEvEERA4_KcEEDTcmclL_ZNS0_7to_jsonEEfp_clsr3stdE7forwardIT0_Efp0_EEcvv_EERT_OSL_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_014adl_serializerIA116_cvE7to_jsonINS0_10basic_jsonINSt3__13mapENS6_6vectorENS6_12basic_stringIcNS6_11char_traitsIcEENS6_9allocatorIcEEEEblmdSC_S1_NS8_IhNSC_IhEEEEvEERA116_KcEEDTcmclL_ZNS0_7to_jsonEEfp_clsr3stdE7forwardIT0_Efp0_EEcvv_EERT_OSL_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_014adl_serializerIA115_cvE7to_jsonINS0_10basic_jsonINSt3__13mapENS6_6vectorENS6_12basic_stringIcNS6_11char_traitsIcEENS6_9allocatorIcEEEEblmdSC_S1_NS8_IhNSC_IhEEEEvEERA115_KcEEDTcmclL_ZNS0_7to_jsonEEfp_clsr3stdE7forwardIT0_Efp0_EEcvv_EERT_OSL_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_014adl_serializerIA619_cvE7to_jsonINS0_10basic_jsonINSt3__13mapENS6_6vectorENS6_12basic_stringIcNS6_11char_traitsIcEENS6_9allocatorIcEEEEblmdSC_S1_NS8_IhNSC_IhEEEEvEERA619_KcEEDTcmclL_ZNS0_7to_jsonEEfp_clsr3stdE7forwardIT0_Efp0_EEcvv_EERT_OSL_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_014adl_serializerIA9_cvE7to_jsonINS0_10basic_jsonINSt3__13mapENS6_6vectorENS6_12basic_stringIcNS6_11char_traitsIcEENS6_9allocatorIcEEEEblmdSC_S1_NS8_IhNSC_IhEEEEvEERA9_KcEEDTcmclL_ZNS0_7to_jsonEEfp_clsr3stdE7forwardIT0_Efp0_EEcvv_EERT_OSL_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_014adl_serializerINSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEEvE7to_jsonINS0_10basic_jsonINS2_3mapENS2_6vectorES8_blmdS6_S1_NSD_IhNS6_IhEEEEvEES8_EEDTcmclL_ZNS0_7to_jsonEEfp_clsr3stdE7forwardIT0_Efp0_EEcvv_EERT_OSH_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_014adl_serializerINSt3__16vectorINS0_10basic_jsonINS2_3mapES3_NS2_12basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEEblmdS9_S1_NS3_IhNS9_IhEEEEvEENS9_ISE_EEEEvE7to_jsonISE_SG_EEDTcmclL_ZNS0_7to_jsonEEfp_clsr3stdE7forwardIT0_Efp0_EEcvv_EERT_OSJ_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_014adl_serializerIbvE7to_jsonINS0_10basic_jsonINSt3__13mapENS5_6vectorENS5_12basic_stringIcNS5_11char_traitsIcEENS5_9allocatorIcEEEEblmdSB_S1_NS7_IhNSB_IhEEEEvEERKbEEDTcmclL_ZNS0_7to_jsonEEfp_clsr3stdE7forwardIT0_Efp0_EEcvv_EERT_OSJ_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_014adl_serializerIjvE7to_jsonINS0_10basic_jsonINSt3__13mapENS5_6vectorENS5_12basic_stringIcNS5_11char_traitsIcEENS5_9allocatorIcEEEEblmdSB_S1_NS7_IhNSB_IhEEEEvEEjEEDTcmclL_ZNS0_7to_jsonEEfp_clsr3stdE7forwardIT0_Efp0_EEcvv_EERT_OSH_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_014adl_serializerIbvE7to_jsonINS0_10basic_jsonINSt3__13mapENS5_6vectorENS5_12basic_stringIcNS5_11char_traitsIcEENS5_9allocatorIcEEEEblmdSB_S1_NS7_IhNSB_IhEEEEvEEbEEDTcmclL_ZNS0_7to_jsonEEfp_clsr3stdE7forwardIT0_Efp0_EEcvv_EERT_OSH_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_014adl_serializerINSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEEvE7to_jsonINS0_10basic_jsonINS2_3mapENS2_6vectorES8_blmdS6_S1_NSD_IhNS6_IhEEEEvEEKS8_EEDTcmclL_ZNS0_7to_jsonEEfp_clsr3stdE7forwardIT0_Efp0_EEcvv_EERT_OSI_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_014adl_serializerIA7_cvE7to_jsonINS0_10basic_jsonINSt3__13mapENS6_6vectorENS6_12basic_stringIcNS6_11char_traitsIcEENS6_9allocatorIcEEEEblmdSC_S1_NS8_IhNSC_IhEEEEvEERA7_KcEEDTcmclL_ZNS0_7to_jsonEEfp_clsr3stdE7forwardIT0_Efp0_EEcvv_EERT_OSL_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_014adl_serializerIA5_cvE7to_jsonINS0_10basic_jsonINSt3__13mapENS6_6vectorENS6_12basic_stringIcNS6_11char_traitsIcEENS6_9allocatorIcEEEEblmdSC_S1_NS8_IhNSC_IhEEEEvEERA5_KcEEDTcmclL_ZNS0_7to_jsonEEfp_clsr3stdE7forwardIT0_Efp0_EEcvv_EERT_OSL_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_014adl_serializerIhvE7to_jsonINS0_10basic_jsonINSt3__13mapENS5_6vectorENS5_12basic_stringIcNS5_11char_traitsIcEENS5_9allocatorIcEEEEblmdSB_S1_NS7_IhNSB_IhEEEEvEERKhEEDTcmclL_ZNS0_7to_jsonEEfp_clsr3stdE7forwardIT0_Efp0_EEcvv_EERT_OSJ_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_014adl_serializerIA17_cvE7to_jsonINS0_10basic_jsonINSt3__13mapENS6_6vectorENS6_12basic_stringIcNS6_11char_traitsIcEENS6_9allocatorIcEEEEblmdSC_S1_NS8_IhNSC_IhEEEEvEERA17_KcEEDTcmclL_ZNS0_7to_jsonEEfp_clsr3stdE7forwardIT0_Efp0_EEcvv_EERT_OSL_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_014adl_serializerIA13_cvE7to_jsonINS0_10basic_jsonINSt3__13mapENS6_6vectorENS6_12basic_stringIcNS6_11char_traitsIcEENS6_9allocatorIcEEEEblmdSC_S1_NS8_IhNSC_IhEEEEvEERA13_KcEEDTcmclL_ZNS0_7to_jsonEEfp_clsr3stdE7forwardIT0_Efp0_EEcvv_EERT_OSL_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_014adl_serializerIA10_cvE7to_jsonINS0_10basic_jsonINSt3__13mapENS6_6vectorENS6_12basic_stringIcNS6_11char_traitsIcEENS6_9allocatorIcEEEEblmdSC_S1_NS8_IhNSC_IhEEEEvEERA10_KcEEDTcmclL_ZNS0_7to_jsonEEfp_clsr3stdE7forwardIT0_Efp0_EEcvv_EERT_OSL_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_014adl_serializerIjvE7to_jsonINS0_10basic_jsonINSt3__13mapENS5_6vectorENS5_12basic_stringIcNS5_11char_traitsIcEENS5_9allocatorIcEEEEblmdSB_S1_NS7_IhNSB_IhEEEEvEERKjEEDTcmclL_ZNS0_7to_jsonEEfp_clsr3stdE7forwardIT0_Efp0_EEcvv_EERT_OSJ_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_014adl_serializerIA8_cvE7to_jsonINS0_10basic_jsonINSt3__13mapENS6_6vectorENS6_12basic_stringIcNS6_11char_traitsIcEENS6_9allocatorIcEEEEblmdSC_S1_NS8_IhNSC_IhEEEEvEERA8_KcEEDTcmclL_ZNS0_7to_jsonEEfp_clsr3stdE7forwardIT0_Efp0_EEcvv_EERT_OSL_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_014adl_serializerIA15_cvE7to_jsonINS0_10basic_jsonINSt3__13mapENS6_6vectorENS6_12basic_stringIcNS6_11char_traitsIcEENS6_9allocatorIcEEEEblmdSC_S1_NS8_IhNSC_IhEEEEvEERA15_KcEEDTcmclL_ZNS0_7to_jsonEEfp_clsr3stdE7forwardIT0_Efp0_EEcvv_EERT_OSL_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_014adl_serializerIA19_cvE7to_jsonINS0_10basic_jsonINSt3__13mapENS6_6vectorENS6_12basic_stringIcNS6_11char_traitsIcEENS6_9allocatorIcEEEEblmdSC_S1_NS8_IhNSC_IhEEEEvEERA19_KcEEDTcmclL_ZNS0_7to_jsonEEfp_clsr3stdE7forwardIT0_Efp0_EEcvv_EERT_OSL_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_014adl_serializerIA12_cvE7to_jsonINS0_10basic_jsonINSt3__13mapENS6_6vectorENS6_12basic_stringIcNS6_11char_traitsIcEENS6_9allocatorIcEEEEblmdSC_S1_NS8_IhNSC_IhEEEEvEERA12_KcEEDTcmclL_ZNS0_7to_jsonEEfp_clsr3stdE7forwardIT0_Efp0_EEcvv_EERT_OSL_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_014adl_serializerIA14_cvE7to_jsonINS0_10basic_jsonINSt3__13mapENS6_6vectorENS6_12basic_stringIcNS6_11char_traitsIcEENS6_9allocatorIcEEEEblmdSC_S1_NS8_IhNSC_IhEEEEvEERA14_KcEEDTcmclL_ZNS0_7to_jsonEEfp_clsr3stdE7forwardIT0_Efp0_EEcvv_EERT_OSL_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_014adl_serializerIA23_cvE7to_jsonINS0_10basic_jsonINSt3__13mapENS6_6vectorENS6_12basic_stringIcNS6_11char_traitsIcEENS6_9allocatorIcEEEEblmdSC_S1_NS8_IhNSC_IhEEEEvEERA23_KcEEDTcmclL_ZNS0_7to_jsonEEfp_clsr3stdE7forwardIT0_Efp0_EEcvv_EERT_OSL_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_014adl_serializerIA18_cvE7to_jsonINS0_10basic_jsonINSt3__13mapENS6_6vectorENS6_12basic_stringIcNS6_11char_traitsIcEENS6_9allocatorIcEEEEblmdSC_S1_NS8_IhNSC_IhEEEEvEERA18_KcEEDTcmclL_ZNS0_7to_jsonEEfp_clsr3stdE7forwardIT0_Efp0_EEcvv_EERT_OSL_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_014adl_serializerIbvE7to_jsonINS0_10basic_jsonINSt3__13mapENS5_6vectorENS5_12basic_stringIcNS5_11char_traitsIcEENS5_9allocatorIcEEEEblmdSB_S1_NS7_IhNSB_IhEEEEvEEKbEEDTcmclL_ZNS0_7to_jsonEEfp_clsr3stdE7forwardIT0_Efp0_EEcvv_EERT_OSI_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_014adl_serializerIPKcvE7to_jsonINS0_10basic_jsonINSt3__13mapENS7_6vectorENS7_12basic_stringIcNS7_11char_traitsIcEENS7_9allocatorIcEEEEblmdSD_S1_NS9_IhNSD_IhEEEEvEERS3_EEDTcmclL_ZNS0_7to_jsonEEfp_clsr3stdE7forwardIT0_Efp0_EEcvv_EERT_OSK_ |
6231 | | }; |
6232 | | |
6233 | | NLOHMANN_JSON_NAMESPACE_END |
6234 | | |
6235 | | // #include <nlohmann/byte_container_with_subtype.hpp> |
6236 | | // __ _____ _____ _____ |
6237 | | // __| | __| | | | JSON for Modern C++ |
6238 | | // | | |__ | | | | | | version 3.12.0 |
6239 | | // |_____|_____|_____|_|___| https://github.com/nlohmann/json |
6240 | | // |
6241 | | // SPDX-FileCopyrightText: 2013-2026 Niels Lohmann <https://nlohmann.me> |
6242 | | // SPDX-License-Identifier: MIT |
6243 | | |
6244 | | |
6245 | | |
6246 | | #include <cstdint> // uint8_t, uint64_t |
6247 | | #include <tuple> // tie |
6248 | | #include <utility> // move |
6249 | | |
6250 | | // #include <nlohmann/detail/abi_macros.hpp> |
6251 | | |
6252 | | |
6253 | | NLOHMANN_JSON_NAMESPACE_BEGIN |
6254 | | |
6255 | | /// @brief an internal type for a backed binary type |
6256 | | /// @sa https://json.nlohmann.me/api/byte_container_with_subtype/ |
6257 | | template<typename BinaryType> |
6258 | | class byte_container_with_subtype : public BinaryType |
6259 | | { |
6260 | | public: |
6261 | | using container_type = BinaryType; |
6262 | | using subtype_type = std::uint64_t; |
6263 | | |
6264 | | /// @sa https://json.nlohmann.me/api/byte_container_with_subtype/byte_container_with_subtype/ |
6265 | | byte_container_with_subtype() noexcept(noexcept(container_type())) |
6266 | 0 | : container_type() |
6267 | 0 | {} |
6268 | | |
6269 | | /// @sa https://json.nlohmann.me/api/byte_container_with_subtype/byte_container_with_subtype/ |
6270 | | byte_container_with_subtype(const container_type& b) noexcept(noexcept(container_type(b))) |
6271 | | : container_type(b) |
6272 | | {} |
6273 | | |
6274 | | /// @sa https://json.nlohmann.me/api/byte_container_with_subtype/byte_container_with_subtype/ |
6275 | | byte_container_with_subtype(container_type&& b) noexcept(noexcept(container_type(std::move(b)))) |
6276 | | : container_type(std::move(b)) |
6277 | | {} |
6278 | | |
6279 | | /// @sa https://json.nlohmann.me/api/byte_container_with_subtype/byte_container_with_subtype/ |
6280 | | byte_container_with_subtype(const container_type& b, subtype_type subtype_) noexcept(noexcept(container_type(b))) |
6281 | | : container_type(b) |
6282 | | , m_subtype(subtype_) |
6283 | | , m_has_subtype(true) |
6284 | | {} |
6285 | | |
6286 | | /// @sa https://json.nlohmann.me/api/byte_container_with_subtype/byte_container_with_subtype/ |
6287 | | byte_container_with_subtype(container_type&& b, subtype_type subtype_) noexcept(noexcept(container_type(std::move(b)))) |
6288 | | : container_type(std::move(b)) |
6289 | | , m_subtype(subtype_) |
6290 | | , m_has_subtype(true) |
6291 | | {} |
6292 | | |
6293 | | bool operator==(const byte_container_with_subtype& rhs) const |
6294 | 0 | { |
6295 | 0 | return std::tie(static_cast<const BinaryType&>(*this), m_subtype, m_has_subtype) == |
6296 | 0 | std::tie(static_cast<const BinaryType&>(rhs), rhs.m_subtype, rhs.m_has_subtype); |
6297 | 0 | } |
6298 | | |
6299 | | bool operator!=(const byte_container_with_subtype& rhs) const |
6300 | | { |
6301 | | return !(rhs == *this); |
6302 | | } |
6303 | | |
6304 | | /// @brief sets the binary subtype |
6305 | | /// @sa https://json.nlohmann.me/api/byte_container_with_subtype/set_subtype/ |
6306 | | void set_subtype(subtype_type subtype_) noexcept |
6307 | | { |
6308 | | m_subtype = subtype_; |
6309 | | m_has_subtype = true; |
6310 | | } |
6311 | | |
6312 | | /// @brief return the binary subtype |
6313 | | /// @sa https://json.nlohmann.me/api/byte_container_with_subtype/subtype/ |
6314 | | constexpr subtype_type subtype() const noexcept |
6315 | 0 | { |
6316 | 0 | return m_has_subtype ? m_subtype : static_cast<subtype_type>(-1); |
6317 | 0 | } |
6318 | | |
6319 | | /// @brief return whether the value has a subtype |
6320 | | /// @sa https://json.nlohmann.me/api/byte_container_with_subtype/has_subtype/ |
6321 | | constexpr bool has_subtype() const noexcept |
6322 | 0 | { |
6323 | 0 | return m_has_subtype; |
6324 | 0 | } |
6325 | | |
6326 | | /// @brief clears the binary subtype |
6327 | | /// @sa https://json.nlohmann.me/api/byte_container_with_subtype/clear_subtype/ |
6328 | | void clear_subtype() noexcept |
6329 | | { |
6330 | | m_subtype = 0; |
6331 | | m_has_subtype = false; |
6332 | | } |
6333 | | |
6334 | | private: |
6335 | | subtype_type m_subtype = 0; |
6336 | | bool m_has_subtype = false; |
6337 | | }; |
6338 | | |
6339 | | NLOHMANN_JSON_NAMESPACE_END |
6340 | | |
6341 | | // #include <nlohmann/detail/conversions/from_json.hpp> |
6342 | | |
6343 | | // #include <nlohmann/detail/conversions/to_json.hpp> |
6344 | | |
6345 | | // #include <nlohmann/detail/exceptions.hpp> |
6346 | | |
6347 | | // #include <nlohmann/detail/hash.hpp> |
6348 | | // __ _____ _____ _____ |
6349 | | // __| | __| | | | JSON for Modern C++ |
6350 | | // | | |__ | | | | | | version 3.12.0 |
6351 | | // |_____|_____|_____|_|___| https://github.com/nlohmann/json |
6352 | | // |
6353 | | // SPDX-FileCopyrightText: 2013-2026 Niels Lohmann <https://nlohmann.me> |
6354 | | // SPDX-License-Identifier: MIT |
6355 | | |
6356 | | |
6357 | | |
6358 | | #include <cstdint> // uint8_t |
6359 | | #include <cstddef> // size_t |
6360 | | #include <functional> // hash |
6361 | | |
6362 | | // #include <nlohmann/detail/abi_macros.hpp> |
6363 | | |
6364 | | // #include <nlohmann/detail/value_t.hpp> |
6365 | | |
6366 | | |
6367 | | NLOHMANN_JSON_NAMESPACE_BEGIN |
6368 | | namespace detail |
6369 | | { |
6370 | | |
6371 | | // boost::hash_combine |
6372 | | inline std::size_t combine(std::size_t seed, std::size_t h) noexcept |
6373 | 0 | { |
6374 | 0 | seed ^= h + 0x9e3779b9 + (seed << 6U) + (seed >> 2U); |
6375 | 0 | return seed; |
6376 | 0 | } |
6377 | | |
6378 | | /*! |
6379 | | @brief hash a JSON value |
6380 | | |
6381 | | The hash function tries to rely on std::hash where possible. Furthermore, the |
6382 | | type of the JSON value is taken into account to have different hash values for |
6383 | | null, 0, 0U, and false, etc. |
6384 | | |
6385 | | @tparam BasicJsonType basic_json specialization |
6386 | | @param j JSON value to hash |
6387 | | @return hash value of j |
6388 | | */ |
6389 | | template<typename BasicJsonType> |
6390 | | std::size_t hash(const BasicJsonType& j) |
6391 | | { |
6392 | | using string_t = typename BasicJsonType::string_t; |
6393 | | using number_integer_t = typename BasicJsonType::number_integer_t; |
6394 | | using number_unsigned_t = typename BasicJsonType::number_unsigned_t; |
6395 | | using number_float_t = typename BasicJsonType::number_float_t; |
6396 | | |
6397 | | const auto type = static_cast<std::size_t>(j.type()); |
6398 | | switch (j.type()) |
6399 | | { |
6400 | | case BasicJsonType::value_t::null: |
6401 | | case BasicJsonType::value_t::discarded: |
6402 | | { |
6403 | | return combine(type, 0); |
6404 | | } |
6405 | | |
6406 | | case BasicJsonType::value_t::object: |
6407 | | { |
6408 | | auto seed = combine(type, j.size()); |
6409 | | for (const auto& element : j.items()) |
6410 | | { |
6411 | | const auto h = std::hash<string_t> {}(element.key()); |
6412 | | seed = combine(seed, h); |
6413 | | seed = combine(seed, hash(element.value())); |
6414 | | } |
6415 | | return seed; |
6416 | | } |
6417 | | |
6418 | | case BasicJsonType::value_t::array: |
6419 | | { |
6420 | | auto seed = combine(type, j.size()); |
6421 | | for (const auto& element : j) |
6422 | | { |
6423 | | seed = combine(seed, hash(element)); |
6424 | | } |
6425 | | return seed; |
6426 | | } |
6427 | | |
6428 | | case BasicJsonType::value_t::string: |
6429 | | { |
6430 | | const auto h = std::hash<string_t> {}(j.template get_ref<const string_t&>()); |
6431 | | return combine(type, h); |
6432 | | } |
6433 | | |
6434 | | case BasicJsonType::value_t::boolean: |
6435 | | { |
6436 | | const auto h = std::hash<bool> {}(j.template get<bool>()); |
6437 | | return combine(type, h); |
6438 | | } |
6439 | | |
6440 | | case BasicJsonType::value_t::number_integer: |
6441 | | { |
6442 | | const auto h = std::hash<number_integer_t> {}(j.template get<number_integer_t>()); |
6443 | | return combine(type, h); |
6444 | | } |
6445 | | |
6446 | | case BasicJsonType::value_t::number_unsigned: |
6447 | | { |
6448 | | const auto h = std::hash<number_unsigned_t> {}(j.template get<number_unsigned_t>()); |
6449 | | return combine(type, h); |
6450 | | } |
6451 | | |
6452 | | case BasicJsonType::value_t::number_float: |
6453 | | { |
6454 | | const auto h = std::hash<number_float_t> {}(j.template get<number_float_t>()); |
6455 | | return combine(type, h); |
6456 | | } |
6457 | | |
6458 | | case BasicJsonType::value_t::binary: |
6459 | | { |
6460 | | auto seed = combine(type, j.get_binary().size()); |
6461 | | const auto h = std::hash<bool> {}(j.get_binary().has_subtype()); |
6462 | | seed = combine(seed, h); |
6463 | | seed = combine(seed, static_cast<std::size_t>(j.get_binary().subtype())); |
6464 | | for (const auto byte : j.get_binary()) |
6465 | | { |
6466 | | seed = combine(seed, std::hash<std::uint8_t> {}(byte)); |
6467 | | } |
6468 | | return seed; |
6469 | | } |
6470 | | |
6471 | | default: // LCOV_EXCL_LINE |
6472 | | JSON_ASSERT(false); // NOLINT(cert-dcl03-c,hicpp-static-assert,misc-static-assert) LCOV_EXCL_LINE |
6473 | | return 0; // LCOV_EXCL_LINE |
6474 | | } |
6475 | | } |
6476 | | |
6477 | | } // namespace detail |
6478 | | NLOHMANN_JSON_NAMESPACE_END |
6479 | | |
6480 | | // #include <nlohmann/detail/input/binary_reader.hpp> |
6481 | | // __ _____ _____ _____ |
6482 | | // __| | __| | | | JSON for Modern C++ |
6483 | | // | | |__ | | | | | | version 3.12.0 |
6484 | | // |_____|_____|_____|_|___| https://github.com/nlohmann/json |
6485 | | // |
6486 | | // SPDX-FileCopyrightText: 2013-2026 Niels Lohmann <https://nlohmann.me> |
6487 | | // SPDX-License-Identifier: MIT |
6488 | | |
6489 | | |
6490 | | |
6491 | | #include <algorithm> // generate_n |
6492 | | #include <array> // array |
6493 | | #include <cmath> // ldexp |
6494 | | #include <cstddef> // size_t |
6495 | | #include <cstdint> // uint8_t, uint16_t, uint32_t, uint64_t |
6496 | | #include <cstdio> // snprintf |
6497 | | #include <cstring> // memcpy |
6498 | | #include <iterator> // back_inserter |
6499 | | #include <limits> // numeric_limits |
6500 | | #include <string> // char_traits, string |
6501 | | #include <utility> // make_pair, move |
6502 | | #include <vector> // vector |
6503 | | #ifdef __cpp_lib_byteswap |
6504 | | #include <bit> //byteswap |
6505 | | #endif |
6506 | | |
6507 | | // #include <nlohmann/detail/exceptions.hpp> |
6508 | | |
6509 | | // #include <nlohmann/detail/input/input_adapters.hpp> |
6510 | | // __ _____ _____ _____ |
6511 | | // __| | __| | | | JSON for Modern C++ |
6512 | | // | | |__ | | | | | | version 3.12.0 |
6513 | | // |_____|_____|_____|_|___| https://github.com/nlohmann/json |
6514 | | // |
6515 | | // SPDX-FileCopyrightText: 2013-2026 Niels Lohmann <https://nlohmann.me> |
6516 | | // SPDX-License-Identifier: MIT |
6517 | | |
6518 | | |
6519 | | |
6520 | | #include <array> // array |
6521 | | #include <cstddef> // size_t |
6522 | | #include <cstring> // strlen |
6523 | | #include <iterator> // begin, end, iterator_traits, random_access_iterator_tag, distance, next |
6524 | | #include <memory> // shared_ptr, make_shared, addressof |
6525 | | #include <numeric> // accumulate |
6526 | | #include <streambuf> // streambuf |
6527 | | #include <string> // string, char_traits |
6528 | | #include <type_traits> // enable_if, is_base_of, is_pointer, is_integral, remove_pointer |
6529 | | #include <utility> // pair, declval |
6530 | | |
6531 | | #ifndef JSON_NO_IO |
6532 | | #include <cstdio> // FILE * |
6533 | | #include <istream> // istream |
6534 | | #endif // JSON_NO_IO |
6535 | | |
6536 | | // #include <nlohmann/detail/exceptions.hpp> |
6537 | | |
6538 | | // #include <nlohmann/detail/iterators/iterator_traits.hpp> |
6539 | | |
6540 | | // #include <nlohmann/detail/macro_scope.hpp> |
6541 | | |
6542 | | // #include <nlohmann/detail/meta/type_traits.hpp> |
6543 | | |
6544 | | |
6545 | | NLOHMANN_JSON_NAMESPACE_BEGIN |
6546 | | namespace detail |
6547 | | { |
6548 | | |
6549 | | /// the supported input formats |
6550 | | enum class input_format_t { json, cbor, msgpack, ubjson, bson, bjdata }; |
6551 | | |
6552 | | //////////////////// |
6553 | | // input adapters // |
6554 | | //////////////////// |
6555 | | |
6556 | | #ifndef JSON_NO_IO |
6557 | | /*! |
6558 | | Input adapter for stdio file access. This adapter read only 1 byte and do not use any |
6559 | | buffer. This adapter is a very low level adapter. |
6560 | | */ |
6561 | | class file_input_adapter |
6562 | | { |
6563 | | public: |
6564 | | using char_type = char; |
6565 | | |
6566 | | JSON_HEDLEY_NON_NULL(2) |
6567 | | explicit file_input_adapter(std::FILE* f) noexcept |
6568 | | : m_file(f) |
6569 | 0 | { |
6570 | 0 | JSON_ASSERT(m_file != nullptr); |
6571 | 0 | } |
6572 | | |
6573 | | // make class move-only |
6574 | | file_input_adapter(const file_input_adapter&) = delete; |
6575 | | file_input_adapter(file_input_adapter&&) noexcept = default; |
6576 | | file_input_adapter& operator=(const file_input_adapter&) = delete; |
6577 | | file_input_adapter& operator=(file_input_adapter&&) = delete; |
6578 | | ~file_input_adapter() = default; |
6579 | | |
6580 | | std::char_traits<char>::int_type get_character() noexcept |
6581 | 0 | { |
6582 | 0 | return std::fgetc(m_file); |
6583 | 0 | } |
6584 | | |
6585 | | // returns the number of characters successfully read |
6586 | | template<class T> |
6587 | | std::size_t get_elements(T* dest, std::size_t count = 1) |
6588 | | { |
6589 | | return fread(dest, 1, sizeof(T) * count, m_file); |
6590 | | } |
6591 | | |
6592 | | private: |
6593 | | /// the file pointer to read from |
6594 | | std::FILE* m_file; |
6595 | | }; |
6596 | | |
6597 | | /*! |
6598 | | Input adapter for a (caching) istream. Ignores a UFT Byte Order Mark at |
6599 | | beginning of input. Does not support changing the underlying std::streambuf |
6600 | | in mid-input. Maintains underlying std::istream and std::streambuf to support |
6601 | | subsequent use of standard std::istream operations to process any input |
6602 | | characters following those used in parsing the JSON input. Clears the |
6603 | | std::istream flags; any input errors (e.g., EOF) will be detected by the first |
6604 | | subsequent call for input from the std::istream. |
6605 | | */ |
6606 | | class input_stream_adapter |
6607 | | { |
6608 | | public: |
6609 | | using char_type = char; |
6610 | | |
6611 | | ~input_stream_adapter() |
6612 | 0 | { |
6613 | | // clear stream flags; we use underlying streambuf I/O, do not |
6614 | | // maintain ifstream flags, except eof |
6615 | 0 | if (is != nullptr) |
6616 | 0 | { |
6617 | 0 | is->clear(is->rdstate() & std::ios::eofbit); |
6618 | 0 | } |
6619 | 0 | } |
6620 | | |
6621 | | explicit input_stream_adapter(std::istream& i) |
6622 | 0 | : is(&i), sb(i.rdbuf()) |
6623 | 0 | {} |
6624 | | |
6625 | | // deleted because of pointer members |
6626 | | input_stream_adapter(const input_stream_adapter&) = delete; |
6627 | | input_stream_adapter& operator=(input_stream_adapter&) = delete; |
6628 | | input_stream_adapter& operator=(input_stream_adapter&&) = delete; |
6629 | | |
6630 | | input_stream_adapter(input_stream_adapter&& rhs) noexcept |
6631 | 0 | : is(rhs.is), sb(rhs.sb) |
6632 | 0 | { |
6633 | 0 | rhs.is = nullptr; |
6634 | 0 | rhs.sb = nullptr; |
6635 | 0 | } |
6636 | | |
6637 | | // std::istream/std::streambuf use std::char_traits<char>::to_int_type, to |
6638 | | // ensure that std::char_traits<char>::eof() and the character 0xFF do not |
6639 | | // end up as the same value, e.g., 0xFFFFFFFF. |
6640 | | std::char_traits<char>::int_type get_character() |
6641 | 0 | { |
6642 | 0 | auto res = sb->sbumpc(); |
6643 | | // set eof manually, as we don't use the istream interface. |
6644 | 0 | if (JSON_HEDLEY_UNLIKELY(res == std::char_traits<char>::eof())) |
6645 | 0 | { |
6646 | 0 | is->clear(is->rdstate() | std::ios::eofbit); |
6647 | 0 | } |
6648 | 0 | return res; |
6649 | 0 | } |
6650 | | |
6651 | | template<class T> |
6652 | | std::size_t get_elements(T* dest, std::size_t count = 1) |
6653 | | { |
6654 | | auto res = static_cast<std::size_t>(sb->sgetn(reinterpret_cast<char*>(dest), static_cast<std::streamsize>(count * sizeof(T)))); |
6655 | | if (JSON_HEDLEY_UNLIKELY(res < count * sizeof(T))) |
6656 | | { |
6657 | | is->clear(is->rdstate() | std::ios::eofbit); |
6658 | | } |
6659 | | return res; |
6660 | | } |
6661 | | |
6662 | | private: |
6663 | | /// the associated input stream |
6664 | | std::istream* is = nullptr; |
6665 | | std::streambuf* sb = nullptr; |
6666 | | }; |
6667 | | #endif // JSON_NO_IO |
6668 | | |
6669 | | // General-purpose iterator-based adapter. It might not be as fast as |
6670 | | // theoretically possible for some containers, but it is extremely versatile. |
6671 | | template<typename IteratorType> |
6672 | | class iterator_input_adapter |
6673 | | { |
6674 | | public: |
6675 | | using char_type = typename std::iterator_traits<IteratorType>::value_type; |
6676 | | |
6677 | | iterator_input_adapter(IteratorType first, IteratorType last) |
6678 | | : current(std::move(first)), end(std::move(last)) |
6679 | | {} |
6680 | | |
6681 | | typename char_traits<char_type>::int_type get_character() |
6682 | 0 | { |
6683 | 0 | if (JSON_HEDLEY_LIKELY(current != end)) |
6684 | 0 | { |
6685 | 0 | auto result = char_traits<char_type>::to_int_type(*current); |
6686 | 0 | std::advance(current, 1); |
6687 | 0 | return result; |
6688 | 0 | } |
6689 | 0 |
|
6690 | 0 | return char_traits<char_type>::eof(); |
6691 | 0 | } |
6692 | | |
6693 | | // for general iterators, we cannot really do something better than falling back to processing the range one-by-one |
6694 | | template<class T> |
6695 | | std::size_t get_elements(T* dest, std::size_t count = 1) |
6696 | | { |
6697 | | auto* ptr = reinterpret_cast<char*>(dest); |
6698 | | for (std::size_t read_index = 0; read_index < count * sizeof(T); ++read_index) |
6699 | | { |
6700 | | if (JSON_HEDLEY_LIKELY(current != end)) |
6701 | | { |
6702 | | ptr[read_index] = static_cast<char>(*current); |
6703 | | std::advance(current, 1); |
6704 | | } |
6705 | | else |
6706 | | { |
6707 | | return read_index; |
6708 | | } |
6709 | | } |
6710 | | return count * sizeof(T); |
6711 | | } |
6712 | | |
6713 | | private: |
6714 | | IteratorType current; |
6715 | | IteratorType end; |
6716 | | |
6717 | | template<typename BaseInputAdapter, size_t T> |
6718 | | friend struct wide_string_input_helper; |
6719 | | |
6720 | | bool empty() const |
6721 | | { |
6722 | | return current == end; |
6723 | | } |
6724 | | }; |
6725 | | |
6726 | | template<typename BaseInputAdapter, size_t T> |
6727 | | struct wide_string_input_helper; |
6728 | | |
6729 | | template<typename BaseInputAdapter> |
6730 | | struct wide_string_input_helper<BaseInputAdapter, 4> |
6731 | | { |
6732 | | // UTF-32 |
6733 | | static void fill_buffer(BaseInputAdapter& input, |
6734 | | std::array<std::char_traits<char>::int_type, 4>& utf8_bytes, |
6735 | | size_t& utf8_bytes_index, |
6736 | | size_t& utf8_bytes_filled) |
6737 | | { |
6738 | | utf8_bytes_index = 0; |
6739 | | |
6740 | | if (JSON_HEDLEY_UNLIKELY(input.empty())) |
6741 | | { |
6742 | | utf8_bytes[0] = std::char_traits<char>::eof(); |
6743 | | utf8_bytes_filled = 1; |
6744 | | } |
6745 | | else |
6746 | | { |
6747 | | // get the current character |
6748 | | const auto wc = input.get_character(); |
6749 | | |
6750 | | // UTF-32 to UTF-8 encoding |
6751 | | if (wc < 0x80) |
6752 | | { |
6753 | | utf8_bytes[0] = static_cast<std::char_traits<char>::int_type>(wc); |
6754 | | utf8_bytes_filled = 1; |
6755 | | } |
6756 | | else if (wc <= 0x7FF) |
6757 | | { |
6758 | | utf8_bytes[0] = static_cast<std::char_traits<char>::int_type>(0xC0u | ((static_cast<unsigned int>(wc) >> 6u) & 0x1Fu)); |
6759 | | utf8_bytes[1] = static_cast<std::char_traits<char>::int_type>(0x80u | (static_cast<unsigned int>(wc) & 0x3Fu)); |
6760 | | utf8_bytes_filled = 2; |
6761 | | } |
6762 | | else if (wc <= 0xFFFF) |
6763 | | { |
6764 | | utf8_bytes[0] = static_cast<std::char_traits<char>::int_type>(0xE0u | ((static_cast<unsigned int>(wc) >> 12u) & 0x0Fu)); |
6765 | | utf8_bytes[1] = static_cast<std::char_traits<char>::int_type>(0x80u | ((static_cast<unsigned int>(wc) >> 6u) & 0x3Fu)); |
6766 | | utf8_bytes[2] = static_cast<std::char_traits<char>::int_type>(0x80u | (static_cast<unsigned int>(wc) & 0x3Fu)); |
6767 | | utf8_bytes_filled = 3; |
6768 | | } |
6769 | | else if (wc <= 0x10FFFF) |
6770 | | { |
6771 | | utf8_bytes[0] = static_cast<std::char_traits<char>::int_type>(0xF0u | ((static_cast<unsigned int>(wc) >> 18u) & 0x07u)); |
6772 | | utf8_bytes[1] = static_cast<std::char_traits<char>::int_type>(0x80u | ((static_cast<unsigned int>(wc) >> 12u) & 0x3Fu)); |
6773 | | utf8_bytes[2] = static_cast<std::char_traits<char>::int_type>(0x80u | ((static_cast<unsigned int>(wc) >> 6u) & 0x3Fu)); |
6774 | | utf8_bytes[3] = static_cast<std::char_traits<char>::int_type>(0x80u | (static_cast<unsigned int>(wc) & 0x3Fu)); |
6775 | | utf8_bytes_filled = 4; |
6776 | | } |
6777 | | else |
6778 | | { |
6779 | | // unknown character |
6780 | | utf8_bytes[0] = static_cast<std::char_traits<char>::int_type>(wc); |
6781 | | utf8_bytes_filled = 1; |
6782 | | } |
6783 | | } |
6784 | | } |
6785 | | }; |
6786 | | |
6787 | | template<typename BaseInputAdapter> |
6788 | | struct wide_string_input_helper<BaseInputAdapter, 2> |
6789 | | { |
6790 | | // UTF-16 |
6791 | | static void fill_buffer(BaseInputAdapter& input, |
6792 | | std::array<std::char_traits<char>::int_type, 4>& utf8_bytes, |
6793 | | size_t& utf8_bytes_index, |
6794 | | size_t& utf8_bytes_filled) |
6795 | | { |
6796 | | utf8_bytes_index = 0; |
6797 | | |
6798 | | if (JSON_HEDLEY_UNLIKELY(input.empty())) |
6799 | | { |
6800 | | utf8_bytes[0] = std::char_traits<char>::eof(); |
6801 | | utf8_bytes_filled = 1; |
6802 | | } |
6803 | | else |
6804 | | { |
6805 | | // get the current character |
6806 | | const auto wc = input.get_character(); |
6807 | | |
6808 | | // UTF-16 to UTF-8 encoding |
6809 | | if (wc < 0x80) |
6810 | | { |
6811 | | utf8_bytes[0] = static_cast<std::char_traits<char>::int_type>(wc); |
6812 | | utf8_bytes_filled = 1; |
6813 | | } |
6814 | | else if (wc <= 0x7FF) |
6815 | | { |
6816 | | utf8_bytes[0] = static_cast<std::char_traits<char>::int_type>(0xC0u | ((static_cast<unsigned int>(wc) >> 6u))); |
6817 | | utf8_bytes[1] = static_cast<std::char_traits<char>::int_type>(0x80u | (static_cast<unsigned int>(wc) & 0x3Fu)); |
6818 | | utf8_bytes_filled = 2; |
6819 | | } |
6820 | | else if (0xD800 > wc || wc >= 0xE000) |
6821 | | { |
6822 | | utf8_bytes[0] = static_cast<std::char_traits<char>::int_type>(0xE0u | ((static_cast<unsigned int>(wc) >> 12u))); |
6823 | | utf8_bytes[1] = static_cast<std::char_traits<char>::int_type>(0x80u | ((static_cast<unsigned int>(wc) >> 6u) & 0x3Fu)); |
6824 | | utf8_bytes[2] = static_cast<std::char_traits<char>::int_type>(0x80u | (static_cast<unsigned int>(wc) & 0x3Fu)); |
6825 | | utf8_bytes_filled = 3; |
6826 | | } |
6827 | | else |
6828 | | { |
6829 | | if (JSON_HEDLEY_UNLIKELY(!input.empty())) |
6830 | | { |
6831 | | const auto wc2 = static_cast<unsigned int>(input.get_character()); |
6832 | | const auto charcode = 0x10000u + (((static_cast<unsigned int>(wc) & 0x3FFu) << 10u) | (wc2 & 0x3FFu)); |
6833 | | utf8_bytes[0] = static_cast<std::char_traits<char>::int_type>(0xF0u | (charcode >> 18u)); |
6834 | | utf8_bytes[1] = static_cast<std::char_traits<char>::int_type>(0x80u | ((charcode >> 12u) & 0x3Fu)); |
6835 | | utf8_bytes[2] = static_cast<std::char_traits<char>::int_type>(0x80u | ((charcode >> 6u) & 0x3Fu)); |
6836 | | utf8_bytes[3] = static_cast<std::char_traits<char>::int_type>(0x80u | (charcode & 0x3Fu)); |
6837 | | utf8_bytes_filled = 4; |
6838 | | } |
6839 | | else |
6840 | | { |
6841 | | utf8_bytes[0] = static_cast<std::char_traits<char>::int_type>(wc); |
6842 | | utf8_bytes_filled = 1; |
6843 | | } |
6844 | | } |
6845 | | } |
6846 | | } |
6847 | | }; |
6848 | | |
6849 | | // Wraps another input adapter to convert wide character types into individual bytes. |
6850 | | template<typename BaseInputAdapter, typename WideCharType> |
6851 | | class wide_string_input_adapter |
6852 | | { |
6853 | | public: |
6854 | | using char_type = char; |
6855 | | |
6856 | | wide_string_input_adapter(BaseInputAdapter base) |
6857 | | : base_adapter(base) {} |
6858 | | |
6859 | | typename std::char_traits<char>::int_type get_character() noexcept |
6860 | | { |
6861 | | // check if the buffer needs to be filled |
6862 | | if (utf8_bytes_index == utf8_bytes_filled) |
6863 | | { |
6864 | | fill_buffer<sizeof(WideCharType)>(); |
6865 | | |
6866 | | JSON_ASSERT(utf8_bytes_filled > 0); |
6867 | | JSON_ASSERT(utf8_bytes_index == 0); |
6868 | | } |
6869 | | |
6870 | | // use buffer |
6871 | | JSON_ASSERT(utf8_bytes_filled > 0); |
6872 | | JSON_ASSERT(utf8_bytes_index < utf8_bytes_filled); |
6873 | | return utf8_bytes[utf8_bytes_index++]; |
6874 | | } |
6875 | | |
6876 | | // parsing binary with wchar doesn't make sense, but since the parsing mode can be runtime, we need something here |
6877 | | template<class T> |
6878 | | std::size_t get_elements(T* /*dest*/, std::size_t /*count*/ = 1) |
6879 | | { |
6880 | | JSON_THROW(parse_error::create(112, 1, "wide string type cannot be interpreted as binary data", nullptr)); |
6881 | | } |
6882 | | |
6883 | | private: |
6884 | | BaseInputAdapter base_adapter; |
6885 | | |
6886 | | template<size_t T> |
6887 | | void fill_buffer() |
6888 | | { |
6889 | | wide_string_input_helper<BaseInputAdapter, T>::fill_buffer(base_adapter, utf8_bytes, utf8_bytes_index, utf8_bytes_filled); |
6890 | | } |
6891 | | |
6892 | | /// a buffer for UTF-8 bytes |
6893 | | std::array<std::char_traits<char>::int_type, 4> utf8_bytes = {{0, 0, 0, 0}}; |
6894 | | |
6895 | | /// index to the utf8_codes array for the next valid byte |
6896 | | std::size_t utf8_bytes_index = 0; |
6897 | | /// number of valid bytes in the utf8_codes array |
6898 | | std::size_t utf8_bytes_filled = 0; |
6899 | | }; |
6900 | | |
6901 | | template<typename IteratorType, typename Enable = void> |
6902 | | struct iterator_input_adapter_factory |
6903 | | { |
6904 | | using iterator_type = IteratorType; |
6905 | | using char_type = typename std::iterator_traits<iterator_type>::value_type; |
6906 | | using adapter_type = iterator_input_adapter<iterator_type>; |
6907 | | |
6908 | | static adapter_type create(IteratorType first, IteratorType last) |
6909 | 0 | { |
6910 | 0 | return adapter_type(std::move(first), std::move(last)); |
6911 | 0 | } |
6912 | | }; |
6913 | | |
6914 | | template<typename T> |
6915 | | struct is_iterator_of_multibyte |
6916 | | { |
6917 | | using value_type = typename std::iterator_traits<T>::value_type; |
6918 | | enum // NOLINT(cppcoreguidelines-use-enum-class) |
6919 | | { |
6920 | | value = sizeof(value_type) > 1 |
6921 | | }; |
6922 | | }; |
6923 | | |
6924 | | template<typename IteratorType> |
6925 | | struct iterator_input_adapter_factory<IteratorType, enable_if_t<is_iterator_of_multibyte<IteratorType>::value>> |
6926 | | { |
6927 | | using iterator_type = IteratorType; |
6928 | | using char_type = typename std::iterator_traits<iterator_type>::value_type; |
6929 | | using base_adapter_type = iterator_input_adapter<iterator_type>; |
6930 | | using adapter_type = wide_string_input_adapter<base_adapter_type, char_type>; |
6931 | | |
6932 | | static adapter_type create(IteratorType first, IteratorType last) |
6933 | | { |
6934 | | return adapter_type(base_adapter_type(std::move(first), std::move(last))); |
6935 | | } |
6936 | | }; |
6937 | | |
6938 | | // General purpose iterator-based input |
6939 | | template<typename IteratorType> |
6940 | | typename iterator_input_adapter_factory<IteratorType>::adapter_type input_adapter(IteratorType first, IteratorType last) |
6941 | 0 | { |
6942 | 0 | using factory_type = iterator_input_adapter_factory<IteratorType>; |
6943 | 0 | return factory_type::create(first, last); |
6944 | 0 | } |
6945 | | |
6946 | | // Convenience shorthand from container to iterator |
6947 | | // Enables ADL on begin(container) and end(container) |
6948 | | // Encloses the using declarations in namespace for not to leak them to outside scope |
6949 | | |
6950 | | namespace container_input_adapter_factory_impl |
6951 | | { |
6952 | | |
6953 | | using std::begin; |
6954 | | using std::end; |
6955 | | |
6956 | | template<typename ContainerType, typename Enable = void> |
6957 | | struct container_input_adapter_factory {}; |
6958 | | |
6959 | | template<typename ContainerType> |
6960 | | struct container_input_adapter_factory< ContainerType, |
6961 | | void_t<decltype(begin(std::declval<ContainerType>()), end(std::declval<ContainerType>()))>> |
6962 | | { |
6963 | | using adapter_type = decltype(input_adapter(begin(std::declval<ContainerType>()), end(std::declval<ContainerType>()))); |
6964 | | |
6965 | | static adapter_type create(const ContainerType& container) |
6966 | | { |
6967 | | return input_adapter(begin(container), end(container)); |
6968 | | } |
6969 | | }; |
6970 | | |
6971 | | } // namespace container_input_adapter_factory_impl |
6972 | | |
6973 | | template<typename ContainerType> |
6974 | | typename container_input_adapter_factory_impl::container_input_adapter_factory<ContainerType>::adapter_type input_adapter(const ContainerType& container) |
6975 | | { |
6976 | | return container_input_adapter_factory_impl::container_input_adapter_factory<ContainerType>::create(container); |
6977 | | } |
6978 | | |
6979 | | // specialization for std::string |
6980 | | using string_input_adapter_type = decltype(input_adapter(std::declval<std::string>())); |
6981 | | |
6982 | | #ifndef JSON_NO_IO |
6983 | | // Special cases with fast paths |
6984 | | inline file_input_adapter input_adapter(std::FILE* file) |
6985 | 0 | { |
6986 | 0 | if (file == nullptr) |
6987 | 0 | { |
6988 | 0 | JSON_THROW(parse_error::create(101, 0, "attempting to parse an empty input; check that your input string or stream contains the expected JSON", nullptr)); |
6989 | 0 | } |
6990 | 0 | return file_input_adapter(file); |
6991 | 0 | } |
6992 | | |
6993 | | inline input_stream_adapter input_adapter(std::istream& stream) |
6994 | 0 | { |
6995 | 0 | return input_stream_adapter(stream); |
6996 | 0 | } |
6997 | | |
6998 | | inline input_stream_adapter input_adapter(std::istream&& stream) |
6999 | 0 | { |
7000 | 0 | return input_stream_adapter(stream); |
7001 | 0 | } |
7002 | | #endif // JSON_NO_IO |
7003 | | |
7004 | | using contiguous_bytes_input_adapter = decltype(input_adapter(std::declval<const char*>(), std::declval<const char*>())); |
7005 | | |
7006 | | // Null-delimited strings, and the like. |
7007 | | template < typename CharT, |
7008 | | typename std::enable_if < |
7009 | | std::is_pointer<CharT>::value&& |
7010 | | !std::is_array<CharT>::value&& |
7011 | | std::is_integral<typename std::remove_pointer<CharT>::type>::value&& |
7012 | | sizeof(typename std::remove_pointer<CharT>::type) == 1, |
7013 | | int >::type = 0 > |
7014 | | contiguous_bytes_input_adapter input_adapter(CharT b) |
7015 | | { |
7016 | | if (b == nullptr) |
7017 | | { |
7018 | | JSON_THROW(parse_error::create(101, 0, "attempting to parse an empty input; check that your input string or stream contains the expected JSON", nullptr)); |
7019 | | } |
7020 | | auto length = std::strlen(reinterpret_cast<const char*>(b)); |
7021 | | const auto* ptr = reinterpret_cast<const char*>(b); |
7022 | | return input_adapter(ptr, ptr + length); // cppcheck-suppress[nullPointerArithmeticRedundantCheck] |
7023 | | } |
7024 | | |
7025 | | template<typename T, std::size_t N> |
7026 | | auto input_adapter(T (&array)[N]) -> decltype(input_adapter(array, array + N)) // NOLINT(cppcoreguidelines-avoid-c-arrays,hicpp-avoid-c-arrays,modernize-avoid-c-arrays) |
7027 | | { |
7028 | | return input_adapter(array, array + N); |
7029 | | } |
7030 | | |
7031 | | // This class only handles inputs of input_buffer_adapter type. |
7032 | | // It's required so that expressions like {ptr, len} can be implicitly cast |
7033 | | // to the correct adapter. |
7034 | | class span_input_adapter |
7035 | | { |
7036 | | public: |
7037 | | template < typename CharT, |
7038 | | typename std::enable_if < |
7039 | | std::is_pointer<CharT>::value&& |
7040 | | std::is_integral<typename std::remove_pointer<CharT>::type>::value&& |
7041 | | sizeof(typename std::remove_pointer<CharT>::type) == 1, |
7042 | | int >::type = 0 > |
7043 | | span_input_adapter(CharT b, std::size_t l) |
7044 | | : ia(reinterpret_cast<const char*>(b), reinterpret_cast<const char*>(b) + l) {} |
7045 | | |
7046 | | template<class IteratorType, |
7047 | | typename std::enable_if< |
7048 | | std::is_same<typename iterator_traits<IteratorType>::iterator_category, std::random_access_iterator_tag>::value, |
7049 | | int>::type = 0> |
7050 | | span_input_adapter(IteratorType first, IteratorType last) |
7051 | | : ia(input_adapter(first, last)) {} |
7052 | | |
7053 | | contiguous_bytes_input_adapter&& get() |
7054 | 0 | { |
7055 | 0 | return std::move(ia); // NOLINT(hicpp-move-const-arg,performance-move-const-arg) |
7056 | 0 | } |
7057 | | |
7058 | | private: |
7059 | | contiguous_bytes_input_adapter ia; |
7060 | | }; |
7061 | | |
7062 | | } // namespace detail |
7063 | | NLOHMANN_JSON_NAMESPACE_END |
7064 | | |
7065 | | // #include <nlohmann/detail/input/json_sax.hpp> |
7066 | | // __ _____ _____ _____ |
7067 | | // __| | __| | | | JSON for Modern C++ |
7068 | | // | | |__ | | | | | | version 3.12.0 |
7069 | | // |_____|_____|_____|_|___| https://github.com/nlohmann/json |
7070 | | // |
7071 | | // SPDX-FileCopyrightText: 2013-2026 Niels Lohmann <https://nlohmann.me> |
7072 | | // SPDX-License-Identifier: MIT |
7073 | | |
7074 | | |
7075 | | |
7076 | | #include <cstddef> |
7077 | | #include <string> // string |
7078 | | #include <type_traits> // enable_if_t |
7079 | | #include <utility> // move |
7080 | | #include <vector> // vector |
7081 | | |
7082 | | // #include <nlohmann/detail/exceptions.hpp> |
7083 | | |
7084 | | // #include <nlohmann/detail/input/lexer.hpp> |
7085 | | // __ _____ _____ _____ |
7086 | | // __| | __| | | | JSON for Modern C++ |
7087 | | // | | |__ | | | | | | version 3.12.0 |
7088 | | // |_____|_____|_____|_|___| https://github.com/nlohmann/json |
7089 | | // |
7090 | | // SPDX-FileCopyrightText: 2013-2026 Niels Lohmann <https://nlohmann.me> |
7091 | | // SPDX-License-Identifier: MIT |
7092 | | |
7093 | | |
7094 | | |
7095 | | #include <array> // array |
7096 | | #include <clocale> // localeconv |
7097 | | #include <cstddef> // size_t |
7098 | | #include <cstdio> // snprintf |
7099 | | #include <cstdlib> // strtof, strtod, strtold, strtoll, strtoull |
7100 | | #include <initializer_list> // initializer_list |
7101 | | #include <string> // char_traits, string |
7102 | | #include <utility> // move |
7103 | | #include <vector> // vector |
7104 | | |
7105 | | // #include <nlohmann/detail/input/input_adapters.hpp> |
7106 | | |
7107 | | // #include <nlohmann/detail/input/position_t.hpp> |
7108 | | |
7109 | | // #include <nlohmann/detail/macro_scope.hpp> |
7110 | | |
7111 | | // #include <nlohmann/detail/meta/type_traits.hpp> |
7112 | | |
7113 | | |
7114 | | NLOHMANN_JSON_NAMESPACE_BEGIN |
7115 | | namespace detail |
7116 | | { |
7117 | | |
7118 | | /////////// |
7119 | | // lexer // |
7120 | | /////////// |
7121 | | |
7122 | | template<typename BasicJsonType> |
7123 | | class lexer_base |
7124 | | { |
7125 | | public: |
7126 | | /// token types for the parser |
7127 | | enum class token_type |
7128 | | { |
7129 | | uninitialized, ///< indicating the scanner is uninitialized |
7130 | | literal_true, ///< the `true` literal |
7131 | | literal_false, ///< the `false` literal |
7132 | | literal_null, ///< the `null` literal |
7133 | | value_string, ///< a string -- use get_string() for actual value |
7134 | | value_unsigned, ///< an unsigned integer -- use get_number_unsigned() for actual value |
7135 | | value_integer, ///< a signed integer -- use get_number_integer() for actual value |
7136 | | value_float, ///< an floating point number -- use get_number_float() for actual value |
7137 | | begin_array, ///< the character for array begin `[` |
7138 | | begin_object, ///< the character for object begin `{` |
7139 | | end_array, ///< the character for array end `]` |
7140 | | end_object, ///< the character for object end `}` |
7141 | | name_separator, ///< the name separator `:` |
7142 | | value_separator, ///< the value separator `,` |
7143 | | parse_error, ///< indicating a parse error |
7144 | | end_of_input, ///< indicating the end of the input buffer |
7145 | | literal_or_value ///< a literal or the begin of a value (only for diagnostics) |
7146 | | }; |
7147 | | |
7148 | | /// return name of values of type token_type (only used for errors) |
7149 | | JSON_HEDLEY_RETURNS_NON_NULL |
7150 | | JSON_HEDLEY_CONST |
7151 | | static const char* token_type_name(const token_type t) noexcept |
7152 | 0 | { |
7153 | 0 | switch (t) |
7154 | 0 | { |
7155 | 0 | case token_type::uninitialized: |
7156 | 0 | return "<uninitialized>"; |
7157 | 0 | case token_type::literal_true: |
7158 | 0 | return "true literal"; |
7159 | 0 | case token_type::literal_false: |
7160 | 0 | return "false literal"; |
7161 | 0 | case token_type::literal_null: |
7162 | 0 | return "null literal"; |
7163 | 0 | case token_type::value_string: |
7164 | 0 | return "string literal"; |
7165 | 0 | case token_type::value_unsigned: |
7166 | 0 | case token_type::value_integer: |
7167 | 0 | case token_type::value_float: |
7168 | 0 | return "number literal"; |
7169 | 0 | case token_type::begin_array: |
7170 | 0 | return "'['"; |
7171 | 0 | case token_type::begin_object: |
7172 | 0 | return "'{'"; |
7173 | 0 | case token_type::end_array: |
7174 | 0 | return "']'"; |
7175 | 0 | case token_type::end_object: |
7176 | 0 | return "'}'"; |
7177 | 0 | case token_type::name_separator: |
7178 | 0 | return "':'"; |
7179 | 0 | case token_type::value_separator: |
7180 | 0 | return "','"; |
7181 | 0 | case token_type::parse_error: |
7182 | 0 | return "<parse error>"; |
7183 | 0 | case token_type::end_of_input: |
7184 | 0 | return "end of input"; |
7185 | 0 | case token_type::literal_or_value: |
7186 | 0 | return "'[', '{', or a literal"; |
7187 | | // LCOV_EXCL_START |
7188 | 0 | default: // catch non-enum values |
7189 | 0 | return "unknown token"; |
7190 | | // LCOV_EXCL_STOP |
7191 | 0 | } |
7192 | 0 | } |
7193 | | }; |
7194 | | /*! |
7195 | | @brief lexical analysis |
7196 | | |
7197 | | This class organizes the lexical analysis during JSON deserialization. |
7198 | | */ |
7199 | | template<typename BasicJsonType, typename InputAdapterType> |
7200 | | class lexer : public lexer_base<BasicJsonType> |
7201 | | { |
7202 | | using number_integer_t = typename BasicJsonType::number_integer_t; |
7203 | | using number_unsigned_t = typename BasicJsonType::number_unsigned_t; |
7204 | | using number_float_t = typename BasicJsonType::number_float_t; |
7205 | | using string_t = typename BasicJsonType::string_t; |
7206 | | using char_type = typename InputAdapterType::char_type; |
7207 | | using char_int_type = typename char_traits<char_type>::int_type; |
7208 | | |
7209 | | public: |
7210 | | using token_type = typename lexer_base<BasicJsonType>::token_type; |
7211 | | |
7212 | | explicit lexer(InputAdapterType&& adapter, bool ignore_comments_ = false) noexcept |
7213 | 0 | : ia(std::move(adapter)) |
7214 | 0 | , ignore_comments(ignore_comments_) |
7215 | 0 | , decimal_point_char(static_cast<char_int_type>(get_decimal_point())) |
7216 | 0 | {} |
7217 | | |
7218 | | // deleted because of pointer members |
7219 | | lexer(const lexer&) = delete; |
7220 | | lexer(lexer&&) = default; // NOLINT(hicpp-noexcept-move,performance-noexcept-move-constructor) |
7221 | | lexer& operator=(lexer&) = delete; |
7222 | | lexer& operator=(lexer&&) = default; // NOLINT(hicpp-noexcept-move,performance-noexcept-move-constructor) |
7223 | 0 | ~lexer() = default; |
7224 | | |
7225 | | private: |
7226 | | ///////////////////// |
7227 | | // locales |
7228 | | ///////////////////// |
7229 | | |
7230 | | /// return the locale-dependent decimal point |
7231 | | JSON_HEDLEY_PURE |
7232 | | static char get_decimal_point() noexcept |
7233 | 0 | { |
7234 | 0 | const auto* loc = localeconv(); |
7235 | 0 | JSON_ASSERT(loc != nullptr); |
7236 | 0 | return (loc->decimal_point == nullptr) ? '.' : *(loc->decimal_point); |
7237 | 0 | } Unexecuted instantiation: nlohmann::json_abi_v3_12_0::detail::lexer<nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>, nlohmann::json_abi_v3_12_0::detail::iterator_input_adapter<char const*> >::get_decimal_point() Unexecuted instantiation: nlohmann::json_abi_v3_12_0::detail::lexer<nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>, nlohmann::json_abi_v3_12_0::detail::input_stream_adapter>::get_decimal_point() |
7238 | | |
7239 | | ///////////////////// |
7240 | | // scan functions |
7241 | | ///////////////////// |
7242 | | |
7243 | | /*! |
7244 | | @brief get codepoint from 4 hex characters following `\u` |
7245 | | |
7246 | | For input "\u c1 c2 c3 c4" the codepoint is: |
7247 | | (c1 * 0x1000) + (c2 * 0x0100) + (c3 * 0x0010) + c4 |
7248 | | = (c1 << 12) + (c2 << 8) + (c3 << 4) + (c4 << 0) |
7249 | | |
7250 | | Furthermore, the possible characters '0'..'9', 'A'..'F', and 'a'..'f' |
7251 | | must be converted to the integers 0x0..0x9, 0xA..0xF, 0xA..0xF, resp. The |
7252 | | conversion is done by subtracting the offset (0x30, 0x37, and 0x57) |
7253 | | between the ASCII value of the character and the desired integer value. |
7254 | | |
7255 | | @return codepoint (0x0000..0xFFFF) or -1 in case of an error (e.g. EOF or |
7256 | | non-hex character) |
7257 | | */ |
7258 | | int get_codepoint() |
7259 | 0 | { |
7260 | | // this function only makes sense after reading `\u` |
7261 | 0 | JSON_ASSERT(current == 'u'); |
7262 | 0 | int codepoint = 0; |
7263 | |
|
7264 | 0 | const auto factors = { 12u, 8u, 4u, 0u }; |
7265 | 0 | for (const auto factor : factors) |
7266 | 0 | { |
7267 | 0 | get(); |
7268 | |
|
7269 | 0 | if (current >= '0' && current <= '9') |
7270 | 0 | { |
7271 | 0 | codepoint += static_cast<int>((static_cast<unsigned int>(current) - 0x30u) << factor); |
7272 | 0 | } |
7273 | 0 | else if (current >= 'A' && current <= 'F') |
7274 | 0 | { |
7275 | 0 | codepoint += static_cast<int>((static_cast<unsigned int>(current) - 0x37u) << factor); |
7276 | 0 | } |
7277 | 0 | else if (current >= 'a' && current <= 'f') |
7278 | 0 | { |
7279 | 0 | codepoint += static_cast<int>((static_cast<unsigned int>(current) - 0x57u) << factor); |
7280 | 0 | } |
7281 | 0 | else |
7282 | 0 | { |
7283 | 0 | return -1; |
7284 | 0 | } |
7285 | 0 | } |
7286 | | |
7287 | 0 | JSON_ASSERT(0x0000 <= codepoint && codepoint <= 0xFFFF); |
7288 | 0 | return codepoint; |
7289 | 0 | } Unexecuted instantiation: nlohmann::json_abi_v3_12_0::detail::lexer<nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>, nlohmann::json_abi_v3_12_0::detail::iterator_input_adapter<char const*> >::get_codepoint() Unexecuted instantiation: nlohmann::json_abi_v3_12_0::detail::lexer<nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>, nlohmann::json_abi_v3_12_0::detail::input_stream_adapter>::get_codepoint() |
7290 | | |
7291 | | /*! |
7292 | | @brief check if the next byte(s) are inside a given range |
7293 | | |
7294 | | Adds the current byte and, for each passed range, reads a new byte and |
7295 | | checks if it is inside the range. If a violation was detected, set up an |
7296 | | error message and return false. Otherwise, return true. |
7297 | | |
7298 | | @param[in] ranges list of integers; interpreted as list of pairs of |
7299 | | inclusive lower and upper bound, respectively |
7300 | | |
7301 | | @pre The passed list @a ranges must have 2, 4, or 6 elements; that is, |
7302 | | 1, 2, or 3 pairs. This precondition is enforced by an assertion. |
7303 | | |
7304 | | @return true if and only if no range violation was detected |
7305 | | */ |
7306 | | bool next_byte_in_range(std::initializer_list<char_int_type> ranges) |
7307 | 0 | { |
7308 | 0 | JSON_ASSERT(ranges.size() == 2 || ranges.size() == 4 || ranges.size() == 6); |
7309 | 0 | add(current); |
7310 | |
|
7311 | 0 | for (auto range = ranges.begin(); range != ranges.end(); ++range) |
7312 | 0 | { |
7313 | 0 | get(); |
7314 | 0 | if (JSON_HEDLEY_LIKELY(*range <= current && current <= *(++range))) // NOLINT(bugprone-inc-dec-in-conditions) |
7315 | 0 | { |
7316 | 0 | add(current); |
7317 | 0 | } |
7318 | 0 | else |
7319 | 0 | { |
7320 | 0 | error_message = "invalid string: ill-formed UTF-8 byte"; |
7321 | 0 | return false; |
7322 | 0 | } |
7323 | 0 | } |
7324 | | |
7325 | 0 | return true; |
7326 | 0 | } Unexecuted instantiation: nlohmann::json_abi_v3_12_0::detail::lexer<nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>, nlohmann::json_abi_v3_12_0::detail::iterator_input_adapter<char const*> >::next_byte_in_range(std::initializer_list<int>) Unexecuted instantiation: nlohmann::json_abi_v3_12_0::detail::lexer<nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>, nlohmann::json_abi_v3_12_0::detail::input_stream_adapter>::next_byte_in_range(std::initializer_list<int>) |
7327 | | |
7328 | | /*! |
7329 | | @brief scan a string literal |
7330 | | |
7331 | | This function scans a string according to Sect. 7 of RFC 8259. While |
7332 | | scanning, bytes are escaped and copied into buffer token_buffer. Then the |
7333 | | function returns successfully, token_buffer is *not* null-terminated (as it |
7334 | | may contain \0 bytes), and token_buffer.size() is the number of bytes in the |
7335 | | string. |
7336 | | |
7337 | | @return token_type::value_string if string could be successfully scanned, |
7338 | | token_type::parse_error otherwise |
7339 | | |
7340 | | @note In case of errors, variable error_message contains a textual |
7341 | | description. |
7342 | | */ |
7343 | | token_type scan_string() |
7344 | 0 | { |
7345 | | // reset token_buffer (ignore opening quote) |
7346 | 0 | reset(); |
7347 | | |
7348 | | // we entered the function by reading an open quote |
7349 | 0 | JSON_ASSERT(current == '\"'); |
7350 | | |
7351 | 0 | while (true) |
7352 | 0 | { |
7353 | | // get the next character |
7354 | 0 | switch (get()) |
7355 | 0 | { |
7356 | | // end of file while parsing the string |
7357 | 0 | case char_traits<char_type>::eof(): |
7358 | 0 | { |
7359 | 0 | error_message = "invalid string: missing closing quote"; |
7360 | 0 | return token_type::parse_error; |
7361 | 0 | } |
7362 | | |
7363 | | // closing quote |
7364 | 0 | case '\"': |
7365 | 0 | { |
7366 | 0 | return token_type::value_string; |
7367 | 0 | } |
7368 | | |
7369 | | // escapes |
7370 | 0 | case '\\': |
7371 | 0 | { |
7372 | 0 | switch (get()) |
7373 | 0 | { |
7374 | | // quotation mark |
7375 | 0 | case '\"': |
7376 | 0 | add('\"'); |
7377 | 0 | break; |
7378 | | // reverse solidus |
7379 | 0 | case '\\': |
7380 | 0 | add('\\'); |
7381 | 0 | break; |
7382 | | // solidus |
7383 | 0 | case '/': |
7384 | 0 | add('/'); |
7385 | 0 | break; |
7386 | | // backspace |
7387 | 0 | case 'b': |
7388 | 0 | add('\b'); |
7389 | 0 | break; |
7390 | | // form feed |
7391 | 0 | case 'f': |
7392 | 0 | add('\f'); |
7393 | 0 | break; |
7394 | | // line feed |
7395 | 0 | case 'n': |
7396 | 0 | add('\n'); |
7397 | 0 | break; |
7398 | | // carriage return |
7399 | 0 | case 'r': |
7400 | 0 | add('\r'); |
7401 | 0 | break; |
7402 | | // tab |
7403 | 0 | case 't': |
7404 | 0 | add('\t'); |
7405 | 0 | break; |
7406 | | |
7407 | | // unicode escapes |
7408 | 0 | case 'u': |
7409 | 0 | { |
7410 | 0 | const int codepoint1 = get_codepoint(); |
7411 | 0 | int codepoint = codepoint1; // start with codepoint1 |
7412 | |
|
7413 | 0 | if (JSON_HEDLEY_UNLIKELY(codepoint1 == -1)) |
7414 | 0 | { |
7415 | 0 | error_message = "invalid string: '\\u' must be followed by 4 hex digits"; |
7416 | 0 | return token_type::parse_error; |
7417 | 0 | } |
7418 | | |
7419 | | // check if code point is a high surrogate |
7420 | 0 | if (0xD800 <= codepoint1 && codepoint1 <= 0xDBFF) |
7421 | 0 | { |
7422 | | // expect next \uxxxx entry |
7423 | 0 | if (JSON_HEDLEY_LIKELY(get() == '\\' && get() == 'u')) |
7424 | 0 | { |
7425 | 0 | const int codepoint2 = get_codepoint(); |
7426 | |
|
7427 | 0 | if (JSON_HEDLEY_UNLIKELY(codepoint2 == -1)) |
7428 | 0 | { |
7429 | 0 | error_message = "invalid string: '\\u' must be followed by 4 hex digits"; |
7430 | 0 | return token_type::parse_error; |
7431 | 0 | } |
7432 | | |
7433 | | // check if codepoint2 is a low surrogate |
7434 | 0 | if (JSON_HEDLEY_LIKELY(0xDC00 <= codepoint2 && codepoint2 <= 0xDFFF)) |
7435 | 0 | { |
7436 | | // overwrite codepoint |
7437 | 0 | codepoint = static_cast<int>( |
7438 | | // high surrogate occupies the most significant 22 bits |
7439 | 0 | (static_cast<unsigned int>(codepoint1) << 10u) |
7440 | | // low surrogate occupies the least significant 15 bits |
7441 | 0 | + static_cast<unsigned int>(codepoint2) |
7442 | | // there is still the 0xD800, 0xDC00, and 0x10000 noise |
7443 | | // in the result, so we have to subtract with: |
7444 | | // (0xD800 << 10) + DC00 - 0x10000 = 0x35FDC00 |
7445 | 0 | - 0x35FDC00u); |
7446 | 0 | } |
7447 | 0 | else |
7448 | 0 | { |
7449 | 0 | error_message = "invalid string: surrogate U+D800..U+DBFF must be followed by U+DC00..U+DFFF"; |
7450 | 0 | return token_type::parse_error; |
7451 | 0 | } |
7452 | 0 | } |
7453 | 0 | else |
7454 | 0 | { |
7455 | 0 | error_message = "invalid string: surrogate U+D800..U+DBFF must be followed by U+DC00..U+DFFF"; |
7456 | 0 | return token_type::parse_error; |
7457 | 0 | } |
7458 | 0 | } |
7459 | 0 | else |
7460 | 0 | { |
7461 | 0 | if (JSON_HEDLEY_UNLIKELY(0xDC00 <= codepoint1 && codepoint1 <= 0xDFFF)) |
7462 | 0 | { |
7463 | 0 | error_message = "invalid string: surrogate U+DC00..U+DFFF must follow U+D800..U+DBFF"; |
7464 | 0 | return token_type::parse_error; |
7465 | 0 | } |
7466 | 0 | } |
7467 | | |
7468 | | // the result of the above calculation yields a proper codepoint |
7469 | 0 | JSON_ASSERT(0x00 <= codepoint && codepoint <= 0x10FFFF); |
7470 | | |
7471 | | // translate codepoint into bytes |
7472 | 0 | if (codepoint < 0x80) |
7473 | 0 | { |
7474 | | // 1-byte characters: 0xxxxxxx (ASCII) |
7475 | 0 | add(static_cast<char_int_type>(codepoint)); |
7476 | 0 | } |
7477 | 0 | else if (codepoint <= 0x7FF) |
7478 | 0 | { |
7479 | | // 2-byte characters: 110xxxxx 10xxxxxx |
7480 | 0 | add(static_cast<char_int_type>(0xC0u | (static_cast<unsigned int>(codepoint) >> 6u))); |
7481 | 0 | add(static_cast<char_int_type>(0x80u | (static_cast<unsigned int>(codepoint) & 0x3Fu))); |
7482 | 0 | } |
7483 | 0 | else if (codepoint <= 0xFFFF) |
7484 | 0 | { |
7485 | | // 3-byte characters: 1110xxxx 10xxxxxx 10xxxxxx |
7486 | 0 | add(static_cast<char_int_type>(0xE0u | (static_cast<unsigned int>(codepoint) >> 12u))); |
7487 | 0 | add(static_cast<char_int_type>(0x80u | ((static_cast<unsigned int>(codepoint) >> 6u) & 0x3Fu))); |
7488 | 0 | add(static_cast<char_int_type>(0x80u | (static_cast<unsigned int>(codepoint) & 0x3Fu))); |
7489 | 0 | } |
7490 | 0 | else |
7491 | 0 | { |
7492 | | // 4-byte characters: 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx |
7493 | 0 | add(static_cast<char_int_type>(0xF0u | (static_cast<unsigned int>(codepoint) >> 18u))); |
7494 | 0 | add(static_cast<char_int_type>(0x80u | ((static_cast<unsigned int>(codepoint) >> 12u) & 0x3Fu))); |
7495 | 0 | add(static_cast<char_int_type>(0x80u | ((static_cast<unsigned int>(codepoint) >> 6u) & 0x3Fu))); |
7496 | 0 | add(static_cast<char_int_type>(0x80u | (static_cast<unsigned int>(codepoint) & 0x3Fu))); |
7497 | 0 | } |
7498 | |
|
7499 | 0 | break; |
7500 | 0 | } |
7501 | | |
7502 | | // other characters after escape |
7503 | 0 | default: |
7504 | 0 | error_message = "invalid string: forbidden character after backslash"; |
7505 | 0 | return token_type::parse_error; |
7506 | 0 | } |
7507 | | |
7508 | 0 | break; |
7509 | 0 | } |
7510 | | |
7511 | | // invalid control characters |
7512 | 0 | case 0x00: |
7513 | 0 | { |
7514 | 0 | error_message = "invalid string: control character U+0000 (NUL) must be escaped to \\u0000"; |
7515 | 0 | return token_type::parse_error; |
7516 | 0 | } |
7517 | | |
7518 | 0 | case 0x01: |
7519 | 0 | { |
7520 | 0 | error_message = "invalid string: control character U+0001 (SOH) must be escaped to \\u0001"; |
7521 | 0 | return token_type::parse_error; |
7522 | 0 | } |
7523 | | |
7524 | 0 | case 0x02: |
7525 | 0 | { |
7526 | 0 | error_message = "invalid string: control character U+0002 (STX) must be escaped to \\u0002"; |
7527 | 0 | return token_type::parse_error; |
7528 | 0 | } |
7529 | | |
7530 | 0 | case 0x03: |
7531 | 0 | { |
7532 | 0 | error_message = "invalid string: control character U+0003 (ETX) must be escaped to \\u0003"; |
7533 | 0 | return token_type::parse_error; |
7534 | 0 | } |
7535 | | |
7536 | 0 | case 0x04: |
7537 | 0 | { |
7538 | 0 | error_message = "invalid string: control character U+0004 (EOT) must be escaped to \\u0004"; |
7539 | 0 | return token_type::parse_error; |
7540 | 0 | } |
7541 | | |
7542 | 0 | case 0x05: |
7543 | 0 | { |
7544 | 0 | error_message = "invalid string: control character U+0005 (ENQ) must be escaped to \\u0005"; |
7545 | 0 | return token_type::parse_error; |
7546 | 0 | } |
7547 | | |
7548 | 0 | case 0x06: |
7549 | 0 | { |
7550 | 0 | error_message = "invalid string: control character U+0006 (ACK) must be escaped to \\u0006"; |
7551 | 0 | return token_type::parse_error; |
7552 | 0 | } |
7553 | | |
7554 | 0 | case 0x07: |
7555 | 0 | { |
7556 | 0 | error_message = "invalid string: control character U+0007 (BEL) must be escaped to \\u0007"; |
7557 | 0 | return token_type::parse_error; |
7558 | 0 | } |
7559 | | |
7560 | 0 | case 0x08: |
7561 | 0 | { |
7562 | 0 | error_message = "invalid string: control character U+0008 (BS) must be escaped to \\u0008 or \\b"; |
7563 | 0 | return token_type::parse_error; |
7564 | 0 | } |
7565 | | |
7566 | 0 | case 0x09: |
7567 | 0 | { |
7568 | 0 | error_message = "invalid string: control character U+0009 (HT) must be escaped to \\u0009 or \\t"; |
7569 | 0 | return token_type::parse_error; |
7570 | 0 | } |
7571 | | |
7572 | 0 | case 0x0A: |
7573 | 0 | { |
7574 | 0 | error_message = "invalid string: control character U+000A (LF) must be escaped to \\u000A or \\n"; |
7575 | 0 | return token_type::parse_error; |
7576 | 0 | } |
7577 | | |
7578 | 0 | case 0x0B: |
7579 | 0 | { |
7580 | 0 | error_message = "invalid string: control character U+000B (VT) must be escaped to \\u000B"; |
7581 | 0 | return token_type::parse_error; |
7582 | 0 | } |
7583 | | |
7584 | 0 | case 0x0C: |
7585 | 0 | { |
7586 | 0 | error_message = "invalid string: control character U+000C (FF) must be escaped to \\u000C or \\f"; |
7587 | 0 | return token_type::parse_error; |
7588 | 0 | } |
7589 | | |
7590 | 0 | case 0x0D: |
7591 | 0 | { |
7592 | 0 | error_message = "invalid string: control character U+000D (CR) must be escaped to \\u000D or \\r"; |
7593 | 0 | return token_type::parse_error; |
7594 | 0 | } |
7595 | | |
7596 | 0 | case 0x0E: |
7597 | 0 | { |
7598 | 0 | error_message = "invalid string: control character U+000E (SO) must be escaped to \\u000E"; |
7599 | 0 | return token_type::parse_error; |
7600 | 0 | } |
7601 | | |
7602 | 0 | case 0x0F: |
7603 | 0 | { |
7604 | 0 | error_message = "invalid string: control character U+000F (SI) must be escaped to \\u000F"; |
7605 | 0 | return token_type::parse_error; |
7606 | 0 | } |
7607 | | |
7608 | 0 | case 0x10: |
7609 | 0 | { |
7610 | 0 | error_message = "invalid string: control character U+0010 (DLE) must be escaped to \\u0010"; |
7611 | 0 | return token_type::parse_error; |
7612 | 0 | } |
7613 | | |
7614 | 0 | case 0x11: |
7615 | 0 | { |
7616 | 0 | error_message = "invalid string: control character U+0011 (DC1) must be escaped to \\u0011"; |
7617 | 0 | return token_type::parse_error; |
7618 | 0 | } |
7619 | | |
7620 | 0 | case 0x12: |
7621 | 0 | { |
7622 | 0 | error_message = "invalid string: control character U+0012 (DC2) must be escaped to \\u0012"; |
7623 | 0 | return token_type::parse_error; |
7624 | 0 | } |
7625 | | |
7626 | 0 | case 0x13: |
7627 | 0 | { |
7628 | 0 | error_message = "invalid string: control character U+0013 (DC3) must be escaped to \\u0013"; |
7629 | 0 | return token_type::parse_error; |
7630 | 0 | } |
7631 | | |
7632 | 0 | case 0x14: |
7633 | 0 | { |
7634 | 0 | error_message = "invalid string: control character U+0014 (DC4) must be escaped to \\u0014"; |
7635 | 0 | return token_type::parse_error; |
7636 | 0 | } |
7637 | | |
7638 | 0 | case 0x15: |
7639 | 0 | { |
7640 | 0 | error_message = "invalid string: control character U+0015 (NAK) must be escaped to \\u0015"; |
7641 | 0 | return token_type::parse_error; |
7642 | 0 | } |
7643 | | |
7644 | 0 | case 0x16: |
7645 | 0 | { |
7646 | 0 | error_message = "invalid string: control character U+0016 (SYN) must be escaped to \\u0016"; |
7647 | 0 | return token_type::parse_error; |
7648 | 0 | } |
7649 | | |
7650 | 0 | case 0x17: |
7651 | 0 | { |
7652 | 0 | error_message = "invalid string: control character U+0017 (ETB) must be escaped to \\u0017"; |
7653 | 0 | return token_type::parse_error; |
7654 | 0 | } |
7655 | | |
7656 | 0 | case 0x18: |
7657 | 0 | { |
7658 | 0 | error_message = "invalid string: control character U+0018 (CAN) must be escaped to \\u0018"; |
7659 | 0 | return token_type::parse_error; |
7660 | 0 | } |
7661 | | |
7662 | 0 | case 0x19: |
7663 | 0 | { |
7664 | 0 | error_message = "invalid string: control character U+0019 (EM) must be escaped to \\u0019"; |
7665 | 0 | return token_type::parse_error; |
7666 | 0 | } |
7667 | | |
7668 | 0 | case 0x1A: |
7669 | 0 | { |
7670 | 0 | error_message = "invalid string: control character U+001A (SUB) must be escaped to \\u001A"; |
7671 | 0 | return token_type::parse_error; |
7672 | 0 | } |
7673 | | |
7674 | 0 | case 0x1B: |
7675 | 0 | { |
7676 | 0 | error_message = "invalid string: control character U+001B (ESC) must be escaped to \\u001B"; |
7677 | 0 | return token_type::parse_error; |
7678 | 0 | } |
7679 | | |
7680 | 0 | case 0x1C: |
7681 | 0 | { |
7682 | 0 | error_message = "invalid string: control character U+001C (FS) must be escaped to \\u001C"; |
7683 | 0 | return token_type::parse_error; |
7684 | 0 | } |
7685 | | |
7686 | 0 | case 0x1D: |
7687 | 0 | { |
7688 | 0 | error_message = "invalid string: control character U+001D (GS) must be escaped to \\u001D"; |
7689 | 0 | return token_type::parse_error; |
7690 | 0 | } |
7691 | | |
7692 | 0 | case 0x1E: |
7693 | 0 | { |
7694 | 0 | error_message = "invalid string: control character U+001E (RS) must be escaped to \\u001E"; |
7695 | 0 | return token_type::parse_error; |
7696 | 0 | } |
7697 | | |
7698 | 0 | case 0x1F: |
7699 | 0 | { |
7700 | 0 | error_message = "invalid string: control character U+001F (US) must be escaped to \\u001F"; |
7701 | 0 | return token_type::parse_error; |
7702 | 0 | } |
7703 | | |
7704 | | // U+0020..U+007F (except U+0022 (quote) and U+005C (backspace)) |
7705 | 0 | case 0x20: |
7706 | 0 | case 0x21: |
7707 | 0 | case 0x23: |
7708 | 0 | case 0x24: |
7709 | 0 | case 0x25: |
7710 | 0 | case 0x26: |
7711 | 0 | case 0x27: |
7712 | 0 | case 0x28: |
7713 | 0 | case 0x29: |
7714 | 0 | case 0x2A: |
7715 | 0 | case 0x2B: |
7716 | 0 | case 0x2C: |
7717 | 0 | case 0x2D: |
7718 | 0 | case 0x2E: |
7719 | 0 | case 0x2F: |
7720 | 0 | case 0x30: |
7721 | 0 | case 0x31: |
7722 | 0 | case 0x32: |
7723 | 0 | case 0x33: |
7724 | 0 | case 0x34: |
7725 | 0 | case 0x35: |
7726 | 0 | case 0x36: |
7727 | 0 | case 0x37: |
7728 | 0 | case 0x38: |
7729 | 0 | case 0x39: |
7730 | 0 | case 0x3A: |
7731 | 0 | case 0x3B: |
7732 | 0 | case 0x3C: |
7733 | 0 | case 0x3D: |
7734 | 0 | case 0x3E: |
7735 | 0 | case 0x3F: |
7736 | 0 | case 0x40: |
7737 | 0 | case 0x41: |
7738 | 0 | case 0x42: |
7739 | 0 | case 0x43: |
7740 | 0 | case 0x44: |
7741 | 0 | case 0x45: |
7742 | 0 | case 0x46: |
7743 | 0 | case 0x47: |
7744 | 0 | case 0x48: |
7745 | 0 | case 0x49: |
7746 | 0 | case 0x4A: |
7747 | 0 | case 0x4B: |
7748 | 0 | case 0x4C: |
7749 | 0 | case 0x4D: |
7750 | 0 | case 0x4E: |
7751 | 0 | case 0x4F: |
7752 | 0 | case 0x50: |
7753 | 0 | case 0x51: |
7754 | 0 | case 0x52: |
7755 | 0 | case 0x53: |
7756 | 0 | case 0x54: |
7757 | 0 | case 0x55: |
7758 | 0 | case 0x56: |
7759 | 0 | case 0x57: |
7760 | 0 | case 0x58: |
7761 | 0 | case 0x59: |
7762 | 0 | case 0x5A: |
7763 | 0 | case 0x5B: |
7764 | 0 | case 0x5D: |
7765 | 0 | case 0x5E: |
7766 | 0 | case 0x5F: |
7767 | 0 | case 0x60: |
7768 | 0 | case 0x61: |
7769 | 0 | case 0x62: |
7770 | 0 | case 0x63: |
7771 | 0 | case 0x64: |
7772 | 0 | case 0x65: |
7773 | 0 | case 0x66: |
7774 | 0 | case 0x67: |
7775 | 0 | case 0x68: |
7776 | 0 | case 0x69: |
7777 | 0 | case 0x6A: |
7778 | 0 | case 0x6B: |
7779 | 0 | case 0x6C: |
7780 | 0 | case 0x6D: |
7781 | 0 | case 0x6E: |
7782 | 0 | case 0x6F: |
7783 | 0 | case 0x70: |
7784 | 0 | case 0x71: |
7785 | 0 | case 0x72: |
7786 | 0 | case 0x73: |
7787 | 0 | case 0x74: |
7788 | 0 | case 0x75: |
7789 | 0 | case 0x76: |
7790 | 0 | case 0x77: |
7791 | 0 | case 0x78: |
7792 | 0 | case 0x79: |
7793 | 0 | case 0x7A: |
7794 | 0 | case 0x7B: |
7795 | 0 | case 0x7C: |
7796 | 0 | case 0x7D: |
7797 | 0 | case 0x7E: |
7798 | 0 | case 0x7F: |
7799 | 0 | { |
7800 | 0 | add(current); |
7801 | 0 | break; |
7802 | 0 | } |
7803 | | |
7804 | | // U+0080..U+07FF: bytes C2..DF 80..BF |
7805 | 0 | case 0xC2: |
7806 | 0 | case 0xC3: |
7807 | 0 | case 0xC4: |
7808 | 0 | case 0xC5: |
7809 | 0 | case 0xC6: |
7810 | 0 | case 0xC7: |
7811 | 0 | case 0xC8: |
7812 | 0 | case 0xC9: |
7813 | 0 | case 0xCA: |
7814 | 0 | case 0xCB: |
7815 | 0 | case 0xCC: |
7816 | 0 | case 0xCD: |
7817 | 0 | case 0xCE: |
7818 | 0 | case 0xCF: |
7819 | 0 | case 0xD0: |
7820 | 0 | case 0xD1: |
7821 | 0 | case 0xD2: |
7822 | 0 | case 0xD3: |
7823 | 0 | case 0xD4: |
7824 | 0 | case 0xD5: |
7825 | 0 | case 0xD6: |
7826 | 0 | case 0xD7: |
7827 | 0 | case 0xD8: |
7828 | 0 | case 0xD9: |
7829 | 0 | case 0xDA: |
7830 | 0 | case 0xDB: |
7831 | 0 | case 0xDC: |
7832 | 0 | case 0xDD: |
7833 | 0 | case 0xDE: |
7834 | 0 | case 0xDF: |
7835 | 0 | { |
7836 | 0 | if (JSON_HEDLEY_UNLIKELY(!next_byte_in_range({0x80, 0xBF}))) |
7837 | 0 | { |
7838 | 0 | return token_type::parse_error; |
7839 | 0 | } |
7840 | 0 | break; |
7841 | 0 | } |
7842 | | |
7843 | | // U+0800..U+0FFF: bytes E0 A0..BF 80..BF |
7844 | 0 | case 0xE0: |
7845 | 0 | { |
7846 | 0 | if (JSON_HEDLEY_UNLIKELY(!(next_byte_in_range({0xA0, 0xBF, 0x80, 0xBF})))) |
7847 | 0 | { |
7848 | 0 | return token_type::parse_error; |
7849 | 0 | } |
7850 | 0 | break; |
7851 | 0 | } |
7852 | | |
7853 | | // U+1000..U+CFFF: bytes E1..EC 80..BF 80..BF |
7854 | | // U+E000..U+FFFF: bytes EE..EF 80..BF 80..BF |
7855 | 0 | case 0xE1: |
7856 | 0 | case 0xE2: |
7857 | 0 | case 0xE3: |
7858 | 0 | case 0xE4: |
7859 | 0 | case 0xE5: |
7860 | 0 | case 0xE6: |
7861 | 0 | case 0xE7: |
7862 | 0 | case 0xE8: |
7863 | 0 | case 0xE9: |
7864 | 0 | case 0xEA: |
7865 | 0 | case 0xEB: |
7866 | 0 | case 0xEC: |
7867 | 0 | case 0xEE: |
7868 | 0 | case 0xEF: |
7869 | 0 | { |
7870 | 0 | if (JSON_HEDLEY_UNLIKELY(!(next_byte_in_range({0x80, 0xBF, 0x80, 0xBF})))) |
7871 | 0 | { |
7872 | 0 | return token_type::parse_error; |
7873 | 0 | } |
7874 | 0 | break; |
7875 | 0 | } |
7876 | | |
7877 | | // U+D000..U+D7FF: bytes ED 80..9F 80..BF |
7878 | 0 | case 0xED: |
7879 | 0 | { |
7880 | 0 | if (JSON_HEDLEY_UNLIKELY(!(next_byte_in_range({0x80, 0x9F, 0x80, 0xBF})))) |
7881 | 0 | { |
7882 | 0 | return token_type::parse_error; |
7883 | 0 | } |
7884 | 0 | break; |
7885 | 0 | } |
7886 | | |
7887 | | // U+10000..U+3FFFF F0 90..BF 80..BF 80..BF |
7888 | 0 | case 0xF0: |
7889 | 0 | { |
7890 | 0 | if (JSON_HEDLEY_UNLIKELY(!(next_byte_in_range({0x90, 0xBF, 0x80, 0xBF, 0x80, 0xBF})))) |
7891 | 0 | { |
7892 | 0 | return token_type::parse_error; |
7893 | 0 | } |
7894 | 0 | break; |
7895 | 0 | } |
7896 | | |
7897 | | // U+40000..U+FFFFF F1..F3 80..BF 80..BF 80..BF |
7898 | 0 | case 0xF1: |
7899 | 0 | case 0xF2: |
7900 | 0 | case 0xF3: |
7901 | 0 | { |
7902 | 0 | if (JSON_HEDLEY_UNLIKELY(!(next_byte_in_range({0x80, 0xBF, 0x80, 0xBF, 0x80, 0xBF})))) |
7903 | 0 | { |
7904 | 0 | return token_type::parse_error; |
7905 | 0 | } |
7906 | 0 | break; |
7907 | 0 | } |
7908 | | |
7909 | | // U+100000..U+10FFFF F4 80..8F 80..BF 80..BF |
7910 | 0 | case 0xF4: |
7911 | 0 | { |
7912 | 0 | if (JSON_HEDLEY_UNLIKELY(!(next_byte_in_range({0x80, 0x8F, 0x80, 0xBF, 0x80, 0xBF})))) |
7913 | 0 | { |
7914 | 0 | return token_type::parse_error; |
7915 | 0 | } |
7916 | 0 | break; |
7917 | 0 | } |
7918 | | |
7919 | | // the remaining bytes (80..C1 and F5..FF) are ill-formed |
7920 | 0 | default: |
7921 | 0 | { |
7922 | 0 | error_message = "invalid string: ill-formed UTF-8 byte"; |
7923 | 0 | return token_type::parse_error; |
7924 | 0 | } |
7925 | 0 | } |
7926 | 0 | } |
7927 | 0 | } Unexecuted instantiation: nlohmann::json_abi_v3_12_0::detail::lexer<nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>, nlohmann::json_abi_v3_12_0::detail::iterator_input_adapter<char const*> >::scan_string() Unexecuted instantiation: nlohmann::json_abi_v3_12_0::detail::lexer<nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>, nlohmann::json_abi_v3_12_0::detail::input_stream_adapter>::scan_string() |
7928 | | |
7929 | | /*! |
7930 | | * @brief scan a comment |
7931 | | * @return whether comment could be scanned successfully |
7932 | | */ |
7933 | | bool scan_comment() |
7934 | 0 | { |
7935 | 0 | switch (get()) |
7936 | 0 | { |
7937 | | // single-line comments skip input until a newline or EOF is read |
7938 | 0 | case '/': |
7939 | 0 | { |
7940 | 0 | while (true) |
7941 | 0 | { |
7942 | 0 | switch (get()) |
7943 | 0 | { |
7944 | 0 | case '\n': |
7945 | 0 | case '\r': |
7946 | 0 | case char_traits<char_type>::eof(): |
7947 | 0 | case '\0': |
7948 | 0 | return true; |
7949 | | |
7950 | 0 | default: |
7951 | 0 | break; |
7952 | 0 | } |
7953 | 0 | } |
7954 | 0 | } |
7955 | | |
7956 | | // multi-line comments skip input until */ is read |
7957 | 0 | case '*': |
7958 | 0 | { |
7959 | 0 | while (true) |
7960 | 0 | { |
7961 | 0 | switch (get()) |
7962 | 0 | { |
7963 | 0 | case char_traits<char_type>::eof(): |
7964 | 0 | case '\0': |
7965 | 0 | { |
7966 | 0 | error_message = "invalid comment; missing closing '*/'"; |
7967 | 0 | return false; |
7968 | 0 | } |
7969 | | |
7970 | 0 | case '*': |
7971 | 0 | { |
7972 | 0 | switch (get()) |
7973 | 0 | { |
7974 | 0 | case '/': |
7975 | 0 | return true; |
7976 | | |
7977 | 0 | default: |
7978 | 0 | { |
7979 | 0 | unget(); |
7980 | 0 | continue; |
7981 | 0 | } |
7982 | 0 | } |
7983 | 0 | } |
7984 | | |
7985 | 0 | default: |
7986 | 0 | continue; |
7987 | 0 | } |
7988 | 0 | } |
7989 | 0 | } |
7990 | | |
7991 | | // unexpected character after reading '/' |
7992 | 0 | default: |
7993 | 0 | { |
7994 | 0 | error_message = "invalid comment; expecting '/' or '*' after '/'"; |
7995 | 0 | return false; |
7996 | 0 | } |
7997 | 0 | } |
7998 | 0 | } Unexecuted instantiation: nlohmann::json_abi_v3_12_0::detail::lexer<nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>, nlohmann::json_abi_v3_12_0::detail::iterator_input_adapter<char const*> >::scan_comment() Unexecuted instantiation: nlohmann::json_abi_v3_12_0::detail::lexer<nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>, nlohmann::json_abi_v3_12_0::detail::input_stream_adapter>::scan_comment() |
7999 | | |
8000 | | JSON_HEDLEY_NON_NULL(2) |
8001 | | static void strtof(float& f, const char* str, char** endptr) noexcept |
8002 | | { |
8003 | | f = std::strtof(str, endptr); |
8004 | | } |
8005 | | |
8006 | | JSON_HEDLEY_NON_NULL(2) |
8007 | | static void strtof(double& f, const char* str, char** endptr) noexcept |
8008 | 0 | { |
8009 | 0 | f = std::strtod(str, endptr); |
8010 | 0 | } Unexecuted instantiation: nlohmann::json_abi_v3_12_0::detail::lexer<nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>, nlohmann::json_abi_v3_12_0::detail::iterator_input_adapter<char const*> >::strtof(double&, char const*, char**) Unexecuted instantiation: nlohmann::json_abi_v3_12_0::detail::lexer<nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>, nlohmann::json_abi_v3_12_0::detail::input_stream_adapter>::strtof(double&, char const*, char**) |
8011 | | |
8012 | | JSON_HEDLEY_NON_NULL(2) |
8013 | | static void strtof(long double& f, const char* str, char** endptr) noexcept |
8014 | | { |
8015 | | f = std::strtold(str, endptr); |
8016 | | } |
8017 | | |
8018 | | /*! |
8019 | | @brief scan a number literal |
8020 | | |
8021 | | This function scans a string according to Sect. 6 of RFC 8259. |
8022 | | |
8023 | | The function is realized with a deterministic finite state machine derived |
8024 | | from the grammar described in RFC 8259. Starting in state "init", the |
8025 | | input is read and used to determined the next state. Only state "done" |
8026 | | accepts the number. State "error" is a trap state to model errors. In the |
8027 | | table below, "anything" means any character but the ones listed before. |
8028 | | |
8029 | | state | 0 | 1-9 | e E | + | - | . | anything |
8030 | | ---------|----------|----------|----------|---------|---------|----------|----------- |
8031 | | init | zero | any1 | [error] | [error] | minus | [error] | [error] |
8032 | | minus | zero | any1 | [error] | [error] | [error] | [error] | [error] |
8033 | | zero | done | done | exponent | done | done | decimal1 | done |
8034 | | any1 | any1 | any1 | exponent | done | done | decimal1 | done |
8035 | | decimal1 | decimal2 | decimal2 | [error] | [error] | [error] | [error] | [error] |
8036 | | decimal2 | decimal2 | decimal2 | exponent | done | done | done | done |
8037 | | exponent | any2 | any2 | [error] | sign | sign | [error] | [error] |
8038 | | sign | any2 | any2 | [error] | [error] | [error] | [error] | [error] |
8039 | | any2 | any2 | any2 | done | done | done | done | done |
8040 | | |
8041 | | The state machine is realized with one label per state (prefixed with |
8042 | | "scan_number_") and `goto` statements between them. The state machine |
8043 | | contains cycles, but any cycle can be left when EOF is read. Therefore, |
8044 | | the function is guaranteed to terminate. |
8045 | | |
8046 | | During scanning, the read bytes are stored in token_buffer. This string is |
8047 | | then converted to a signed integer, an unsigned integer, or a |
8048 | | floating-point number. |
8049 | | |
8050 | | @return token_type::value_unsigned, token_type::value_integer, or |
8051 | | token_type::value_float if number could be successfully scanned, |
8052 | | token_type::parse_error otherwise |
8053 | | |
8054 | | @note The scanner is independent of the current locale. Internally, the |
8055 | | locale's decimal point is used instead of `.` to work with the |
8056 | | locale-dependent converters. |
8057 | | */ |
8058 | | token_type scan_number() // lgtm [cpp/use-of-goto] `goto` is used in this function to implement the number-parsing state machine described above. By design, any finite input will eventually reach the "done" state or return token_type::parse_error. In each intermediate state, 1 byte of the input is appended to the token_buffer vector, and only the already initialized variables token_buffer, number_type, and error_message are manipulated. |
8059 | 0 | { |
8060 | | // reset token_buffer to store the number's bytes |
8061 | 0 | reset(); |
8062 | | |
8063 | | // the type of the parsed number; initially set to unsigned; will be |
8064 | | // changed if minus sign, decimal point, or exponent is read |
8065 | 0 | token_type number_type = token_type::value_unsigned; |
8066 | | |
8067 | | // state (init): we just found out we need to scan a number |
8068 | 0 | switch (current) |
8069 | 0 | { |
8070 | 0 | case '-': |
8071 | 0 | { |
8072 | 0 | add(current); |
8073 | 0 | goto scan_number_minus; |
8074 | 0 | } |
8075 | | |
8076 | 0 | case '0': |
8077 | 0 | { |
8078 | 0 | add(current); |
8079 | 0 | goto scan_number_zero; |
8080 | 0 | } |
8081 | | |
8082 | 0 | case '1': |
8083 | 0 | case '2': |
8084 | 0 | case '3': |
8085 | 0 | case '4': |
8086 | 0 | case '5': |
8087 | 0 | case '6': |
8088 | 0 | case '7': |
8089 | 0 | case '8': |
8090 | 0 | case '9': |
8091 | 0 | { |
8092 | 0 | add(current); |
8093 | 0 | goto scan_number_any1; |
8094 | 0 | } |
8095 | | |
8096 | | // all other characters are rejected outside scan_number() |
8097 | 0 | default: // LCOV_EXCL_LINE |
8098 | 0 | JSON_ASSERT(false); // NOLINT(cert-dcl03-c,hicpp-static-assert,misc-static-assert) LCOV_EXCL_LINE |
8099 | 0 | } |
8100 | | |
8101 | 0 | scan_number_minus: |
8102 | | // state: we just parsed a leading minus sign |
8103 | 0 | number_type = token_type::value_integer; |
8104 | 0 | switch (get()) |
8105 | 0 | { |
8106 | 0 | case '0': |
8107 | 0 | { |
8108 | 0 | add(current); |
8109 | 0 | goto scan_number_zero; |
8110 | 0 | } |
8111 | | |
8112 | 0 | case '1': |
8113 | 0 | case '2': |
8114 | 0 | case '3': |
8115 | 0 | case '4': |
8116 | 0 | case '5': |
8117 | 0 | case '6': |
8118 | 0 | case '7': |
8119 | 0 | case '8': |
8120 | 0 | case '9': |
8121 | 0 | { |
8122 | 0 | add(current); |
8123 | 0 | goto scan_number_any1; |
8124 | 0 | } |
8125 | | |
8126 | 0 | default: |
8127 | 0 | { |
8128 | 0 | error_message = "invalid number; expected digit after '-'"; |
8129 | 0 | return token_type::parse_error; |
8130 | 0 | } |
8131 | 0 | } |
8132 | | |
8133 | 0 | scan_number_zero: |
8134 | | // state: we just parse a zero (maybe with a leading minus sign) |
8135 | 0 | switch (get()) |
8136 | 0 | { |
8137 | 0 | case '.': |
8138 | 0 | { |
8139 | 0 | add(decimal_point_char); |
8140 | 0 | decimal_point_position = token_buffer.size() - 1; |
8141 | 0 | goto scan_number_decimal1; |
8142 | 0 | } |
8143 | | |
8144 | 0 | case 'e': |
8145 | 0 | case 'E': |
8146 | 0 | { |
8147 | 0 | add(current); |
8148 | 0 | goto scan_number_exponent; |
8149 | 0 | } |
8150 | | |
8151 | 0 | default: |
8152 | 0 | goto scan_number_done; |
8153 | 0 | } |
8154 | | |
8155 | 0 | scan_number_any1: |
8156 | | // state: we just parsed a number 0-9 (maybe with a leading minus sign) |
8157 | 0 | switch (get()) |
8158 | 0 | { |
8159 | 0 | case '0': |
8160 | 0 | case '1': |
8161 | 0 | case '2': |
8162 | 0 | case '3': |
8163 | 0 | case '4': |
8164 | 0 | case '5': |
8165 | 0 | case '6': |
8166 | 0 | case '7': |
8167 | 0 | case '8': |
8168 | 0 | case '9': |
8169 | 0 | { |
8170 | 0 | add(current); |
8171 | 0 | goto scan_number_any1; |
8172 | 0 | } |
8173 | | |
8174 | 0 | case '.': |
8175 | 0 | { |
8176 | 0 | add(decimal_point_char); |
8177 | 0 | decimal_point_position = token_buffer.size() - 1; |
8178 | 0 | goto scan_number_decimal1; |
8179 | 0 | } |
8180 | | |
8181 | 0 | case 'e': |
8182 | 0 | case 'E': |
8183 | 0 | { |
8184 | 0 | add(current); |
8185 | 0 | goto scan_number_exponent; |
8186 | 0 | } |
8187 | | |
8188 | 0 | default: |
8189 | 0 | goto scan_number_done; |
8190 | 0 | } |
8191 | | |
8192 | 0 | scan_number_decimal1: |
8193 | | // state: we just parsed a decimal point |
8194 | 0 | number_type = token_type::value_float; |
8195 | 0 | switch (get()) |
8196 | 0 | { |
8197 | 0 | case '0': |
8198 | 0 | case '1': |
8199 | 0 | case '2': |
8200 | 0 | case '3': |
8201 | 0 | case '4': |
8202 | 0 | case '5': |
8203 | 0 | case '6': |
8204 | 0 | case '7': |
8205 | 0 | case '8': |
8206 | 0 | case '9': |
8207 | 0 | { |
8208 | 0 | add(current); |
8209 | 0 | goto scan_number_decimal2; |
8210 | 0 | } |
8211 | | |
8212 | 0 | default: |
8213 | 0 | { |
8214 | 0 | error_message = "invalid number; expected digit after '.'"; |
8215 | 0 | return token_type::parse_error; |
8216 | 0 | } |
8217 | 0 | } |
8218 | | |
8219 | 0 | scan_number_decimal2: |
8220 | | // we just parsed at least one number after a decimal point |
8221 | 0 | switch (get()) |
8222 | 0 | { |
8223 | 0 | case '0': |
8224 | 0 | case '1': |
8225 | 0 | case '2': |
8226 | 0 | case '3': |
8227 | 0 | case '4': |
8228 | 0 | case '5': |
8229 | 0 | case '6': |
8230 | 0 | case '7': |
8231 | 0 | case '8': |
8232 | 0 | case '9': |
8233 | 0 | { |
8234 | 0 | add(current); |
8235 | 0 | goto scan_number_decimal2; |
8236 | 0 | } |
8237 | | |
8238 | 0 | case 'e': |
8239 | 0 | case 'E': |
8240 | 0 | { |
8241 | 0 | add(current); |
8242 | 0 | goto scan_number_exponent; |
8243 | 0 | } |
8244 | | |
8245 | 0 | default: |
8246 | 0 | goto scan_number_done; |
8247 | 0 | } |
8248 | | |
8249 | 0 | scan_number_exponent: |
8250 | | // we just parsed an exponent |
8251 | 0 | number_type = token_type::value_float; |
8252 | 0 | switch (get()) |
8253 | 0 | { |
8254 | 0 | case '+': |
8255 | 0 | case '-': |
8256 | 0 | { |
8257 | 0 | add(current); |
8258 | 0 | goto scan_number_sign; |
8259 | 0 | } |
8260 | | |
8261 | 0 | case '0': |
8262 | 0 | case '1': |
8263 | 0 | case '2': |
8264 | 0 | case '3': |
8265 | 0 | case '4': |
8266 | 0 | case '5': |
8267 | 0 | case '6': |
8268 | 0 | case '7': |
8269 | 0 | case '8': |
8270 | 0 | case '9': |
8271 | 0 | { |
8272 | 0 | add(current); |
8273 | 0 | goto scan_number_any2; |
8274 | 0 | } |
8275 | | |
8276 | 0 | default: |
8277 | 0 | { |
8278 | 0 | error_message = |
8279 | 0 | "invalid number; expected '+', '-', or digit after exponent"; |
8280 | 0 | return token_type::parse_error; |
8281 | 0 | } |
8282 | 0 | } |
8283 | | |
8284 | 0 | scan_number_sign: |
8285 | | // we just parsed an exponent sign |
8286 | 0 | switch (get()) |
8287 | 0 | { |
8288 | 0 | case '0': |
8289 | 0 | case '1': |
8290 | 0 | case '2': |
8291 | 0 | case '3': |
8292 | 0 | case '4': |
8293 | 0 | case '5': |
8294 | 0 | case '6': |
8295 | 0 | case '7': |
8296 | 0 | case '8': |
8297 | 0 | case '9': |
8298 | 0 | { |
8299 | 0 | add(current); |
8300 | 0 | goto scan_number_any2; |
8301 | 0 | } |
8302 | | |
8303 | 0 | default: |
8304 | 0 | { |
8305 | 0 | error_message = "invalid number; expected digit after exponent sign"; |
8306 | 0 | return token_type::parse_error; |
8307 | 0 | } |
8308 | 0 | } |
8309 | | |
8310 | 0 | scan_number_any2: |
8311 | | // we just parsed a number after the exponent or exponent sign |
8312 | 0 | switch (get()) |
8313 | 0 | { |
8314 | 0 | case '0': |
8315 | 0 | case '1': |
8316 | 0 | case '2': |
8317 | 0 | case '3': |
8318 | 0 | case '4': |
8319 | 0 | case '5': |
8320 | 0 | case '6': |
8321 | 0 | case '7': |
8322 | 0 | case '8': |
8323 | 0 | case '9': |
8324 | 0 | { |
8325 | 0 | add(current); |
8326 | 0 | goto scan_number_any2; |
8327 | 0 | } |
8328 | | |
8329 | 0 | default: |
8330 | 0 | goto scan_number_done; |
8331 | 0 | } |
8332 | | |
8333 | 0 | scan_number_done: |
8334 | | // unget the character after the number (we only read it to know that |
8335 | | // we are done scanning a number) |
8336 | 0 | unget(); |
8337 | |
|
8338 | 0 | char* endptr = nullptr; // NOLINT(misc-const-correctness,cppcoreguidelines-pro-type-vararg,hicpp-vararg) |
8339 | 0 | errno = 0; |
8340 | | |
8341 | | // try to parse integers first and fall back to floats |
8342 | 0 | if (number_type == token_type::value_unsigned) |
8343 | 0 | { |
8344 | 0 | const auto x = std::strtoull(token_buffer.data(), &endptr, 10); |
8345 | | |
8346 | | // we checked the number format before |
8347 | 0 | JSON_ASSERT(endptr == token_buffer.data() + token_buffer.size()); |
8348 | | |
8349 | 0 | if (errno != ERANGE) |
8350 | 0 | { |
8351 | 0 | value_unsigned = static_cast<number_unsigned_t>(x); |
8352 | 0 | if (value_unsigned == x) |
8353 | 0 | { |
8354 | 0 | return token_type::value_unsigned; |
8355 | 0 | } |
8356 | 0 | } |
8357 | 0 | } |
8358 | 0 | else if (number_type == token_type::value_integer) |
8359 | 0 | { |
8360 | 0 | const auto x = std::strtoll(token_buffer.data(), &endptr, 10); |
8361 | | |
8362 | | // we checked the number format before |
8363 | 0 | JSON_ASSERT(endptr == token_buffer.data() + token_buffer.size()); |
8364 | | |
8365 | 0 | if (errno != ERANGE) |
8366 | 0 | { |
8367 | 0 | value_integer = static_cast<number_integer_t>(x); |
8368 | 0 | if (value_integer == x) |
8369 | 0 | { |
8370 | 0 | return token_type::value_integer; |
8371 | 0 | } |
8372 | 0 | } |
8373 | 0 | } |
8374 | | |
8375 | | // this code is reached if we parse a floating-point number or if an |
8376 | | // integer conversion above failed |
8377 | 0 | strtof(value_float, token_buffer.data(), &endptr); |
8378 | | |
8379 | | // we checked the number format before |
8380 | 0 | JSON_ASSERT(endptr == token_buffer.data() + token_buffer.size()); |
8381 | | |
8382 | 0 | return token_type::value_float; |
8383 | 0 | } Unexecuted instantiation: nlohmann::json_abi_v3_12_0::detail::lexer<nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>, nlohmann::json_abi_v3_12_0::detail::iterator_input_adapter<char const*> >::scan_number() Unexecuted instantiation: nlohmann::json_abi_v3_12_0::detail::lexer<nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>, nlohmann::json_abi_v3_12_0::detail::input_stream_adapter>::scan_number() |
8384 | | |
8385 | | /*! |
8386 | | @param[in] literal_text the literal text to expect |
8387 | | @param[in] length the length of the passed literal text |
8388 | | @param[in] return_type the token type to return on success |
8389 | | */ |
8390 | | JSON_HEDLEY_NON_NULL(2) |
8391 | | token_type scan_literal(const char_type* literal_text, const std::size_t length, |
8392 | | token_type return_type) |
8393 | 0 | { |
8394 | 0 | JSON_ASSERT(char_traits<char_type>::to_char_type(current) == literal_text[0]); |
8395 | 0 | for (std::size_t i = 1; i < length; ++i) |
8396 | 0 | { |
8397 | 0 | if (JSON_HEDLEY_UNLIKELY(char_traits<char_type>::to_char_type(get()) != literal_text[i])) |
8398 | 0 | { |
8399 | 0 | error_message = "invalid literal"; |
8400 | 0 | return token_type::parse_error; |
8401 | 0 | } |
8402 | 0 | } |
8403 | 0 | return return_type; |
8404 | 0 | } Unexecuted instantiation: nlohmann::json_abi_v3_12_0::detail::lexer<nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>, nlohmann::json_abi_v3_12_0::detail::iterator_input_adapter<char const*> >::scan_literal(char const*, unsigned long, nlohmann::json_abi_v3_12_0::detail::lexer_base<nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void> >::token_type) Unexecuted instantiation: nlohmann::json_abi_v3_12_0::detail::lexer<nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>, nlohmann::json_abi_v3_12_0::detail::input_stream_adapter>::scan_literal(char const*, unsigned long, nlohmann::json_abi_v3_12_0::detail::lexer_base<nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void> >::token_type) |
8405 | | |
8406 | | ///////////////////// |
8407 | | // input management |
8408 | | ///////////////////// |
8409 | | |
8410 | | /// reset token_buffer; current character is beginning of token |
8411 | | void reset() noexcept |
8412 | 0 | { |
8413 | 0 | token_buffer.clear(); |
8414 | 0 | token_string.clear(); |
8415 | 0 | decimal_point_position = std::string::npos; |
8416 | 0 | token_string.push_back(char_traits<char_type>::to_char_type(current)); |
8417 | 0 | } Unexecuted instantiation: nlohmann::json_abi_v3_12_0::detail::lexer<nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>, nlohmann::json_abi_v3_12_0::detail::iterator_input_adapter<char const*> >::reset() Unexecuted instantiation: nlohmann::json_abi_v3_12_0::detail::lexer<nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>, nlohmann::json_abi_v3_12_0::detail::input_stream_adapter>::reset() |
8418 | | |
8419 | | /* |
8420 | | @brief get next character from the input |
8421 | | |
8422 | | This function provides the interface to the used input adapter. It does |
8423 | | not throw in case the input reached EOF, but returns a |
8424 | | `char_traits<char>::eof()` in that case. Stores the scanned characters |
8425 | | for use in error messages. |
8426 | | |
8427 | | @return character read from the input |
8428 | | */ |
8429 | | char_int_type get() |
8430 | 0 | { |
8431 | 0 | ++position.chars_read_total; |
8432 | 0 | ++position.chars_read_current_line; |
8433 | |
|
8434 | 0 | if (next_unget) |
8435 | 0 | { |
8436 | | // only reset the next_unget variable and work with current |
8437 | 0 | next_unget = false; |
8438 | 0 | } |
8439 | 0 | else |
8440 | 0 | { |
8441 | 0 | current = ia.get_character(); |
8442 | 0 | } |
8443 | |
|
8444 | 0 | if (JSON_HEDLEY_LIKELY(current != char_traits<char_type>::eof())) |
8445 | 0 | { |
8446 | 0 | token_string.push_back(char_traits<char_type>::to_char_type(current)); |
8447 | 0 | } |
8448 | |
|
8449 | 0 | if (current == '\n') |
8450 | 0 | { |
8451 | 0 | ++position.lines_read; |
8452 | 0 | position.chars_read_current_line = 0; |
8453 | 0 | } |
8454 | |
|
8455 | 0 | return current; |
8456 | 0 | } Unexecuted instantiation: nlohmann::json_abi_v3_12_0::detail::lexer<nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>, nlohmann::json_abi_v3_12_0::detail::iterator_input_adapter<char const*> >::get() Unexecuted instantiation: nlohmann::json_abi_v3_12_0::detail::lexer<nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>, nlohmann::json_abi_v3_12_0::detail::input_stream_adapter>::get() |
8457 | | |
8458 | | /*! |
8459 | | @brief unget current character (read it again on next get) |
8460 | | |
8461 | | We implement unget by setting variable next_unget to true. The input is not |
8462 | | changed - we just simulate ungetting by modifying chars_read_total, |
8463 | | chars_read_current_line, and token_string. The next call to get() will |
8464 | | behave as if the unget character is read again. |
8465 | | */ |
8466 | | void unget() |
8467 | 0 | { |
8468 | 0 | next_unget = true; |
8469 | |
|
8470 | 0 | --position.chars_read_total; |
8471 | | |
8472 | | // in case we "unget" a newline, we have to also decrement the lines_read |
8473 | 0 | if (position.chars_read_current_line == 0) |
8474 | 0 | { |
8475 | 0 | if (position.lines_read > 0) |
8476 | 0 | { |
8477 | 0 | --position.lines_read; |
8478 | 0 | } |
8479 | 0 | } |
8480 | 0 | else |
8481 | 0 | { |
8482 | 0 | --position.chars_read_current_line; |
8483 | 0 | } |
8484 | |
|
8485 | 0 | if (JSON_HEDLEY_LIKELY(current != char_traits<char_type>::eof())) |
8486 | 0 | { |
8487 | 0 | JSON_ASSERT(!token_string.empty()); |
8488 | 0 | token_string.pop_back(); |
8489 | 0 | } |
8490 | 0 | } Unexecuted instantiation: nlohmann::json_abi_v3_12_0::detail::lexer<nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>, nlohmann::json_abi_v3_12_0::detail::iterator_input_adapter<char const*> >::unget() Unexecuted instantiation: nlohmann::json_abi_v3_12_0::detail::lexer<nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>, nlohmann::json_abi_v3_12_0::detail::input_stream_adapter>::unget() |
8491 | | |
8492 | | /// add a character to token_buffer |
8493 | | void add(char_int_type c) |
8494 | 0 | { |
8495 | 0 | token_buffer.push_back(static_cast<typename string_t::value_type>(c)); |
8496 | 0 | } Unexecuted instantiation: nlohmann::json_abi_v3_12_0::detail::lexer<nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>, nlohmann::json_abi_v3_12_0::detail::iterator_input_adapter<char const*> >::add(int) Unexecuted instantiation: nlohmann::json_abi_v3_12_0::detail::lexer<nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>, nlohmann::json_abi_v3_12_0::detail::input_stream_adapter>::add(int) |
8497 | | |
8498 | | public: |
8499 | | ///////////////////// |
8500 | | // value getters |
8501 | | ///////////////////// |
8502 | | |
8503 | | /// return integer value |
8504 | | constexpr number_integer_t get_number_integer() const noexcept |
8505 | 0 | { |
8506 | 0 | return value_integer; |
8507 | 0 | } Unexecuted instantiation: nlohmann::json_abi_v3_12_0::detail::lexer<nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>, nlohmann::json_abi_v3_12_0::detail::iterator_input_adapter<char const*> >::get_number_integer() const Unexecuted instantiation: nlohmann::json_abi_v3_12_0::detail::lexer<nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>, nlohmann::json_abi_v3_12_0::detail::input_stream_adapter>::get_number_integer() const |
8508 | | |
8509 | | /// return unsigned integer value |
8510 | | constexpr number_unsigned_t get_number_unsigned() const noexcept |
8511 | 0 | { |
8512 | 0 | return value_unsigned; |
8513 | 0 | } Unexecuted instantiation: nlohmann::json_abi_v3_12_0::detail::lexer<nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>, nlohmann::json_abi_v3_12_0::detail::iterator_input_adapter<char const*> >::get_number_unsigned() const Unexecuted instantiation: nlohmann::json_abi_v3_12_0::detail::lexer<nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>, nlohmann::json_abi_v3_12_0::detail::input_stream_adapter>::get_number_unsigned() const |
8514 | | |
8515 | | /// return floating-point value |
8516 | | constexpr number_float_t get_number_float() const noexcept |
8517 | 0 | { |
8518 | 0 | return value_float; |
8519 | 0 | } Unexecuted instantiation: nlohmann::json_abi_v3_12_0::detail::lexer<nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>, nlohmann::json_abi_v3_12_0::detail::iterator_input_adapter<char const*> >::get_number_float() const Unexecuted instantiation: nlohmann::json_abi_v3_12_0::detail::lexer<nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>, nlohmann::json_abi_v3_12_0::detail::input_stream_adapter>::get_number_float() const |
8520 | | |
8521 | | /// return current string value (implicitly resets the token; useful only once) |
8522 | | string_t& get_string() |
8523 | 0 | { |
8524 | | // translate decimal points from locale back to '.' (#4084) |
8525 | 0 | if (decimal_point_char != '.' && decimal_point_position != std::string::npos) |
8526 | 0 | { |
8527 | 0 | token_buffer[decimal_point_position] = '.'; |
8528 | 0 | } |
8529 | 0 | return token_buffer; |
8530 | 0 | } Unexecuted instantiation: nlohmann::json_abi_v3_12_0::detail::lexer<nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>, nlohmann::json_abi_v3_12_0::detail::iterator_input_adapter<char const*> >::get_string() Unexecuted instantiation: nlohmann::json_abi_v3_12_0::detail::lexer<nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>, nlohmann::json_abi_v3_12_0::detail::input_stream_adapter>::get_string() |
8531 | | |
8532 | | ///////////////////// |
8533 | | // diagnostics |
8534 | | ///////////////////// |
8535 | | |
8536 | | /// return position of last read token |
8537 | | constexpr position_t get_position() const noexcept |
8538 | 0 | { |
8539 | 0 | return position; |
8540 | 0 | } Unexecuted instantiation: nlohmann::json_abi_v3_12_0::detail::lexer<nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>, nlohmann::json_abi_v3_12_0::detail::iterator_input_adapter<char const*> >::get_position() const Unexecuted instantiation: nlohmann::json_abi_v3_12_0::detail::lexer<nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>, nlohmann::json_abi_v3_12_0::detail::input_stream_adapter>::get_position() const |
8541 | | |
8542 | | /// return the last read token (for errors only). Will never contain EOF |
8543 | | /// (an arbitrary value that is not a valid char value, often -1), because |
8544 | | /// 255 may legitimately occur. May contain NUL, which should be escaped. |
8545 | | std::string get_token_string() const |
8546 | 0 | { |
8547 | | // escape control characters |
8548 | 0 | std::string result; |
8549 | 0 | for (const auto c : token_string) |
8550 | 0 | { |
8551 | 0 | if (static_cast<unsigned char>(c) <= '\x1F') |
8552 | 0 | { |
8553 | | // escape control characters |
8554 | 0 | std::array<char, 9> cs{{}}; |
8555 | 0 | static_cast<void>((std::snprintf)(cs.data(), cs.size(), "<U+%.4X>", static_cast<unsigned char>(c))); // NOLINT(cppcoreguidelines-pro-type-vararg,hicpp-vararg) |
8556 | 0 | result += cs.data(); |
8557 | 0 | } |
8558 | 0 | else |
8559 | 0 | { |
8560 | | // add character as is |
8561 | 0 | result.push_back(static_cast<std::string::value_type>(c)); |
8562 | 0 | } |
8563 | 0 | } |
8564 | |
|
8565 | 0 | return result; |
8566 | 0 | } Unexecuted instantiation: nlohmann::json_abi_v3_12_0::detail::lexer<nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>, nlohmann::json_abi_v3_12_0::detail::iterator_input_adapter<char const*> >::get_token_string() const Unexecuted instantiation: nlohmann::json_abi_v3_12_0::detail::lexer<nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>, nlohmann::json_abi_v3_12_0::detail::input_stream_adapter>::get_token_string() const |
8567 | | |
8568 | | /// return syntax error message |
8569 | | JSON_HEDLEY_RETURNS_NON_NULL |
8570 | | constexpr const char* get_error_message() const noexcept |
8571 | 0 | { |
8572 | 0 | return error_message; |
8573 | 0 | } Unexecuted instantiation: nlohmann::json_abi_v3_12_0::detail::lexer<nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>, nlohmann::json_abi_v3_12_0::detail::iterator_input_adapter<char const*> >::get_error_message() const Unexecuted instantiation: nlohmann::json_abi_v3_12_0::detail::lexer<nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>, nlohmann::json_abi_v3_12_0::detail::input_stream_adapter>::get_error_message() const |
8574 | | |
8575 | | ///////////////////// |
8576 | | // actual scanner |
8577 | | ///////////////////// |
8578 | | |
8579 | | /*! |
8580 | | @brief skip the UTF-8 byte order mark |
8581 | | @return true iff there is no BOM or the correct BOM has been skipped |
8582 | | */ |
8583 | | bool skip_bom() |
8584 | 0 | { |
8585 | 0 | if (get() == 0xEF) |
8586 | 0 | { |
8587 | | // check if we completely parse the BOM |
8588 | 0 | return get() == 0xBB && get() == 0xBF; |
8589 | 0 | } |
8590 | | |
8591 | | // the first character is not the beginning of the BOM; unget it to |
8592 | | // process is later |
8593 | 0 | unget(); |
8594 | 0 | return true; |
8595 | 0 | } Unexecuted instantiation: nlohmann::json_abi_v3_12_0::detail::lexer<nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>, nlohmann::json_abi_v3_12_0::detail::iterator_input_adapter<char const*> >::skip_bom() Unexecuted instantiation: nlohmann::json_abi_v3_12_0::detail::lexer<nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>, nlohmann::json_abi_v3_12_0::detail::input_stream_adapter>::skip_bom() |
8596 | | |
8597 | | void skip_whitespace() |
8598 | 0 | { |
8599 | 0 | do |
8600 | 0 | { |
8601 | 0 | get(); |
8602 | 0 | } |
8603 | 0 | while (current == ' ' || current == '\t' || current == '\n' || current == '\r'); |
8604 | 0 | } Unexecuted instantiation: nlohmann::json_abi_v3_12_0::detail::lexer<nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>, nlohmann::json_abi_v3_12_0::detail::iterator_input_adapter<char const*> >::skip_whitespace() Unexecuted instantiation: nlohmann::json_abi_v3_12_0::detail::lexer<nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>, nlohmann::json_abi_v3_12_0::detail::input_stream_adapter>::skip_whitespace() |
8605 | | |
8606 | | token_type scan() |
8607 | 0 | { |
8608 | | // initially, skip the BOM |
8609 | 0 | if (position.chars_read_total == 0 && !skip_bom()) |
8610 | 0 | { |
8611 | 0 | error_message = "invalid BOM; must be 0xEF 0xBB 0xBF if given"; |
8612 | 0 | return token_type::parse_error; |
8613 | 0 | } |
8614 | | |
8615 | | // read the next character and ignore whitespace |
8616 | 0 | skip_whitespace(); |
8617 | | |
8618 | | // ignore comments |
8619 | 0 | while (ignore_comments && current == '/') |
8620 | 0 | { |
8621 | 0 | if (!scan_comment()) |
8622 | 0 | { |
8623 | 0 | return token_type::parse_error; |
8624 | 0 | } |
8625 | | |
8626 | | // skip following whitespace |
8627 | 0 | skip_whitespace(); |
8628 | 0 | } |
8629 | | |
8630 | 0 | switch (current) |
8631 | 0 | { |
8632 | | // structural characters |
8633 | 0 | case '[': |
8634 | 0 | return token_type::begin_array; |
8635 | 0 | case ']': |
8636 | 0 | return token_type::end_array; |
8637 | 0 | case '{': |
8638 | 0 | return token_type::begin_object; |
8639 | 0 | case '}': |
8640 | 0 | return token_type::end_object; |
8641 | 0 | case ':': |
8642 | 0 | return token_type::name_separator; |
8643 | 0 | case ',': |
8644 | 0 | return token_type::value_separator; |
8645 | | |
8646 | | // literals |
8647 | 0 | case 't': |
8648 | 0 | { |
8649 | 0 | std::array<char_type, 4> true_literal = {{static_cast<char_type>('t'), static_cast<char_type>('r'), static_cast<char_type>('u'), static_cast<char_type>('e')}}; |
8650 | 0 | return scan_literal(true_literal.data(), true_literal.size(), token_type::literal_true); |
8651 | 0 | } |
8652 | 0 | case 'f': |
8653 | 0 | { |
8654 | 0 | std::array<char_type, 5> false_literal = {{static_cast<char_type>('f'), static_cast<char_type>('a'), static_cast<char_type>('l'), static_cast<char_type>('s'), static_cast<char_type>('e')}}; |
8655 | 0 | return scan_literal(false_literal.data(), false_literal.size(), token_type::literal_false); |
8656 | 0 | } |
8657 | 0 | case 'n': |
8658 | 0 | { |
8659 | 0 | std::array<char_type, 4> null_literal = {{static_cast<char_type>('n'), static_cast<char_type>('u'), static_cast<char_type>('l'), static_cast<char_type>('l')}}; |
8660 | 0 | return scan_literal(null_literal.data(), null_literal.size(), token_type::literal_null); |
8661 | 0 | } |
8662 | | |
8663 | | // string |
8664 | 0 | case '\"': |
8665 | 0 | return scan_string(); |
8666 | | |
8667 | | // number |
8668 | 0 | case '-': |
8669 | 0 | case '0': |
8670 | 0 | case '1': |
8671 | 0 | case '2': |
8672 | 0 | case '3': |
8673 | 0 | case '4': |
8674 | 0 | case '5': |
8675 | 0 | case '6': |
8676 | 0 | case '7': |
8677 | 0 | case '8': |
8678 | 0 | case '9': |
8679 | 0 | return scan_number(); |
8680 | | |
8681 | | // end of input (the null byte is needed when parsing from |
8682 | | // string literals) |
8683 | 0 | case '\0': |
8684 | 0 | case char_traits<char_type>::eof(): |
8685 | 0 | return token_type::end_of_input; |
8686 | | |
8687 | | // error |
8688 | 0 | default: |
8689 | 0 | error_message = "invalid literal"; |
8690 | 0 | return token_type::parse_error; |
8691 | 0 | } |
8692 | 0 | } Unexecuted instantiation: nlohmann::json_abi_v3_12_0::detail::lexer<nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>, nlohmann::json_abi_v3_12_0::detail::iterator_input_adapter<char const*> >::scan() Unexecuted instantiation: nlohmann::json_abi_v3_12_0::detail::lexer<nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>, nlohmann::json_abi_v3_12_0::detail::input_stream_adapter>::scan() |
8693 | | |
8694 | | private: |
8695 | | /// input adapter |
8696 | | InputAdapterType ia; |
8697 | | |
8698 | | /// whether comments should be ignored (true) or signaled as errors (false) |
8699 | | const bool ignore_comments = false; |
8700 | | |
8701 | | /// the current character |
8702 | | char_int_type current = char_traits<char_type>::eof(); |
8703 | | |
8704 | | /// whether the next get() call should just return current |
8705 | | bool next_unget = false; |
8706 | | |
8707 | | /// the start position of the current token |
8708 | | position_t position {}; |
8709 | | |
8710 | | /// raw input token string (for error messages) |
8711 | | std::vector<char_type> token_string {}; |
8712 | | |
8713 | | /// buffer for variable-length tokens (numbers, strings) |
8714 | | string_t token_buffer {}; |
8715 | | |
8716 | | /// a description of occurred lexer errors |
8717 | | const char* error_message = ""; |
8718 | | |
8719 | | // number values |
8720 | | number_integer_t value_integer = 0; |
8721 | | number_unsigned_t value_unsigned = 0; |
8722 | | number_float_t value_float = 0; |
8723 | | |
8724 | | /// the decimal point |
8725 | | const char_int_type decimal_point_char = '.'; |
8726 | | /// the position of the decimal point in the input |
8727 | | std::size_t decimal_point_position = std::string::npos; |
8728 | | }; |
8729 | | |
8730 | | } // namespace detail |
8731 | | NLOHMANN_JSON_NAMESPACE_END |
8732 | | |
8733 | | // #include <nlohmann/detail/macro_scope.hpp> |
8734 | | |
8735 | | // #include <nlohmann/detail/string_concat.hpp> |
8736 | | |
8737 | | NLOHMANN_JSON_NAMESPACE_BEGIN |
8738 | | |
8739 | | /*! |
8740 | | @brief SAX interface |
8741 | | |
8742 | | This class describes the SAX interface used by @ref nlohmann::json::sax_parse. |
8743 | | Each function is called in different situations while the input is parsed. The |
8744 | | boolean return value informs the parser whether to continue processing the |
8745 | | input. |
8746 | | */ |
8747 | | template<typename BasicJsonType> |
8748 | | struct json_sax |
8749 | | { |
8750 | | using number_integer_t = typename BasicJsonType::number_integer_t; |
8751 | | using number_unsigned_t = typename BasicJsonType::number_unsigned_t; |
8752 | | using number_float_t = typename BasicJsonType::number_float_t; |
8753 | | using string_t = typename BasicJsonType::string_t; |
8754 | | using binary_t = typename BasicJsonType::binary_t; |
8755 | | |
8756 | | /*! |
8757 | | @brief a null value was read |
8758 | | @return whether parsing should proceed |
8759 | | */ |
8760 | | virtual bool null() = 0; |
8761 | | |
8762 | | /*! |
8763 | | @brief a boolean value was read |
8764 | | @param[in] val boolean value |
8765 | | @return whether parsing should proceed |
8766 | | */ |
8767 | | virtual bool boolean(bool val) = 0; |
8768 | | |
8769 | | /*! |
8770 | | @brief an integer number was read |
8771 | | @param[in] val integer value |
8772 | | @return whether parsing should proceed |
8773 | | */ |
8774 | | virtual bool number_integer(number_integer_t val) = 0; |
8775 | | |
8776 | | /*! |
8777 | | @brief an unsigned integer number was read |
8778 | | @param[in] val unsigned integer value |
8779 | | @return whether parsing should proceed |
8780 | | */ |
8781 | | virtual bool number_unsigned(number_unsigned_t val) = 0; |
8782 | | |
8783 | | /*! |
8784 | | @brief a floating-point number was read |
8785 | | @param[in] val floating-point value |
8786 | | @param[in] s raw token value |
8787 | | @return whether parsing should proceed |
8788 | | */ |
8789 | | virtual bool number_float(number_float_t val, const string_t& s) = 0; |
8790 | | |
8791 | | /*! |
8792 | | @brief a string value was read |
8793 | | @param[in] val string value |
8794 | | @return whether parsing should proceed |
8795 | | @note It is safe to move the passed string value. |
8796 | | */ |
8797 | | virtual bool string(string_t& val) = 0; |
8798 | | |
8799 | | /*! |
8800 | | @brief a binary value was read |
8801 | | @param[in] val binary value |
8802 | | @return whether parsing should proceed |
8803 | | @note It is safe to move the passed binary value. |
8804 | | */ |
8805 | | virtual bool binary(binary_t& val) = 0; |
8806 | | |
8807 | | /*! |
8808 | | @brief the beginning of an object was read |
8809 | | @param[in] elements number of object elements or -1 if unknown |
8810 | | @return whether parsing should proceed |
8811 | | @note binary formats may report the number of elements |
8812 | | */ |
8813 | | virtual bool start_object(std::size_t elements) = 0; |
8814 | | |
8815 | | /*! |
8816 | | @brief an object key was read |
8817 | | @param[in] val object key |
8818 | | @return whether parsing should proceed |
8819 | | @note It is safe to move the passed string. |
8820 | | */ |
8821 | | virtual bool key(string_t& val) = 0; |
8822 | | |
8823 | | /*! |
8824 | | @brief the end of an object was read |
8825 | | @return whether parsing should proceed |
8826 | | */ |
8827 | | virtual bool end_object() = 0; |
8828 | | |
8829 | | /*! |
8830 | | @brief the beginning of an array was read |
8831 | | @param[in] elements number of array elements or -1 if unknown |
8832 | | @return whether parsing should proceed |
8833 | | @note binary formats may report the number of elements |
8834 | | */ |
8835 | | virtual bool start_array(std::size_t elements) = 0; |
8836 | | |
8837 | | /*! |
8838 | | @brief the end of an array was read |
8839 | | @return whether parsing should proceed |
8840 | | */ |
8841 | | virtual bool end_array() = 0; |
8842 | | |
8843 | | /*! |
8844 | | @brief a parse error occurred |
8845 | | @param[in] position the position in the input where the error occurs |
8846 | | @param[in] last_token the last read token |
8847 | | @param[in] ex an exception object describing the error |
8848 | | @return whether parsing should proceed (must return false) |
8849 | | */ |
8850 | | virtual bool parse_error(std::size_t position, |
8851 | | const std::string& last_token, |
8852 | | const detail::exception& ex) = 0; |
8853 | | |
8854 | | json_sax() = default; |
8855 | | json_sax(const json_sax&) = default; |
8856 | | json_sax(json_sax&&) noexcept = default; |
8857 | | json_sax& operator=(const json_sax&) = default; |
8858 | | json_sax& operator=(json_sax&&) noexcept = default; |
8859 | | virtual ~json_sax() = default; |
8860 | | }; |
8861 | | |
8862 | | namespace detail |
8863 | | { |
8864 | | constexpr std::size_t unknown_size() |
8865 | 0 | { |
8866 | 0 | return (std::numeric_limits<std::size_t>::max)(); |
8867 | 0 | } |
8868 | | |
8869 | | /*! |
8870 | | @brief SAX implementation to create a JSON value from SAX events |
8871 | | |
8872 | | This class implements the @ref json_sax interface and processes the SAX events |
8873 | | to create a JSON value which makes it basically a DOM parser. The structure or |
8874 | | hierarchy of the JSON value is managed by the stack `ref_stack` which contains |
8875 | | a pointer to the respective array or object for each recursion depth. |
8876 | | |
8877 | | After successful parsing, the value that is passed by reference to the |
8878 | | constructor contains the parsed value. |
8879 | | |
8880 | | @tparam BasicJsonType the JSON type |
8881 | | */ |
8882 | | template<typename BasicJsonType, typename InputAdapterType> |
8883 | | class json_sax_dom_parser |
8884 | | { |
8885 | | public: |
8886 | | using number_integer_t = typename BasicJsonType::number_integer_t; |
8887 | | using number_unsigned_t = typename BasicJsonType::number_unsigned_t; |
8888 | | using number_float_t = typename BasicJsonType::number_float_t; |
8889 | | using string_t = typename BasicJsonType::string_t; |
8890 | | using binary_t = typename BasicJsonType::binary_t; |
8891 | | using lexer_t = lexer<BasicJsonType, InputAdapterType>; |
8892 | | |
8893 | | /*! |
8894 | | @param[in,out] r reference to a JSON value that is manipulated while |
8895 | | parsing |
8896 | | @param[in] allow_exceptions_ whether parse errors yield exceptions |
8897 | | */ |
8898 | | explicit json_sax_dom_parser(BasicJsonType& r, const bool allow_exceptions_ = true, lexer_t* lexer_ = nullptr) |
8899 | 0 | : root(r), allow_exceptions(allow_exceptions_), m_lexer_ref(lexer_) |
8900 | 0 | {} |
8901 | | |
8902 | | // make class move-only |
8903 | | json_sax_dom_parser(const json_sax_dom_parser&) = delete; |
8904 | | json_sax_dom_parser(json_sax_dom_parser&&) = default; // NOLINT(hicpp-noexcept-move,performance-noexcept-move-constructor) |
8905 | | json_sax_dom_parser& operator=(const json_sax_dom_parser&) = delete; |
8906 | | json_sax_dom_parser& operator=(json_sax_dom_parser&&) = default; // NOLINT(hicpp-noexcept-move,performance-noexcept-move-constructor) |
8907 | 0 | ~json_sax_dom_parser() = default; |
8908 | | |
8909 | | bool null() |
8910 | 0 | { |
8911 | 0 | handle_value(nullptr); |
8912 | 0 | return true; |
8913 | 0 | } Unexecuted instantiation: nlohmann::json_abi_v3_12_0::detail::json_sax_dom_parser<nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>, nlohmann::json_abi_v3_12_0::detail::iterator_input_adapter<char const*> >::null() Unexecuted instantiation: nlohmann::json_abi_v3_12_0::detail::json_sax_dom_parser<nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>, nlohmann::json_abi_v3_12_0::detail::input_stream_adapter>::null() |
8914 | | |
8915 | | bool boolean(bool val) |
8916 | 0 | { |
8917 | 0 | handle_value(val); |
8918 | 0 | return true; |
8919 | 0 | } Unexecuted instantiation: nlohmann::json_abi_v3_12_0::detail::json_sax_dom_parser<nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>, nlohmann::json_abi_v3_12_0::detail::iterator_input_adapter<char const*> >::boolean(bool) Unexecuted instantiation: nlohmann::json_abi_v3_12_0::detail::json_sax_dom_parser<nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>, nlohmann::json_abi_v3_12_0::detail::input_stream_adapter>::boolean(bool) |
8920 | | |
8921 | | bool number_integer(number_integer_t val) |
8922 | 0 | { |
8923 | 0 | handle_value(val); |
8924 | 0 | return true; |
8925 | 0 | } Unexecuted instantiation: nlohmann::json_abi_v3_12_0::detail::json_sax_dom_parser<nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>, nlohmann::json_abi_v3_12_0::detail::iterator_input_adapter<char const*> >::number_integer(long) Unexecuted instantiation: nlohmann::json_abi_v3_12_0::detail::json_sax_dom_parser<nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>, nlohmann::json_abi_v3_12_0::detail::input_stream_adapter>::number_integer(long) |
8926 | | |
8927 | | bool number_unsigned(number_unsigned_t val) |
8928 | 0 | { |
8929 | 0 | handle_value(val); |
8930 | 0 | return true; |
8931 | 0 | } Unexecuted instantiation: nlohmann::json_abi_v3_12_0::detail::json_sax_dom_parser<nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>, nlohmann::json_abi_v3_12_0::detail::iterator_input_adapter<char const*> >::number_unsigned(unsigned long) Unexecuted instantiation: nlohmann::json_abi_v3_12_0::detail::json_sax_dom_parser<nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>, nlohmann::json_abi_v3_12_0::detail::input_stream_adapter>::number_unsigned(unsigned long) |
8932 | | |
8933 | | bool number_float(number_float_t val, const string_t& /*unused*/) |
8934 | 0 | { |
8935 | 0 | handle_value(val); |
8936 | 0 | return true; |
8937 | 0 | } Unexecuted instantiation: nlohmann::json_abi_v3_12_0::detail::json_sax_dom_parser<nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>, nlohmann::json_abi_v3_12_0::detail::iterator_input_adapter<char const*> >::number_float(double, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) Unexecuted instantiation: nlohmann::json_abi_v3_12_0::detail::json_sax_dom_parser<nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>, nlohmann::json_abi_v3_12_0::detail::input_stream_adapter>::number_float(double, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) |
8938 | | |
8939 | | bool string(string_t& val) |
8940 | 0 | { |
8941 | 0 | handle_value(val); |
8942 | 0 | return true; |
8943 | 0 | } Unexecuted instantiation: nlohmann::json_abi_v3_12_0::detail::json_sax_dom_parser<nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>, nlohmann::json_abi_v3_12_0::detail::iterator_input_adapter<char const*> >::string(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&) Unexecuted instantiation: nlohmann::json_abi_v3_12_0::detail::json_sax_dom_parser<nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>, nlohmann::json_abi_v3_12_0::detail::input_stream_adapter>::string(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&) |
8944 | | |
8945 | | bool binary(binary_t& val) |
8946 | | { |
8947 | | handle_value(std::move(val)); |
8948 | | return true; |
8949 | | } |
8950 | | |
8951 | | bool start_object(std::size_t len) |
8952 | 0 | { |
8953 | 0 | ref_stack.push_back(handle_value(BasicJsonType::value_t::object)); |
8954 | |
|
8955 | | #if JSON_DIAGNOSTIC_POSITIONS |
8956 | | // Manually set the start position of the object here. |
8957 | | // Ensure this is after the call to handle_value to ensure correct start position. |
8958 | | if (m_lexer_ref) |
8959 | | { |
8960 | | // Lexer has read the first character of the object, so |
8961 | | // subtract 1 from the position to get the correct start position. |
8962 | | ref_stack.back()->start_position = m_lexer_ref->get_position() - 1; |
8963 | | } |
8964 | | #endif |
8965 | |
|
8966 | 0 | if (JSON_HEDLEY_UNLIKELY(len != detail::unknown_size() && len > ref_stack.back()->max_size())) |
8967 | 0 | { |
8968 | 0 | JSON_THROW(out_of_range::create(408, concat("excessive object size: ", std::to_string(len)), ref_stack.back())); |
8969 | 0 | } |
8970 | | |
8971 | 0 | return true; |
8972 | 0 | } Unexecuted instantiation: nlohmann::json_abi_v3_12_0::detail::json_sax_dom_parser<nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>, nlohmann::json_abi_v3_12_0::detail::iterator_input_adapter<char const*> >::start_object(unsigned long) Unexecuted instantiation: nlohmann::json_abi_v3_12_0::detail::json_sax_dom_parser<nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>, nlohmann::json_abi_v3_12_0::detail::input_stream_adapter>::start_object(unsigned long) |
8973 | | |
8974 | | bool key(string_t& val) |
8975 | 0 | { |
8976 | 0 | JSON_ASSERT(!ref_stack.empty()); |
8977 | 0 | JSON_ASSERT(ref_stack.back()->is_object()); |
8978 | | |
8979 | | // add null at the given key and store the reference for later |
8980 | 0 | object_element = &(ref_stack.back()->m_data.m_value.object->operator[](val)); |
8981 | 0 | return true; |
8982 | 0 | } Unexecuted instantiation: nlohmann::json_abi_v3_12_0::detail::json_sax_dom_parser<nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>, nlohmann::json_abi_v3_12_0::detail::iterator_input_adapter<char const*> >::key(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&) Unexecuted instantiation: nlohmann::json_abi_v3_12_0::detail::json_sax_dom_parser<nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>, nlohmann::json_abi_v3_12_0::detail::input_stream_adapter>::key(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&) |
8983 | | |
8984 | | bool end_object() |
8985 | 0 | { |
8986 | 0 | JSON_ASSERT(!ref_stack.empty()); |
8987 | 0 | JSON_ASSERT(ref_stack.back()->is_object()); |
8988 | | |
8989 | | #if JSON_DIAGNOSTIC_POSITIONS |
8990 | | if (m_lexer_ref) |
8991 | | { |
8992 | | // Lexer's position is past the closing brace, so set that as the end position. |
8993 | | ref_stack.back()->end_position = m_lexer_ref->get_position(); |
8994 | | } |
8995 | | #endif |
8996 | | |
8997 | 0 | ref_stack.back()->set_parents(); |
8998 | 0 | ref_stack.pop_back(); |
8999 | 0 | return true; |
9000 | 0 | } Unexecuted instantiation: nlohmann::json_abi_v3_12_0::detail::json_sax_dom_parser<nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>, nlohmann::json_abi_v3_12_0::detail::iterator_input_adapter<char const*> >::end_object() Unexecuted instantiation: nlohmann::json_abi_v3_12_0::detail::json_sax_dom_parser<nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>, nlohmann::json_abi_v3_12_0::detail::input_stream_adapter>::end_object() |
9001 | | |
9002 | | bool start_array(std::size_t len) |
9003 | 0 | { |
9004 | 0 | ref_stack.push_back(handle_value(BasicJsonType::value_t::array)); |
9005 | |
|
9006 | | #if JSON_DIAGNOSTIC_POSITIONS |
9007 | | // Manually set the start position of the array here. |
9008 | | // Ensure this is after the call to handle_value to ensure correct start position. |
9009 | | if (m_lexer_ref) |
9010 | | { |
9011 | | ref_stack.back()->start_position = m_lexer_ref->get_position() - 1; |
9012 | | } |
9013 | | #endif |
9014 | |
|
9015 | 0 | if (JSON_HEDLEY_UNLIKELY(len != detail::unknown_size() && len > ref_stack.back()->max_size())) |
9016 | 0 | { |
9017 | 0 | JSON_THROW(out_of_range::create(408, concat("excessive array size: ", std::to_string(len)), ref_stack.back())); |
9018 | 0 | } |
9019 | | |
9020 | 0 | return true; |
9021 | 0 | } Unexecuted instantiation: nlohmann::json_abi_v3_12_0::detail::json_sax_dom_parser<nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>, nlohmann::json_abi_v3_12_0::detail::iterator_input_adapter<char const*> >::start_array(unsigned long) Unexecuted instantiation: nlohmann::json_abi_v3_12_0::detail::json_sax_dom_parser<nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>, nlohmann::json_abi_v3_12_0::detail::input_stream_adapter>::start_array(unsigned long) |
9022 | | |
9023 | | bool end_array() |
9024 | 0 | { |
9025 | 0 | JSON_ASSERT(!ref_stack.empty()); |
9026 | 0 | JSON_ASSERT(ref_stack.back()->is_array()); |
9027 | | |
9028 | | #if JSON_DIAGNOSTIC_POSITIONS |
9029 | | if (m_lexer_ref) |
9030 | | { |
9031 | | // Lexer's position is past the closing bracket, so set that as the end position. |
9032 | | ref_stack.back()->end_position = m_lexer_ref->get_position(); |
9033 | | } |
9034 | | #endif |
9035 | | |
9036 | 0 | ref_stack.back()->set_parents(); |
9037 | 0 | ref_stack.pop_back(); |
9038 | 0 | return true; |
9039 | 0 | } Unexecuted instantiation: nlohmann::json_abi_v3_12_0::detail::json_sax_dom_parser<nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>, nlohmann::json_abi_v3_12_0::detail::iterator_input_adapter<char const*> >::end_array() Unexecuted instantiation: nlohmann::json_abi_v3_12_0::detail::json_sax_dom_parser<nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>, nlohmann::json_abi_v3_12_0::detail::input_stream_adapter>::end_array() |
9040 | | |
9041 | | template<class Exception> |
9042 | | bool parse_error(std::size_t /*unused*/, const std::string& /*unused*/, |
9043 | | const Exception& ex) |
9044 | 0 | { |
9045 | 0 | errored = true; |
9046 | 0 | static_cast<void>(ex); |
9047 | 0 | if (allow_exceptions) |
9048 | 0 | { |
9049 | 0 | JSON_THROW(ex); |
9050 | 0 | } |
9051 | 0 | return false; |
9052 | 0 | } Unexecuted instantiation: bool nlohmann::json_abi_v3_12_0::detail::json_sax_dom_parser<nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>, nlohmann::json_abi_v3_12_0::detail::iterator_input_adapter<char const*> >::parse_error<nlohmann::json_abi_v3_12_0::detail::out_of_range>(unsigned long, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, nlohmann::json_abi_v3_12_0::detail::out_of_range const&) Unexecuted instantiation: bool nlohmann::json_abi_v3_12_0::detail::json_sax_dom_parser<nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>, nlohmann::json_abi_v3_12_0::detail::iterator_input_adapter<char const*> >::parse_error<nlohmann::json_abi_v3_12_0::detail::parse_error>(unsigned long, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, nlohmann::json_abi_v3_12_0::detail::parse_error const&) Unexecuted instantiation: bool nlohmann::json_abi_v3_12_0::detail::json_sax_dom_parser<nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>, nlohmann::json_abi_v3_12_0::detail::input_stream_adapter>::parse_error<nlohmann::json_abi_v3_12_0::detail::out_of_range>(unsigned long, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, nlohmann::json_abi_v3_12_0::detail::out_of_range const&) Unexecuted instantiation: bool nlohmann::json_abi_v3_12_0::detail::json_sax_dom_parser<nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>, nlohmann::json_abi_v3_12_0::detail::input_stream_adapter>::parse_error<nlohmann::json_abi_v3_12_0::detail::parse_error>(unsigned long, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, nlohmann::json_abi_v3_12_0::detail::parse_error const&) |
9053 | | |
9054 | | constexpr bool is_errored() const |
9055 | 0 | { |
9056 | 0 | return errored; |
9057 | 0 | } Unexecuted instantiation: nlohmann::json_abi_v3_12_0::detail::json_sax_dom_parser<nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>, nlohmann::json_abi_v3_12_0::detail::iterator_input_adapter<char const*> >::is_errored() const Unexecuted instantiation: nlohmann::json_abi_v3_12_0::detail::json_sax_dom_parser<nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>, nlohmann::json_abi_v3_12_0::detail::input_stream_adapter>::is_errored() const |
9058 | | |
9059 | | private: |
9060 | | |
9061 | | #if JSON_DIAGNOSTIC_POSITIONS |
9062 | | void handle_diagnostic_positions_for_json_value(BasicJsonType& v) |
9063 | | { |
9064 | | if (m_lexer_ref) |
9065 | | { |
9066 | | // Lexer has read past the current field value, so set the end position to the current position. |
9067 | | // The start position will be set below based on the length of the string representation |
9068 | | // of the value. |
9069 | | v.end_position = m_lexer_ref->get_position(); |
9070 | | |
9071 | | switch (v.type()) |
9072 | | { |
9073 | | case value_t::boolean: |
9074 | | { |
9075 | | // 4 and 5 are the string length of "true" and "false" |
9076 | | v.start_position = v.end_position - (v.m_data.m_value.boolean ? 4 : 5); |
9077 | | break; |
9078 | | } |
9079 | | |
9080 | | case value_t::null: |
9081 | | { |
9082 | | // 4 is the string length of "null" |
9083 | | v.start_position = v.end_position - 4; |
9084 | | break; |
9085 | | } |
9086 | | |
9087 | | case value_t::string: |
9088 | | { |
9089 | | // include the length of the quotes, which is 2 |
9090 | | v.start_position = v.end_position - v.m_data.m_value.string->size() - 2; |
9091 | | break; |
9092 | | } |
9093 | | |
9094 | | // As we handle the start and end positions for values created during parsing, |
9095 | | // we do not expect the following value type to be called. Regardless, set the positions |
9096 | | // in case this is created manually or through a different constructor. Exclude from lcov |
9097 | | // since the exact condition of this switch is esoteric. |
9098 | | // LCOV_EXCL_START |
9099 | | case value_t::discarded: |
9100 | | { |
9101 | | v.end_position = std::string::npos; |
9102 | | v.start_position = v.end_position; |
9103 | | break; |
9104 | | } |
9105 | | // LCOV_EXCL_STOP |
9106 | | case value_t::binary: |
9107 | | case value_t::number_integer: |
9108 | | case value_t::number_unsigned: |
9109 | | case value_t::number_float: |
9110 | | { |
9111 | | v.start_position = v.end_position - m_lexer_ref->get_string().size(); |
9112 | | break; |
9113 | | } |
9114 | | case value_t::object: |
9115 | | case value_t::array: |
9116 | | { |
9117 | | // object and array are handled in start_object() and start_array() handlers |
9118 | | // skip setting the values here. |
9119 | | break; |
9120 | | } |
9121 | | default: // LCOV_EXCL_LINE |
9122 | | // Handle all possible types discretely, default handler should never be reached. |
9123 | | JSON_ASSERT(false); // NOLINT(cert-dcl03-c,hicpp-static-assert,misc-static-assert,-warnings-as-errors) LCOV_EXCL_LINE |
9124 | | } |
9125 | | } |
9126 | | } |
9127 | | #endif |
9128 | | |
9129 | | /*! |
9130 | | @invariant If the ref stack is empty, then the passed value will be the new |
9131 | | root. |
9132 | | @invariant If the ref stack contains a value, then it is an array or an |
9133 | | object to which we can add elements |
9134 | | */ |
9135 | | template<typename Value> |
9136 | | JSON_HEDLEY_RETURNS_NON_NULL |
9137 | | BasicJsonType* handle_value(Value&& v) |
9138 | 0 | { |
9139 | 0 | if (ref_stack.empty()) |
9140 | 0 | { |
9141 | 0 | root = BasicJsonType(std::forward<Value>(v)); |
9142 | |
|
9143 | | #if JSON_DIAGNOSTIC_POSITIONS |
9144 | | handle_diagnostic_positions_for_json_value(root); |
9145 | | #endif |
9146 | |
|
9147 | 0 | return &root; |
9148 | 0 | } |
9149 | | |
9150 | 0 | JSON_ASSERT(ref_stack.back()->is_array() || ref_stack.back()->is_object()); |
9151 | | |
9152 | 0 | if (ref_stack.back()->is_array()) |
9153 | 0 | { |
9154 | 0 | ref_stack.back()->m_data.m_value.array->emplace_back(std::forward<Value>(v)); |
9155 | |
|
9156 | | #if JSON_DIAGNOSTIC_POSITIONS |
9157 | | handle_diagnostic_positions_for_json_value(ref_stack.back()->m_data.m_value.array->back()); |
9158 | | #endif |
9159 | |
|
9160 | 0 | return &(ref_stack.back()->m_data.m_value.array->back()); |
9161 | 0 | } |
9162 | | |
9163 | 0 | JSON_ASSERT(ref_stack.back()->is_object()); |
9164 | 0 | JSON_ASSERT(object_element); |
9165 | 0 | *object_element = BasicJsonType(std::forward<Value>(v)); |
9166 | |
|
9167 | | #if JSON_DIAGNOSTIC_POSITIONS |
9168 | | handle_diagnostic_positions_for_json_value(*object_element); |
9169 | | #endif |
9170 | |
|
9171 | 0 | return object_element; |
9172 | 0 | } Unexecuted instantiation: nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>* nlohmann::json_abi_v3_12_0::detail::json_sax_dom_parser<nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>, nlohmann::json_abi_v3_12_0::detail::iterator_input_adapter<char const*> >::handle_value<nlohmann::json_abi_v3_12_0::detail::value_t>(nlohmann::json_abi_v3_12_0::detail::value_t&&) Unexecuted instantiation: nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>* nlohmann::json_abi_v3_12_0::detail::json_sax_dom_parser<nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>, nlohmann::json_abi_v3_12_0::detail::iterator_input_adapter<char const*> >::handle_value<double&>(double&) Unexecuted instantiation: nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>* nlohmann::json_abi_v3_12_0::detail::json_sax_dom_parser<nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>, nlohmann::json_abi_v3_12_0::detail::iterator_input_adapter<char const*> >::handle_value<bool&>(bool&) Unexecuted instantiation: nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>* nlohmann::json_abi_v3_12_0::detail::json_sax_dom_parser<nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>, nlohmann::json_abi_v3_12_0::detail::iterator_input_adapter<char const*> >::handle_value<decltype(nullptr)>(decltype(nullptr)&&) Unexecuted instantiation: nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>* nlohmann::json_abi_v3_12_0::detail::json_sax_dom_parser<nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>, nlohmann::json_abi_v3_12_0::detail::iterator_input_adapter<char const*> >::handle_value<long&>(long&) Unexecuted instantiation: nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>* nlohmann::json_abi_v3_12_0::detail::json_sax_dom_parser<nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>, nlohmann::json_abi_v3_12_0::detail::iterator_input_adapter<char const*> >::handle_value<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&>(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&) Unexecuted instantiation: nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>* nlohmann::json_abi_v3_12_0::detail::json_sax_dom_parser<nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>, nlohmann::json_abi_v3_12_0::detail::iterator_input_adapter<char const*> >::handle_value<unsigned long&>(unsigned long&) Unexecuted instantiation: nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>* nlohmann::json_abi_v3_12_0::detail::json_sax_dom_parser<nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>, nlohmann::json_abi_v3_12_0::detail::input_stream_adapter>::handle_value<nlohmann::json_abi_v3_12_0::detail::value_t>(nlohmann::json_abi_v3_12_0::detail::value_t&&) Unexecuted instantiation: nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>* nlohmann::json_abi_v3_12_0::detail::json_sax_dom_parser<nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>, nlohmann::json_abi_v3_12_0::detail::input_stream_adapter>::handle_value<double&>(double&) Unexecuted instantiation: nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>* nlohmann::json_abi_v3_12_0::detail::json_sax_dom_parser<nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>, nlohmann::json_abi_v3_12_0::detail::input_stream_adapter>::handle_value<bool&>(bool&) Unexecuted instantiation: nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>* nlohmann::json_abi_v3_12_0::detail::json_sax_dom_parser<nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>, nlohmann::json_abi_v3_12_0::detail::input_stream_adapter>::handle_value<decltype(nullptr)>(decltype(nullptr)&&) Unexecuted instantiation: nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>* nlohmann::json_abi_v3_12_0::detail::json_sax_dom_parser<nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>, nlohmann::json_abi_v3_12_0::detail::input_stream_adapter>::handle_value<long&>(long&) Unexecuted instantiation: nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>* nlohmann::json_abi_v3_12_0::detail::json_sax_dom_parser<nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>, nlohmann::json_abi_v3_12_0::detail::input_stream_adapter>::handle_value<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&>(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&) Unexecuted instantiation: nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>* nlohmann::json_abi_v3_12_0::detail::json_sax_dom_parser<nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>, nlohmann::json_abi_v3_12_0::detail::input_stream_adapter>::handle_value<unsigned long&>(unsigned long&) |
9173 | | |
9174 | | /// the parsed JSON value |
9175 | | BasicJsonType& root; |
9176 | | /// stack to model hierarchy of values |
9177 | | std::vector<BasicJsonType*> ref_stack {}; |
9178 | | /// helper to hold the reference for the next object element |
9179 | | BasicJsonType* object_element = nullptr; |
9180 | | /// whether a syntax error occurred |
9181 | | bool errored = false; |
9182 | | /// whether to throw exceptions in case of errors |
9183 | | const bool allow_exceptions = true; |
9184 | | /// the lexer reference to obtain the current position |
9185 | | lexer_t* m_lexer_ref = nullptr; |
9186 | | }; |
9187 | | |
9188 | | template<typename BasicJsonType, typename InputAdapterType> |
9189 | | class json_sax_dom_callback_parser |
9190 | | { |
9191 | | public: |
9192 | | using number_integer_t = typename BasicJsonType::number_integer_t; |
9193 | | using number_unsigned_t = typename BasicJsonType::number_unsigned_t; |
9194 | | using number_float_t = typename BasicJsonType::number_float_t; |
9195 | | using string_t = typename BasicJsonType::string_t; |
9196 | | using binary_t = typename BasicJsonType::binary_t; |
9197 | | using parser_callback_t = typename BasicJsonType::parser_callback_t; |
9198 | | using parse_event_t = typename BasicJsonType::parse_event_t; |
9199 | | using lexer_t = lexer<BasicJsonType, InputAdapterType>; |
9200 | | |
9201 | | json_sax_dom_callback_parser(BasicJsonType& r, |
9202 | | parser_callback_t cb, |
9203 | | const bool allow_exceptions_ = true, |
9204 | | lexer_t* lexer_ = nullptr) |
9205 | 0 | : root(r), callback(std::move(cb)), allow_exceptions(allow_exceptions_), m_lexer_ref(lexer_) |
9206 | 0 | { |
9207 | 0 | keep_stack.push_back(true); |
9208 | 0 | } |
9209 | | |
9210 | | // make class move-only |
9211 | | json_sax_dom_callback_parser(const json_sax_dom_callback_parser&) = delete; |
9212 | | json_sax_dom_callback_parser(json_sax_dom_callback_parser&&) = default; // NOLINT(hicpp-noexcept-move,performance-noexcept-move-constructor) |
9213 | | json_sax_dom_callback_parser& operator=(const json_sax_dom_callback_parser&) = delete; |
9214 | | json_sax_dom_callback_parser& operator=(json_sax_dom_callback_parser&&) = default; // NOLINT(hicpp-noexcept-move,performance-noexcept-move-constructor) |
9215 | 0 | ~json_sax_dom_callback_parser() = default; |
9216 | | |
9217 | | bool null() |
9218 | 0 | { |
9219 | 0 | handle_value(nullptr); |
9220 | 0 | return true; |
9221 | 0 | } Unexecuted instantiation: nlohmann::json_abi_v3_12_0::detail::json_sax_dom_callback_parser<nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>, nlohmann::json_abi_v3_12_0::detail::iterator_input_adapter<char const*> >::null() Unexecuted instantiation: nlohmann::json_abi_v3_12_0::detail::json_sax_dom_callback_parser<nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>, nlohmann::json_abi_v3_12_0::detail::input_stream_adapter>::null() |
9222 | | |
9223 | | bool boolean(bool val) |
9224 | 0 | { |
9225 | 0 | handle_value(val); |
9226 | 0 | return true; |
9227 | 0 | } Unexecuted instantiation: nlohmann::json_abi_v3_12_0::detail::json_sax_dom_callback_parser<nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>, nlohmann::json_abi_v3_12_0::detail::iterator_input_adapter<char const*> >::boolean(bool) Unexecuted instantiation: nlohmann::json_abi_v3_12_0::detail::json_sax_dom_callback_parser<nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>, nlohmann::json_abi_v3_12_0::detail::input_stream_adapter>::boolean(bool) |
9228 | | |
9229 | | bool number_integer(number_integer_t val) |
9230 | 0 | { |
9231 | 0 | handle_value(val); |
9232 | 0 | return true; |
9233 | 0 | } Unexecuted instantiation: nlohmann::json_abi_v3_12_0::detail::json_sax_dom_callback_parser<nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>, nlohmann::json_abi_v3_12_0::detail::iterator_input_adapter<char const*> >::number_integer(long) Unexecuted instantiation: nlohmann::json_abi_v3_12_0::detail::json_sax_dom_callback_parser<nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>, nlohmann::json_abi_v3_12_0::detail::input_stream_adapter>::number_integer(long) |
9234 | | |
9235 | | bool number_unsigned(number_unsigned_t val) |
9236 | 0 | { |
9237 | 0 | handle_value(val); |
9238 | 0 | return true; |
9239 | 0 | } Unexecuted instantiation: nlohmann::json_abi_v3_12_0::detail::json_sax_dom_callback_parser<nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>, nlohmann::json_abi_v3_12_0::detail::iterator_input_adapter<char const*> >::number_unsigned(unsigned long) Unexecuted instantiation: nlohmann::json_abi_v3_12_0::detail::json_sax_dom_callback_parser<nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>, nlohmann::json_abi_v3_12_0::detail::input_stream_adapter>::number_unsigned(unsigned long) |
9240 | | |
9241 | | bool number_float(number_float_t val, const string_t& /*unused*/) |
9242 | 0 | { |
9243 | 0 | handle_value(val); |
9244 | 0 | return true; |
9245 | 0 | } Unexecuted instantiation: nlohmann::json_abi_v3_12_0::detail::json_sax_dom_callback_parser<nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>, nlohmann::json_abi_v3_12_0::detail::iterator_input_adapter<char const*> >::number_float(double, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) Unexecuted instantiation: nlohmann::json_abi_v3_12_0::detail::json_sax_dom_callback_parser<nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>, nlohmann::json_abi_v3_12_0::detail::input_stream_adapter>::number_float(double, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) |
9246 | | |
9247 | | bool string(string_t& val) |
9248 | 0 | { |
9249 | 0 | handle_value(val); |
9250 | 0 | return true; |
9251 | 0 | } Unexecuted instantiation: nlohmann::json_abi_v3_12_0::detail::json_sax_dom_callback_parser<nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>, nlohmann::json_abi_v3_12_0::detail::iterator_input_adapter<char const*> >::string(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&) Unexecuted instantiation: nlohmann::json_abi_v3_12_0::detail::json_sax_dom_callback_parser<nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>, nlohmann::json_abi_v3_12_0::detail::input_stream_adapter>::string(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&) |
9252 | | |
9253 | | bool binary(binary_t& val) |
9254 | | { |
9255 | | handle_value(std::move(val)); |
9256 | | return true; |
9257 | | } |
9258 | | |
9259 | | bool start_object(std::size_t len) |
9260 | 0 | { |
9261 | | // check callback for object start |
9262 | 0 | const bool keep = callback(static_cast<int>(ref_stack.size()), parse_event_t::object_start, discarded); |
9263 | 0 | keep_stack.push_back(keep); |
9264 | |
|
9265 | 0 | auto val = handle_value(BasicJsonType::value_t::object, true); |
9266 | 0 | ref_stack.push_back(val.second); |
9267 | |
|
9268 | 0 | if (ref_stack.back()) |
9269 | 0 | { |
9270 | |
|
9271 | | #if JSON_DIAGNOSTIC_POSITIONS |
9272 | | // Manually set the start position of the object here. |
9273 | | // Ensure this is after the call to handle_value to ensure correct start position. |
9274 | | if (m_lexer_ref) |
9275 | | { |
9276 | | // Lexer has read the first character of the object, so |
9277 | | // subtract 1 from the position to get the correct start position. |
9278 | | ref_stack.back()->start_position = m_lexer_ref->get_position() - 1; |
9279 | | } |
9280 | | #endif |
9281 | | |
9282 | | // check object limit |
9283 | 0 | if (JSON_HEDLEY_UNLIKELY(len != detail::unknown_size() && len > ref_stack.back()->max_size())) |
9284 | 0 | { |
9285 | 0 | JSON_THROW(out_of_range::create(408, concat("excessive object size: ", std::to_string(len)), ref_stack.back())); |
9286 | 0 | } |
9287 | 0 | } |
9288 | 0 | return true; |
9289 | 0 | } Unexecuted instantiation: nlohmann::json_abi_v3_12_0::detail::json_sax_dom_callback_parser<nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>, nlohmann::json_abi_v3_12_0::detail::iterator_input_adapter<char const*> >::start_object(unsigned long) Unexecuted instantiation: nlohmann::json_abi_v3_12_0::detail::json_sax_dom_callback_parser<nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>, nlohmann::json_abi_v3_12_0::detail::input_stream_adapter>::start_object(unsigned long) |
9290 | | |
9291 | | bool key(string_t& val) |
9292 | 0 | { |
9293 | 0 | BasicJsonType k = BasicJsonType(val); |
9294 | | |
9295 | | // check callback for the key |
9296 | 0 | const bool keep = callback(static_cast<int>(ref_stack.size()), parse_event_t::key, k); |
9297 | 0 | key_keep_stack.push_back(keep); |
9298 | | |
9299 | | // add discarded value at the given key and store the reference for later |
9300 | 0 | if (keep && ref_stack.back()) |
9301 | 0 | { |
9302 | 0 | object_element = &(ref_stack.back()->m_data.m_value.object->operator[](val) = discarded); |
9303 | 0 | } |
9304 | |
|
9305 | 0 | return true; |
9306 | 0 | } Unexecuted instantiation: nlohmann::json_abi_v3_12_0::detail::json_sax_dom_callback_parser<nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>, nlohmann::json_abi_v3_12_0::detail::iterator_input_adapter<char const*> >::key(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&) Unexecuted instantiation: nlohmann::json_abi_v3_12_0::detail::json_sax_dom_callback_parser<nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>, nlohmann::json_abi_v3_12_0::detail::input_stream_adapter>::key(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&) |
9307 | | |
9308 | | bool end_object() |
9309 | 0 | { |
9310 | 0 | if (ref_stack.back()) |
9311 | 0 | { |
9312 | 0 | if (!callback(static_cast<int>(ref_stack.size()) - 1, parse_event_t::object_end, *ref_stack.back())) |
9313 | 0 | { |
9314 | | // discard object |
9315 | 0 | *ref_stack.back() = discarded; |
9316 | |
|
9317 | | #if JSON_DIAGNOSTIC_POSITIONS |
9318 | | // Set start/end positions for discarded object. |
9319 | | handle_diagnostic_positions_for_json_value(*ref_stack.back()); |
9320 | | #endif |
9321 | 0 | } |
9322 | 0 | else |
9323 | 0 | { |
9324 | |
|
9325 | | #if JSON_DIAGNOSTIC_POSITIONS |
9326 | | if (m_lexer_ref) |
9327 | | { |
9328 | | // Lexer's position is past the closing brace, so set that as the end position. |
9329 | | ref_stack.back()->end_position = m_lexer_ref->get_position(); |
9330 | | } |
9331 | | #endif |
9332 | |
|
9333 | 0 | ref_stack.back()->set_parents(); |
9334 | 0 | } |
9335 | 0 | } |
9336 | |
|
9337 | 0 | JSON_ASSERT(!ref_stack.empty()); |
9338 | 0 | JSON_ASSERT(!keep_stack.empty()); |
9339 | 0 | ref_stack.pop_back(); |
9340 | 0 | keep_stack.pop_back(); |
9341 | |
|
9342 | 0 | if (!ref_stack.empty() && ref_stack.back() && ref_stack.back()->is_structured()) |
9343 | 0 | { |
9344 | | // remove discarded value |
9345 | 0 | for (auto it = ref_stack.back()->begin(); it != ref_stack.back()->end(); ++it) |
9346 | 0 | { |
9347 | 0 | if (it->is_discarded()) |
9348 | 0 | { |
9349 | 0 | ref_stack.back()->erase(it); |
9350 | 0 | break; |
9351 | 0 | } |
9352 | 0 | } |
9353 | 0 | } |
9354 | |
|
9355 | 0 | return true; |
9356 | 0 | } Unexecuted instantiation: nlohmann::json_abi_v3_12_0::detail::json_sax_dom_callback_parser<nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>, nlohmann::json_abi_v3_12_0::detail::iterator_input_adapter<char const*> >::end_object() Unexecuted instantiation: nlohmann::json_abi_v3_12_0::detail::json_sax_dom_callback_parser<nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>, nlohmann::json_abi_v3_12_0::detail::input_stream_adapter>::end_object() |
9357 | | |
9358 | | bool start_array(std::size_t len) |
9359 | 0 | { |
9360 | 0 | const bool keep = callback(static_cast<int>(ref_stack.size()), parse_event_t::array_start, discarded); |
9361 | 0 | keep_stack.push_back(keep); |
9362 | |
|
9363 | 0 | auto val = handle_value(BasicJsonType::value_t::array, true); |
9364 | 0 | ref_stack.push_back(val.second); |
9365 | |
|
9366 | 0 | if (ref_stack.back()) |
9367 | 0 | { |
9368 | |
|
9369 | | #if JSON_DIAGNOSTIC_POSITIONS |
9370 | | // Manually set the start position of the array here. |
9371 | | // Ensure this is after the call to handle_value to ensure correct start position. |
9372 | | if (m_lexer_ref) |
9373 | | { |
9374 | | // Lexer has read the first character of the array, so |
9375 | | // subtract 1 from the position to get the correct start position. |
9376 | | ref_stack.back()->start_position = m_lexer_ref->get_position() - 1; |
9377 | | } |
9378 | | #endif |
9379 | | |
9380 | | // check array limit |
9381 | 0 | if (JSON_HEDLEY_UNLIKELY(len != detail::unknown_size() && len > ref_stack.back()->max_size())) |
9382 | 0 | { |
9383 | 0 | JSON_THROW(out_of_range::create(408, concat("excessive array size: ", std::to_string(len)), ref_stack.back())); |
9384 | 0 | } |
9385 | 0 | } |
9386 | | |
9387 | 0 | return true; |
9388 | 0 | } Unexecuted instantiation: nlohmann::json_abi_v3_12_0::detail::json_sax_dom_callback_parser<nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>, nlohmann::json_abi_v3_12_0::detail::iterator_input_adapter<char const*> >::start_array(unsigned long) Unexecuted instantiation: nlohmann::json_abi_v3_12_0::detail::json_sax_dom_callback_parser<nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>, nlohmann::json_abi_v3_12_0::detail::input_stream_adapter>::start_array(unsigned long) |
9389 | | |
9390 | | bool end_array() |
9391 | 0 | { |
9392 | 0 | bool keep = true; |
9393 | |
|
9394 | 0 | if (ref_stack.back()) |
9395 | 0 | { |
9396 | 0 | keep = callback(static_cast<int>(ref_stack.size()) - 1, parse_event_t::array_end, *ref_stack.back()); |
9397 | 0 | if (keep) |
9398 | 0 | { |
9399 | |
|
9400 | | #if JSON_DIAGNOSTIC_POSITIONS |
9401 | | if (m_lexer_ref) |
9402 | | { |
9403 | | // Lexer's position is past the closing bracket, so set that as the end position. |
9404 | | ref_stack.back()->end_position = m_lexer_ref->get_position(); |
9405 | | } |
9406 | | #endif |
9407 | |
|
9408 | 0 | ref_stack.back()->set_parents(); |
9409 | 0 | } |
9410 | 0 | else |
9411 | 0 | { |
9412 | | // discard array |
9413 | 0 | *ref_stack.back() = discarded; |
9414 | |
|
9415 | | #if JSON_DIAGNOSTIC_POSITIONS |
9416 | | // Set start/end positions for discarded array. |
9417 | | handle_diagnostic_positions_for_json_value(*ref_stack.back()); |
9418 | | #endif |
9419 | 0 | } |
9420 | 0 | } |
9421 | |
|
9422 | 0 | JSON_ASSERT(!ref_stack.empty()); |
9423 | 0 | JSON_ASSERT(!keep_stack.empty()); |
9424 | 0 | ref_stack.pop_back(); |
9425 | 0 | keep_stack.pop_back(); |
9426 | | |
9427 | | // remove discarded value |
9428 | 0 | if (!keep && !ref_stack.empty() && ref_stack.back()->is_array()) |
9429 | 0 | { |
9430 | 0 | ref_stack.back()->m_data.m_value.array->pop_back(); |
9431 | 0 | } |
9432 | |
|
9433 | 0 | return true; |
9434 | 0 | } Unexecuted instantiation: nlohmann::json_abi_v3_12_0::detail::json_sax_dom_callback_parser<nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>, nlohmann::json_abi_v3_12_0::detail::iterator_input_adapter<char const*> >::end_array() Unexecuted instantiation: nlohmann::json_abi_v3_12_0::detail::json_sax_dom_callback_parser<nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>, nlohmann::json_abi_v3_12_0::detail::input_stream_adapter>::end_array() |
9435 | | |
9436 | | template<class Exception> |
9437 | | bool parse_error(std::size_t /*unused*/, const std::string& /*unused*/, |
9438 | | const Exception& ex) |
9439 | 0 | { |
9440 | 0 | errored = true; |
9441 | 0 | static_cast<void>(ex); |
9442 | 0 | if (allow_exceptions) |
9443 | 0 | { |
9444 | 0 | JSON_THROW(ex); |
9445 | 0 | } |
9446 | 0 | return false; |
9447 | 0 | } Unexecuted instantiation: bool nlohmann::json_abi_v3_12_0::detail::json_sax_dom_callback_parser<nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>, nlohmann::json_abi_v3_12_0::detail::iterator_input_adapter<char const*> >::parse_error<nlohmann::json_abi_v3_12_0::detail::out_of_range>(unsigned long, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, nlohmann::json_abi_v3_12_0::detail::out_of_range const&) Unexecuted instantiation: bool nlohmann::json_abi_v3_12_0::detail::json_sax_dom_callback_parser<nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>, nlohmann::json_abi_v3_12_0::detail::iterator_input_adapter<char const*> >::parse_error<nlohmann::json_abi_v3_12_0::detail::parse_error>(unsigned long, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, nlohmann::json_abi_v3_12_0::detail::parse_error const&) Unexecuted instantiation: bool nlohmann::json_abi_v3_12_0::detail::json_sax_dom_callback_parser<nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>, nlohmann::json_abi_v3_12_0::detail::input_stream_adapter>::parse_error<nlohmann::json_abi_v3_12_0::detail::out_of_range>(unsigned long, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, nlohmann::json_abi_v3_12_0::detail::out_of_range const&) Unexecuted instantiation: bool nlohmann::json_abi_v3_12_0::detail::json_sax_dom_callback_parser<nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>, nlohmann::json_abi_v3_12_0::detail::input_stream_adapter>::parse_error<nlohmann::json_abi_v3_12_0::detail::parse_error>(unsigned long, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, nlohmann::json_abi_v3_12_0::detail::parse_error const&) |
9448 | | |
9449 | | constexpr bool is_errored() const |
9450 | 0 | { |
9451 | 0 | return errored; |
9452 | 0 | } Unexecuted instantiation: nlohmann::json_abi_v3_12_0::detail::json_sax_dom_callback_parser<nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>, nlohmann::json_abi_v3_12_0::detail::iterator_input_adapter<char const*> >::is_errored() const Unexecuted instantiation: nlohmann::json_abi_v3_12_0::detail::json_sax_dom_callback_parser<nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>, nlohmann::json_abi_v3_12_0::detail::input_stream_adapter>::is_errored() const |
9453 | | |
9454 | | private: |
9455 | | |
9456 | | #if JSON_DIAGNOSTIC_POSITIONS |
9457 | | void handle_diagnostic_positions_for_json_value(BasicJsonType& v) |
9458 | | { |
9459 | | if (m_lexer_ref) |
9460 | | { |
9461 | | // Lexer has read past the current field value, so set the end position to the current position. |
9462 | | // The start position will be set below based on the length of the string representation |
9463 | | // of the value. |
9464 | | v.end_position = m_lexer_ref->get_position(); |
9465 | | |
9466 | | switch (v.type()) |
9467 | | { |
9468 | | case value_t::boolean: |
9469 | | { |
9470 | | // 4 and 5 are the string length of "true" and "false" |
9471 | | v.start_position = v.end_position - (v.m_data.m_value.boolean ? 4 : 5); |
9472 | | break; |
9473 | | } |
9474 | | |
9475 | | case value_t::null: |
9476 | | { |
9477 | | // 4 is the string length of "null" |
9478 | | v.start_position = v.end_position - 4; |
9479 | | break; |
9480 | | } |
9481 | | |
9482 | | case value_t::string: |
9483 | | { |
9484 | | // include the length of the quotes, which is 2 |
9485 | | v.start_position = v.end_position - v.m_data.m_value.string->size() - 2; |
9486 | | break; |
9487 | | } |
9488 | | |
9489 | | case value_t::discarded: |
9490 | | { |
9491 | | v.end_position = std::string::npos; |
9492 | | v.start_position = v.end_position; |
9493 | | break; |
9494 | | } |
9495 | | |
9496 | | case value_t::binary: |
9497 | | case value_t::number_integer: |
9498 | | case value_t::number_unsigned: |
9499 | | case value_t::number_float: |
9500 | | { |
9501 | | v.start_position = v.end_position - m_lexer_ref->get_string().size(); |
9502 | | break; |
9503 | | } |
9504 | | |
9505 | | case value_t::object: |
9506 | | case value_t::array: |
9507 | | { |
9508 | | // object and array are handled in start_object() and start_array() handlers |
9509 | | // skip setting the values here. |
9510 | | break; |
9511 | | } |
9512 | | default: // LCOV_EXCL_LINE |
9513 | | // Handle all possible types discretely, default handler should never be reached. |
9514 | | JSON_ASSERT(false); // NOLINT(cert-dcl03-c,hicpp-static-assert,misc-static-assert,-warnings-as-errors) LCOV_EXCL_LINE |
9515 | | } |
9516 | | } |
9517 | | } |
9518 | | #endif |
9519 | | |
9520 | | /*! |
9521 | | @param[in] v value to add to the JSON value we build during parsing |
9522 | | @param[in] skip_callback whether we should skip calling the callback |
9523 | | function; this is required after start_array() and |
9524 | | start_object() SAX events, because otherwise we would call the |
9525 | | callback function with an empty array or object, respectively. |
9526 | | |
9527 | | @invariant If the ref stack is empty, then the passed value will be the new |
9528 | | root. |
9529 | | @invariant If the ref stack contains a value, then it is an array or an |
9530 | | object to which we can add elements |
9531 | | |
9532 | | @return pair of boolean (whether value should be kept) and pointer (to the |
9533 | | passed value in the ref_stack hierarchy; nullptr if not kept) |
9534 | | */ |
9535 | | template<typename Value> |
9536 | | std::pair<bool, BasicJsonType*> handle_value(Value&& v, const bool skip_callback = false) |
9537 | 0 | { |
9538 | 0 | JSON_ASSERT(!keep_stack.empty()); |
9539 | | |
9540 | | // do not handle this value if we know it would be added to a discarded |
9541 | | // container |
9542 | 0 | if (!keep_stack.back()) |
9543 | 0 | { |
9544 | 0 | return {false, nullptr}; |
9545 | 0 | } |
9546 | | |
9547 | | // create value |
9548 | 0 | auto value = BasicJsonType(std::forward<Value>(v)); |
9549 | |
|
9550 | | #if JSON_DIAGNOSTIC_POSITIONS |
9551 | | handle_diagnostic_positions_for_json_value(value); |
9552 | | #endif |
9553 | | |
9554 | | // check callback |
9555 | 0 | const bool keep = skip_callback || callback(static_cast<int>(ref_stack.size()), parse_event_t::value, value); |
9556 | | |
9557 | | // do not handle this value if we just learnt it shall be discarded |
9558 | 0 | if (!keep) |
9559 | 0 | { |
9560 | 0 | return {false, nullptr}; |
9561 | 0 | } |
9562 | | |
9563 | 0 | if (ref_stack.empty()) |
9564 | 0 | { |
9565 | 0 | root = std::move(value); |
9566 | 0 | return {true, & root}; |
9567 | 0 | } |
9568 | | |
9569 | | // skip this value if we already decided to skip the parent |
9570 | | // (https://github.com/nlohmann/json/issues/971#issuecomment-413678360) |
9571 | 0 | if (!ref_stack.back()) |
9572 | 0 | { |
9573 | 0 | return {false, nullptr}; |
9574 | 0 | } |
9575 | | |
9576 | | // we now only expect arrays and objects |
9577 | 0 | JSON_ASSERT(ref_stack.back()->is_array() || ref_stack.back()->is_object()); |
9578 | | |
9579 | | // array |
9580 | 0 | if (ref_stack.back()->is_array()) |
9581 | 0 | { |
9582 | 0 | ref_stack.back()->m_data.m_value.array->emplace_back(std::move(value)); |
9583 | 0 | return {true, & (ref_stack.back()->m_data.m_value.array->back())}; |
9584 | 0 | } |
9585 | | |
9586 | | // object |
9587 | 0 | JSON_ASSERT(ref_stack.back()->is_object()); |
9588 | | // check if we should store an element for the current key |
9589 | 0 | JSON_ASSERT(!key_keep_stack.empty()); |
9590 | 0 | const bool store_element = key_keep_stack.back(); |
9591 | 0 | key_keep_stack.pop_back(); |
9592 | |
|
9593 | 0 | if (!store_element) |
9594 | 0 | { |
9595 | 0 | return {false, nullptr}; |
9596 | 0 | } |
9597 | | |
9598 | 0 | JSON_ASSERT(object_element); |
9599 | 0 | *object_element = std::move(value); |
9600 | 0 | return {true, object_element}; |
9601 | 0 | } Unexecuted instantiation: std::__1::pair<bool, nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>*> nlohmann::json_abi_v3_12_0::detail::json_sax_dom_callback_parser<nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>, nlohmann::json_abi_v3_12_0::detail::iterator_input_adapter<char const*> >::handle_value<nlohmann::json_abi_v3_12_0::detail::value_t>(nlohmann::json_abi_v3_12_0::detail::value_t&&, bool) Unexecuted instantiation: std::__1::pair<bool, nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>*> nlohmann::json_abi_v3_12_0::detail::json_sax_dom_callback_parser<nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>, nlohmann::json_abi_v3_12_0::detail::iterator_input_adapter<char const*> >::handle_value<double&>(double&, bool) Unexecuted instantiation: std::__1::pair<bool, nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>*> nlohmann::json_abi_v3_12_0::detail::json_sax_dom_callback_parser<nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>, nlohmann::json_abi_v3_12_0::detail::iterator_input_adapter<char const*> >::handle_value<bool&>(bool&, bool) Unexecuted instantiation: std::__1::pair<bool, nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>*> nlohmann::json_abi_v3_12_0::detail::json_sax_dom_callback_parser<nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>, nlohmann::json_abi_v3_12_0::detail::iterator_input_adapter<char const*> >::handle_value<decltype(nullptr)>(decltype(nullptr)&&, bool) Unexecuted instantiation: std::__1::pair<bool, nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>*> nlohmann::json_abi_v3_12_0::detail::json_sax_dom_callback_parser<nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>, nlohmann::json_abi_v3_12_0::detail::iterator_input_adapter<char const*> >::handle_value<long&>(long&, bool) Unexecuted instantiation: std::__1::pair<bool, nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>*> nlohmann::json_abi_v3_12_0::detail::json_sax_dom_callback_parser<nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>, nlohmann::json_abi_v3_12_0::detail::iterator_input_adapter<char const*> >::handle_value<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&>(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&, bool) Unexecuted instantiation: std::__1::pair<bool, nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>*> nlohmann::json_abi_v3_12_0::detail::json_sax_dom_callback_parser<nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>, nlohmann::json_abi_v3_12_0::detail::iterator_input_adapter<char const*> >::handle_value<unsigned long&>(unsigned long&, bool) Unexecuted instantiation: std::__1::pair<bool, nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>*> nlohmann::json_abi_v3_12_0::detail::json_sax_dom_callback_parser<nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>, nlohmann::json_abi_v3_12_0::detail::input_stream_adapter>::handle_value<nlohmann::json_abi_v3_12_0::detail::value_t>(nlohmann::json_abi_v3_12_0::detail::value_t&&, bool) Unexecuted instantiation: std::__1::pair<bool, nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>*> nlohmann::json_abi_v3_12_0::detail::json_sax_dom_callback_parser<nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>, nlohmann::json_abi_v3_12_0::detail::input_stream_adapter>::handle_value<double&>(double&, bool) Unexecuted instantiation: std::__1::pair<bool, nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>*> nlohmann::json_abi_v3_12_0::detail::json_sax_dom_callback_parser<nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>, nlohmann::json_abi_v3_12_0::detail::input_stream_adapter>::handle_value<bool&>(bool&, bool) Unexecuted instantiation: std::__1::pair<bool, nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>*> nlohmann::json_abi_v3_12_0::detail::json_sax_dom_callback_parser<nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>, nlohmann::json_abi_v3_12_0::detail::input_stream_adapter>::handle_value<decltype(nullptr)>(decltype(nullptr)&&, bool) Unexecuted instantiation: std::__1::pair<bool, nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>*> nlohmann::json_abi_v3_12_0::detail::json_sax_dom_callback_parser<nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>, nlohmann::json_abi_v3_12_0::detail::input_stream_adapter>::handle_value<long&>(long&, bool) Unexecuted instantiation: std::__1::pair<bool, nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>*> nlohmann::json_abi_v3_12_0::detail::json_sax_dom_callback_parser<nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>, nlohmann::json_abi_v3_12_0::detail::input_stream_adapter>::handle_value<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&>(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&, bool) Unexecuted instantiation: std::__1::pair<bool, nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>*> nlohmann::json_abi_v3_12_0::detail::json_sax_dom_callback_parser<nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>, nlohmann::json_abi_v3_12_0::detail::input_stream_adapter>::handle_value<unsigned long&>(unsigned long&, bool) |
9602 | | |
9603 | | /// the parsed JSON value |
9604 | | BasicJsonType& root; |
9605 | | /// stack to model hierarchy of values |
9606 | | std::vector<BasicJsonType*> ref_stack {}; |
9607 | | /// stack to manage which values to keep |
9608 | | std::vector<bool> keep_stack {}; // NOLINT(readability-redundant-member-init) |
9609 | | /// stack to manage which object keys to keep |
9610 | | std::vector<bool> key_keep_stack {}; // NOLINT(readability-redundant-member-init) |
9611 | | /// helper to hold the reference for the next object element |
9612 | | BasicJsonType* object_element = nullptr; |
9613 | | /// whether a syntax error occurred |
9614 | | bool errored = false; |
9615 | | /// callback function |
9616 | | const parser_callback_t callback = nullptr; |
9617 | | /// whether to throw exceptions in case of errors |
9618 | | const bool allow_exceptions = true; |
9619 | | /// a discarded value for the callback |
9620 | | BasicJsonType discarded = BasicJsonType::value_t::discarded; |
9621 | | /// the lexer reference to obtain the current position |
9622 | | lexer_t* m_lexer_ref = nullptr; |
9623 | | }; |
9624 | | |
9625 | | template<typename BasicJsonType> |
9626 | | class json_sax_acceptor |
9627 | | { |
9628 | | public: |
9629 | | using number_integer_t = typename BasicJsonType::number_integer_t; |
9630 | | using number_unsigned_t = typename BasicJsonType::number_unsigned_t; |
9631 | | using number_float_t = typename BasicJsonType::number_float_t; |
9632 | | using string_t = typename BasicJsonType::string_t; |
9633 | | using binary_t = typename BasicJsonType::binary_t; |
9634 | | |
9635 | | bool null() |
9636 | | { |
9637 | | return true; |
9638 | | } |
9639 | | |
9640 | | bool boolean(bool /*unused*/) |
9641 | | { |
9642 | | return true; |
9643 | | } |
9644 | | |
9645 | | bool number_integer(number_integer_t /*unused*/) |
9646 | | { |
9647 | | return true; |
9648 | | } |
9649 | | |
9650 | | bool number_unsigned(number_unsigned_t /*unused*/) |
9651 | | { |
9652 | | return true; |
9653 | | } |
9654 | | |
9655 | | bool number_float(number_float_t /*unused*/, const string_t& /*unused*/) |
9656 | | { |
9657 | | return true; |
9658 | | } |
9659 | | |
9660 | | bool string(string_t& /*unused*/) |
9661 | | { |
9662 | | return true; |
9663 | | } |
9664 | | |
9665 | | bool binary(binary_t& /*unused*/) |
9666 | | { |
9667 | | return true; |
9668 | | } |
9669 | | |
9670 | | bool start_object(std::size_t /*unused*/ = detail::unknown_size()) |
9671 | | { |
9672 | | return true; |
9673 | | } |
9674 | | |
9675 | | bool key(string_t& /*unused*/) |
9676 | | { |
9677 | | return true; |
9678 | | } |
9679 | | |
9680 | | bool end_object() |
9681 | | { |
9682 | | return true; |
9683 | | } |
9684 | | |
9685 | | bool start_array(std::size_t /*unused*/ = detail::unknown_size()) |
9686 | | { |
9687 | | return true; |
9688 | | } |
9689 | | |
9690 | | bool end_array() |
9691 | | { |
9692 | | return true; |
9693 | | } |
9694 | | |
9695 | | bool parse_error(std::size_t /*unused*/, const std::string& /*unused*/, const detail::exception& /*unused*/) |
9696 | | { |
9697 | | return false; |
9698 | | } |
9699 | | }; |
9700 | | |
9701 | | } // namespace detail |
9702 | | NLOHMANN_JSON_NAMESPACE_END |
9703 | | |
9704 | | // #include <nlohmann/detail/input/lexer.hpp> |
9705 | | |
9706 | | // #include <nlohmann/detail/macro_scope.hpp> |
9707 | | |
9708 | | // #include <nlohmann/detail/meta/is_sax.hpp> |
9709 | | // __ _____ _____ _____ |
9710 | | // __| | __| | | | JSON for Modern C++ |
9711 | | // | | |__ | | | | | | version 3.12.0 |
9712 | | // |_____|_____|_____|_|___| https://github.com/nlohmann/json |
9713 | | // |
9714 | | // SPDX-FileCopyrightText: 2013-2026 Niels Lohmann <https://nlohmann.me> |
9715 | | // SPDX-License-Identifier: MIT |
9716 | | |
9717 | | |
9718 | | |
9719 | | #include <cstdint> // size_t |
9720 | | #include <utility> // declval |
9721 | | #include <string> // string |
9722 | | |
9723 | | // #include <nlohmann/detail/abi_macros.hpp> |
9724 | | |
9725 | | // #include <nlohmann/detail/meta/detected.hpp> |
9726 | | |
9727 | | // #include <nlohmann/detail/meta/type_traits.hpp> |
9728 | | |
9729 | | |
9730 | | NLOHMANN_JSON_NAMESPACE_BEGIN |
9731 | | namespace detail |
9732 | | { |
9733 | | |
9734 | | template<typename T> |
9735 | | using null_function_t = decltype(std::declval<T&>().null()); |
9736 | | |
9737 | | template<typename T> |
9738 | | using boolean_function_t = |
9739 | | decltype(std::declval<T&>().boolean(std::declval<bool>())); |
9740 | | |
9741 | | template<typename T, typename Integer> |
9742 | | using number_integer_function_t = |
9743 | | decltype(std::declval<T&>().number_integer(std::declval<Integer>())); |
9744 | | |
9745 | | template<typename T, typename Unsigned> |
9746 | | using number_unsigned_function_t = |
9747 | | decltype(std::declval<T&>().number_unsigned(std::declval<Unsigned>())); |
9748 | | |
9749 | | template<typename T, typename Float, typename String> |
9750 | | using number_float_function_t = decltype(std::declval<T&>().number_float( |
9751 | | std::declval<Float>(), std::declval<const String&>())); |
9752 | | |
9753 | | template<typename T, typename String> |
9754 | | using string_function_t = |
9755 | | decltype(std::declval<T&>().string(std::declval<String&>())); |
9756 | | |
9757 | | template<typename T, typename Binary> |
9758 | | using binary_function_t = |
9759 | | decltype(std::declval<T&>().binary(std::declval<Binary&>())); |
9760 | | |
9761 | | template<typename T> |
9762 | | using start_object_function_t = |
9763 | | decltype(std::declval<T&>().start_object(std::declval<std::size_t>())); |
9764 | | |
9765 | | template<typename T, typename String> |
9766 | | using key_function_t = |
9767 | | decltype(std::declval<T&>().key(std::declval<String&>())); |
9768 | | |
9769 | | template<typename T> |
9770 | | using end_object_function_t = decltype(std::declval<T&>().end_object()); |
9771 | | |
9772 | | template<typename T> |
9773 | | using start_array_function_t = |
9774 | | decltype(std::declval<T&>().start_array(std::declval<std::size_t>())); |
9775 | | |
9776 | | template<typename T> |
9777 | | using end_array_function_t = decltype(std::declval<T&>().end_array()); |
9778 | | |
9779 | | template<typename T, typename Exception> |
9780 | | using parse_error_function_t = decltype(std::declval<T&>().parse_error( |
9781 | | std::declval<std::size_t>(), std::declval<const std::string&>(), |
9782 | | std::declval<const Exception&>())); |
9783 | | |
9784 | | template<typename SAX, typename BasicJsonType> |
9785 | | struct is_sax |
9786 | | { |
9787 | | private: |
9788 | | static_assert(is_basic_json<BasicJsonType>::value, |
9789 | | "BasicJsonType must be of type basic_json<...>"); |
9790 | | |
9791 | | using number_integer_t = typename BasicJsonType::number_integer_t; |
9792 | | using number_unsigned_t = typename BasicJsonType::number_unsigned_t; |
9793 | | using number_float_t = typename BasicJsonType::number_float_t; |
9794 | | using string_t = typename BasicJsonType::string_t; |
9795 | | using binary_t = typename BasicJsonType::binary_t; |
9796 | | using exception_t = typename BasicJsonType::exception; |
9797 | | |
9798 | | public: |
9799 | | static constexpr bool value = |
9800 | | is_detected_exact<bool, null_function_t, SAX>::value && |
9801 | | is_detected_exact<bool, boolean_function_t, SAX>::value && |
9802 | | is_detected_exact<bool, number_integer_function_t, SAX, number_integer_t>::value && |
9803 | | is_detected_exact<bool, number_unsigned_function_t, SAX, number_unsigned_t>::value && |
9804 | | is_detected_exact<bool, number_float_function_t, SAX, number_float_t, string_t>::value && |
9805 | | is_detected_exact<bool, string_function_t, SAX, string_t>::value && |
9806 | | is_detected_exact<bool, binary_function_t, SAX, binary_t>::value && |
9807 | | is_detected_exact<bool, start_object_function_t, SAX>::value && |
9808 | | is_detected_exact<bool, key_function_t, SAX, string_t>::value && |
9809 | | is_detected_exact<bool, end_object_function_t, SAX>::value && |
9810 | | is_detected_exact<bool, start_array_function_t, SAX>::value && |
9811 | | is_detected_exact<bool, end_array_function_t, SAX>::value && |
9812 | | is_detected_exact<bool, parse_error_function_t, SAX, exception_t>::value; |
9813 | | }; |
9814 | | |
9815 | | template<typename SAX, typename BasicJsonType> |
9816 | | struct is_sax_static_asserts |
9817 | | { |
9818 | | private: |
9819 | | static_assert(is_basic_json<BasicJsonType>::value, |
9820 | | "BasicJsonType must be of type basic_json<...>"); |
9821 | | |
9822 | | using number_integer_t = typename BasicJsonType::number_integer_t; |
9823 | | using number_unsigned_t = typename BasicJsonType::number_unsigned_t; |
9824 | | using number_float_t = typename BasicJsonType::number_float_t; |
9825 | | using string_t = typename BasicJsonType::string_t; |
9826 | | using binary_t = typename BasicJsonType::binary_t; |
9827 | | using exception_t = typename BasicJsonType::exception; |
9828 | | |
9829 | | public: |
9830 | | static_assert(is_detected_exact<bool, null_function_t, SAX>::value, |
9831 | | "Missing/invalid function: bool null()"); |
9832 | | static_assert(is_detected_exact<bool, boolean_function_t, SAX>::value, |
9833 | | "Missing/invalid function: bool boolean(bool)"); |
9834 | | static_assert(is_detected_exact<bool, boolean_function_t, SAX>::value, |
9835 | | "Missing/invalid function: bool boolean(bool)"); |
9836 | | static_assert( |
9837 | | is_detected_exact<bool, number_integer_function_t, SAX, |
9838 | | number_integer_t>::value, |
9839 | | "Missing/invalid function: bool number_integer(number_integer_t)"); |
9840 | | static_assert( |
9841 | | is_detected_exact<bool, number_unsigned_function_t, SAX, |
9842 | | number_unsigned_t>::value, |
9843 | | "Missing/invalid function: bool number_unsigned(number_unsigned_t)"); |
9844 | | static_assert(is_detected_exact<bool, number_float_function_t, SAX, |
9845 | | number_float_t, string_t>::value, |
9846 | | "Missing/invalid function: bool number_float(number_float_t, const string_t&)"); |
9847 | | static_assert( |
9848 | | is_detected_exact<bool, string_function_t, SAX, string_t>::value, |
9849 | | "Missing/invalid function: bool string(string_t&)"); |
9850 | | static_assert( |
9851 | | is_detected_exact<bool, binary_function_t, SAX, binary_t>::value, |
9852 | | "Missing/invalid function: bool binary(binary_t&)"); |
9853 | | static_assert(is_detected_exact<bool, start_object_function_t, SAX>::value, |
9854 | | "Missing/invalid function: bool start_object(std::size_t)"); |
9855 | | static_assert(is_detected_exact<bool, key_function_t, SAX, string_t>::value, |
9856 | | "Missing/invalid function: bool key(string_t&)"); |
9857 | | static_assert(is_detected_exact<bool, end_object_function_t, SAX>::value, |
9858 | | "Missing/invalid function: bool end_object()"); |
9859 | | static_assert(is_detected_exact<bool, start_array_function_t, SAX>::value, |
9860 | | "Missing/invalid function: bool start_array(std::size_t)"); |
9861 | | static_assert(is_detected_exact<bool, end_array_function_t, SAX>::value, |
9862 | | "Missing/invalid function: bool end_array()"); |
9863 | | static_assert( |
9864 | | is_detected_exact<bool, parse_error_function_t, SAX, exception_t>::value, |
9865 | | "Missing/invalid function: bool parse_error(std::size_t, const " |
9866 | | "std::string&, const exception&)"); |
9867 | | }; |
9868 | | |
9869 | | } // namespace detail |
9870 | | NLOHMANN_JSON_NAMESPACE_END |
9871 | | |
9872 | | // #include <nlohmann/detail/meta/type_traits.hpp> |
9873 | | |
9874 | | // #include <nlohmann/detail/string_concat.hpp> |
9875 | | |
9876 | | // #include <nlohmann/detail/value_t.hpp> |
9877 | | |
9878 | | |
9879 | | NLOHMANN_JSON_NAMESPACE_BEGIN |
9880 | | namespace detail |
9881 | | { |
9882 | | |
9883 | | /// how to treat CBOR tags |
9884 | | enum class cbor_tag_handler_t |
9885 | | { |
9886 | | error, ///< throw a parse_error exception in case of a tag |
9887 | | ignore, ///< ignore tags |
9888 | | store ///< store tags as binary type |
9889 | | }; |
9890 | | |
9891 | | /*! |
9892 | | @brief determine system byte order |
9893 | | |
9894 | | @return true if and only if system's byte order is little endian |
9895 | | |
9896 | | @note from https://stackoverflow.com/a/1001328/266378 |
9897 | | */ |
9898 | | inline bool little_endianness(int num = 1) noexcept |
9899 | 0 | { |
9900 | 0 | return *reinterpret_cast<char*>(&num) == 1; |
9901 | 0 | } |
9902 | | |
9903 | | /////////////////// |
9904 | | // binary reader // |
9905 | | /////////////////// |
9906 | | |
9907 | | /*! |
9908 | | @brief deserialization of CBOR, MessagePack, and UBJSON values |
9909 | | */ |
9910 | | template<typename BasicJsonType, typename InputAdapterType, typename SAX = json_sax_dom_parser<BasicJsonType, InputAdapterType>> |
9911 | | class binary_reader |
9912 | | { |
9913 | | using number_integer_t = typename BasicJsonType::number_integer_t; |
9914 | | using number_unsigned_t = typename BasicJsonType::number_unsigned_t; |
9915 | | using number_float_t = typename BasicJsonType::number_float_t; |
9916 | | using string_t = typename BasicJsonType::string_t; |
9917 | | using binary_t = typename BasicJsonType::binary_t; |
9918 | | using json_sax_t = SAX; |
9919 | | using char_type = typename InputAdapterType::char_type; |
9920 | | using char_int_type = typename char_traits<char_type>::int_type; |
9921 | | |
9922 | | public: |
9923 | | /*! |
9924 | | @brief create a binary reader |
9925 | | |
9926 | | @param[in] adapter input adapter to read from |
9927 | | */ |
9928 | | explicit binary_reader(InputAdapterType&& adapter, const input_format_t format = input_format_t::json) noexcept : ia(std::move(adapter)), input_format(format) |
9929 | | { |
9930 | | (void)detail::is_sax_static_asserts<SAX, BasicJsonType> {}; |
9931 | | } |
9932 | | |
9933 | | // make class move-only |
9934 | | binary_reader(const binary_reader&) = delete; |
9935 | | binary_reader(binary_reader&&) = default; // NOLINT(hicpp-noexcept-move,performance-noexcept-move-constructor) |
9936 | | binary_reader& operator=(const binary_reader&) = delete; |
9937 | | binary_reader& operator=(binary_reader&&) = default; // NOLINT(hicpp-noexcept-move,performance-noexcept-move-constructor) |
9938 | | ~binary_reader() = default; |
9939 | | |
9940 | | /*! |
9941 | | @param[in] format the binary format to parse |
9942 | | @param[in] sax_ a SAX event processor |
9943 | | @param[in] strict whether to expect the input to be consumed completed |
9944 | | @param[in] tag_handler how to treat CBOR tags |
9945 | | |
9946 | | @return whether parsing was successful |
9947 | | */ |
9948 | | JSON_HEDLEY_NON_NULL(3) |
9949 | | bool sax_parse(const input_format_t format, |
9950 | | json_sax_t* sax_, |
9951 | | const bool strict = true, |
9952 | | const cbor_tag_handler_t tag_handler = cbor_tag_handler_t::error) |
9953 | | { |
9954 | | sax = sax_; |
9955 | | bool result = false; |
9956 | | |
9957 | | switch (format) |
9958 | | { |
9959 | | case input_format_t::bson: |
9960 | | result = parse_bson_internal(); |
9961 | | break; |
9962 | | |
9963 | | case input_format_t::cbor: |
9964 | | result = parse_cbor_internal(true, tag_handler); |
9965 | | break; |
9966 | | |
9967 | | case input_format_t::msgpack: |
9968 | | result = parse_msgpack_internal(); |
9969 | | break; |
9970 | | |
9971 | | case input_format_t::ubjson: |
9972 | | case input_format_t::bjdata: |
9973 | | result = parse_ubjson_internal(); |
9974 | | break; |
9975 | | |
9976 | | case input_format_t::json: // LCOV_EXCL_LINE |
9977 | | default: // LCOV_EXCL_LINE |
9978 | | JSON_ASSERT(false); // NOLINT(cert-dcl03-c,hicpp-static-assert,misc-static-assert) LCOV_EXCL_LINE |
9979 | | } |
9980 | | |
9981 | | // strict mode: next byte must be EOF |
9982 | | if (result && strict) |
9983 | | { |
9984 | | if (input_format == input_format_t::ubjson || input_format == input_format_t::bjdata) |
9985 | | { |
9986 | | get_ignore_noop(); |
9987 | | } |
9988 | | else |
9989 | | { |
9990 | | get(); |
9991 | | } |
9992 | | |
9993 | | if (JSON_HEDLEY_UNLIKELY(current != char_traits<char_type>::eof())) |
9994 | | { |
9995 | | return sax->parse_error(chars_read, get_token_string(), parse_error::create(110, chars_read, |
9996 | | exception_message(input_format, concat("expected end of input; last byte: 0x", get_token_string()), "value"), nullptr)); |
9997 | | } |
9998 | | } |
9999 | | |
10000 | | return result; |
10001 | | } |
10002 | | |
10003 | | private: |
10004 | | ////////// |
10005 | | // BSON // |
10006 | | ////////// |
10007 | | |
10008 | | /*! |
10009 | | @brief Reads in a BSON-object and passes it to the SAX-parser. |
10010 | | @return whether a valid BSON-value was passed to the SAX parser |
10011 | | */ |
10012 | | bool parse_bson_internal() |
10013 | | { |
10014 | | std::int32_t document_size{}; |
10015 | | get_number<std::int32_t, true>(input_format_t::bson, document_size); |
10016 | | |
10017 | | if (JSON_HEDLEY_UNLIKELY(!sax->start_object(detail::unknown_size()))) |
10018 | | { |
10019 | | return false; |
10020 | | } |
10021 | | |
10022 | | if (JSON_HEDLEY_UNLIKELY(!parse_bson_element_list(/*is_array*/false))) |
10023 | | { |
10024 | | return false; |
10025 | | } |
10026 | | |
10027 | | return sax->end_object(); |
10028 | | } |
10029 | | |
10030 | | /*! |
10031 | | @brief Parses a C-style string from the BSON input. |
10032 | | @param[in,out] result A reference to the string variable where the read |
10033 | | string is to be stored. |
10034 | | @return `true` if the \x00-byte indicating the end of the string was |
10035 | | encountered before the EOF; false` indicates an unexpected EOF. |
10036 | | */ |
10037 | | bool get_bson_cstr(string_t& result) |
10038 | | { |
10039 | | auto out = std::back_inserter(result); |
10040 | | while (true) |
10041 | | { |
10042 | | get(); |
10043 | | if (JSON_HEDLEY_UNLIKELY(!unexpect_eof(input_format_t::bson, "cstring"))) |
10044 | | { |
10045 | | return false; |
10046 | | } |
10047 | | if (current == 0x00) |
10048 | | { |
10049 | | return true; |
10050 | | } |
10051 | | *out++ = static_cast<typename string_t::value_type>(current); |
10052 | | } |
10053 | | } |
10054 | | |
10055 | | /*! |
10056 | | @brief Parses a zero-terminated string of length @a len from the BSON |
10057 | | input. |
10058 | | @param[in] len The length (including the zero-byte at the end) of the |
10059 | | string to be read. |
10060 | | @param[in,out] result A reference to the string variable where the read |
10061 | | string is to be stored. |
10062 | | @tparam NumberType The type of the length @a len |
10063 | | @pre len >= 1 |
10064 | | @return `true` if the string was successfully parsed |
10065 | | */ |
10066 | | template<typename NumberType> |
10067 | | bool get_bson_string(const NumberType len, string_t& result) |
10068 | | { |
10069 | | if (JSON_HEDLEY_UNLIKELY(len < 1)) |
10070 | | { |
10071 | | auto last_token = get_token_string(); |
10072 | | return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read, |
10073 | | exception_message(input_format_t::bson, concat("string length must be at least 1, is ", std::to_string(len)), "string"), nullptr)); |
10074 | | } |
10075 | | |
10076 | | return get_string(input_format_t::bson, len - static_cast<NumberType>(1), result) && get() != char_traits<char_type>::eof(); |
10077 | | } |
10078 | | |
10079 | | /*! |
10080 | | @brief Parses a byte array input of length @a len from the BSON input. |
10081 | | @param[in] len The length of the byte array to be read. |
10082 | | @param[in,out] result A reference to the binary variable where the read |
10083 | | array is to be stored. |
10084 | | @tparam NumberType The type of the length @a len |
10085 | | @pre len >= 0 |
10086 | | @return `true` if the byte array was successfully parsed |
10087 | | */ |
10088 | | template<typename NumberType> |
10089 | | bool get_bson_binary(const NumberType len, binary_t& result) |
10090 | | { |
10091 | | if (JSON_HEDLEY_UNLIKELY(len < 0)) |
10092 | | { |
10093 | | auto last_token = get_token_string(); |
10094 | | return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read, |
10095 | | exception_message(input_format_t::bson, concat("byte array length cannot be negative, is ", std::to_string(len)), "binary"), nullptr)); |
10096 | | } |
10097 | | |
10098 | | // All BSON binary values have a subtype |
10099 | | std::uint8_t subtype{}; |
10100 | | get_number<std::uint8_t>(input_format_t::bson, subtype); |
10101 | | result.set_subtype(subtype); |
10102 | | |
10103 | | return get_binary(input_format_t::bson, len, result); |
10104 | | } |
10105 | | |
10106 | | /*! |
10107 | | @brief Read a BSON document element of the given @a element_type. |
10108 | | @param[in] element_type The BSON element type, c.f. http://bsonspec.org/spec.html |
10109 | | @param[in] element_type_parse_position The position in the input stream, |
10110 | | where the `element_type` was read. |
10111 | | @warning Not all BSON element types are supported yet. An unsupported |
10112 | | @a element_type will give rise to a parse_error.114: |
10113 | | Unsupported BSON record type 0x... |
10114 | | @return whether a valid BSON-object/array was passed to the SAX parser |
10115 | | */ |
10116 | | bool parse_bson_element_internal(const char_int_type element_type, |
10117 | | const std::size_t element_type_parse_position) |
10118 | | { |
10119 | | switch (element_type) |
10120 | | { |
10121 | | case 0x01: // double |
10122 | | { |
10123 | | double number{}; |
10124 | | return get_number<double, true>(input_format_t::bson, number) && sax->number_float(static_cast<number_float_t>(number), ""); |
10125 | | } |
10126 | | |
10127 | | case 0x02: // string |
10128 | | { |
10129 | | std::int32_t len{}; |
10130 | | string_t value; |
10131 | | return get_number<std::int32_t, true>(input_format_t::bson, len) && get_bson_string(len, value) && sax->string(value); |
10132 | | } |
10133 | | |
10134 | | case 0x03: // object |
10135 | | { |
10136 | | return parse_bson_internal(); |
10137 | | } |
10138 | | |
10139 | | case 0x04: // array |
10140 | | { |
10141 | | return parse_bson_array(); |
10142 | | } |
10143 | | |
10144 | | case 0x05: // binary |
10145 | | { |
10146 | | std::int32_t len{}; |
10147 | | binary_t value; |
10148 | | return get_number<std::int32_t, true>(input_format_t::bson, len) && get_bson_binary(len, value) && sax->binary(value); |
10149 | | } |
10150 | | |
10151 | | case 0x08: // boolean |
10152 | | { |
10153 | | return sax->boolean(get() != 0); |
10154 | | } |
10155 | | |
10156 | | case 0x0A: // null |
10157 | | { |
10158 | | return sax->null(); |
10159 | | } |
10160 | | |
10161 | | case 0x10: // int32 |
10162 | | { |
10163 | | std::int32_t value{}; |
10164 | | return get_number<std::int32_t, true>(input_format_t::bson, value) && sax->number_integer(value); |
10165 | | } |
10166 | | |
10167 | | case 0x12: // int64 |
10168 | | { |
10169 | | std::int64_t value{}; |
10170 | | return get_number<std::int64_t, true>(input_format_t::bson, value) && sax->number_integer(value); |
10171 | | } |
10172 | | |
10173 | | case 0x11: // uint64 |
10174 | | { |
10175 | | std::uint64_t value{}; |
10176 | | return get_number<std::uint64_t, true>(input_format_t::bson, value) && sax->number_unsigned(value); |
10177 | | } |
10178 | | |
10179 | | default: // anything else is not supported (yet) |
10180 | | { |
10181 | | std::array<char, 3> cr{{}}; |
10182 | | static_cast<void>((std::snprintf)(cr.data(), cr.size(), "%.2hhX", static_cast<unsigned char>(element_type))); // NOLINT(cppcoreguidelines-pro-type-vararg,hicpp-vararg) |
10183 | | const std::string cr_str{cr.data()}; |
10184 | | return sax->parse_error(element_type_parse_position, cr_str, |
10185 | | parse_error::create(114, element_type_parse_position, concat("Unsupported BSON record type 0x", cr_str), nullptr)); |
10186 | | } |
10187 | | } |
10188 | | } |
10189 | | |
10190 | | /*! |
10191 | | @brief Read a BSON element list (as specified in the BSON-spec) |
10192 | | |
10193 | | The same binary layout is used for objects and arrays, hence it must be |
10194 | | indicated with the argument @a is_array which one is expected |
10195 | | (true --> array, false --> object). |
10196 | | |
10197 | | @param[in] is_array Determines if the element list being read is to be |
10198 | | treated as an object (@a is_array == false), or as an |
10199 | | array (@a is_array == true). |
10200 | | @return whether a valid BSON-object/array was passed to the SAX parser |
10201 | | */ |
10202 | | bool parse_bson_element_list(const bool is_array) |
10203 | | { |
10204 | | string_t key; |
10205 | | |
10206 | | while (auto element_type = get()) |
10207 | | { |
10208 | | if (JSON_HEDLEY_UNLIKELY(!unexpect_eof(input_format_t::bson, "element list"))) |
10209 | | { |
10210 | | return false; |
10211 | | } |
10212 | | |
10213 | | const std::size_t element_type_parse_position = chars_read; |
10214 | | if (JSON_HEDLEY_UNLIKELY(!get_bson_cstr(key))) |
10215 | | { |
10216 | | return false; |
10217 | | } |
10218 | | |
10219 | | if (!is_array && !sax->key(key)) |
10220 | | { |
10221 | | return false; |
10222 | | } |
10223 | | |
10224 | | if (JSON_HEDLEY_UNLIKELY(!parse_bson_element_internal(element_type, element_type_parse_position))) |
10225 | | { |
10226 | | return false; |
10227 | | } |
10228 | | |
10229 | | // get_bson_cstr only appends |
10230 | | key.clear(); |
10231 | | } |
10232 | | |
10233 | | return true; |
10234 | | } |
10235 | | |
10236 | | /*! |
10237 | | @brief Reads an array from the BSON input and passes it to the SAX-parser. |
10238 | | @return whether a valid BSON-array was passed to the SAX parser |
10239 | | */ |
10240 | | bool parse_bson_array() |
10241 | | { |
10242 | | std::int32_t document_size{}; |
10243 | | get_number<std::int32_t, true>(input_format_t::bson, document_size); |
10244 | | |
10245 | | if (JSON_HEDLEY_UNLIKELY(!sax->start_array(detail::unknown_size()))) |
10246 | | { |
10247 | | return false; |
10248 | | } |
10249 | | |
10250 | | if (JSON_HEDLEY_UNLIKELY(!parse_bson_element_list(/*is_array*/true))) |
10251 | | { |
10252 | | return false; |
10253 | | } |
10254 | | |
10255 | | return sax->end_array(); |
10256 | | } |
10257 | | |
10258 | | ////////// |
10259 | | // CBOR // |
10260 | | ////////// |
10261 | | |
10262 | | /*! |
10263 | | @param[in] get_char whether a new character should be retrieved from the |
10264 | | input (true) or whether the last read character should |
10265 | | be considered instead (false) |
10266 | | @param[in] tag_handler how CBOR tags should be treated |
10267 | | |
10268 | | @return whether a valid CBOR value was passed to the SAX parser |
10269 | | */ |
10270 | | |
10271 | | template<typename NumberType> |
10272 | | bool get_cbor_negative_integer() |
10273 | | { |
10274 | | NumberType number{}; |
10275 | | if (JSON_HEDLEY_UNLIKELY(!get_number(input_format_t::cbor, number))) |
10276 | | { |
10277 | | return false; |
10278 | | } |
10279 | | const auto max_val = static_cast<NumberType>((std::numeric_limits<number_integer_t>::max)()); |
10280 | | if (number > max_val) |
10281 | | { |
10282 | | return sax->parse_error(chars_read, get_token_string(), |
10283 | | parse_error::create(112, chars_read, |
10284 | | exception_message(input_format_t::cbor, "negative integer overflow", "value"), nullptr)); |
10285 | | } |
10286 | | return sax->number_integer(static_cast<number_integer_t>(-1) - static_cast<number_integer_t>(number)); |
10287 | | } |
10288 | | |
10289 | | bool parse_cbor_internal(const bool get_char, |
10290 | | const cbor_tag_handler_t tag_handler) |
10291 | | { |
10292 | | switch (get_char ? get() : current) |
10293 | | { |
10294 | | // EOF |
10295 | | case char_traits<char_type>::eof(): |
10296 | | return unexpect_eof(input_format_t::cbor, "value"); |
10297 | | |
10298 | | // Integer 0x00..0x17 (0..23) |
10299 | | case 0x00: |
10300 | | case 0x01: |
10301 | | case 0x02: |
10302 | | case 0x03: |
10303 | | case 0x04: |
10304 | | case 0x05: |
10305 | | case 0x06: |
10306 | | case 0x07: |
10307 | | case 0x08: |
10308 | | case 0x09: |
10309 | | case 0x0A: |
10310 | | case 0x0B: |
10311 | | case 0x0C: |
10312 | | case 0x0D: |
10313 | | case 0x0E: |
10314 | | case 0x0F: |
10315 | | case 0x10: |
10316 | | case 0x11: |
10317 | | case 0x12: |
10318 | | case 0x13: |
10319 | | case 0x14: |
10320 | | case 0x15: |
10321 | | case 0x16: |
10322 | | case 0x17: |
10323 | | return sax->number_unsigned(static_cast<number_unsigned_t>(current)); |
10324 | | |
10325 | | case 0x18: // Unsigned integer (one-byte uint8_t follows) |
10326 | | { |
10327 | | std::uint8_t number{}; |
10328 | | return get_number(input_format_t::cbor, number) && sax->number_unsigned(number); |
10329 | | } |
10330 | | |
10331 | | case 0x19: // Unsigned integer (two-byte uint16_t follows) |
10332 | | { |
10333 | | std::uint16_t number{}; |
10334 | | return get_number(input_format_t::cbor, number) && sax->number_unsigned(number); |
10335 | | } |
10336 | | |
10337 | | case 0x1A: // Unsigned integer (four-byte uint32_t follows) |
10338 | | { |
10339 | | std::uint32_t number{}; |
10340 | | return get_number(input_format_t::cbor, number) && sax->number_unsigned(number); |
10341 | | } |
10342 | | |
10343 | | case 0x1B: // Unsigned integer (eight-byte uint64_t follows) |
10344 | | { |
10345 | | std::uint64_t number{}; |
10346 | | return get_number(input_format_t::cbor, number) && sax->number_unsigned(number); |
10347 | | } |
10348 | | |
10349 | | // Negative integer -1-0x00..-1-0x17 (-1..-24) |
10350 | | case 0x20: |
10351 | | case 0x21: |
10352 | | case 0x22: |
10353 | | case 0x23: |
10354 | | case 0x24: |
10355 | | case 0x25: |
10356 | | case 0x26: |
10357 | | case 0x27: |
10358 | | case 0x28: |
10359 | | case 0x29: |
10360 | | case 0x2A: |
10361 | | case 0x2B: |
10362 | | case 0x2C: |
10363 | | case 0x2D: |
10364 | | case 0x2E: |
10365 | | case 0x2F: |
10366 | | case 0x30: |
10367 | | case 0x31: |
10368 | | case 0x32: |
10369 | | case 0x33: |
10370 | | case 0x34: |
10371 | | case 0x35: |
10372 | | case 0x36: |
10373 | | case 0x37: |
10374 | | return sax->number_integer(static_cast<std::int8_t>(0x20 - 1 - current)); |
10375 | | |
10376 | | case 0x38: // Negative integer (one-byte uint8_t follows) |
10377 | | return get_cbor_negative_integer<std::uint8_t>(); |
10378 | | |
10379 | | case 0x39: // Negative integer -1-n (two-byte uint16_t follows) |
10380 | | return get_cbor_negative_integer<std::uint16_t>(); |
10381 | | |
10382 | | case 0x3A: // Negative integer -1-n (four-byte uint32_t follows) |
10383 | | return get_cbor_negative_integer<std::uint32_t>(); |
10384 | | |
10385 | | case 0x3B: // Negative integer -1-n (eight-byte uint64_t follows) |
10386 | | return get_cbor_negative_integer<std::uint64_t>(); |
10387 | | |
10388 | | // Binary data (0x00..0x17 bytes follow) |
10389 | | case 0x40: |
10390 | | case 0x41: |
10391 | | case 0x42: |
10392 | | case 0x43: |
10393 | | case 0x44: |
10394 | | case 0x45: |
10395 | | case 0x46: |
10396 | | case 0x47: |
10397 | | case 0x48: |
10398 | | case 0x49: |
10399 | | case 0x4A: |
10400 | | case 0x4B: |
10401 | | case 0x4C: |
10402 | | case 0x4D: |
10403 | | case 0x4E: |
10404 | | case 0x4F: |
10405 | | case 0x50: |
10406 | | case 0x51: |
10407 | | case 0x52: |
10408 | | case 0x53: |
10409 | | case 0x54: |
10410 | | case 0x55: |
10411 | | case 0x56: |
10412 | | case 0x57: |
10413 | | case 0x58: // Binary data (one-byte uint8_t for n follows) |
10414 | | case 0x59: // Binary data (two-byte uint16_t for n follow) |
10415 | | case 0x5A: // Binary data (four-byte uint32_t for n follow) |
10416 | | case 0x5B: // Binary data (eight-byte uint64_t for n follow) |
10417 | | case 0x5F: // Binary data (indefinite length) |
10418 | | { |
10419 | | binary_t b; |
10420 | | return get_cbor_binary(b) && sax->binary(b); |
10421 | | } |
10422 | | |
10423 | | // UTF-8 string (0x00..0x17 bytes follow) |
10424 | | case 0x60: |
10425 | | case 0x61: |
10426 | | case 0x62: |
10427 | | case 0x63: |
10428 | | case 0x64: |
10429 | | case 0x65: |
10430 | | case 0x66: |
10431 | | case 0x67: |
10432 | | case 0x68: |
10433 | | case 0x69: |
10434 | | case 0x6A: |
10435 | | case 0x6B: |
10436 | | case 0x6C: |
10437 | | case 0x6D: |
10438 | | case 0x6E: |
10439 | | case 0x6F: |
10440 | | case 0x70: |
10441 | | case 0x71: |
10442 | | case 0x72: |
10443 | | case 0x73: |
10444 | | case 0x74: |
10445 | | case 0x75: |
10446 | | case 0x76: |
10447 | | case 0x77: |
10448 | | case 0x78: // UTF-8 string (one-byte uint8_t for n follows) |
10449 | | case 0x79: // UTF-8 string (two-byte uint16_t for n follow) |
10450 | | case 0x7A: // UTF-8 string (four-byte uint32_t for n follow) |
10451 | | case 0x7B: // UTF-8 string (eight-byte uint64_t for n follow) |
10452 | | case 0x7F: // UTF-8 string (indefinite length) |
10453 | | { |
10454 | | string_t s; |
10455 | | return get_cbor_string(s) && sax->string(s); |
10456 | | } |
10457 | | |
10458 | | // array (0x00..0x17 data items follow) |
10459 | | case 0x80: |
10460 | | case 0x81: |
10461 | | case 0x82: |
10462 | | case 0x83: |
10463 | | case 0x84: |
10464 | | case 0x85: |
10465 | | case 0x86: |
10466 | | case 0x87: |
10467 | | case 0x88: |
10468 | | case 0x89: |
10469 | | case 0x8A: |
10470 | | case 0x8B: |
10471 | | case 0x8C: |
10472 | | case 0x8D: |
10473 | | case 0x8E: |
10474 | | case 0x8F: |
10475 | | case 0x90: |
10476 | | case 0x91: |
10477 | | case 0x92: |
10478 | | case 0x93: |
10479 | | case 0x94: |
10480 | | case 0x95: |
10481 | | case 0x96: |
10482 | | case 0x97: |
10483 | | return get_cbor_array( |
10484 | | conditional_static_cast<std::size_t>(static_cast<unsigned int>(current) & 0x1Fu), tag_handler); |
10485 | | |
10486 | | case 0x98: // array (one-byte uint8_t for n follows) |
10487 | | { |
10488 | | std::uint8_t len{}; |
10489 | | return get_number(input_format_t::cbor, len) && get_cbor_array(static_cast<std::size_t>(len), tag_handler); |
10490 | | } |
10491 | | |
10492 | | case 0x99: // array (two-byte uint16_t for n follow) |
10493 | | { |
10494 | | std::uint16_t len{}; |
10495 | | return get_number(input_format_t::cbor, len) && get_cbor_array(static_cast<std::size_t>(len), tag_handler); |
10496 | | } |
10497 | | |
10498 | | case 0x9A: // array (four-byte uint32_t for n follow) |
10499 | | { |
10500 | | std::uint32_t len{}; |
10501 | | return get_number(input_format_t::cbor, len) && get_cbor_array(conditional_static_cast<std::size_t>(len), tag_handler); |
10502 | | } |
10503 | | |
10504 | | case 0x9B: // array (eight-byte uint64_t for n follow) |
10505 | | { |
10506 | | std::uint64_t len{}; |
10507 | | return get_number(input_format_t::cbor, len) && get_cbor_array(conditional_static_cast<std::size_t>(len), tag_handler); |
10508 | | } |
10509 | | |
10510 | | case 0x9F: // array (indefinite length) |
10511 | | return get_cbor_array(detail::unknown_size(), tag_handler); |
10512 | | |
10513 | | // map (0x00..0x17 pairs of data items follow) |
10514 | | case 0xA0: |
10515 | | case 0xA1: |
10516 | | case 0xA2: |
10517 | | case 0xA3: |
10518 | | case 0xA4: |
10519 | | case 0xA5: |
10520 | | case 0xA6: |
10521 | | case 0xA7: |
10522 | | case 0xA8: |
10523 | | case 0xA9: |
10524 | | case 0xAA: |
10525 | | case 0xAB: |
10526 | | case 0xAC: |
10527 | | case 0xAD: |
10528 | | case 0xAE: |
10529 | | case 0xAF: |
10530 | | case 0xB0: |
10531 | | case 0xB1: |
10532 | | case 0xB2: |
10533 | | case 0xB3: |
10534 | | case 0xB4: |
10535 | | case 0xB5: |
10536 | | case 0xB6: |
10537 | | case 0xB7: |
10538 | | return get_cbor_object(conditional_static_cast<std::size_t>(static_cast<unsigned int>(current) & 0x1Fu), tag_handler); |
10539 | | |
10540 | | case 0xB8: // map (one-byte uint8_t for n follows) |
10541 | | { |
10542 | | std::uint8_t len{}; |
10543 | | return get_number(input_format_t::cbor, len) && get_cbor_object(static_cast<std::size_t>(len), tag_handler); |
10544 | | } |
10545 | | |
10546 | | case 0xB9: // map (two-byte uint16_t for n follow) |
10547 | | { |
10548 | | std::uint16_t len{}; |
10549 | | return get_number(input_format_t::cbor, len) && get_cbor_object(static_cast<std::size_t>(len), tag_handler); |
10550 | | } |
10551 | | |
10552 | | case 0xBA: // map (four-byte uint32_t for n follow) |
10553 | | { |
10554 | | std::uint32_t len{}; |
10555 | | return get_number(input_format_t::cbor, len) && get_cbor_object(conditional_static_cast<std::size_t>(len), tag_handler); |
10556 | | } |
10557 | | |
10558 | | case 0xBB: // map (eight-byte uint64_t for n follow) |
10559 | | { |
10560 | | std::uint64_t len{}; |
10561 | | return get_number(input_format_t::cbor, len) && get_cbor_object(conditional_static_cast<std::size_t>(len), tag_handler); |
10562 | | } |
10563 | | |
10564 | | case 0xBF: // map (indefinite length) |
10565 | | return get_cbor_object(detail::unknown_size(), tag_handler); |
10566 | | |
10567 | | case 0xC6: // tagged item |
10568 | | case 0xC7: |
10569 | | case 0xC8: |
10570 | | case 0xC9: |
10571 | | case 0xCA: |
10572 | | case 0xCB: |
10573 | | case 0xCC: |
10574 | | case 0xCD: |
10575 | | case 0xCE: |
10576 | | case 0xCF: |
10577 | | case 0xD0: |
10578 | | case 0xD1: |
10579 | | case 0xD2: |
10580 | | case 0xD3: |
10581 | | case 0xD4: |
10582 | | case 0xD8: // tagged item (1 byte follows) |
10583 | | case 0xD9: // tagged item (2 bytes follow) |
10584 | | case 0xDA: // tagged item (4 bytes follow) |
10585 | | case 0xDB: // tagged item (8 bytes follow) |
10586 | | { |
10587 | | switch (tag_handler) |
10588 | | { |
10589 | | case cbor_tag_handler_t::error: |
10590 | | { |
10591 | | auto last_token = get_token_string(); |
10592 | | return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read, |
10593 | | exception_message(input_format_t::cbor, concat("invalid byte: 0x", last_token), "value"), nullptr)); |
10594 | | } |
10595 | | |
10596 | | case cbor_tag_handler_t::ignore: |
10597 | | { |
10598 | | // ignore binary subtype |
10599 | | switch (current) |
10600 | | { |
10601 | | case 0xD8: |
10602 | | { |
10603 | | std::uint8_t subtype_to_ignore{}; |
10604 | | get_number(input_format_t::cbor, subtype_to_ignore); |
10605 | | break; |
10606 | | } |
10607 | | case 0xD9: |
10608 | | { |
10609 | | std::uint16_t subtype_to_ignore{}; |
10610 | | get_number(input_format_t::cbor, subtype_to_ignore); |
10611 | | break; |
10612 | | } |
10613 | | case 0xDA: |
10614 | | { |
10615 | | std::uint32_t subtype_to_ignore{}; |
10616 | | get_number(input_format_t::cbor, subtype_to_ignore); |
10617 | | break; |
10618 | | } |
10619 | | case 0xDB: |
10620 | | { |
10621 | | std::uint64_t subtype_to_ignore{}; |
10622 | | get_number(input_format_t::cbor, subtype_to_ignore); |
10623 | | break; |
10624 | | } |
10625 | | default: |
10626 | | break; |
10627 | | } |
10628 | | return parse_cbor_internal(true, tag_handler); |
10629 | | } |
10630 | | |
10631 | | case cbor_tag_handler_t::store: |
10632 | | { |
10633 | | binary_t b; |
10634 | | // use binary subtype and store in a binary container |
10635 | | switch (current) |
10636 | | { |
10637 | | case 0xD8: |
10638 | | { |
10639 | | std::uint8_t subtype{}; |
10640 | | get_number(input_format_t::cbor, subtype); |
10641 | | b.set_subtype(detail::conditional_static_cast<typename binary_t::subtype_type>(subtype)); |
10642 | | break; |
10643 | | } |
10644 | | case 0xD9: |
10645 | | { |
10646 | | std::uint16_t subtype{}; |
10647 | | get_number(input_format_t::cbor, subtype); |
10648 | | b.set_subtype(detail::conditional_static_cast<typename binary_t::subtype_type>(subtype)); |
10649 | | break; |
10650 | | } |
10651 | | case 0xDA: |
10652 | | { |
10653 | | std::uint32_t subtype{}; |
10654 | | get_number(input_format_t::cbor, subtype); |
10655 | | b.set_subtype(detail::conditional_static_cast<typename binary_t::subtype_type>(subtype)); |
10656 | | break; |
10657 | | } |
10658 | | case 0xDB: |
10659 | | { |
10660 | | std::uint64_t subtype{}; |
10661 | | get_number(input_format_t::cbor, subtype); |
10662 | | b.set_subtype(detail::conditional_static_cast<typename binary_t::subtype_type>(subtype)); |
10663 | | break; |
10664 | | } |
10665 | | default: |
10666 | | return parse_cbor_internal(true, tag_handler); |
10667 | | } |
10668 | | get(); |
10669 | | return get_cbor_binary(b) && sax->binary(b); |
10670 | | } |
10671 | | |
10672 | | default: // LCOV_EXCL_LINE |
10673 | | JSON_ASSERT(false); // NOLINT(cert-dcl03-c,hicpp-static-assert,misc-static-assert) LCOV_EXCL_LINE |
10674 | | return false; // LCOV_EXCL_LINE |
10675 | | } |
10676 | | } |
10677 | | |
10678 | | case 0xF4: // false |
10679 | | return sax->boolean(false); |
10680 | | |
10681 | | case 0xF5: // true |
10682 | | return sax->boolean(true); |
10683 | | |
10684 | | case 0xF6: // null |
10685 | | return sax->null(); |
10686 | | |
10687 | | case 0xF9: // Half-Precision Float (two-byte IEEE 754) |
10688 | | { |
10689 | | const auto byte1_raw = get(); |
10690 | | if (JSON_HEDLEY_UNLIKELY(!unexpect_eof(input_format_t::cbor, "number"))) |
10691 | | { |
10692 | | return false; |
10693 | | } |
10694 | | const auto byte2_raw = get(); |
10695 | | if (JSON_HEDLEY_UNLIKELY(!unexpect_eof(input_format_t::cbor, "number"))) |
10696 | | { |
10697 | | return false; |
10698 | | } |
10699 | | |
10700 | | const auto byte1 = static_cast<unsigned char>(byte1_raw); |
10701 | | const auto byte2 = static_cast<unsigned char>(byte2_raw); |
10702 | | |
10703 | | // Code from RFC 7049, Appendix D, Figure 3: |
10704 | | // As half-precision floating-point numbers were only added |
10705 | | // to IEEE 754 in 2008, today's programming platforms often |
10706 | | // still only have limited support for them. It is very |
10707 | | // easy to include at least decoding support for them even |
10708 | | // without such support. An example of a small decoder for |
10709 | | // half-precision floating-point numbers in the C language |
10710 | | // is shown in Fig. 3. |
10711 | | const auto half = static_cast<unsigned int>((byte1 << 8u) + byte2); |
10712 | | const double val = [&half] |
10713 | | { |
10714 | | const int exp = (half >> 10u) & 0x1Fu; |
10715 | | const unsigned int mant = half & 0x3FFu; |
10716 | | JSON_ASSERT(0 <= exp&& exp <= 32); |
10717 | | JSON_ASSERT(mant <= 1024); |
10718 | | switch (exp) |
10719 | | { |
10720 | | case 0: |
10721 | | return std::ldexp(mant, -24); |
10722 | | case 31: |
10723 | | return (mant == 0) |
10724 | | ? std::numeric_limits<double>::infinity() |
10725 | | : std::numeric_limits<double>::quiet_NaN(); |
10726 | | default: |
10727 | | return std::ldexp(mant + 1024, exp - 25); |
10728 | | } |
10729 | | }(); |
10730 | | return sax->number_float((half & 0x8000u) != 0 |
10731 | | ? static_cast<number_float_t>(-val) |
10732 | | : static_cast<number_float_t>(val), ""); |
10733 | | } |
10734 | | |
10735 | | case 0xFA: // Single-Precision Float (four-byte IEEE 754) |
10736 | | { |
10737 | | float number{}; |
10738 | | return get_number(input_format_t::cbor, number) && sax->number_float(static_cast<number_float_t>(number), ""); |
10739 | | } |
10740 | | |
10741 | | case 0xFB: // Double-Precision Float (eight-byte IEEE 754) |
10742 | | { |
10743 | | double number{}; |
10744 | | return get_number(input_format_t::cbor, number) && sax->number_float(static_cast<number_float_t>(number), ""); |
10745 | | } |
10746 | | |
10747 | | default: // anything else (0xFF is handled inside the other types) |
10748 | | { |
10749 | | auto last_token = get_token_string(); |
10750 | | return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read, |
10751 | | exception_message(input_format_t::cbor, concat("invalid byte: 0x", last_token), "value"), nullptr)); |
10752 | | } |
10753 | | } |
10754 | | } |
10755 | | |
10756 | | /*! |
10757 | | @brief reads a CBOR string |
10758 | | |
10759 | | This function first reads starting bytes to determine the expected |
10760 | | string length and then copies this number of bytes into a string. |
10761 | | Additionally, CBOR's strings with indefinite lengths are supported. |
10762 | | |
10763 | | @param[out] result created string |
10764 | | |
10765 | | @return whether string creation completed |
10766 | | */ |
10767 | | bool get_cbor_string(string_t& result) |
10768 | | { |
10769 | | if (JSON_HEDLEY_UNLIKELY(!unexpect_eof(input_format_t::cbor, "string"))) |
10770 | | { |
10771 | | return false; |
10772 | | } |
10773 | | |
10774 | | switch (current) |
10775 | | { |
10776 | | // UTF-8 string (0x00..0x17 bytes follow) |
10777 | | case 0x60: |
10778 | | case 0x61: |
10779 | | case 0x62: |
10780 | | case 0x63: |
10781 | | case 0x64: |
10782 | | case 0x65: |
10783 | | case 0x66: |
10784 | | case 0x67: |
10785 | | case 0x68: |
10786 | | case 0x69: |
10787 | | case 0x6A: |
10788 | | case 0x6B: |
10789 | | case 0x6C: |
10790 | | case 0x6D: |
10791 | | case 0x6E: |
10792 | | case 0x6F: |
10793 | | case 0x70: |
10794 | | case 0x71: |
10795 | | case 0x72: |
10796 | | case 0x73: |
10797 | | case 0x74: |
10798 | | case 0x75: |
10799 | | case 0x76: |
10800 | | case 0x77: |
10801 | | { |
10802 | | return get_string(input_format_t::cbor, static_cast<unsigned int>(current) & 0x1Fu, result); |
10803 | | } |
10804 | | |
10805 | | case 0x78: // UTF-8 string (one-byte uint8_t for n follows) |
10806 | | { |
10807 | | std::uint8_t len{}; |
10808 | | return get_number(input_format_t::cbor, len) && get_string(input_format_t::cbor, len, result); |
10809 | | } |
10810 | | |
10811 | | case 0x79: // UTF-8 string (two-byte uint16_t for n follow) |
10812 | | { |
10813 | | std::uint16_t len{}; |
10814 | | return get_number(input_format_t::cbor, len) && get_string(input_format_t::cbor, len, result); |
10815 | | } |
10816 | | |
10817 | | case 0x7A: // UTF-8 string (four-byte uint32_t for n follow) |
10818 | | { |
10819 | | std::uint32_t len{}; |
10820 | | return get_number(input_format_t::cbor, len) && get_string(input_format_t::cbor, len, result); |
10821 | | } |
10822 | | |
10823 | | case 0x7B: // UTF-8 string (eight-byte uint64_t for n follow) |
10824 | | { |
10825 | | std::uint64_t len{}; |
10826 | | return get_number(input_format_t::cbor, len) && get_string(input_format_t::cbor, len, result); |
10827 | | } |
10828 | | |
10829 | | case 0x7F: // UTF-8 string (indefinite length) |
10830 | | { |
10831 | | while (get() != 0xFF) |
10832 | | { |
10833 | | string_t chunk; |
10834 | | if (!get_cbor_string(chunk)) |
10835 | | { |
10836 | | return false; |
10837 | | } |
10838 | | result.append(chunk); |
10839 | | } |
10840 | | return true; |
10841 | | } |
10842 | | |
10843 | | default: |
10844 | | { |
10845 | | auto last_token = get_token_string(); |
10846 | | return sax->parse_error(chars_read, last_token, parse_error::create(113, chars_read, |
10847 | | exception_message(input_format_t::cbor, concat("expected length specification (0x60-0x7B) or indefinite string type (0x7F); last byte: 0x", last_token), "string"), nullptr)); |
10848 | | } |
10849 | | } |
10850 | | } |
10851 | | |
10852 | | /*! |
10853 | | @brief reads a CBOR byte array |
10854 | | |
10855 | | This function first reads starting bytes to determine the expected |
10856 | | byte array length and then copies this number of bytes into the byte array. |
10857 | | Additionally, CBOR's byte arrays with indefinite lengths are supported. |
10858 | | |
10859 | | @param[out] result created byte array |
10860 | | |
10861 | | @return whether byte array creation completed |
10862 | | */ |
10863 | | bool get_cbor_binary(binary_t& result) |
10864 | | { |
10865 | | if (JSON_HEDLEY_UNLIKELY(!unexpect_eof(input_format_t::cbor, "binary"))) |
10866 | | { |
10867 | | return false; |
10868 | | } |
10869 | | |
10870 | | switch (current) |
10871 | | { |
10872 | | // Binary data (0x00..0x17 bytes follow) |
10873 | | case 0x40: |
10874 | | case 0x41: |
10875 | | case 0x42: |
10876 | | case 0x43: |
10877 | | case 0x44: |
10878 | | case 0x45: |
10879 | | case 0x46: |
10880 | | case 0x47: |
10881 | | case 0x48: |
10882 | | case 0x49: |
10883 | | case 0x4A: |
10884 | | case 0x4B: |
10885 | | case 0x4C: |
10886 | | case 0x4D: |
10887 | | case 0x4E: |
10888 | | case 0x4F: |
10889 | | case 0x50: |
10890 | | case 0x51: |
10891 | | case 0x52: |
10892 | | case 0x53: |
10893 | | case 0x54: |
10894 | | case 0x55: |
10895 | | case 0x56: |
10896 | | case 0x57: |
10897 | | { |
10898 | | return get_binary(input_format_t::cbor, static_cast<unsigned int>(current) & 0x1Fu, result); |
10899 | | } |
10900 | | |
10901 | | case 0x58: // Binary data (one-byte uint8_t for n follows) |
10902 | | { |
10903 | | std::uint8_t len{}; |
10904 | | return get_number(input_format_t::cbor, len) && |
10905 | | get_binary(input_format_t::cbor, len, result); |
10906 | | } |
10907 | | |
10908 | | case 0x59: // Binary data (two-byte uint16_t for n follow) |
10909 | | { |
10910 | | std::uint16_t len{}; |
10911 | | return get_number(input_format_t::cbor, len) && |
10912 | | get_binary(input_format_t::cbor, len, result); |
10913 | | } |
10914 | | |
10915 | | case 0x5A: // Binary data (four-byte uint32_t for n follow) |
10916 | | { |
10917 | | std::uint32_t len{}; |
10918 | | return get_number(input_format_t::cbor, len) && |
10919 | | get_binary(input_format_t::cbor, len, result); |
10920 | | } |
10921 | | |
10922 | | case 0x5B: // Binary data (eight-byte uint64_t for n follow) |
10923 | | { |
10924 | | std::uint64_t len{}; |
10925 | | return get_number(input_format_t::cbor, len) && |
10926 | | get_binary(input_format_t::cbor, len, result); |
10927 | | } |
10928 | | |
10929 | | case 0x5F: // Binary data (indefinite length) |
10930 | | { |
10931 | | while (get() != 0xFF) |
10932 | | { |
10933 | | binary_t chunk; |
10934 | | if (!get_cbor_binary(chunk)) |
10935 | | { |
10936 | | return false; |
10937 | | } |
10938 | | result.insert(result.end(), chunk.begin(), chunk.end()); |
10939 | | } |
10940 | | return true; |
10941 | | } |
10942 | | |
10943 | | default: |
10944 | | { |
10945 | | auto last_token = get_token_string(); |
10946 | | return sax->parse_error(chars_read, last_token, parse_error::create(113, chars_read, |
10947 | | exception_message(input_format_t::cbor, concat("expected length specification (0x40-0x5B) or indefinite binary array type (0x5F); last byte: 0x", last_token), "binary"), nullptr)); |
10948 | | } |
10949 | | } |
10950 | | } |
10951 | | |
10952 | | /*! |
10953 | | @param[in] len the length of the array or detail::unknown_size() for an |
10954 | | array of indefinite size |
10955 | | @param[in] tag_handler how CBOR tags should be treated |
10956 | | @return whether array creation completed |
10957 | | */ |
10958 | | bool get_cbor_array(const std::size_t len, |
10959 | | const cbor_tag_handler_t tag_handler) |
10960 | | { |
10961 | | if (JSON_HEDLEY_UNLIKELY(!sax->start_array(len))) |
10962 | | { |
10963 | | return false; |
10964 | | } |
10965 | | |
10966 | | if (len != detail::unknown_size()) |
10967 | | { |
10968 | | for (std::size_t i = 0; i < len; ++i) |
10969 | | { |
10970 | | if (JSON_HEDLEY_UNLIKELY(!parse_cbor_internal(true, tag_handler))) |
10971 | | { |
10972 | | return false; |
10973 | | } |
10974 | | } |
10975 | | } |
10976 | | else |
10977 | | { |
10978 | | while (get() != 0xFF) |
10979 | | { |
10980 | | if (JSON_HEDLEY_UNLIKELY(!parse_cbor_internal(false, tag_handler))) |
10981 | | { |
10982 | | return false; |
10983 | | } |
10984 | | } |
10985 | | } |
10986 | | |
10987 | | return sax->end_array(); |
10988 | | } |
10989 | | |
10990 | | /*! |
10991 | | @param[in] len the length of the object or detail::unknown_size() for an |
10992 | | object of indefinite size |
10993 | | @param[in] tag_handler how CBOR tags should be treated |
10994 | | @return whether object creation completed |
10995 | | */ |
10996 | | bool get_cbor_object(const std::size_t len, |
10997 | | const cbor_tag_handler_t tag_handler) |
10998 | | { |
10999 | | if (JSON_HEDLEY_UNLIKELY(!sax->start_object(len))) |
11000 | | { |
11001 | | return false; |
11002 | | } |
11003 | | |
11004 | | if (len != 0) |
11005 | | { |
11006 | | string_t key; |
11007 | | if (len != detail::unknown_size()) |
11008 | | { |
11009 | | for (std::size_t i = 0; i < len; ++i) |
11010 | | { |
11011 | | get(); |
11012 | | if (JSON_HEDLEY_UNLIKELY(!get_cbor_string(key) || !sax->key(key))) |
11013 | | { |
11014 | | return false; |
11015 | | } |
11016 | | |
11017 | | if (JSON_HEDLEY_UNLIKELY(!parse_cbor_internal(true, tag_handler))) |
11018 | | { |
11019 | | return false; |
11020 | | } |
11021 | | key.clear(); |
11022 | | } |
11023 | | } |
11024 | | else |
11025 | | { |
11026 | | while (get() != 0xFF) |
11027 | | { |
11028 | | if (JSON_HEDLEY_UNLIKELY(!get_cbor_string(key) || !sax->key(key))) |
11029 | | { |
11030 | | return false; |
11031 | | } |
11032 | | |
11033 | | if (JSON_HEDLEY_UNLIKELY(!parse_cbor_internal(true, tag_handler))) |
11034 | | { |
11035 | | return false; |
11036 | | } |
11037 | | key.clear(); |
11038 | | } |
11039 | | } |
11040 | | } |
11041 | | |
11042 | | return sax->end_object(); |
11043 | | } |
11044 | | |
11045 | | ///////////// |
11046 | | // MsgPack // |
11047 | | ///////////// |
11048 | | |
11049 | | /*! |
11050 | | @return whether a valid MessagePack value was passed to the SAX parser |
11051 | | */ |
11052 | | bool parse_msgpack_internal() |
11053 | | { |
11054 | | switch (get()) |
11055 | | { |
11056 | | // EOF |
11057 | | case char_traits<char_type>::eof(): |
11058 | | return unexpect_eof(input_format_t::msgpack, "value"); |
11059 | | |
11060 | | // positive fixint |
11061 | | case 0x00: |
11062 | | case 0x01: |
11063 | | case 0x02: |
11064 | | case 0x03: |
11065 | | case 0x04: |
11066 | | case 0x05: |
11067 | | case 0x06: |
11068 | | case 0x07: |
11069 | | case 0x08: |
11070 | | case 0x09: |
11071 | | case 0x0A: |
11072 | | case 0x0B: |
11073 | | case 0x0C: |
11074 | | case 0x0D: |
11075 | | case 0x0E: |
11076 | | case 0x0F: |
11077 | | case 0x10: |
11078 | | case 0x11: |
11079 | | case 0x12: |
11080 | | case 0x13: |
11081 | | case 0x14: |
11082 | | case 0x15: |
11083 | | case 0x16: |
11084 | | case 0x17: |
11085 | | case 0x18: |
11086 | | case 0x19: |
11087 | | case 0x1A: |
11088 | | case 0x1B: |
11089 | | case 0x1C: |
11090 | | case 0x1D: |
11091 | | case 0x1E: |
11092 | | case 0x1F: |
11093 | | case 0x20: |
11094 | | case 0x21: |
11095 | | case 0x22: |
11096 | | case 0x23: |
11097 | | case 0x24: |
11098 | | case 0x25: |
11099 | | case 0x26: |
11100 | | case 0x27: |
11101 | | case 0x28: |
11102 | | case 0x29: |
11103 | | case 0x2A: |
11104 | | case 0x2B: |
11105 | | case 0x2C: |
11106 | | case 0x2D: |
11107 | | case 0x2E: |
11108 | | case 0x2F: |
11109 | | case 0x30: |
11110 | | case 0x31: |
11111 | | case 0x32: |
11112 | | case 0x33: |
11113 | | case 0x34: |
11114 | | case 0x35: |
11115 | | case 0x36: |
11116 | | case 0x37: |
11117 | | case 0x38: |
11118 | | case 0x39: |
11119 | | case 0x3A: |
11120 | | case 0x3B: |
11121 | | case 0x3C: |
11122 | | case 0x3D: |
11123 | | case 0x3E: |
11124 | | case 0x3F: |
11125 | | case 0x40: |
11126 | | case 0x41: |
11127 | | case 0x42: |
11128 | | case 0x43: |
11129 | | case 0x44: |
11130 | | case 0x45: |
11131 | | case 0x46: |
11132 | | case 0x47: |
11133 | | case 0x48: |
11134 | | case 0x49: |
11135 | | case 0x4A: |
11136 | | case 0x4B: |
11137 | | case 0x4C: |
11138 | | case 0x4D: |
11139 | | case 0x4E: |
11140 | | case 0x4F: |
11141 | | case 0x50: |
11142 | | case 0x51: |
11143 | | case 0x52: |
11144 | | case 0x53: |
11145 | | case 0x54: |
11146 | | case 0x55: |
11147 | | case 0x56: |
11148 | | case 0x57: |
11149 | | case 0x58: |
11150 | | case 0x59: |
11151 | | case 0x5A: |
11152 | | case 0x5B: |
11153 | | case 0x5C: |
11154 | | case 0x5D: |
11155 | | case 0x5E: |
11156 | | case 0x5F: |
11157 | | case 0x60: |
11158 | | case 0x61: |
11159 | | case 0x62: |
11160 | | case 0x63: |
11161 | | case 0x64: |
11162 | | case 0x65: |
11163 | | case 0x66: |
11164 | | case 0x67: |
11165 | | case 0x68: |
11166 | | case 0x69: |
11167 | | case 0x6A: |
11168 | | case 0x6B: |
11169 | | case 0x6C: |
11170 | | case 0x6D: |
11171 | | case 0x6E: |
11172 | | case 0x6F: |
11173 | | case 0x70: |
11174 | | case 0x71: |
11175 | | case 0x72: |
11176 | | case 0x73: |
11177 | | case 0x74: |
11178 | | case 0x75: |
11179 | | case 0x76: |
11180 | | case 0x77: |
11181 | | case 0x78: |
11182 | | case 0x79: |
11183 | | case 0x7A: |
11184 | | case 0x7B: |
11185 | | case 0x7C: |
11186 | | case 0x7D: |
11187 | | case 0x7E: |
11188 | | case 0x7F: |
11189 | | return sax->number_unsigned(static_cast<number_unsigned_t>(current)); |
11190 | | |
11191 | | // fixmap |
11192 | | case 0x80: |
11193 | | case 0x81: |
11194 | | case 0x82: |
11195 | | case 0x83: |
11196 | | case 0x84: |
11197 | | case 0x85: |
11198 | | case 0x86: |
11199 | | case 0x87: |
11200 | | case 0x88: |
11201 | | case 0x89: |
11202 | | case 0x8A: |
11203 | | case 0x8B: |
11204 | | case 0x8C: |
11205 | | case 0x8D: |
11206 | | case 0x8E: |
11207 | | case 0x8F: |
11208 | | return get_msgpack_object(conditional_static_cast<std::size_t>(static_cast<unsigned int>(current) & 0x0Fu)); |
11209 | | |
11210 | | // fixarray |
11211 | | case 0x90: |
11212 | | case 0x91: |
11213 | | case 0x92: |
11214 | | case 0x93: |
11215 | | case 0x94: |
11216 | | case 0x95: |
11217 | | case 0x96: |
11218 | | case 0x97: |
11219 | | case 0x98: |
11220 | | case 0x99: |
11221 | | case 0x9A: |
11222 | | case 0x9B: |
11223 | | case 0x9C: |
11224 | | case 0x9D: |
11225 | | case 0x9E: |
11226 | | case 0x9F: |
11227 | | return get_msgpack_array(conditional_static_cast<std::size_t>(static_cast<unsigned int>(current) & 0x0Fu)); |
11228 | | |
11229 | | // fixstr |
11230 | | case 0xA0: |
11231 | | case 0xA1: |
11232 | | case 0xA2: |
11233 | | case 0xA3: |
11234 | | case 0xA4: |
11235 | | case 0xA5: |
11236 | | case 0xA6: |
11237 | | case 0xA7: |
11238 | | case 0xA8: |
11239 | | case 0xA9: |
11240 | | case 0xAA: |
11241 | | case 0xAB: |
11242 | | case 0xAC: |
11243 | | case 0xAD: |
11244 | | case 0xAE: |
11245 | | case 0xAF: |
11246 | | case 0xB0: |
11247 | | case 0xB1: |
11248 | | case 0xB2: |
11249 | | case 0xB3: |
11250 | | case 0xB4: |
11251 | | case 0xB5: |
11252 | | case 0xB6: |
11253 | | case 0xB7: |
11254 | | case 0xB8: |
11255 | | case 0xB9: |
11256 | | case 0xBA: |
11257 | | case 0xBB: |
11258 | | case 0xBC: |
11259 | | case 0xBD: |
11260 | | case 0xBE: |
11261 | | case 0xBF: |
11262 | | case 0xD9: // str 8 |
11263 | | case 0xDA: // str 16 |
11264 | | case 0xDB: // str 32 |
11265 | | { |
11266 | | string_t s; |
11267 | | return get_msgpack_string(s) && sax->string(s); |
11268 | | } |
11269 | | |
11270 | | case 0xC0: // nil |
11271 | | return sax->null(); |
11272 | | |
11273 | | case 0xC2: // false |
11274 | | return sax->boolean(false); |
11275 | | |
11276 | | case 0xC3: // true |
11277 | | return sax->boolean(true); |
11278 | | |
11279 | | case 0xC4: // bin 8 |
11280 | | case 0xC5: // bin 16 |
11281 | | case 0xC6: // bin 32 |
11282 | | case 0xC7: // ext 8 |
11283 | | case 0xC8: // ext 16 |
11284 | | case 0xC9: // ext 32 |
11285 | | case 0xD4: // fixext 1 |
11286 | | case 0xD5: // fixext 2 |
11287 | | case 0xD6: // fixext 4 |
11288 | | case 0xD7: // fixext 8 |
11289 | | case 0xD8: // fixext 16 |
11290 | | { |
11291 | | binary_t b; |
11292 | | return get_msgpack_binary(b) && sax->binary(b); |
11293 | | } |
11294 | | |
11295 | | case 0xCA: // float 32 |
11296 | | { |
11297 | | float number{}; |
11298 | | return get_number(input_format_t::msgpack, number) && sax->number_float(static_cast<number_float_t>(number), ""); |
11299 | | } |
11300 | | |
11301 | | case 0xCB: // float 64 |
11302 | | { |
11303 | | double number{}; |
11304 | | return get_number(input_format_t::msgpack, number) && sax->number_float(static_cast<number_float_t>(number), ""); |
11305 | | } |
11306 | | |
11307 | | case 0xCC: // uint 8 |
11308 | | { |
11309 | | std::uint8_t number{}; |
11310 | | return get_number(input_format_t::msgpack, number) && sax->number_unsigned(number); |
11311 | | } |
11312 | | |
11313 | | case 0xCD: // uint 16 |
11314 | | { |
11315 | | std::uint16_t number{}; |
11316 | | return get_number(input_format_t::msgpack, number) && sax->number_unsigned(number); |
11317 | | } |
11318 | | |
11319 | | case 0xCE: // uint 32 |
11320 | | { |
11321 | | std::uint32_t number{}; |
11322 | | return get_number(input_format_t::msgpack, number) && sax->number_unsigned(number); |
11323 | | } |
11324 | | |
11325 | | case 0xCF: // uint 64 |
11326 | | { |
11327 | | std::uint64_t number{}; |
11328 | | return get_number(input_format_t::msgpack, number) && sax->number_unsigned(number); |
11329 | | } |
11330 | | |
11331 | | case 0xD0: // int 8 |
11332 | | { |
11333 | | std::int8_t number{}; |
11334 | | return get_number(input_format_t::msgpack, number) && sax->number_integer(number); |
11335 | | } |
11336 | | |
11337 | | case 0xD1: // int 16 |
11338 | | { |
11339 | | std::int16_t number{}; |
11340 | | return get_number(input_format_t::msgpack, number) && sax->number_integer(number); |
11341 | | } |
11342 | | |
11343 | | case 0xD2: // int 32 |
11344 | | { |
11345 | | std::int32_t number{}; |
11346 | | return get_number(input_format_t::msgpack, number) && sax->number_integer(number); |
11347 | | } |
11348 | | |
11349 | | case 0xD3: // int 64 |
11350 | | { |
11351 | | std::int64_t number{}; |
11352 | | return get_number(input_format_t::msgpack, number) && sax->number_integer(number); |
11353 | | } |
11354 | | |
11355 | | case 0xDC: // array 16 |
11356 | | { |
11357 | | std::uint16_t len{}; |
11358 | | return get_number(input_format_t::msgpack, len) && get_msgpack_array(static_cast<std::size_t>(len)); |
11359 | | } |
11360 | | |
11361 | | case 0xDD: // array 32 |
11362 | | { |
11363 | | std::uint32_t len{}; |
11364 | | return get_number(input_format_t::msgpack, len) && get_msgpack_array(conditional_static_cast<std::size_t>(len)); |
11365 | | } |
11366 | | |
11367 | | case 0xDE: // map 16 |
11368 | | { |
11369 | | std::uint16_t len{}; |
11370 | | return get_number(input_format_t::msgpack, len) && get_msgpack_object(static_cast<std::size_t>(len)); |
11371 | | } |
11372 | | |
11373 | | case 0xDF: // map 32 |
11374 | | { |
11375 | | std::uint32_t len{}; |
11376 | | return get_number(input_format_t::msgpack, len) && get_msgpack_object(conditional_static_cast<std::size_t>(len)); |
11377 | | } |
11378 | | |
11379 | | // negative fixint |
11380 | | case 0xE0: |
11381 | | case 0xE1: |
11382 | | case 0xE2: |
11383 | | case 0xE3: |
11384 | | case 0xE4: |
11385 | | case 0xE5: |
11386 | | case 0xE6: |
11387 | | case 0xE7: |
11388 | | case 0xE8: |
11389 | | case 0xE9: |
11390 | | case 0xEA: |
11391 | | case 0xEB: |
11392 | | case 0xEC: |
11393 | | case 0xED: |
11394 | | case 0xEE: |
11395 | | case 0xEF: |
11396 | | case 0xF0: |
11397 | | case 0xF1: |
11398 | | case 0xF2: |
11399 | | case 0xF3: |
11400 | | case 0xF4: |
11401 | | case 0xF5: |
11402 | | case 0xF6: |
11403 | | case 0xF7: |
11404 | | case 0xF8: |
11405 | | case 0xF9: |
11406 | | case 0xFA: |
11407 | | case 0xFB: |
11408 | | case 0xFC: |
11409 | | case 0xFD: |
11410 | | case 0xFE: |
11411 | | case 0xFF: |
11412 | | return sax->number_integer(static_cast<std::int8_t>(current)); |
11413 | | |
11414 | | default: // anything else |
11415 | | { |
11416 | | auto last_token = get_token_string(); |
11417 | | return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read, |
11418 | | exception_message(input_format_t::msgpack, concat("invalid byte: 0x", last_token), "value"), nullptr)); |
11419 | | } |
11420 | | } |
11421 | | } |
11422 | | |
11423 | | /*! |
11424 | | @brief reads a MessagePack string |
11425 | | |
11426 | | This function first reads starting bytes to determine the expected |
11427 | | string length and then copies this number of bytes into a string. |
11428 | | |
11429 | | @param[out] result created string |
11430 | | |
11431 | | @return whether string creation completed |
11432 | | */ |
11433 | | bool get_msgpack_string(string_t& result) |
11434 | | { |
11435 | | if (JSON_HEDLEY_UNLIKELY(!unexpect_eof(input_format_t::msgpack, "string"))) |
11436 | | { |
11437 | | return false; |
11438 | | } |
11439 | | |
11440 | | switch (current) |
11441 | | { |
11442 | | // fixstr |
11443 | | case 0xA0: |
11444 | | case 0xA1: |
11445 | | case 0xA2: |
11446 | | case 0xA3: |
11447 | | case 0xA4: |
11448 | | case 0xA5: |
11449 | | case 0xA6: |
11450 | | case 0xA7: |
11451 | | case 0xA8: |
11452 | | case 0xA9: |
11453 | | case 0xAA: |
11454 | | case 0xAB: |
11455 | | case 0xAC: |
11456 | | case 0xAD: |
11457 | | case 0xAE: |
11458 | | case 0xAF: |
11459 | | case 0xB0: |
11460 | | case 0xB1: |
11461 | | case 0xB2: |
11462 | | case 0xB3: |
11463 | | case 0xB4: |
11464 | | case 0xB5: |
11465 | | case 0xB6: |
11466 | | case 0xB7: |
11467 | | case 0xB8: |
11468 | | case 0xB9: |
11469 | | case 0xBA: |
11470 | | case 0xBB: |
11471 | | case 0xBC: |
11472 | | case 0xBD: |
11473 | | case 0xBE: |
11474 | | case 0xBF: |
11475 | | { |
11476 | | return get_string(input_format_t::msgpack, static_cast<unsigned int>(current) & 0x1Fu, result); |
11477 | | } |
11478 | | |
11479 | | case 0xD9: // str 8 |
11480 | | { |
11481 | | std::uint8_t len{}; |
11482 | | return get_number(input_format_t::msgpack, len) && get_string(input_format_t::msgpack, len, result); |
11483 | | } |
11484 | | |
11485 | | case 0xDA: // str 16 |
11486 | | { |
11487 | | std::uint16_t len{}; |
11488 | | return get_number(input_format_t::msgpack, len) && get_string(input_format_t::msgpack, len, result); |
11489 | | } |
11490 | | |
11491 | | case 0xDB: // str 32 |
11492 | | { |
11493 | | std::uint32_t len{}; |
11494 | | return get_number(input_format_t::msgpack, len) && get_string(input_format_t::msgpack, len, result); |
11495 | | } |
11496 | | |
11497 | | default: |
11498 | | { |
11499 | | auto last_token = get_token_string(); |
11500 | | return sax->parse_error(chars_read, last_token, parse_error::create(113, chars_read, |
11501 | | exception_message(input_format_t::msgpack, concat("expected length specification (0xA0-0xBF, 0xD9-0xDB); last byte: 0x", last_token), "string"), nullptr)); |
11502 | | } |
11503 | | } |
11504 | | } |
11505 | | |
11506 | | /*! |
11507 | | @brief reads a MessagePack byte array |
11508 | | |
11509 | | This function first reads starting bytes to determine the expected |
11510 | | byte array length and then copies this number of bytes into a byte array. |
11511 | | |
11512 | | @param[out] result created byte array |
11513 | | |
11514 | | @return whether byte array creation completed |
11515 | | */ |
11516 | | bool get_msgpack_binary(binary_t& result) |
11517 | | { |
11518 | | // helper function to set the subtype |
11519 | | auto assign_and_return_true = [&result](std::int8_t subtype) |
11520 | | { |
11521 | | result.set_subtype(static_cast<std::uint8_t>(subtype)); |
11522 | | return true; |
11523 | | }; |
11524 | | |
11525 | | switch (current) |
11526 | | { |
11527 | | case 0xC4: // bin 8 |
11528 | | { |
11529 | | std::uint8_t len{}; |
11530 | | return get_number(input_format_t::msgpack, len) && |
11531 | | get_binary(input_format_t::msgpack, len, result); |
11532 | | } |
11533 | | |
11534 | | case 0xC5: // bin 16 |
11535 | | { |
11536 | | std::uint16_t len{}; |
11537 | | return get_number(input_format_t::msgpack, len) && |
11538 | | get_binary(input_format_t::msgpack, len, result); |
11539 | | } |
11540 | | |
11541 | | case 0xC6: // bin 32 |
11542 | | { |
11543 | | std::uint32_t len{}; |
11544 | | return get_number(input_format_t::msgpack, len) && |
11545 | | get_binary(input_format_t::msgpack, len, result); |
11546 | | } |
11547 | | |
11548 | | case 0xC7: // ext 8 |
11549 | | { |
11550 | | std::uint8_t len{}; |
11551 | | std::int8_t subtype{}; |
11552 | | return get_number(input_format_t::msgpack, len) && |
11553 | | get_number(input_format_t::msgpack, subtype) && |
11554 | | get_binary(input_format_t::msgpack, len, result) && |
11555 | | assign_and_return_true(subtype); |
11556 | | } |
11557 | | |
11558 | | case 0xC8: // ext 16 |
11559 | | { |
11560 | | std::uint16_t len{}; |
11561 | | std::int8_t subtype{}; |
11562 | | return get_number(input_format_t::msgpack, len) && |
11563 | | get_number(input_format_t::msgpack, subtype) && |
11564 | | get_binary(input_format_t::msgpack, len, result) && |
11565 | | assign_and_return_true(subtype); |
11566 | | } |
11567 | | |
11568 | | case 0xC9: // ext 32 |
11569 | | { |
11570 | | std::uint32_t len{}; |
11571 | | std::int8_t subtype{}; |
11572 | | return get_number(input_format_t::msgpack, len) && |
11573 | | get_number(input_format_t::msgpack, subtype) && |
11574 | | get_binary(input_format_t::msgpack, len, result) && |
11575 | | assign_and_return_true(subtype); |
11576 | | } |
11577 | | |
11578 | | case 0xD4: // fixext 1 |
11579 | | { |
11580 | | std::int8_t subtype{}; |
11581 | | return get_number(input_format_t::msgpack, subtype) && |
11582 | | get_binary(input_format_t::msgpack, 1, result) && |
11583 | | assign_and_return_true(subtype); |
11584 | | } |
11585 | | |
11586 | | case 0xD5: // fixext 2 |
11587 | | { |
11588 | | std::int8_t subtype{}; |
11589 | | return get_number(input_format_t::msgpack, subtype) && |
11590 | | get_binary(input_format_t::msgpack, 2, result) && |
11591 | | assign_and_return_true(subtype); |
11592 | | } |
11593 | | |
11594 | | case 0xD6: // fixext 4 |
11595 | | { |
11596 | | std::int8_t subtype{}; |
11597 | | return get_number(input_format_t::msgpack, subtype) && |
11598 | | get_binary(input_format_t::msgpack, 4, result) && |
11599 | | assign_and_return_true(subtype); |
11600 | | } |
11601 | | |
11602 | | case 0xD7: // fixext 8 |
11603 | | { |
11604 | | std::int8_t subtype{}; |
11605 | | return get_number(input_format_t::msgpack, subtype) && |
11606 | | get_binary(input_format_t::msgpack, 8, result) && |
11607 | | assign_and_return_true(subtype); |
11608 | | } |
11609 | | |
11610 | | case 0xD8: // fixext 16 |
11611 | | { |
11612 | | std::int8_t subtype{}; |
11613 | | return get_number(input_format_t::msgpack, subtype) && |
11614 | | get_binary(input_format_t::msgpack, 16, result) && |
11615 | | assign_and_return_true(subtype); |
11616 | | } |
11617 | | |
11618 | | default: // LCOV_EXCL_LINE |
11619 | | return false; // LCOV_EXCL_LINE |
11620 | | } |
11621 | | } |
11622 | | |
11623 | | /*! |
11624 | | @param[in] len the length of the array |
11625 | | @return whether array creation completed |
11626 | | */ |
11627 | | bool get_msgpack_array(const std::size_t len) |
11628 | | { |
11629 | | if (JSON_HEDLEY_UNLIKELY(!sax->start_array(len))) |
11630 | | { |
11631 | | return false; |
11632 | | } |
11633 | | |
11634 | | for (std::size_t i = 0; i < len; ++i) |
11635 | | { |
11636 | | if (JSON_HEDLEY_UNLIKELY(!parse_msgpack_internal())) |
11637 | | { |
11638 | | return false; |
11639 | | } |
11640 | | } |
11641 | | |
11642 | | return sax->end_array(); |
11643 | | } |
11644 | | |
11645 | | /*! |
11646 | | @param[in] len the length of the object |
11647 | | @return whether object creation completed |
11648 | | */ |
11649 | | bool get_msgpack_object(const std::size_t len) |
11650 | | { |
11651 | | if (JSON_HEDLEY_UNLIKELY(!sax->start_object(len))) |
11652 | | { |
11653 | | return false; |
11654 | | } |
11655 | | |
11656 | | string_t key; |
11657 | | for (std::size_t i = 0; i < len; ++i) |
11658 | | { |
11659 | | get(); |
11660 | | if (JSON_HEDLEY_UNLIKELY(!get_msgpack_string(key) || !sax->key(key))) |
11661 | | { |
11662 | | return false; |
11663 | | } |
11664 | | |
11665 | | if (JSON_HEDLEY_UNLIKELY(!parse_msgpack_internal())) |
11666 | | { |
11667 | | return false; |
11668 | | } |
11669 | | key.clear(); |
11670 | | } |
11671 | | |
11672 | | return sax->end_object(); |
11673 | | } |
11674 | | |
11675 | | //////////// |
11676 | | // UBJSON // |
11677 | | //////////// |
11678 | | |
11679 | | /*! |
11680 | | @param[in] get_char whether a new character should be retrieved from the |
11681 | | input (true, default) or whether the last read |
11682 | | character should be considered instead |
11683 | | |
11684 | | @return whether a valid UBJSON value was passed to the SAX parser |
11685 | | */ |
11686 | | bool parse_ubjson_internal(const bool get_char = true) |
11687 | | { |
11688 | | return get_ubjson_value(get_char ? get_ignore_noop() : current); |
11689 | | } |
11690 | | |
11691 | | /*! |
11692 | | @brief reads a UBJSON string |
11693 | | |
11694 | | This function is either called after reading the 'S' byte explicitly |
11695 | | indicating a string, or in case of an object key where the 'S' byte can be |
11696 | | left out. |
11697 | | |
11698 | | @param[out] result created string |
11699 | | @param[in] get_char whether a new character should be retrieved from the |
11700 | | input (true, default) or whether the last read |
11701 | | character should be considered instead |
11702 | | |
11703 | | @return whether string creation completed |
11704 | | */ |
11705 | | bool get_ubjson_string(string_t& result, const bool get_char = true) |
11706 | | { |
11707 | | if (get_char) |
11708 | | { |
11709 | | get(); // TODO(niels): may we ignore N here? |
11710 | | } |
11711 | | |
11712 | | if (JSON_HEDLEY_UNLIKELY(!unexpect_eof(input_format, "value"))) |
11713 | | { |
11714 | | return false; |
11715 | | } |
11716 | | |
11717 | | switch (current) |
11718 | | { |
11719 | | case 'U': |
11720 | | { |
11721 | | std::uint8_t len{}; |
11722 | | return get_number(input_format, len) && get_string(input_format, len, result); |
11723 | | } |
11724 | | |
11725 | | case 'i': |
11726 | | { |
11727 | | std::int8_t len{}; |
11728 | | return get_number(input_format, len) && get_string(input_format, len, result); |
11729 | | } |
11730 | | |
11731 | | case 'I': |
11732 | | { |
11733 | | std::int16_t len{}; |
11734 | | return get_number(input_format, len) && get_string(input_format, len, result); |
11735 | | } |
11736 | | |
11737 | | case 'l': |
11738 | | { |
11739 | | std::int32_t len{}; |
11740 | | return get_number(input_format, len) && get_string(input_format, len, result); |
11741 | | } |
11742 | | |
11743 | | case 'L': |
11744 | | { |
11745 | | std::int64_t len{}; |
11746 | | return get_number(input_format, len) && get_string(input_format, len, result); |
11747 | | } |
11748 | | |
11749 | | case 'u': |
11750 | | { |
11751 | | if (input_format != input_format_t::bjdata) |
11752 | | { |
11753 | | break; |
11754 | | } |
11755 | | std::uint16_t len{}; |
11756 | | return get_number(input_format, len) && get_string(input_format, len, result); |
11757 | | } |
11758 | | |
11759 | | case 'm': |
11760 | | { |
11761 | | if (input_format != input_format_t::bjdata) |
11762 | | { |
11763 | | break; |
11764 | | } |
11765 | | std::uint32_t len{}; |
11766 | | return get_number(input_format, len) && get_string(input_format, len, result); |
11767 | | } |
11768 | | |
11769 | | case 'M': |
11770 | | { |
11771 | | if (input_format != input_format_t::bjdata) |
11772 | | { |
11773 | | break; |
11774 | | } |
11775 | | std::uint64_t len{}; |
11776 | | return get_number(input_format, len) && get_string(input_format, len, result); |
11777 | | } |
11778 | | |
11779 | | default: |
11780 | | break; |
11781 | | } |
11782 | | auto last_token = get_token_string(); |
11783 | | std::string message; |
11784 | | |
11785 | | if (input_format != input_format_t::bjdata) |
11786 | | { |
11787 | | message = "expected length type specification (U, i, I, l, L); last byte: 0x" + last_token; |
11788 | | } |
11789 | | else |
11790 | | { |
11791 | | message = "expected length type specification (U, i, u, I, m, l, M, L); last byte: 0x" + last_token; |
11792 | | } |
11793 | | return sax->parse_error(chars_read, last_token, parse_error::create(113, chars_read, exception_message(input_format, message, "string"), nullptr)); |
11794 | | } |
11795 | | |
11796 | | /*! |
11797 | | @param[out] dim an integer vector storing the ND array dimensions |
11798 | | @return whether reading ND array size vector is successful |
11799 | | */ |
11800 | | bool get_ubjson_ndarray_size(std::vector<size_t>& dim) |
11801 | | { |
11802 | | std::pair<std::size_t, char_int_type> size_and_type; |
11803 | | size_t dimlen = 0; |
11804 | | bool no_ndarray = true; |
11805 | | |
11806 | | if (JSON_HEDLEY_UNLIKELY(!get_ubjson_size_type(size_and_type, no_ndarray))) |
11807 | | { |
11808 | | return false; |
11809 | | } |
11810 | | |
11811 | | if (size_and_type.first != npos) |
11812 | | { |
11813 | | if (size_and_type.second != 0) |
11814 | | { |
11815 | | if (size_and_type.second != 'N') |
11816 | | { |
11817 | | for (std::size_t i = 0; i < size_and_type.first; ++i) |
11818 | | { |
11819 | | if (JSON_HEDLEY_UNLIKELY(!get_ubjson_size_value(dimlen, no_ndarray, size_and_type.second))) |
11820 | | { |
11821 | | return false; |
11822 | | } |
11823 | | dim.push_back(dimlen); |
11824 | | } |
11825 | | } |
11826 | | } |
11827 | | else |
11828 | | { |
11829 | | for (std::size_t i = 0; i < size_and_type.first; ++i) |
11830 | | { |
11831 | | if (JSON_HEDLEY_UNLIKELY(!get_ubjson_size_value(dimlen, no_ndarray))) |
11832 | | { |
11833 | | return false; |
11834 | | } |
11835 | | dim.push_back(dimlen); |
11836 | | } |
11837 | | } |
11838 | | } |
11839 | | else |
11840 | | { |
11841 | | while (current != ']') |
11842 | | { |
11843 | | if (JSON_HEDLEY_UNLIKELY(!get_ubjson_size_value(dimlen, no_ndarray, current))) |
11844 | | { |
11845 | | return false; |
11846 | | } |
11847 | | dim.push_back(dimlen); |
11848 | | get_ignore_noop(); |
11849 | | } |
11850 | | } |
11851 | | return true; |
11852 | | } |
11853 | | |
11854 | | /*! |
11855 | | @param[out] result determined size |
11856 | | @param[in,out] is_ndarray for input, `true` means already inside an ndarray vector |
11857 | | or ndarray dimension is not allowed; `false` means ndarray |
11858 | | is allowed; for output, `true` means an ndarray is found; |
11859 | | is_ndarray can only return `true` when its initial value |
11860 | | is `false` |
11861 | | @param[in] prefix type marker if already read, otherwise set to 0 |
11862 | | |
11863 | | @return whether size determination completed |
11864 | | */ |
11865 | | bool get_ubjson_size_value(std::size_t& result, bool& is_ndarray, char_int_type prefix = 0) |
11866 | | { |
11867 | | if (prefix == 0) |
11868 | | { |
11869 | | prefix = get_ignore_noop(); |
11870 | | } |
11871 | | |
11872 | | switch (prefix) |
11873 | | { |
11874 | | case 'U': |
11875 | | { |
11876 | | std::uint8_t number{}; |
11877 | | if (JSON_HEDLEY_UNLIKELY(!get_number(input_format, number))) |
11878 | | { |
11879 | | return false; |
11880 | | } |
11881 | | result = static_cast<std::size_t>(number); |
11882 | | return true; |
11883 | | } |
11884 | | |
11885 | | case 'i': |
11886 | | { |
11887 | | std::int8_t number{}; |
11888 | | if (JSON_HEDLEY_UNLIKELY(!get_number(input_format, number))) |
11889 | | { |
11890 | | return false; |
11891 | | } |
11892 | | if (number < 0) |
11893 | | { |
11894 | | return sax->parse_error(chars_read, get_token_string(), parse_error::create(113, chars_read, |
11895 | | exception_message(input_format, "count in an optimized container must be positive", "size"), nullptr)); |
11896 | | } |
11897 | | result = static_cast<std::size_t>(number); // NOLINT(bugprone-signed-char-misuse,cert-str34-c): number is not a char |
11898 | | return true; |
11899 | | } |
11900 | | |
11901 | | case 'I': |
11902 | | { |
11903 | | std::int16_t number{}; |
11904 | | if (JSON_HEDLEY_UNLIKELY(!get_number(input_format, number))) |
11905 | | { |
11906 | | return false; |
11907 | | } |
11908 | | if (number < 0) |
11909 | | { |
11910 | | return sax->parse_error(chars_read, get_token_string(), parse_error::create(113, chars_read, |
11911 | | exception_message(input_format, "count in an optimized container must be positive", "size"), nullptr)); |
11912 | | } |
11913 | | result = static_cast<std::size_t>(number); |
11914 | | return true; |
11915 | | } |
11916 | | |
11917 | | case 'l': |
11918 | | { |
11919 | | std::int32_t number{}; |
11920 | | if (JSON_HEDLEY_UNLIKELY(!get_number(input_format, number))) |
11921 | | { |
11922 | | return false; |
11923 | | } |
11924 | | if (number < 0) |
11925 | | { |
11926 | | return sax->parse_error(chars_read, get_token_string(), parse_error::create(113, chars_read, |
11927 | | exception_message(input_format, "count in an optimized container must be positive", "size"), nullptr)); |
11928 | | } |
11929 | | result = static_cast<std::size_t>(number); |
11930 | | return true; |
11931 | | } |
11932 | | |
11933 | | case 'L': |
11934 | | { |
11935 | | std::int64_t number{}; |
11936 | | if (JSON_HEDLEY_UNLIKELY(!get_number(input_format, number))) |
11937 | | { |
11938 | | return false; |
11939 | | } |
11940 | | if (number < 0) |
11941 | | { |
11942 | | return sax->parse_error(chars_read, get_token_string(), parse_error::create(113, chars_read, |
11943 | | exception_message(input_format, "count in an optimized container must be positive", "size"), nullptr)); |
11944 | | } |
11945 | | if (!value_in_range_of<std::size_t>(number)) |
11946 | | { |
11947 | | return sax->parse_error(chars_read, get_token_string(), out_of_range::create(408, |
11948 | | exception_message(input_format, "integer value overflow", "size"), nullptr)); |
11949 | | } |
11950 | | result = static_cast<std::size_t>(number); |
11951 | | return true; |
11952 | | } |
11953 | | |
11954 | | case 'u': |
11955 | | { |
11956 | | if (input_format != input_format_t::bjdata) |
11957 | | { |
11958 | | break; |
11959 | | } |
11960 | | std::uint16_t number{}; |
11961 | | if (JSON_HEDLEY_UNLIKELY(!get_number(input_format, number))) |
11962 | | { |
11963 | | return false; |
11964 | | } |
11965 | | result = static_cast<std::size_t>(number); |
11966 | | return true; |
11967 | | } |
11968 | | |
11969 | | case 'm': |
11970 | | { |
11971 | | if (input_format != input_format_t::bjdata) |
11972 | | { |
11973 | | break; |
11974 | | } |
11975 | | std::uint32_t number{}; |
11976 | | if (JSON_HEDLEY_UNLIKELY(!get_number(input_format, number))) |
11977 | | { |
11978 | | return false; |
11979 | | } |
11980 | | result = conditional_static_cast<std::size_t>(number); |
11981 | | return true; |
11982 | | } |
11983 | | |
11984 | | case 'M': |
11985 | | { |
11986 | | if (input_format != input_format_t::bjdata) |
11987 | | { |
11988 | | break; |
11989 | | } |
11990 | | std::uint64_t number{}; |
11991 | | if (JSON_HEDLEY_UNLIKELY(!get_number(input_format, number))) |
11992 | | { |
11993 | | return false; |
11994 | | } |
11995 | | if (!value_in_range_of<std::size_t>(number)) |
11996 | | { |
11997 | | return sax->parse_error(chars_read, get_token_string(), out_of_range::create(408, |
11998 | | exception_message(input_format, "integer value overflow", "size"), nullptr)); |
11999 | | } |
12000 | | result = detail::conditional_static_cast<std::size_t>(number); |
12001 | | return true; |
12002 | | } |
12003 | | |
12004 | | case '[': |
12005 | | { |
12006 | | if (input_format != input_format_t::bjdata) |
12007 | | { |
12008 | | break; |
12009 | | } |
12010 | | if (is_ndarray) // ndarray dimensional vector can only contain integers and cannot embed another array |
12011 | | { |
12012 | | return sax->parse_error(chars_read, get_token_string(), parse_error::create(113, chars_read, exception_message(input_format, "ndarray dimensional vector is not allowed", "size"), nullptr)); |
12013 | | } |
12014 | | std::vector<size_t> dim; |
12015 | | if (JSON_HEDLEY_UNLIKELY(!get_ubjson_ndarray_size(dim))) |
12016 | | { |
12017 | | return false; |
12018 | | } |
12019 | | if (dim.size() == 1 || (dim.size() == 2 && dim.at(0) == 1)) // return normal array size if 1D row vector |
12020 | | { |
12021 | | result = dim.at(dim.size() - 1); |
12022 | | return true; |
12023 | | } |
12024 | | if (!dim.empty()) // if ndarray, convert to an object in JData annotated array format |
12025 | | { |
12026 | | for (auto i : dim) // test if any dimension in an ndarray is 0, if so, return a 1D empty container |
12027 | | { |
12028 | | if ( i == 0 ) |
12029 | | { |
12030 | | result = 0; |
12031 | | return true; |
12032 | | } |
12033 | | } |
12034 | | |
12035 | | string_t key = "_ArraySize_"; |
12036 | | if (JSON_HEDLEY_UNLIKELY(!sax->start_object(3) || !sax->key(key) || !sax->start_array(dim.size()))) |
12037 | | { |
12038 | | return false; |
12039 | | } |
12040 | | result = 1; |
12041 | | for (auto i : dim) |
12042 | | { |
12043 | | // Pre-multiplication overflow check: if i > 0 and result > SIZE_MAX/i, then result*i would overflow. |
12044 | | // This check must happen before multiplication since overflow detection after the fact is unreliable |
12045 | | // as modular arithmetic can produce any value, not just 0 or SIZE_MAX. |
12046 | | if (JSON_HEDLEY_UNLIKELY(i > 0 && result > (std::numeric_limits<std::size_t>::max)() / i)) |
12047 | | { |
12048 | | return sax->parse_error(chars_read, get_token_string(), out_of_range::create(408, exception_message(input_format, "excessive ndarray size caused overflow", "size"), nullptr)); |
12049 | | } |
12050 | | result *= i; |
12051 | | // Additional post-multiplication check to catch any edge cases the pre-check might miss |
12052 | | if (result == 0 || result == npos) |
12053 | | { |
12054 | | return sax->parse_error(chars_read, get_token_string(), out_of_range::create(408, exception_message(input_format, "excessive ndarray size caused overflow", "size"), nullptr)); |
12055 | | } |
12056 | | if (JSON_HEDLEY_UNLIKELY(!sax->number_unsigned(static_cast<number_unsigned_t>(i)))) |
12057 | | { |
12058 | | return false; |
12059 | | } |
12060 | | } |
12061 | | is_ndarray = true; |
12062 | | return sax->end_array(); |
12063 | | } |
12064 | | result = 0; |
12065 | | return true; |
12066 | | } |
12067 | | |
12068 | | default: |
12069 | | break; |
12070 | | } |
12071 | | auto last_token = get_token_string(); |
12072 | | std::string message; |
12073 | | |
12074 | | if (input_format != input_format_t::bjdata) |
12075 | | { |
12076 | | message = "expected length type specification (U, i, I, l, L) after '#'; last byte: 0x" + last_token; |
12077 | | } |
12078 | | else |
12079 | | { |
12080 | | message = "expected length type specification (U, i, u, I, m, l, M, L) after '#'; last byte: 0x" + last_token; |
12081 | | } |
12082 | | return sax->parse_error(chars_read, last_token, parse_error::create(113, chars_read, exception_message(input_format, message, "size"), nullptr)); |
12083 | | } |
12084 | | |
12085 | | /*! |
12086 | | @brief determine the type and size for a container |
12087 | | |
12088 | | In the optimized UBJSON format, a type and a size can be provided to allow |
12089 | | for a more compact representation. |
12090 | | |
12091 | | @param[out] result pair of the size and the type |
12092 | | @param[in] inside_ndarray whether the parser is parsing an ND array dimensional vector |
12093 | | |
12094 | | @return whether pair creation completed |
12095 | | */ |
12096 | | bool get_ubjson_size_type(std::pair<std::size_t, char_int_type>& result, bool inside_ndarray = false) |
12097 | | { |
12098 | | result.first = npos; // size |
12099 | | result.second = 0; // type |
12100 | | bool is_ndarray = false; |
12101 | | |
12102 | | get_ignore_noop(); |
12103 | | |
12104 | | if (current == '$') |
12105 | | { |
12106 | | result.second = get(); // must not ignore 'N', because 'N' maybe the type |
12107 | | if (input_format == input_format_t::bjdata |
12108 | | && JSON_HEDLEY_UNLIKELY(std::binary_search(bjd_optimized_type_markers.begin(), bjd_optimized_type_markers.end(), result.second))) |
12109 | | { |
12110 | | auto last_token = get_token_string(); |
12111 | | return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read, |
12112 | | exception_message(input_format, concat("marker 0x", last_token, " is not a permitted optimized array type"), "type"), nullptr)); |
12113 | | } |
12114 | | |
12115 | | if (JSON_HEDLEY_UNLIKELY(!unexpect_eof(input_format, "type"))) |
12116 | | { |
12117 | | return false; |
12118 | | } |
12119 | | |
12120 | | get_ignore_noop(); |
12121 | | if (JSON_HEDLEY_UNLIKELY(current != '#')) |
12122 | | { |
12123 | | if (JSON_HEDLEY_UNLIKELY(!unexpect_eof(input_format, "value"))) |
12124 | | { |
12125 | | return false; |
12126 | | } |
12127 | | auto last_token = get_token_string(); |
12128 | | return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read, |
12129 | | exception_message(input_format, concat("expected '#' after type information; last byte: 0x", last_token), "size"), nullptr)); |
12130 | | } |
12131 | | |
12132 | | const bool is_error = get_ubjson_size_value(result.first, is_ndarray); |
12133 | | if (input_format == input_format_t::bjdata && is_ndarray) |
12134 | | { |
12135 | | if (inside_ndarray) |
12136 | | { |
12137 | | return sax->parse_error(chars_read, get_token_string(), parse_error::create(112, chars_read, |
12138 | | exception_message(input_format, "ndarray can not be recursive", "size"), nullptr)); |
12139 | | } |
12140 | | result.second |= (1 << 8); // use bit 8 to indicate ndarray, all UBJSON and BJData markers should be ASCII letters |
12141 | | } |
12142 | | return is_error; |
12143 | | } |
12144 | | |
12145 | | if (current == '#') |
12146 | | { |
12147 | | const bool is_error = get_ubjson_size_value(result.first, is_ndarray); |
12148 | | if (input_format == input_format_t::bjdata && is_ndarray) |
12149 | | { |
12150 | | return sax->parse_error(chars_read, get_token_string(), parse_error::create(112, chars_read, |
12151 | | exception_message(input_format, "ndarray requires both type and size", "size"), nullptr)); |
12152 | | } |
12153 | | return is_error; |
12154 | | } |
12155 | | |
12156 | | return true; |
12157 | | } |
12158 | | |
12159 | | /*! |
12160 | | @param prefix the previously read or set type prefix |
12161 | | @return whether value creation completed |
12162 | | */ |
12163 | | bool get_ubjson_value(const char_int_type prefix) |
12164 | | { |
12165 | | switch (prefix) |
12166 | | { |
12167 | | case char_traits<char_type>::eof(): // EOF |
12168 | | return unexpect_eof(input_format, "value"); |
12169 | | |
12170 | | case 'T': // true |
12171 | | return sax->boolean(true); |
12172 | | case 'F': // false |
12173 | | return sax->boolean(false); |
12174 | | |
12175 | | case 'Z': // null |
12176 | | return sax->null(); |
12177 | | |
12178 | | case 'B': // byte |
12179 | | { |
12180 | | if (input_format != input_format_t::bjdata) |
12181 | | { |
12182 | | break; |
12183 | | } |
12184 | | std::uint8_t number{}; |
12185 | | return get_number(input_format, number) && sax->number_unsigned(number); |
12186 | | } |
12187 | | |
12188 | | case 'U': |
12189 | | { |
12190 | | std::uint8_t number{}; |
12191 | | return get_number(input_format, number) && sax->number_unsigned(number); |
12192 | | } |
12193 | | |
12194 | | case 'i': |
12195 | | { |
12196 | | std::int8_t number{}; |
12197 | | return get_number(input_format, number) && sax->number_integer(number); |
12198 | | } |
12199 | | |
12200 | | case 'I': |
12201 | | { |
12202 | | std::int16_t number{}; |
12203 | | return get_number(input_format, number) && sax->number_integer(number); |
12204 | | } |
12205 | | |
12206 | | case 'l': |
12207 | | { |
12208 | | std::int32_t number{}; |
12209 | | return get_number(input_format, number) && sax->number_integer(number); |
12210 | | } |
12211 | | |
12212 | | case 'L': |
12213 | | { |
12214 | | std::int64_t number{}; |
12215 | | return get_number(input_format, number) && sax->number_integer(number); |
12216 | | } |
12217 | | |
12218 | | case 'u': |
12219 | | { |
12220 | | if (input_format != input_format_t::bjdata) |
12221 | | { |
12222 | | break; |
12223 | | } |
12224 | | std::uint16_t number{}; |
12225 | | return get_number(input_format, number) && sax->number_unsigned(number); |
12226 | | } |
12227 | | |
12228 | | case 'm': |
12229 | | { |
12230 | | if (input_format != input_format_t::bjdata) |
12231 | | { |
12232 | | break; |
12233 | | } |
12234 | | std::uint32_t number{}; |
12235 | | return get_number(input_format, number) && sax->number_unsigned(number); |
12236 | | } |
12237 | | |
12238 | | case 'M': |
12239 | | { |
12240 | | if (input_format != input_format_t::bjdata) |
12241 | | { |
12242 | | break; |
12243 | | } |
12244 | | std::uint64_t number{}; |
12245 | | return get_number(input_format, number) && sax->number_unsigned(number); |
12246 | | } |
12247 | | |
12248 | | case 'h': |
12249 | | { |
12250 | | if (input_format != input_format_t::bjdata) |
12251 | | { |
12252 | | break; |
12253 | | } |
12254 | | const auto byte1_raw = get(); |
12255 | | if (JSON_HEDLEY_UNLIKELY(!unexpect_eof(input_format, "number"))) |
12256 | | { |
12257 | | return false; |
12258 | | } |
12259 | | const auto byte2_raw = get(); |
12260 | | if (JSON_HEDLEY_UNLIKELY(!unexpect_eof(input_format, "number"))) |
12261 | | { |
12262 | | return false; |
12263 | | } |
12264 | | |
12265 | | const auto byte1 = static_cast<unsigned char>(byte1_raw); |
12266 | | const auto byte2 = static_cast<unsigned char>(byte2_raw); |
12267 | | |
12268 | | // Code from RFC 7049, Appendix D, Figure 3: |
12269 | | // As half-precision floating-point numbers were only added |
12270 | | // to IEEE 754 in 2008, today's programming platforms often |
12271 | | // still only have limited support for them. It is very |
12272 | | // easy to include at least decoding support for them even |
12273 | | // without such support. An example of a small decoder for |
12274 | | // half-precision floating-point numbers in the C language |
12275 | | // is shown in Fig. 3. |
12276 | | const auto half = static_cast<unsigned int>((byte2 << 8u) + byte1); |
12277 | | const double val = [&half] |
12278 | | { |
12279 | | const int exp = (half >> 10u) & 0x1Fu; |
12280 | | const unsigned int mant = half & 0x3FFu; |
12281 | | JSON_ASSERT(0 <= exp&& exp <= 32); |
12282 | | JSON_ASSERT(mant <= 1024); |
12283 | | switch (exp) |
12284 | | { |
12285 | | case 0: |
12286 | | return std::ldexp(mant, -24); |
12287 | | case 31: |
12288 | | return (mant == 0) |
12289 | | ? std::numeric_limits<double>::infinity() |
12290 | | : std::numeric_limits<double>::quiet_NaN(); |
12291 | | default: |
12292 | | return std::ldexp(mant + 1024, exp - 25); |
12293 | | } |
12294 | | }(); |
12295 | | return sax->number_float((half & 0x8000u) != 0 |
12296 | | ? static_cast<number_float_t>(-val) |
12297 | | : static_cast<number_float_t>(val), ""); |
12298 | | } |
12299 | | |
12300 | | case 'd': |
12301 | | { |
12302 | | float number{}; |
12303 | | return get_number(input_format, number) && sax->number_float(static_cast<number_float_t>(number), ""); |
12304 | | } |
12305 | | |
12306 | | case 'D': |
12307 | | { |
12308 | | double number{}; |
12309 | | return get_number(input_format, number) && sax->number_float(static_cast<number_float_t>(number), ""); |
12310 | | } |
12311 | | |
12312 | | case 'H': |
12313 | | { |
12314 | | return get_ubjson_high_precision_number(); |
12315 | | } |
12316 | | |
12317 | | case 'C': // char |
12318 | | { |
12319 | | get(); |
12320 | | if (JSON_HEDLEY_UNLIKELY(!unexpect_eof(input_format, "char"))) |
12321 | | { |
12322 | | return false; |
12323 | | } |
12324 | | if (JSON_HEDLEY_UNLIKELY(current > 127)) |
12325 | | { |
12326 | | auto last_token = get_token_string(); |
12327 | | return sax->parse_error(chars_read, last_token, parse_error::create(113, chars_read, |
12328 | | exception_message(input_format, concat("byte after 'C' must be in range 0x00..0x7F; last byte: 0x", last_token), "char"), nullptr)); |
12329 | | } |
12330 | | string_t s(1, static_cast<typename string_t::value_type>(current)); |
12331 | | return sax->string(s); |
12332 | | } |
12333 | | |
12334 | | case 'S': // string |
12335 | | { |
12336 | | string_t s; |
12337 | | return get_ubjson_string(s) && sax->string(s); |
12338 | | } |
12339 | | |
12340 | | case '[': // array |
12341 | | return get_ubjson_array(); |
12342 | | |
12343 | | case '{': // object |
12344 | | return get_ubjson_object(); |
12345 | | |
12346 | | default: // anything else |
12347 | | break; |
12348 | | } |
12349 | | auto last_token = get_token_string(); |
12350 | | return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read, exception_message(input_format, "invalid byte: 0x" + last_token, "value"), nullptr)); |
12351 | | } |
12352 | | |
12353 | | /*! |
12354 | | @return whether array creation completed |
12355 | | */ |
12356 | | bool get_ubjson_array() |
12357 | | { |
12358 | | std::pair<std::size_t, char_int_type> size_and_type; |
12359 | | if (JSON_HEDLEY_UNLIKELY(!get_ubjson_size_type(size_and_type))) |
12360 | | { |
12361 | | return false; |
12362 | | } |
12363 | | |
12364 | | // if bit-8 of size_and_type.second is set to 1, encode bjdata ndarray as an object in JData annotated array format (https://github.com/NeuroJSON/jdata): |
12365 | | // {"_ArrayType_" : "typeid", "_ArraySize_" : [n1, n2, ...], "_ArrayData_" : [v1, v2, ...]} |
12366 | | |
12367 | | if (input_format == input_format_t::bjdata && size_and_type.first != npos && (size_and_type.second & (1 << 8)) != 0) |
12368 | | { |
12369 | | size_and_type.second &= ~(static_cast<char_int_type>(1) << 8); // use bit 8 to indicate ndarray, here we remove the bit to restore the type marker |
12370 | | auto it = std::lower_bound(bjd_types_map.begin(), bjd_types_map.end(), size_and_type.second, [](const bjd_type & p, char_int_type t) |
12371 | | { |
12372 | | return p.first < t; |
12373 | | }); |
12374 | | string_t key = "_ArrayType_"; |
12375 | | if (JSON_HEDLEY_UNLIKELY(it == bjd_types_map.end() || it->first != size_and_type.second)) |
12376 | | { |
12377 | | auto last_token = get_token_string(); |
12378 | | return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read, |
12379 | | exception_message(input_format, "invalid byte: 0x" + last_token, "type"), nullptr)); |
12380 | | } |
12381 | | |
12382 | | string_t type = it->second; // sax->string() takes a reference |
12383 | | if (JSON_HEDLEY_UNLIKELY(!sax->key(key) || !sax->string(type))) |
12384 | | { |
12385 | | return false; |
12386 | | } |
12387 | | |
12388 | | if (size_and_type.second == 'C' || size_and_type.second == 'B') |
12389 | | { |
12390 | | size_and_type.second = 'U'; |
12391 | | } |
12392 | | |
12393 | | key = "_ArrayData_"; |
12394 | | if (JSON_HEDLEY_UNLIKELY(!sax->key(key) || !sax->start_array(size_and_type.first) )) |
12395 | | { |
12396 | | return false; |
12397 | | } |
12398 | | |
12399 | | for (std::size_t i = 0; i < size_and_type.first; ++i) |
12400 | | { |
12401 | | if (JSON_HEDLEY_UNLIKELY(!get_ubjson_value(size_and_type.second))) |
12402 | | { |
12403 | | return false; |
12404 | | } |
12405 | | } |
12406 | | |
12407 | | return (sax->end_array() && sax->end_object()); |
12408 | | } |
12409 | | |
12410 | | // If BJData type marker is 'B' decode as binary |
12411 | | if (input_format == input_format_t::bjdata && size_and_type.first != npos && size_and_type.second == 'B') |
12412 | | { |
12413 | | binary_t result; |
12414 | | return get_binary(input_format, size_and_type.first, result) && sax->binary(result); |
12415 | | } |
12416 | | |
12417 | | if (size_and_type.first != npos) |
12418 | | { |
12419 | | if (JSON_HEDLEY_UNLIKELY(!sax->start_array(size_and_type.first))) |
12420 | | { |
12421 | | return false; |
12422 | | } |
12423 | | |
12424 | | if (size_and_type.second != 0) |
12425 | | { |
12426 | | if (size_and_type.second != 'N') |
12427 | | { |
12428 | | for (std::size_t i = 0; i < size_and_type.first; ++i) |
12429 | | { |
12430 | | if (JSON_HEDLEY_UNLIKELY(!get_ubjson_value(size_and_type.second))) |
12431 | | { |
12432 | | return false; |
12433 | | } |
12434 | | } |
12435 | | } |
12436 | | } |
12437 | | else |
12438 | | { |
12439 | | for (std::size_t i = 0; i < size_and_type.first; ++i) |
12440 | | { |
12441 | | if (JSON_HEDLEY_UNLIKELY(!parse_ubjson_internal())) |
12442 | | { |
12443 | | return false; |
12444 | | } |
12445 | | } |
12446 | | } |
12447 | | } |
12448 | | else |
12449 | | { |
12450 | | if (JSON_HEDLEY_UNLIKELY(!sax->start_array(detail::unknown_size()))) |
12451 | | { |
12452 | | return false; |
12453 | | } |
12454 | | |
12455 | | while (current != ']') |
12456 | | { |
12457 | | if (JSON_HEDLEY_UNLIKELY(!parse_ubjson_internal(false))) |
12458 | | { |
12459 | | return false; |
12460 | | } |
12461 | | get_ignore_noop(); |
12462 | | } |
12463 | | } |
12464 | | |
12465 | | return sax->end_array(); |
12466 | | } |
12467 | | |
12468 | | /*! |
12469 | | @return whether object creation completed |
12470 | | */ |
12471 | | bool get_ubjson_object() |
12472 | | { |
12473 | | std::pair<std::size_t, char_int_type> size_and_type; |
12474 | | if (JSON_HEDLEY_UNLIKELY(!get_ubjson_size_type(size_and_type))) |
12475 | | { |
12476 | | return false; |
12477 | | } |
12478 | | |
12479 | | // do not accept ND-array size in objects in BJData |
12480 | | if (input_format == input_format_t::bjdata && size_and_type.first != npos && (size_and_type.second & (1 << 8)) != 0) |
12481 | | { |
12482 | | auto last_token = get_token_string(); |
12483 | | return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read, |
12484 | | exception_message(input_format, "BJData object does not support ND-array size in optimized format", "object"), nullptr)); |
12485 | | } |
12486 | | |
12487 | | string_t key; |
12488 | | if (size_and_type.first != npos) |
12489 | | { |
12490 | | if (JSON_HEDLEY_UNLIKELY(!sax->start_object(size_and_type.first))) |
12491 | | { |
12492 | | return false; |
12493 | | } |
12494 | | |
12495 | | if (size_and_type.second != 0) |
12496 | | { |
12497 | | for (std::size_t i = 0; i < size_and_type.first; ++i) |
12498 | | { |
12499 | | if (JSON_HEDLEY_UNLIKELY(!get_ubjson_string(key) || !sax->key(key))) |
12500 | | { |
12501 | | return false; |
12502 | | } |
12503 | | if (JSON_HEDLEY_UNLIKELY(!get_ubjson_value(size_and_type.second))) |
12504 | | { |
12505 | | return false; |
12506 | | } |
12507 | | key.clear(); |
12508 | | } |
12509 | | } |
12510 | | else |
12511 | | { |
12512 | | for (std::size_t i = 0; i < size_and_type.first; ++i) |
12513 | | { |
12514 | | if (JSON_HEDLEY_UNLIKELY(!get_ubjson_string(key) || !sax->key(key))) |
12515 | | { |
12516 | | return false; |
12517 | | } |
12518 | | if (JSON_HEDLEY_UNLIKELY(!parse_ubjson_internal())) |
12519 | | { |
12520 | | return false; |
12521 | | } |
12522 | | key.clear(); |
12523 | | } |
12524 | | } |
12525 | | } |
12526 | | else |
12527 | | { |
12528 | | if (JSON_HEDLEY_UNLIKELY(!sax->start_object(detail::unknown_size()))) |
12529 | | { |
12530 | | return false; |
12531 | | } |
12532 | | |
12533 | | while (current != '}') |
12534 | | { |
12535 | | if (JSON_HEDLEY_UNLIKELY(!get_ubjson_string(key, false) || !sax->key(key))) |
12536 | | { |
12537 | | return false; |
12538 | | } |
12539 | | if (JSON_HEDLEY_UNLIKELY(!parse_ubjson_internal())) |
12540 | | { |
12541 | | return false; |
12542 | | } |
12543 | | get_ignore_noop(); |
12544 | | key.clear(); |
12545 | | } |
12546 | | } |
12547 | | |
12548 | | return sax->end_object(); |
12549 | | } |
12550 | | |
12551 | | // Note, no reader for UBJSON binary types is implemented because they do |
12552 | | // not exist |
12553 | | |
12554 | | bool get_ubjson_high_precision_number() |
12555 | | { |
12556 | | // get the size of the following number string |
12557 | | std::size_t size{}; |
12558 | | bool no_ndarray = true; |
12559 | | auto res = get_ubjson_size_value(size, no_ndarray); |
12560 | | if (JSON_HEDLEY_UNLIKELY(!res)) |
12561 | | { |
12562 | | return res; |
12563 | | } |
12564 | | |
12565 | | // get number string |
12566 | | std::vector<char> number_vector; |
12567 | | for (std::size_t i = 0; i < size; ++i) |
12568 | | { |
12569 | | get(); |
12570 | | if (JSON_HEDLEY_UNLIKELY(!unexpect_eof(input_format, "number"))) |
12571 | | { |
12572 | | return false; |
12573 | | } |
12574 | | number_vector.push_back(static_cast<char>(current)); |
12575 | | } |
12576 | | |
12577 | | // parse number string |
12578 | | using ia_type = decltype(detail::input_adapter(number_vector)); |
12579 | | auto number_lexer = detail::lexer<BasicJsonType, ia_type>(detail::input_adapter(number_vector), false); |
12580 | | const auto result_number = number_lexer.scan(); |
12581 | | const auto number_string = number_lexer.get_token_string(); |
12582 | | const auto result_remainder = number_lexer.scan(); |
12583 | | |
12584 | | using token_type = typename detail::lexer_base<BasicJsonType>::token_type; |
12585 | | |
12586 | | if (JSON_HEDLEY_UNLIKELY(result_remainder != token_type::end_of_input)) |
12587 | | { |
12588 | | return sax->parse_error(chars_read, number_string, parse_error::create(115, chars_read, |
12589 | | exception_message(input_format, concat("invalid number text: ", number_lexer.get_token_string()), "high-precision number"), nullptr)); |
12590 | | } |
12591 | | |
12592 | | switch (result_number) |
12593 | | { |
12594 | | case token_type::value_integer: |
12595 | | return sax->number_integer(number_lexer.get_number_integer()); |
12596 | | case token_type::value_unsigned: |
12597 | | return sax->number_unsigned(number_lexer.get_number_unsigned()); |
12598 | | case token_type::value_float: |
12599 | | return sax->number_float(number_lexer.get_number_float(), std::move(number_string)); |
12600 | | case token_type::uninitialized: |
12601 | | case token_type::literal_true: |
12602 | | case token_type::literal_false: |
12603 | | case token_type::literal_null: |
12604 | | case token_type::value_string: |
12605 | | case token_type::begin_array: |
12606 | | case token_type::begin_object: |
12607 | | case token_type::end_array: |
12608 | | case token_type::end_object: |
12609 | | case token_type::name_separator: |
12610 | | case token_type::value_separator: |
12611 | | case token_type::parse_error: |
12612 | | case token_type::end_of_input: |
12613 | | case token_type::literal_or_value: |
12614 | | default: |
12615 | | return sax->parse_error(chars_read, number_string, parse_error::create(115, chars_read, |
12616 | | exception_message(input_format, concat("invalid number text: ", number_lexer.get_token_string()), "high-precision number"), nullptr)); |
12617 | | } |
12618 | | } |
12619 | | |
12620 | | /////////////////////// |
12621 | | // Utility functions // |
12622 | | /////////////////////// |
12623 | | |
12624 | | /*! |
12625 | | @brief get next character from the input |
12626 | | |
12627 | | This function provides the interface to the used input adapter. It does |
12628 | | not throw in case the input reached EOF, but returns a -'ve valued |
12629 | | `char_traits<char_type>::eof()` in that case. |
12630 | | |
12631 | | @return character read from the input |
12632 | | */ |
12633 | | char_int_type get() |
12634 | | { |
12635 | | ++chars_read; |
12636 | | return current = ia.get_character(); |
12637 | | } |
12638 | | |
12639 | | /*! |
12640 | | @brief get_to read into a primitive type |
12641 | | |
12642 | | This function provides the interface to the used input adapter. It does |
12643 | | not throw in case the input reached EOF, but returns false instead |
12644 | | |
12645 | | @return bool, whether the read was successful |
12646 | | */ |
12647 | | template<class T> |
12648 | | bool get_to(T& dest, const input_format_t format, const char* context) |
12649 | | { |
12650 | | auto new_chars_read = ia.get_elements(&dest); |
12651 | | chars_read += new_chars_read; |
12652 | | if (JSON_HEDLEY_UNLIKELY(new_chars_read < sizeof(T))) |
12653 | | { |
12654 | | // in case of failure, advance position by 1 to report the failing location |
12655 | | ++chars_read; |
12656 | | sax->parse_error(chars_read, "<end of file>", parse_error::create(110, chars_read, exception_message(format, "unexpected end of input", context), nullptr)); |
12657 | | return false; |
12658 | | } |
12659 | | return true; |
12660 | | } |
12661 | | |
12662 | | /*! |
12663 | | @return character read from the input after ignoring all 'N' entries |
12664 | | */ |
12665 | | char_int_type get_ignore_noop() |
12666 | | { |
12667 | | do |
12668 | | { |
12669 | | get(); |
12670 | | } |
12671 | | while (current == 'N'); |
12672 | | |
12673 | | return current; |
12674 | | } |
12675 | | |
12676 | | template<class NumberType> |
12677 | | static void byte_swap(NumberType& number) |
12678 | | { |
12679 | | constexpr std::size_t sz = sizeof(number); |
12680 | | #ifdef __cpp_lib_byteswap |
12681 | | if constexpr (sz == 1) |
12682 | | { |
12683 | | return; |
12684 | | } |
12685 | | else if constexpr(std::is_integral_v<NumberType>) |
12686 | | { |
12687 | | number = std::byteswap(number); |
12688 | | return; |
12689 | | } |
12690 | | else |
12691 | | { |
12692 | | #endif |
12693 | | auto* ptr = reinterpret_cast<std::uint8_t*>(&number); |
12694 | | for (std::size_t i = 0; i < sz / 2; ++i) |
12695 | | { |
12696 | | std::swap(ptr[i], ptr[sz - i - 1]); |
12697 | | } |
12698 | | #ifdef __cpp_lib_byteswap |
12699 | | } |
12700 | | #endif |
12701 | | } |
12702 | | |
12703 | | /* |
12704 | | @brief read a number from the input |
12705 | | |
12706 | | @tparam NumberType the type of the number |
12707 | | @param[in] format the current format (for diagnostics) |
12708 | | @param[out] result number of type @a NumberType |
12709 | | |
12710 | | @return whether conversion completed |
12711 | | |
12712 | | @note This function needs to respect the system's endianness, because |
12713 | | bytes in CBOR, MessagePack, and UBJSON are stored in network order |
12714 | | (big endian) and therefore need reordering on little endian systems. |
12715 | | On the other hand, BSON and BJData use little endian and should reorder |
12716 | | on big endian systems. |
12717 | | */ |
12718 | | template<typename NumberType, bool InputIsLittleEndian = false> |
12719 | | bool get_number(const input_format_t format, NumberType& result) |
12720 | | { |
12721 | | // read in the original format |
12722 | | |
12723 | | if (JSON_HEDLEY_UNLIKELY(!get_to(result, format, "number"))) |
12724 | | { |
12725 | | return false; |
12726 | | } |
12727 | | if (is_little_endian != (InputIsLittleEndian || format == input_format_t::bjdata)) |
12728 | | { |
12729 | | byte_swap(result); |
12730 | | } |
12731 | | return true; |
12732 | | } |
12733 | | |
12734 | | /*! |
12735 | | @brief create a string by reading characters from the input |
12736 | | |
12737 | | @tparam NumberType the type of the number |
12738 | | @param[in] format the current format (for diagnostics) |
12739 | | @param[in] len number of characters to read |
12740 | | @param[out] result string created by reading @a len bytes |
12741 | | |
12742 | | @return whether string creation completed |
12743 | | |
12744 | | @note We can not reserve @a len bytes for the result, because @a len |
12745 | | may be too large. Usually, @ref unexpect_eof() detects the end of |
12746 | | the input before we run out of string memory. |
12747 | | */ |
12748 | | template<typename NumberType> |
12749 | | bool get_string(const input_format_t format, |
12750 | | const NumberType len, |
12751 | | string_t& result) |
12752 | | { |
12753 | | bool success = true; |
12754 | | for (NumberType i = 0; i < len; i++) |
12755 | | { |
12756 | | get(); |
12757 | | if (JSON_HEDLEY_UNLIKELY(!unexpect_eof(format, "string"))) |
12758 | | { |
12759 | | success = false; |
12760 | | break; |
12761 | | } |
12762 | | result.push_back(static_cast<typename string_t::value_type>(current)); |
12763 | | } |
12764 | | return success; |
12765 | | } |
12766 | | |
12767 | | /*! |
12768 | | @brief create a byte array by reading bytes from the input |
12769 | | |
12770 | | @tparam NumberType the type of the number |
12771 | | @param[in] format the current format (for diagnostics) |
12772 | | @param[in] len number of bytes to read |
12773 | | @param[out] result byte array created by reading @a len bytes |
12774 | | |
12775 | | @return whether byte array creation completed |
12776 | | |
12777 | | @note We can not reserve @a len bytes for the result, because @a len |
12778 | | may be too large. Usually, @ref unexpect_eof() detects the end of |
12779 | | the input before we run out of memory. |
12780 | | */ |
12781 | | template<typename NumberType> |
12782 | | bool get_binary(const input_format_t format, |
12783 | | const NumberType len, |
12784 | | binary_t& result) |
12785 | | { |
12786 | | bool success = true; |
12787 | | for (NumberType i = 0; i < len; i++) |
12788 | | { |
12789 | | get(); |
12790 | | if (JSON_HEDLEY_UNLIKELY(!unexpect_eof(format, "binary"))) |
12791 | | { |
12792 | | success = false; |
12793 | | break; |
12794 | | } |
12795 | | result.push_back(static_cast<typename binary_t::value_type>(current)); |
12796 | | } |
12797 | | return success; |
12798 | | } |
12799 | | |
12800 | | /*! |
12801 | | @param[in] format the current format (for diagnostics) |
12802 | | @param[in] context further context information (for diagnostics) |
12803 | | @return whether the last read character is not EOF |
12804 | | */ |
12805 | | JSON_HEDLEY_NON_NULL(3) |
12806 | | bool unexpect_eof(const input_format_t format, const char* context) const |
12807 | | { |
12808 | | if (JSON_HEDLEY_UNLIKELY(current == char_traits<char_type>::eof())) |
12809 | | { |
12810 | | return sax->parse_error(chars_read, "<end of file>", |
12811 | | parse_error::create(110, chars_read, exception_message(format, "unexpected end of input", context), nullptr)); |
12812 | | } |
12813 | | return true; |
12814 | | } |
12815 | | |
12816 | | /*! |
12817 | | @return a string representation of the last read byte |
12818 | | */ |
12819 | | std::string get_token_string() const |
12820 | | { |
12821 | | std::array<char, 3> cr{{}}; |
12822 | | static_cast<void>((std::snprintf)(cr.data(), cr.size(), "%.2hhX", static_cast<unsigned char>(current))); // NOLINT(cppcoreguidelines-pro-type-vararg,hicpp-vararg) |
12823 | | return std::string{cr.data()}; |
12824 | | } |
12825 | | |
12826 | | /*! |
12827 | | @param[in] format the current format |
12828 | | @param[in] detail a detailed error message |
12829 | | @param[in] context further context information |
12830 | | @return a message string to use in the parse_error exceptions |
12831 | | */ |
12832 | | std::string exception_message(const input_format_t format, |
12833 | | const std::string& detail, |
12834 | | const std::string& context) const |
12835 | | { |
12836 | | std::string error_msg = "syntax error while parsing "; |
12837 | | |
12838 | | switch (format) |
12839 | | { |
12840 | | case input_format_t::cbor: |
12841 | | error_msg += "CBOR"; |
12842 | | break; |
12843 | | |
12844 | | case input_format_t::msgpack: |
12845 | | error_msg += "MessagePack"; |
12846 | | break; |
12847 | | |
12848 | | case input_format_t::ubjson: |
12849 | | error_msg += "UBJSON"; |
12850 | | break; |
12851 | | |
12852 | | case input_format_t::bson: |
12853 | | error_msg += "BSON"; |
12854 | | break; |
12855 | | |
12856 | | case input_format_t::bjdata: |
12857 | | error_msg += "BJData"; |
12858 | | break; |
12859 | | |
12860 | | case input_format_t::json: // LCOV_EXCL_LINE |
12861 | | default: // LCOV_EXCL_LINE |
12862 | | JSON_ASSERT(false); // NOLINT(cert-dcl03-c,hicpp-static-assert,misc-static-assert) LCOV_EXCL_LINE |
12863 | | } |
12864 | | |
12865 | | return concat(error_msg, ' ', context, ": ", detail); |
12866 | | } |
12867 | | |
12868 | | private: |
12869 | | static JSON_INLINE_VARIABLE constexpr std::size_t npos = detail::unknown_size(); |
12870 | | |
12871 | | /// input adapter |
12872 | | InputAdapterType ia; |
12873 | | |
12874 | | /// the current character |
12875 | | char_int_type current = char_traits<char_type>::eof(); |
12876 | | |
12877 | | /// the number of characters read |
12878 | | std::size_t chars_read = 0; |
12879 | | |
12880 | | /// whether we can assume little endianness |
12881 | | const bool is_little_endian = little_endianness(); |
12882 | | |
12883 | | /// input format |
12884 | | const input_format_t input_format = input_format_t::json; |
12885 | | |
12886 | | /// the SAX parser |
12887 | | json_sax_t* sax = nullptr; |
12888 | | |
12889 | | // excluded markers in bjdata optimized type |
12890 | | #define JSON_BINARY_READER_MAKE_BJD_OPTIMIZED_TYPE_MARKERS_ \ |
12891 | | make_array<char_int_type>('F', 'H', 'N', 'S', 'T', 'Z', '[', '{') |
12892 | | |
12893 | | #define JSON_BINARY_READER_MAKE_BJD_TYPES_MAP_ \ |
12894 | | make_array<bjd_type>( \ |
12895 | | bjd_type{'B', "byte"}, \ |
12896 | | bjd_type{'C', "char"}, \ |
12897 | | bjd_type{'D', "double"}, \ |
12898 | | bjd_type{'I', "int16"}, \ |
12899 | | bjd_type{'L', "int64"}, \ |
12900 | | bjd_type{'M', "uint64"}, \ |
12901 | | bjd_type{'U', "uint8"}, \ |
12902 | | bjd_type{'d', "single"}, \ |
12903 | | bjd_type{'i', "int8"}, \ |
12904 | | bjd_type{'l', "int32"}, \ |
12905 | | bjd_type{'m', "uint32"}, \ |
12906 | | bjd_type{'u', "uint16"}) |
12907 | | |
12908 | | JSON_PRIVATE_UNLESS_TESTED: |
12909 | | // lookup tables |
12910 | | // NOLINTNEXTLINE(cppcoreguidelines-non-private-member-variables-in-classes) |
12911 | | const decltype(JSON_BINARY_READER_MAKE_BJD_OPTIMIZED_TYPE_MARKERS_) bjd_optimized_type_markers = |
12912 | | JSON_BINARY_READER_MAKE_BJD_OPTIMIZED_TYPE_MARKERS_; |
12913 | | |
12914 | | using bjd_type = std::pair<char_int_type, string_t>; |
12915 | | // NOLINTNEXTLINE(cppcoreguidelines-non-private-member-variables-in-classes) |
12916 | | const decltype(JSON_BINARY_READER_MAKE_BJD_TYPES_MAP_) bjd_types_map = |
12917 | | JSON_BINARY_READER_MAKE_BJD_TYPES_MAP_; |
12918 | | |
12919 | | #undef JSON_BINARY_READER_MAKE_BJD_OPTIMIZED_TYPE_MARKERS_ |
12920 | | #undef JSON_BINARY_READER_MAKE_BJD_TYPES_MAP_ |
12921 | | }; |
12922 | | |
12923 | | #ifndef JSON_HAS_CPP_17 |
12924 | | template<typename BasicJsonType, typename InputAdapterType, typename SAX> |
12925 | | constexpr std::size_t binary_reader<BasicJsonType, InputAdapterType, SAX>::npos; |
12926 | | #endif |
12927 | | |
12928 | | } // namespace detail |
12929 | | NLOHMANN_JSON_NAMESPACE_END |
12930 | | |
12931 | | // #include <nlohmann/detail/input/input_adapters.hpp> |
12932 | | |
12933 | | // #include <nlohmann/detail/input/lexer.hpp> |
12934 | | |
12935 | | // #include <nlohmann/detail/input/parser.hpp> |
12936 | | // __ _____ _____ _____ |
12937 | | // __| | __| | | | JSON for Modern C++ |
12938 | | // | | |__ | | | | | | version 3.12.0 |
12939 | | // |_____|_____|_____|_|___| https://github.com/nlohmann/json |
12940 | | // |
12941 | | // SPDX-FileCopyrightText: 2013-2026 Niels Lohmann <https://nlohmann.me> |
12942 | | // SPDX-License-Identifier: MIT |
12943 | | |
12944 | | |
12945 | | |
12946 | | #include <cmath> // isfinite |
12947 | | #include <cstdint> // uint8_t |
12948 | | #include <functional> // function |
12949 | | #include <string> // string |
12950 | | #include <utility> // move |
12951 | | #include <vector> // vector |
12952 | | |
12953 | | // #include <nlohmann/detail/exceptions.hpp> |
12954 | | |
12955 | | // #include <nlohmann/detail/input/input_adapters.hpp> |
12956 | | |
12957 | | // #include <nlohmann/detail/input/json_sax.hpp> |
12958 | | |
12959 | | // #include <nlohmann/detail/input/lexer.hpp> |
12960 | | |
12961 | | // #include <nlohmann/detail/macro_scope.hpp> |
12962 | | |
12963 | | // #include <nlohmann/detail/meta/is_sax.hpp> |
12964 | | |
12965 | | // #include <nlohmann/detail/string_concat.hpp> |
12966 | | |
12967 | | // #include <nlohmann/detail/value_t.hpp> |
12968 | | |
12969 | | |
12970 | | NLOHMANN_JSON_NAMESPACE_BEGIN |
12971 | | namespace detail |
12972 | | { |
12973 | | //////////// |
12974 | | // parser // |
12975 | | //////////// |
12976 | | |
12977 | | enum class parse_event_t : std::uint8_t |
12978 | | { |
12979 | | /// the parser read `{` and started to process a JSON object |
12980 | | object_start, |
12981 | | /// the parser read `}` and finished processing a JSON object |
12982 | | object_end, |
12983 | | /// the parser read `[` and started to process a JSON array |
12984 | | array_start, |
12985 | | /// the parser read `]` and finished processing a JSON array |
12986 | | array_end, |
12987 | | /// the parser read a key of a value in an object |
12988 | | key, |
12989 | | /// the parser finished reading a JSON value |
12990 | | value |
12991 | | }; |
12992 | | |
12993 | | template<typename BasicJsonType> |
12994 | | using parser_callback_t = |
12995 | | std::function<bool(int /*depth*/, parse_event_t /*event*/, BasicJsonType& /*parsed*/)>; |
12996 | | |
12997 | | /*! |
12998 | | @brief syntax analysis |
12999 | | |
13000 | | This class implements a recursive descent parser. |
13001 | | */ |
13002 | | template<typename BasicJsonType, typename InputAdapterType> |
13003 | | class parser |
13004 | | { |
13005 | | using number_integer_t = typename BasicJsonType::number_integer_t; |
13006 | | using number_unsigned_t = typename BasicJsonType::number_unsigned_t; |
13007 | | using number_float_t = typename BasicJsonType::number_float_t; |
13008 | | using string_t = typename BasicJsonType::string_t; |
13009 | | using lexer_t = lexer<BasicJsonType, InputAdapterType>; |
13010 | | using token_type = typename lexer_t::token_type; |
13011 | | |
13012 | | public: |
13013 | | /// a parser reading from an input adapter |
13014 | | explicit parser(InputAdapterType&& adapter, |
13015 | | parser_callback_t<BasicJsonType> cb = nullptr, |
13016 | | const bool allow_exceptions_ = true, |
13017 | | const bool ignore_comments = false, |
13018 | | const bool ignore_trailing_commas_ = false) |
13019 | 0 | : callback(std::move(cb)) |
13020 | 0 | , m_lexer(std::move(adapter), ignore_comments) |
13021 | 0 | , allow_exceptions(allow_exceptions_) |
13022 | 0 | , ignore_trailing_commas(ignore_trailing_commas_) |
13023 | 0 | { |
13024 | | // read first token |
13025 | 0 | get_token(); |
13026 | 0 | } |
13027 | | |
13028 | | /*! |
13029 | | @brief public parser interface |
13030 | | |
13031 | | @param[in] strict whether to expect the last token to be EOF |
13032 | | @param[in,out] result parsed JSON value |
13033 | | |
13034 | | @throw parse_error.101 in case of an unexpected token |
13035 | | @throw parse_error.102 if to_unicode fails or surrogate error |
13036 | | @throw parse_error.103 if to_unicode fails |
13037 | | */ |
13038 | | void parse(const bool strict, BasicJsonType& result) |
13039 | 0 | { |
13040 | 0 | if (callback) |
13041 | 0 | { |
13042 | 0 | json_sax_dom_callback_parser<BasicJsonType, InputAdapterType> sdp(result, callback, allow_exceptions, &m_lexer); |
13043 | 0 | sax_parse_internal(&sdp); |
13044 | | |
13045 | | // in strict mode, input must be completely read |
13046 | 0 | if (strict && (get_token() != token_type::end_of_input)) |
13047 | 0 | { |
13048 | 0 | sdp.parse_error(m_lexer.get_position(), |
13049 | 0 | m_lexer.get_token_string(), |
13050 | 0 | parse_error::create(101, m_lexer.get_position(), |
13051 | 0 | exception_message(token_type::end_of_input, "value"), nullptr)); |
13052 | 0 | } |
13053 | | |
13054 | | // in case of an error, return a discarded value |
13055 | 0 | if (sdp.is_errored()) |
13056 | 0 | { |
13057 | 0 | result = value_t::discarded; |
13058 | 0 | return; |
13059 | 0 | } |
13060 | | |
13061 | | // set top-level value to null if it was discarded by the callback |
13062 | | // function |
13063 | 0 | if (result.is_discarded()) |
13064 | 0 | { |
13065 | 0 | result = nullptr; |
13066 | 0 | } |
13067 | 0 | } |
13068 | 0 | else |
13069 | 0 | { |
13070 | 0 | json_sax_dom_parser<BasicJsonType, InputAdapterType> sdp(result, allow_exceptions, &m_lexer); |
13071 | 0 | sax_parse_internal(&sdp); |
13072 | | |
13073 | | // in strict mode, input must be completely read |
13074 | 0 | if (strict && (get_token() != token_type::end_of_input)) |
13075 | 0 | { |
13076 | 0 | sdp.parse_error(m_lexer.get_position(), |
13077 | 0 | m_lexer.get_token_string(), |
13078 | 0 | parse_error::create(101, m_lexer.get_position(), exception_message(token_type::end_of_input, "value"), nullptr)); |
13079 | 0 | } |
13080 | | |
13081 | | // in case of an error, return a discarded value |
13082 | 0 | if (sdp.is_errored()) |
13083 | 0 | { |
13084 | 0 | result = value_t::discarded; |
13085 | 0 | return; |
13086 | 0 | } |
13087 | 0 | } |
13088 | | |
13089 | 0 | result.assert_invariant(); |
13090 | 0 | } Unexecuted instantiation: nlohmann::json_abi_v3_12_0::detail::parser<nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>, nlohmann::json_abi_v3_12_0::detail::iterator_input_adapter<char const*> >::parse(bool, nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>&) Unexecuted instantiation: nlohmann::json_abi_v3_12_0::detail::parser<nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>, nlohmann::json_abi_v3_12_0::detail::input_stream_adapter>::parse(bool, nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>&) |
13091 | | |
13092 | | /*! |
13093 | | @brief public accept interface |
13094 | | |
13095 | | @param[in] strict whether to expect the last token to be EOF |
13096 | | @return whether the input is a proper JSON text |
13097 | | */ |
13098 | | bool accept(const bool strict = true) |
13099 | | { |
13100 | | json_sax_acceptor<BasicJsonType> sax_acceptor; |
13101 | | return sax_parse(&sax_acceptor, strict); |
13102 | | } |
13103 | | |
13104 | | template<typename SAX> |
13105 | | JSON_HEDLEY_NON_NULL(2) |
13106 | | bool sax_parse(SAX* sax, const bool strict = true) |
13107 | | { |
13108 | | (void)detail::is_sax_static_asserts<SAX, BasicJsonType> {}; |
13109 | | const bool result = sax_parse_internal(sax); |
13110 | | |
13111 | | // strict mode: next byte must be EOF |
13112 | | if (result && strict && (get_token() != token_type::end_of_input)) |
13113 | | { |
13114 | | return sax->parse_error(m_lexer.get_position(), |
13115 | | m_lexer.get_token_string(), |
13116 | | parse_error::create(101, m_lexer.get_position(), exception_message(token_type::end_of_input, "value"), nullptr)); |
13117 | | } |
13118 | | |
13119 | | return result; |
13120 | | } |
13121 | | |
13122 | | private: |
13123 | | template<typename SAX> |
13124 | | JSON_HEDLEY_NON_NULL(2) |
13125 | | bool sax_parse_internal(SAX* sax) |
13126 | 0 | { |
13127 | | // stack to remember the hierarchy of structured values we are parsing |
13128 | | // true = array; false = object |
13129 | 0 | std::vector<bool> states; |
13130 | | // value to avoid a goto (see comment where set to true) |
13131 | 0 | bool skip_to_state_evaluation = false; |
13132 | |
|
13133 | 0 | while (true) |
13134 | 0 | { |
13135 | 0 | if (!skip_to_state_evaluation) |
13136 | 0 | { |
13137 | | // invariant: get_token() was called before each iteration |
13138 | 0 | switch (last_token) |
13139 | 0 | { |
13140 | 0 | case token_type::begin_object: |
13141 | 0 | { |
13142 | 0 | if (JSON_HEDLEY_UNLIKELY(!sax->start_object(detail::unknown_size()))) |
13143 | 0 | { |
13144 | 0 | return false; |
13145 | 0 | } |
13146 | | |
13147 | | // closing } -> we are done |
13148 | 0 | if (get_token() == token_type::end_object) |
13149 | 0 | { |
13150 | 0 | if (JSON_HEDLEY_UNLIKELY(!sax->end_object())) |
13151 | 0 | { |
13152 | 0 | return false; |
13153 | 0 | } |
13154 | 0 | break; |
13155 | 0 | } |
13156 | | |
13157 | | // parse key |
13158 | 0 | if (JSON_HEDLEY_UNLIKELY(last_token != token_type::value_string)) |
13159 | 0 | { |
13160 | 0 | return sax->parse_error(m_lexer.get_position(), |
13161 | 0 | m_lexer.get_token_string(), |
13162 | 0 | parse_error::create(101, m_lexer.get_position(), exception_message(token_type::value_string, "object key"), nullptr)); |
13163 | 0 | } |
13164 | 0 | if (JSON_HEDLEY_UNLIKELY(!sax->key(m_lexer.get_string()))) |
13165 | 0 | { |
13166 | 0 | return false; |
13167 | 0 | } |
13168 | | |
13169 | | // parse separator (:) |
13170 | 0 | if (JSON_HEDLEY_UNLIKELY(get_token() != token_type::name_separator)) |
13171 | 0 | { |
13172 | 0 | return sax->parse_error(m_lexer.get_position(), |
13173 | 0 | m_lexer.get_token_string(), |
13174 | 0 | parse_error::create(101, m_lexer.get_position(), exception_message(token_type::name_separator, "object separator"), nullptr)); |
13175 | 0 | } |
13176 | | |
13177 | | // remember we are now inside an object |
13178 | 0 | states.push_back(false); |
13179 | | |
13180 | | // parse values |
13181 | 0 | get_token(); |
13182 | 0 | continue; |
13183 | 0 | } |
13184 | | |
13185 | 0 | case token_type::begin_array: |
13186 | 0 | { |
13187 | 0 | if (JSON_HEDLEY_UNLIKELY(!sax->start_array(detail::unknown_size()))) |
13188 | 0 | { |
13189 | 0 | return false; |
13190 | 0 | } |
13191 | | |
13192 | | // closing ] -> we are done |
13193 | 0 | if (get_token() == token_type::end_array) |
13194 | 0 | { |
13195 | 0 | if (JSON_HEDLEY_UNLIKELY(!sax->end_array())) |
13196 | 0 | { |
13197 | 0 | return false; |
13198 | 0 | } |
13199 | 0 | break; |
13200 | 0 | } |
13201 | | |
13202 | | // remember we are now inside an array |
13203 | 0 | states.push_back(true); |
13204 | | |
13205 | | // parse values (no need to call get_token) |
13206 | 0 | continue; |
13207 | 0 | } |
13208 | | |
13209 | 0 | case token_type::value_float: |
13210 | 0 | { |
13211 | 0 | const auto res = m_lexer.get_number_float(); |
13212 | |
|
13213 | 0 | if (JSON_HEDLEY_UNLIKELY(!std::isfinite(res))) |
13214 | 0 | { |
13215 | 0 | return sax->parse_error(m_lexer.get_position(), |
13216 | 0 | m_lexer.get_token_string(), |
13217 | 0 | out_of_range::create(406, concat("number overflow parsing '", m_lexer.get_token_string(), '\''), nullptr)); |
13218 | 0 | } |
13219 | | |
13220 | 0 | if (JSON_HEDLEY_UNLIKELY(!sax->number_float(res, m_lexer.get_string()))) |
13221 | 0 | { |
13222 | 0 | return false; |
13223 | 0 | } |
13224 | | |
13225 | 0 | break; |
13226 | 0 | } |
13227 | | |
13228 | 0 | case token_type::literal_false: |
13229 | 0 | { |
13230 | 0 | if (JSON_HEDLEY_UNLIKELY(!sax->boolean(false))) |
13231 | 0 | { |
13232 | 0 | return false; |
13233 | 0 | } |
13234 | 0 | break; |
13235 | 0 | } |
13236 | | |
13237 | 0 | case token_type::literal_null: |
13238 | 0 | { |
13239 | 0 | if (JSON_HEDLEY_UNLIKELY(!sax->null())) |
13240 | 0 | { |
13241 | 0 | return false; |
13242 | 0 | } |
13243 | 0 | break; |
13244 | 0 | } |
13245 | | |
13246 | 0 | case token_type::literal_true: |
13247 | 0 | { |
13248 | 0 | if (JSON_HEDLEY_UNLIKELY(!sax->boolean(true))) |
13249 | 0 | { |
13250 | 0 | return false; |
13251 | 0 | } |
13252 | 0 | break; |
13253 | 0 | } |
13254 | | |
13255 | 0 | case token_type::value_integer: |
13256 | 0 | { |
13257 | 0 | if (JSON_HEDLEY_UNLIKELY(!sax->number_integer(m_lexer.get_number_integer()))) |
13258 | 0 | { |
13259 | 0 | return false; |
13260 | 0 | } |
13261 | 0 | break; |
13262 | 0 | } |
13263 | | |
13264 | 0 | case token_type::value_string: |
13265 | 0 | { |
13266 | 0 | if (JSON_HEDLEY_UNLIKELY(!sax->string(m_lexer.get_string()))) |
13267 | 0 | { |
13268 | 0 | return false; |
13269 | 0 | } |
13270 | 0 | break; |
13271 | 0 | } |
13272 | | |
13273 | 0 | case token_type::value_unsigned: |
13274 | 0 | { |
13275 | 0 | if (JSON_HEDLEY_UNLIKELY(!sax->number_unsigned(m_lexer.get_number_unsigned()))) |
13276 | 0 | { |
13277 | 0 | return false; |
13278 | 0 | } |
13279 | 0 | break; |
13280 | 0 | } |
13281 | | |
13282 | 0 | case token_type::parse_error: |
13283 | 0 | { |
13284 | | // using "uninitialized" to avoid an "expected" message |
13285 | 0 | return sax->parse_error(m_lexer.get_position(), |
13286 | 0 | m_lexer.get_token_string(), |
13287 | 0 | parse_error::create(101, m_lexer.get_position(), exception_message(token_type::uninitialized, "value"), nullptr)); |
13288 | 0 | } |
13289 | 0 | case token_type::end_of_input: |
13290 | 0 | { |
13291 | 0 | if (JSON_HEDLEY_UNLIKELY(m_lexer.get_position().chars_read_total == 1)) |
13292 | 0 | { |
13293 | 0 | return sax->parse_error(m_lexer.get_position(), |
13294 | 0 | m_lexer.get_token_string(), |
13295 | 0 | parse_error::create(101, m_lexer.get_position(), |
13296 | 0 | "attempting to parse an empty input; check that your input string or stream contains the expected JSON", nullptr)); |
13297 | 0 | } |
13298 | | |
13299 | 0 | return sax->parse_error(m_lexer.get_position(), |
13300 | 0 | m_lexer.get_token_string(), |
13301 | 0 | parse_error::create(101, m_lexer.get_position(), exception_message(token_type::literal_or_value, "value"), nullptr)); |
13302 | 0 | } |
13303 | 0 | case token_type::uninitialized: |
13304 | 0 | case token_type::end_array: |
13305 | 0 | case token_type::end_object: |
13306 | 0 | case token_type::name_separator: |
13307 | 0 | case token_type::value_separator: |
13308 | 0 | case token_type::literal_or_value: |
13309 | 0 | default: // the last token was unexpected |
13310 | 0 | { |
13311 | 0 | return sax->parse_error(m_lexer.get_position(), |
13312 | 0 | m_lexer.get_token_string(), |
13313 | 0 | parse_error::create(101, m_lexer.get_position(), exception_message(token_type::literal_or_value, "value"), nullptr)); |
13314 | 0 | } |
13315 | 0 | } |
13316 | 0 | } |
13317 | 0 | else |
13318 | 0 | { |
13319 | 0 | skip_to_state_evaluation = false; |
13320 | 0 | } |
13321 | | |
13322 | | // we reached this line after we successfully parsed a value |
13323 | 0 | if (states.empty()) |
13324 | 0 | { |
13325 | | // empty stack: we reached the end of the hierarchy: done |
13326 | 0 | return true; |
13327 | 0 | } |
13328 | | |
13329 | 0 | if (states.back()) // array |
13330 | 0 | { |
13331 | | // comma -> next value |
13332 | | // or end of array (ignore_trailing_commas = true) |
13333 | 0 | if (get_token() == token_type::value_separator) |
13334 | 0 | { |
13335 | | // parse a new value |
13336 | 0 | get_token(); |
13337 | | |
13338 | | // if ignore_trailing_commas and last_token is ], we can continue to "closing ]" |
13339 | 0 | if (!(ignore_trailing_commas && last_token == token_type::end_array)) |
13340 | 0 | { |
13341 | 0 | continue; |
13342 | 0 | } |
13343 | 0 | } |
13344 | | |
13345 | | // closing ] |
13346 | 0 | if (JSON_HEDLEY_LIKELY(last_token == token_type::end_array)) |
13347 | 0 | { |
13348 | 0 | if (JSON_HEDLEY_UNLIKELY(!sax->end_array())) |
13349 | 0 | { |
13350 | 0 | return false; |
13351 | 0 | } |
13352 | | |
13353 | | // We are done with this array. Before we can parse a |
13354 | | // new value, we need to evaluate the new state first. |
13355 | | // By setting skip_to_state_evaluation to false, we |
13356 | | // are effectively jumping to the beginning of this if. |
13357 | 0 | JSON_ASSERT(!states.empty()); |
13358 | 0 | states.pop_back(); |
13359 | 0 | skip_to_state_evaluation = true; |
13360 | 0 | continue; |
13361 | 0 | } |
13362 | | |
13363 | 0 | return sax->parse_error(m_lexer.get_position(), |
13364 | 0 | m_lexer.get_token_string(), |
13365 | 0 | parse_error::create(101, m_lexer.get_position(), exception_message(token_type::end_array, "array"), nullptr)); |
13366 | 0 | } |
13367 | | |
13368 | | // states.back() is false -> object |
13369 | | |
13370 | | // comma -> next value |
13371 | | // or end of object (ignore_trailing_commas = true) |
13372 | 0 | if (get_token() == token_type::value_separator) |
13373 | 0 | { |
13374 | 0 | get_token(); |
13375 | | |
13376 | | // if ignore_trailing_commas and last_token is }, we can continue to "closing }" |
13377 | 0 | if (!(ignore_trailing_commas && last_token == token_type::end_object)) |
13378 | 0 | { |
13379 | | // parse key |
13380 | 0 | if (JSON_HEDLEY_UNLIKELY(last_token != token_type::value_string)) |
13381 | 0 | { |
13382 | 0 | return sax->parse_error(m_lexer.get_position(), |
13383 | 0 | m_lexer.get_token_string(), |
13384 | 0 | parse_error::create(101, m_lexer.get_position(), exception_message(token_type::value_string, "object key"), nullptr)); |
13385 | 0 | } |
13386 | | |
13387 | 0 | if (JSON_HEDLEY_UNLIKELY(!sax->key(m_lexer.get_string()))) |
13388 | 0 | { |
13389 | 0 | return false; |
13390 | 0 | } |
13391 | | |
13392 | | // parse separator (:) |
13393 | 0 | if (JSON_HEDLEY_UNLIKELY(get_token() != token_type::name_separator)) |
13394 | 0 | { |
13395 | 0 | return sax->parse_error(m_lexer.get_position(), |
13396 | 0 | m_lexer.get_token_string(), |
13397 | 0 | parse_error::create(101, m_lexer.get_position(), exception_message(token_type::name_separator, "object separator"), nullptr)); |
13398 | 0 | } |
13399 | | |
13400 | | // parse values |
13401 | 0 | get_token(); |
13402 | 0 | continue; |
13403 | 0 | } |
13404 | 0 | } |
13405 | | |
13406 | | // closing } |
13407 | 0 | if (JSON_HEDLEY_LIKELY(last_token == token_type::end_object)) |
13408 | 0 | { |
13409 | 0 | if (JSON_HEDLEY_UNLIKELY(!sax->end_object())) |
13410 | 0 | { |
13411 | 0 | return false; |
13412 | 0 | } |
13413 | | |
13414 | | // We are done with this object. Before we can parse a |
13415 | | // new value, we need to evaluate the new state first. |
13416 | | // By setting skip_to_state_evaluation to false, we |
13417 | | // are effectively jumping to the beginning of this if. |
13418 | 0 | JSON_ASSERT(!states.empty()); |
13419 | 0 | states.pop_back(); |
13420 | 0 | skip_to_state_evaluation = true; |
13421 | 0 | continue; |
13422 | 0 | } |
13423 | | |
13424 | 0 | return sax->parse_error(m_lexer.get_position(), |
13425 | 0 | m_lexer.get_token_string(), |
13426 | 0 | parse_error::create(101, m_lexer.get_position(), exception_message(token_type::end_object, "object"), nullptr)); |
13427 | 0 | } |
13428 | 0 | } Unexecuted instantiation: bool nlohmann::json_abi_v3_12_0::detail::parser<nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>, nlohmann::json_abi_v3_12_0::detail::iterator_input_adapter<char const*> >::sax_parse_internal<nlohmann::json_abi_v3_12_0::detail::json_sax_dom_callback_parser<nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>, nlohmann::json_abi_v3_12_0::detail::iterator_input_adapter<char const*> > >(nlohmann::json_abi_v3_12_0::detail::json_sax_dom_callback_parser<nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>, nlohmann::json_abi_v3_12_0::detail::iterator_input_adapter<char const*> >*) Unexecuted instantiation: bool nlohmann::json_abi_v3_12_0::detail::parser<nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>, nlohmann::json_abi_v3_12_0::detail::iterator_input_adapter<char const*> >::sax_parse_internal<nlohmann::json_abi_v3_12_0::detail::json_sax_dom_parser<nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>, nlohmann::json_abi_v3_12_0::detail::iterator_input_adapter<char const*> > >(nlohmann::json_abi_v3_12_0::detail::json_sax_dom_parser<nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>, nlohmann::json_abi_v3_12_0::detail::iterator_input_adapter<char const*> >*) Unexecuted instantiation: bool nlohmann::json_abi_v3_12_0::detail::parser<nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>, nlohmann::json_abi_v3_12_0::detail::input_stream_adapter>::sax_parse_internal<nlohmann::json_abi_v3_12_0::detail::json_sax_dom_callback_parser<nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>, nlohmann::json_abi_v3_12_0::detail::input_stream_adapter> >(nlohmann::json_abi_v3_12_0::detail::json_sax_dom_callback_parser<nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>, nlohmann::json_abi_v3_12_0::detail::input_stream_adapter>*) Unexecuted instantiation: bool nlohmann::json_abi_v3_12_0::detail::parser<nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>, nlohmann::json_abi_v3_12_0::detail::input_stream_adapter>::sax_parse_internal<nlohmann::json_abi_v3_12_0::detail::json_sax_dom_parser<nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>, nlohmann::json_abi_v3_12_0::detail::input_stream_adapter> >(nlohmann::json_abi_v3_12_0::detail::json_sax_dom_parser<nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>, nlohmann::json_abi_v3_12_0::detail::input_stream_adapter>*) |
13429 | | |
13430 | | /// get next token from lexer |
13431 | | token_type get_token() |
13432 | 0 | { |
13433 | 0 | return last_token = m_lexer.scan(); |
13434 | 0 | } Unexecuted instantiation: nlohmann::json_abi_v3_12_0::detail::parser<nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>, nlohmann::json_abi_v3_12_0::detail::iterator_input_adapter<char const*> >::get_token() Unexecuted instantiation: nlohmann::json_abi_v3_12_0::detail::parser<nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>, nlohmann::json_abi_v3_12_0::detail::input_stream_adapter>::get_token() |
13435 | | |
13436 | | std::string exception_message(const token_type expected, const std::string& context) |
13437 | 0 | { |
13438 | 0 | std::string error_msg = "syntax error "; |
13439 | |
|
13440 | 0 | if (!context.empty()) |
13441 | 0 | { |
13442 | 0 | error_msg += concat("while parsing ", context, ' '); |
13443 | 0 | } |
13444 | |
|
13445 | 0 | error_msg += "- "; |
13446 | |
|
13447 | 0 | if (last_token == token_type::parse_error) |
13448 | 0 | { |
13449 | 0 | error_msg += concat(m_lexer.get_error_message(), "; last read: '", |
13450 | 0 | m_lexer.get_token_string(), '\''); |
13451 | 0 | } |
13452 | 0 | else |
13453 | 0 | { |
13454 | 0 | error_msg += concat("unexpected ", lexer_t::token_type_name(last_token)); |
13455 | 0 | } |
13456 | |
|
13457 | 0 | if (expected != token_type::uninitialized) |
13458 | 0 | { |
13459 | 0 | error_msg += concat("; expected ", lexer_t::token_type_name(expected)); |
13460 | 0 | } |
13461 | |
|
13462 | 0 | return error_msg; |
13463 | 0 | } Unexecuted instantiation: nlohmann::json_abi_v3_12_0::detail::parser<nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>, nlohmann::json_abi_v3_12_0::detail::iterator_input_adapter<char const*> >::exception_message(nlohmann::json_abi_v3_12_0::detail::lexer_base<nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void> >::token_type, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) Unexecuted instantiation: nlohmann::json_abi_v3_12_0::detail::parser<nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>, nlohmann::json_abi_v3_12_0::detail::input_stream_adapter>::exception_message(nlohmann::json_abi_v3_12_0::detail::lexer_base<nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void> >::token_type, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) |
13464 | | |
13465 | | private: |
13466 | | /// callback function |
13467 | | const parser_callback_t<BasicJsonType> callback = nullptr; |
13468 | | /// the type of the last read token |
13469 | | token_type last_token = token_type::uninitialized; |
13470 | | /// the lexer |
13471 | | lexer_t m_lexer; |
13472 | | /// whether to throw exceptions in case of errors |
13473 | | const bool allow_exceptions = true; |
13474 | | /// whether trailing commas in objects and arrays should be ignored (true) or signaled as errors (false) |
13475 | | const bool ignore_trailing_commas = false; |
13476 | | }; |
13477 | | |
13478 | | } // namespace detail |
13479 | | NLOHMANN_JSON_NAMESPACE_END |
13480 | | |
13481 | | // #include <nlohmann/detail/iterators/internal_iterator.hpp> |
13482 | | // __ _____ _____ _____ |
13483 | | // __| | __| | | | JSON for Modern C++ |
13484 | | // | | |__ | | | | | | version 3.12.0 |
13485 | | // |_____|_____|_____|_|___| https://github.com/nlohmann/json |
13486 | | // |
13487 | | // SPDX-FileCopyrightText: 2013-2026 Niels Lohmann <https://nlohmann.me> |
13488 | | // SPDX-License-Identifier: MIT |
13489 | | |
13490 | | |
13491 | | |
13492 | | // #include <nlohmann/detail/abi_macros.hpp> |
13493 | | |
13494 | | // #include <nlohmann/detail/iterators/primitive_iterator.hpp> |
13495 | | // __ _____ _____ _____ |
13496 | | // __| | __| | | | JSON for Modern C++ |
13497 | | // | | |__ | | | | | | version 3.12.0 |
13498 | | // |_____|_____|_____|_|___| https://github.com/nlohmann/json |
13499 | | // |
13500 | | // SPDX-FileCopyrightText: 2013-2026 Niels Lohmann <https://nlohmann.me> |
13501 | | // SPDX-License-Identifier: MIT |
13502 | | |
13503 | | |
13504 | | |
13505 | | #include <cstddef> // ptrdiff_t |
13506 | | #include <limits> // numeric_limits |
13507 | | |
13508 | | // #include <nlohmann/detail/macro_scope.hpp> |
13509 | | |
13510 | | |
13511 | | NLOHMANN_JSON_NAMESPACE_BEGIN |
13512 | | namespace detail |
13513 | | { |
13514 | | |
13515 | | /* |
13516 | | @brief an iterator for primitive JSON types |
13517 | | |
13518 | | This class models an iterator for primitive JSON types (boolean, number, |
13519 | | string). Its only purpose is to allow the iterator/const_iterator classes |
13520 | | to "iterate" over primitive values. Internally, the iterator is modeled by |
13521 | | a `difference_type` variable. Value begin_value (`0`) models the begin and |
13522 | | end_value (`1`) models past the end. |
13523 | | */ |
13524 | | class primitive_iterator_t |
13525 | | { |
13526 | | private: |
13527 | | using difference_type = std::ptrdiff_t; |
13528 | | static constexpr difference_type begin_value = 0; |
13529 | | static constexpr difference_type end_value = begin_value + 1; |
13530 | | |
13531 | | JSON_PRIVATE_UNLESS_TESTED: |
13532 | | /// iterator as signed integer type |
13533 | | difference_type m_it = (std::numeric_limits<std::ptrdiff_t>::min)(); |
13534 | | |
13535 | | public: |
13536 | | constexpr difference_type get_value() const noexcept |
13537 | 0 | { |
13538 | 0 | return m_it; |
13539 | 0 | } |
13540 | | |
13541 | | /// set iterator to a defined beginning |
13542 | | void set_begin() noexcept |
13543 | 0 | { |
13544 | 0 | m_it = begin_value; |
13545 | 0 | } |
13546 | | |
13547 | | /// set iterator to a defined past the end |
13548 | | void set_end() noexcept |
13549 | 0 | { |
13550 | 0 | m_it = end_value; |
13551 | 0 | } |
13552 | | |
13553 | | /// return whether the iterator can be dereferenced |
13554 | | constexpr bool is_begin() const noexcept |
13555 | 0 | { |
13556 | 0 | return m_it == begin_value; |
13557 | 0 | } |
13558 | | |
13559 | | /// return whether the iterator is at end |
13560 | | constexpr bool is_end() const noexcept |
13561 | 0 | { |
13562 | 0 | return m_it == end_value; |
13563 | 0 | } |
13564 | | |
13565 | | friend constexpr bool operator==(primitive_iterator_t lhs, primitive_iterator_t rhs) noexcept |
13566 | 0 | { |
13567 | 0 | return lhs.m_it == rhs.m_it; |
13568 | 0 | } |
13569 | | |
13570 | | friend constexpr bool operator<(primitive_iterator_t lhs, primitive_iterator_t rhs) noexcept |
13571 | 0 | { |
13572 | 0 | return lhs.m_it < rhs.m_it; |
13573 | 0 | } |
13574 | | |
13575 | | primitive_iterator_t operator+(difference_type n) noexcept |
13576 | 0 | { |
13577 | 0 | auto result = *this; |
13578 | 0 | result += n; |
13579 | 0 | return result; |
13580 | 0 | } |
13581 | | |
13582 | | friend constexpr difference_type operator-(primitive_iterator_t lhs, primitive_iterator_t rhs) noexcept |
13583 | 0 | { |
13584 | 0 | return lhs.m_it - rhs.m_it; |
13585 | 0 | } |
13586 | | |
13587 | | primitive_iterator_t& operator++() noexcept |
13588 | 0 | { |
13589 | 0 | ++m_it; |
13590 | 0 | return *this; |
13591 | 0 | } |
13592 | | |
13593 | | primitive_iterator_t operator++(int)& noexcept // NOLINT(cert-dcl21-cpp) |
13594 | 0 | { |
13595 | 0 | auto result = *this; |
13596 | 0 | ++m_it; |
13597 | 0 | return result; |
13598 | 0 | } |
13599 | | |
13600 | | primitive_iterator_t& operator--() noexcept |
13601 | 0 | { |
13602 | 0 | --m_it; |
13603 | 0 | return *this; |
13604 | 0 | } |
13605 | | |
13606 | | primitive_iterator_t operator--(int)& noexcept // NOLINT(cert-dcl21-cpp) |
13607 | 0 | { |
13608 | 0 | auto result = *this; |
13609 | 0 | --m_it; |
13610 | 0 | return result; |
13611 | 0 | } |
13612 | | |
13613 | | primitive_iterator_t& operator+=(difference_type n) noexcept |
13614 | 0 | { |
13615 | 0 | m_it += n; |
13616 | 0 | return *this; |
13617 | 0 | } |
13618 | | |
13619 | | primitive_iterator_t& operator-=(difference_type n) noexcept |
13620 | 0 | { |
13621 | 0 | m_it -= n; |
13622 | 0 | return *this; |
13623 | 0 | } |
13624 | | }; |
13625 | | |
13626 | | } // namespace detail |
13627 | | NLOHMANN_JSON_NAMESPACE_END |
13628 | | |
13629 | | |
13630 | | NLOHMANN_JSON_NAMESPACE_BEGIN |
13631 | | namespace detail |
13632 | | { |
13633 | | |
13634 | | /*! |
13635 | | @brief an iterator value |
13636 | | |
13637 | | @note This structure could easily be a union, but MSVC currently does not allow |
13638 | | unions members with complex constructors, see https://github.com/nlohmann/json/pull/105. |
13639 | | */ |
13640 | | template<typename BasicJsonType> struct internal_iterator |
13641 | | { |
13642 | | /// iterator for JSON objects |
13643 | | typename BasicJsonType::object_t::iterator object_iterator {}; |
13644 | | /// iterator for JSON arrays |
13645 | | typename BasicJsonType::array_t::iterator array_iterator {}; |
13646 | | /// generic iterator for all other types |
13647 | | primitive_iterator_t primitive_iterator {}; |
13648 | | }; |
13649 | | |
13650 | | } // namespace detail |
13651 | | NLOHMANN_JSON_NAMESPACE_END |
13652 | | |
13653 | | // #include <nlohmann/detail/iterators/iter_impl.hpp> |
13654 | | // __ _____ _____ _____ |
13655 | | // __| | __| | | | JSON for Modern C++ |
13656 | | // | | |__ | | | | | | version 3.12.0 |
13657 | | // |_____|_____|_____|_|___| https://github.com/nlohmann/json |
13658 | | // |
13659 | | // SPDX-FileCopyrightText: 2013-2026 Niels Lohmann <https://nlohmann.me> |
13660 | | // SPDX-License-Identifier: MIT |
13661 | | |
13662 | | |
13663 | | |
13664 | | #include <iterator> // iterator, random_access_iterator_tag, bidirectional_iterator_tag, advance, next |
13665 | | #include <type_traits> // conditional, is_const, remove_const |
13666 | | |
13667 | | // #include <nlohmann/detail/exceptions.hpp> |
13668 | | |
13669 | | // #include <nlohmann/detail/iterators/internal_iterator.hpp> |
13670 | | |
13671 | | // #include <nlohmann/detail/iterators/primitive_iterator.hpp> |
13672 | | |
13673 | | // #include <nlohmann/detail/macro_scope.hpp> |
13674 | | |
13675 | | // #include <nlohmann/detail/meta/cpp_future.hpp> |
13676 | | |
13677 | | // #include <nlohmann/detail/meta/type_traits.hpp> |
13678 | | |
13679 | | // #include <nlohmann/detail/value_t.hpp> |
13680 | | |
13681 | | |
13682 | | NLOHMANN_JSON_NAMESPACE_BEGIN |
13683 | | namespace detail |
13684 | | { |
13685 | | |
13686 | | // forward declare to be able to friend it later on |
13687 | | template<typename IteratorType> class iteration_proxy; |
13688 | | template<typename IteratorType> class iteration_proxy_value; |
13689 | | |
13690 | | /*! |
13691 | | @brief a template for a bidirectional iterator for the @ref basic_json class |
13692 | | This class implements a both iterators (iterator and const_iterator) for the |
13693 | | @ref basic_json class. |
13694 | | @note An iterator is called *initialized* when a pointer to a JSON value has |
13695 | | been set (e.g., by a constructor or a copy assignment). If the iterator is |
13696 | | default-constructed, it is *uninitialized* and most methods are undefined. |
13697 | | **The library uses assertions to detect calls on uninitialized iterators.** |
13698 | | @requirement The class satisfies the following concept requirements: |
13699 | | - |
13700 | | [BidirectionalIterator](https://en.cppreference.com/w/cpp/named_req/BidirectionalIterator): |
13701 | | The iterator that can be moved can be moved in both directions (i.e. |
13702 | | incremented and decremented). |
13703 | | @since version 1.0.0, simplified in version 2.0.9, change to bidirectional |
13704 | | iterators in version 3.0.0 (see https://github.com/nlohmann/json/issues/593) |
13705 | | */ |
13706 | | template<typename BasicJsonType> |
13707 | | class iter_impl // NOLINT(cppcoreguidelines-special-member-functions,hicpp-special-member-functions) |
13708 | | { |
13709 | | /// the iterator with BasicJsonType of different const-ness |
13710 | | using other_iter_impl = iter_impl<typename std::conditional<std::is_const<BasicJsonType>::value, typename std::remove_const<BasicJsonType>::type, const BasicJsonType>::type>; |
13711 | | /// allow basic_json to access private members |
13712 | | friend other_iter_impl; |
13713 | | friend BasicJsonType; |
13714 | | friend iteration_proxy<iter_impl>; |
13715 | | friend iteration_proxy_value<iter_impl>; |
13716 | | |
13717 | | using object_t = typename BasicJsonType::object_t; |
13718 | | using array_t = typename BasicJsonType::array_t; |
13719 | | // make sure BasicJsonType is basic_json or const basic_json |
13720 | | static_assert(is_basic_json<typename std::remove_const<BasicJsonType>::type>::value, |
13721 | | "iter_impl only accepts (const) basic_json"); |
13722 | | // superficial check for the LegacyBidirectionalIterator named requirement |
13723 | | static_assert(std::is_base_of<std::bidirectional_iterator_tag, std::bidirectional_iterator_tag>::value |
13724 | | && std::is_base_of<std::bidirectional_iterator_tag, typename std::iterator_traits<typename array_t::iterator>::iterator_category>::value, |
13725 | | "basic_json iterator assumes array and object type iterators satisfy the LegacyBidirectionalIterator named requirement."); |
13726 | | |
13727 | | public: |
13728 | | /// The std::iterator class template (used as a base class to provide typedefs) is deprecated in C++17. |
13729 | | /// The C++ Standard has never required user-defined iterators to derive from std::iterator. |
13730 | | /// A user-defined iterator should provide publicly accessible typedefs named |
13731 | | /// iterator_category, value_type, difference_type, pointer, and reference. |
13732 | | /// Note that value_type is required to be non-const, even for constant iterators. |
13733 | | using iterator_category = std::bidirectional_iterator_tag; |
13734 | | |
13735 | | /// the type of the values when the iterator is dereferenced |
13736 | | using value_type = typename BasicJsonType::value_type; |
13737 | | /// a type to represent differences between iterators |
13738 | | using difference_type = typename BasicJsonType::difference_type; |
13739 | | /// defines a pointer to the type iterated over (value_type) |
13740 | | using pointer = typename std::conditional<std::is_const<BasicJsonType>::value, |
13741 | | typename BasicJsonType::const_pointer, |
13742 | | typename BasicJsonType::pointer>::type; |
13743 | | /// defines a reference to the type iterated over (value_type) |
13744 | | using reference = |
13745 | | typename std::conditional<std::is_const<BasicJsonType>::value, |
13746 | | typename BasicJsonType::const_reference, |
13747 | | typename BasicJsonType::reference>::type; |
13748 | | |
13749 | | iter_impl() = default; |
13750 | | ~iter_impl() = default; |
13751 | | iter_impl(iter_impl&&) noexcept = default; |
13752 | | iter_impl& operator=(iter_impl&&) noexcept = default; |
13753 | | |
13754 | | /*! |
13755 | | @brief constructor for a given JSON instance |
13756 | | @param[in] object pointer to a JSON object for this iterator |
13757 | | @pre object != nullptr |
13758 | | @post The iterator is initialized; i.e. `m_object != nullptr`. |
13759 | | */ |
13760 | 0 | explicit iter_impl(pointer object) noexcept : m_object(object) |
13761 | 0 | { |
13762 | 0 | JSON_ASSERT(m_object != nullptr); |
13763 | | |
13764 | 0 | switch (m_object->m_data.m_type) |
13765 | 0 | { |
13766 | 0 | case value_t::object: |
13767 | 0 | { |
13768 | 0 | m_it.object_iterator = typename object_t::iterator(); |
13769 | 0 | break; |
13770 | 0 | } |
13771 | | |
13772 | 0 | case value_t::array: |
13773 | 0 | { |
13774 | 0 | m_it.array_iterator = typename array_t::iterator(); |
13775 | 0 | break; |
13776 | 0 | } |
13777 | | |
13778 | 0 | case value_t::null: |
13779 | 0 | case value_t::string: |
13780 | 0 | case value_t::boolean: |
13781 | 0 | case value_t::number_integer: |
13782 | 0 | case value_t::number_unsigned: |
13783 | 0 | case value_t::number_float: |
13784 | 0 | case value_t::binary: |
13785 | 0 | case value_t::discarded: |
13786 | 0 | default: |
13787 | 0 | { |
13788 | 0 | m_it.primitive_iterator = primitive_iterator_t(); |
13789 | 0 | break; |
13790 | 0 | } |
13791 | 0 | } |
13792 | 0 | } Unexecuted instantiation: nlohmann::json_abi_v3_12_0::detail::iter_impl<nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void> >::iter_impl(nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>*) Unexecuted instantiation: nlohmann::json_abi_v3_12_0::detail::iter_impl<nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void> const>::iter_impl(nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void> const*) |
13793 | | |
13794 | | /*! |
13795 | | @note The conventional copy constructor and copy assignment are implicitly |
13796 | | defined. Combined with the following converting constructor and |
13797 | | assignment, they support: (1) copy from iterator to iterator, (2) |
13798 | | copy from const iterator to const iterator, and (3) conversion from |
13799 | | iterator to const iterator. However conversion from const iterator |
13800 | | to iterator is not defined. |
13801 | | */ |
13802 | | |
13803 | | /*! |
13804 | | @brief const copy constructor |
13805 | | @param[in] other const iterator to copy from |
13806 | | @note This copy constructor had to be defined explicitly to circumvent a bug |
13807 | | occurring on msvc v19.0 compiler (VS 2015) debug build. For more |
13808 | | information refer to: https://github.com/nlohmann/json/issues/1608 |
13809 | | */ |
13810 | | iter_impl(const iter_impl<const BasicJsonType>& other) noexcept |
13811 | | : m_object(other.m_object), m_it(other.m_it) |
13812 | | {} |
13813 | | |
13814 | | /*! |
13815 | | @brief converting assignment |
13816 | | @param[in] other const iterator to copy from |
13817 | | @return const/non-const iterator |
13818 | | @note It is not checked whether @a other is initialized. |
13819 | | */ |
13820 | | iter_impl& operator=(const iter_impl<const BasicJsonType>& other) noexcept |
13821 | | { |
13822 | | if (&other != this) |
13823 | | { |
13824 | | m_object = other.m_object; |
13825 | | m_it = other.m_it; |
13826 | | } |
13827 | | return *this; |
13828 | | } |
13829 | | |
13830 | | /*! |
13831 | | @brief converting constructor |
13832 | | @param[in] other non-const iterator to copy from |
13833 | | @note It is not checked whether @a other is initialized. |
13834 | | */ |
13835 | | iter_impl(const iter_impl<typename std::remove_const<BasicJsonType>::type>& other) noexcept |
13836 | 0 | : m_object(other.m_object), m_it(other.m_it) |
13837 | 0 | {} |
13838 | | |
13839 | | /*! |
13840 | | @brief converting assignment |
13841 | | @param[in] other non-const iterator to copy from |
13842 | | @return const/non-const iterator |
13843 | | @note It is not checked whether @a other is initialized. |
13844 | | */ |
13845 | | iter_impl& operator=(const iter_impl<typename std::remove_const<BasicJsonType>::type>& other) noexcept // NOLINT(cert-oop54-cpp) |
13846 | | { |
13847 | | m_object = other.m_object; |
13848 | | m_it = other.m_it; |
13849 | | return *this; |
13850 | | } |
13851 | | |
13852 | | JSON_PRIVATE_UNLESS_TESTED: |
13853 | | /*! |
13854 | | @brief set the iterator to the first value |
13855 | | @pre The iterator is initialized; i.e. `m_object != nullptr`. |
13856 | | */ |
13857 | | void set_begin() noexcept |
13858 | 0 | { |
13859 | 0 | JSON_ASSERT(m_object != nullptr); |
13860 | | |
13861 | 0 | switch (m_object->m_data.m_type) |
13862 | 0 | { |
13863 | 0 | case value_t::object: |
13864 | 0 | { |
13865 | 0 | m_it.object_iterator = m_object->m_data.m_value.object->begin(); |
13866 | 0 | break; |
13867 | 0 | } |
13868 | | |
13869 | 0 | case value_t::array: |
13870 | 0 | { |
13871 | 0 | m_it.array_iterator = m_object->m_data.m_value.array->begin(); |
13872 | 0 | break; |
13873 | 0 | } |
13874 | | |
13875 | 0 | case value_t::null: |
13876 | 0 | { |
13877 | | // set to end so begin()==end() is true: null is empty |
13878 | 0 | m_it.primitive_iterator.set_end(); |
13879 | 0 | break; |
13880 | 0 | } |
13881 | | |
13882 | 0 | case value_t::string: |
13883 | 0 | case value_t::boolean: |
13884 | 0 | case value_t::number_integer: |
13885 | 0 | case value_t::number_unsigned: |
13886 | 0 | case value_t::number_float: |
13887 | 0 | case value_t::binary: |
13888 | 0 | case value_t::discarded: |
13889 | 0 | default: |
13890 | 0 | { |
13891 | 0 | m_it.primitive_iterator.set_begin(); |
13892 | 0 | break; |
13893 | 0 | } |
13894 | 0 | } |
13895 | 0 | } Unexecuted instantiation: nlohmann::json_abi_v3_12_0::detail::iter_impl<nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void> >::set_begin() Unexecuted instantiation: nlohmann::json_abi_v3_12_0::detail::iter_impl<nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void> const>::set_begin() |
13896 | | |
13897 | | /*! |
13898 | | @brief set the iterator past the last value |
13899 | | @pre The iterator is initialized; i.e. `m_object != nullptr`. |
13900 | | */ |
13901 | | void set_end() noexcept |
13902 | 0 | { |
13903 | 0 | JSON_ASSERT(m_object != nullptr); |
13904 | | |
13905 | 0 | switch (m_object->m_data.m_type) |
13906 | 0 | { |
13907 | 0 | case value_t::object: |
13908 | 0 | { |
13909 | 0 | m_it.object_iterator = m_object->m_data.m_value.object->end(); |
13910 | 0 | break; |
13911 | 0 | } |
13912 | | |
13913 | 0 | case value_t::array: |
13914 | 0 | { |
13915 | 0 | m_it.array_iterator = m_object->m_data.m_value.array->end(); |
13916 | 0 | break; |
13917 | 0 | } |
13918 | | |
13919 | 0 | case value_t::null: |
13920 | 0 | case value_t::string: |
13921 | 0 | case value_t::boolean: |
13922 | 0 | case value_t::number_integer: |
13923 | 0 | case value_t::number_unsigned: |
13924 | 0 | case value_t::number_float: |
13925 | 0 | case value_t::binary: |
13926 | 0 | case value_t::discarded: |
13927 | 0 | default: |
13928 | 0 | { |
13929 | 0 | m_it.primitive_iterator.set_end(); |
13930 | 0 | break; |
13931 | 0 | } |
13932 | 0 | } |
13933 | 0 | } Unexecuted instantiation: nlohmann::json_abi_v3_12_0::detail::iter_impl<nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void> >::set_end() Unexecuted instantiation: nlohmann::json_abi_v3_12_0::detail::iter_impl<nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void> const>::set_end() |
13934 | | |
13935 | | public: |
13936 | | /*! |
13937 | | @brief return a reference to the value pointed to by the iterator |
13938 | | @pre The iterator is initialized; i.e. `m_object != nullptr`. |
13939 | | */ |
13940 | | reference operator*() const |
13941 | 0 | { |
13942 | 0 | JSON_ASSERT(m_object != nullptr); |
13943 | | |
13944 | 0 | switch (m_object->m_data.m_type) |
13945 | 0 | { |
13946 | 0 | case value_t::object: |
13947 | 0 | { |
13948 | 0 | JSON_ASSERT(m_it.object_iterator != m_object->m_data.m_value.object->end()); |
13949 | 0 | return m_it.object_iterator->second; |
13950 | 0 | } |
13951 | | |
13952 | 0 | case value_t::array: |
13953 | 0 | { |
13954 | 0 | JSON_ASSERT(m_it.array_iterator != m_object->m_data.m_value.array->end()); |
13955 | 0 | return *m_it.array_iterator; |
13956 | 0 | } |
13957 | | |
13958 | 0 | case value_t::null: |
13959 | 0 | JSON_THROW(invalid_iterator::create(214, "cannot get value", m_object)); |
13960 | | |
13961 | 0 | case value_t::string: |
13962 | 0 | case value_t::boolean: |
13963 | 0 | case value_t::number_integer: |
13964 | 0 | case value_t::number_unsigned: |
13965 | 0 | case value_t::number_float: |
13966 | 0 | case value_t::binary: |
13967 | 0 | case value_t::discarded: |
13968 | 0 | default: |
13969 | 0 | { |
13970 | 0 | if (JSON_HEDLEY_LIKELY(m_it.primitive_iterator.is_begin())) |
13971 | 0 | { |
13972 | 0 | return *m_object; |
13973 | 0 | } |
13974 | | |
13975 | 0 | JSON_THROW(invalid_iterator::create(214, "cannot get value", m_object)); |
13976 | 0 | } |
13977 | 0 | } |
13978 | 0 | } Unexecuted instantiation: nlohmann::json_abi_v3_12_0::detail::iter_impl<nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void> >::operator*() const Unexecuted instantiation: nlohmann::json_abi_v3_12_0::detail::iter_impl<nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void> const>::operator*() const |
13979 | | |
13980 | | /*! |
13981 | | @brief dereference the iterator |
13982 | | @pre The iterator is initialized; i.e. `m_object != nullptr`. |
13983 | | */ |
13984 | | pointer operator->() const |
13985 | 0 | { |
13986 | 0 | JSON_ASSERT(m_object != nullptr); |
13987 | | |
13988 | 0 | switch (m_object->m_data.m_type) |
13989 | 0 | { |
13990 | 0 | case value_t::object: |
13991 | 0 | { |
13992 | 0 | JSON_ASSERT(m_it.object_iterator != m_object->m_data.m_value.object->end()); |
13993 | 0 | return &(m_it.object_iterator->second); |
13994 | 0 | } |
13995 | | |
13996 | 0 | case value_t::array: |
13997 | 0 | { |
13998 | 0 | JSON_ASSERT(m_it.array_iterator != m_object->m_data.m_value.array->end()); |
13999 | 0 | return &*m_it.array_iterator; |
14000 | 0 | } |
14001 | | |
14002 | 0 | case value_t::null: |
14003 | 0 | case value_t::string: |
14004 | 0 | case value_t::boolean: |
14005 | 0 | case value_t::number_integer: |
14006 | 0 | case value_t::number_unsigned: |
14007 | 0 | case value_t::number_float: |
14008 | 0 | case value_t::binary: |
14009 | 0 | case value_t::discarded: |
14010 | 0 | default: |
14011 | 0 | { |
14012 | 0 | if (JSON_HEDLEY_LIKELY(m_it.primitive_iterator.is_begin())) |
14013 | 0 | { |
14014 | 0 | return m_object; |
14015 | 0 | } |
14016 | | |
14017 | 0 | JSON_THROW(invalid_iterator::create(214, "cannot get value", m_object)); |
14018 | 0 | } |
14019 | 0 | } |
14020 | 0 | } |
14021 | | |
14022 | | /*! |
14023 | | @brief post-increment (it++) |
14024 | | @pre The iterator is initialized; i.e. `m_object != nullptr`. |
14025 | | */ |
14026 | | iter_impl operator++(int)& // NOLINT(cert-dcl21-cpp) |
14027 | | { |
14028 | | auto result = *this; |
14029 | | ++(*this); |
14030 | | return result; |
14031 | | } |
14032 | | |
14033 | | /*! |
14034 | | @brief pre-increment (++it) |
14035 | | @pre The iterator is initialized; i.e. `m_object != nullptr`. |
14036 | | */ |
14037 | | iter_impl& operator++() |
14038 | 0 | { |
14039 | 0 | JSON_ASSERT(m_object != nullptr); |
14040 | | |
14041 | 0 | switch (m_object->m_data.m_type) |
14042 | 0 | { |
14043 | 0 | case value_t::object: |
14044 | 0 | { |
14045 | 0 | std::advance(m_it.object_iterator, 1); |
14046 | 0 | break; |
14047 | 0 | } |
14048 | | |
14049 | 0 | case value_t::array: |
14050 | 0 | { |
14051 | 0 | std::advance(m_it.array_iterator, 1); |
14052 | 0 | break; |
14053 | 0 | } |
14054 | | |
14055 | 0 | case value_t::null: |
14056 | 0 | case value_t::string: |
14057 | 0 | case value_t::boolean: |
14058 | 0 | case value_t::number_integer: |
14059 | 0 | case value_t::number_unsigned: |
14060 | 0 | case value_t::number_float: |
14061 | 0 | case value_t::binary: |
14062 | 0 | case value_t::discarded: |
14063 | 0 | default: |
14064 | 0 | { |
14065 | 0 | ++m_it.primitive_iterator; |
14066 | 0 | break; |
14067 | 0 | } |
14068 | 0 | } |
14069 | | |
14070 | 0 | return *this; |
14071 | 0 | } Unexecuted instantiation: nlohmann::json_abi_v3_12_0::detail::iter_impl<nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void> >::operator++() Unexecuted instantiation: nlohmann::json_abi_v3_12_0::detail::iter_impl<nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void> const>::operator++() |
14072 | | |
14073 | | /*! |
14074 | | @brief post-decrement (it--) |
14075 | | @pre The iterator is initialized; i.e. `m_object != nullptr`. |
14076 | | */ |
14077 | | iter_impl operator--(int)& // NOLINT(cert-dcl21-cpp) |
14078 | | { |
14079 | | auto result = *this; |
14080 | | --(*this); |
14081 | | return result; |
14082 | | } |
14083 | | |
14084 | | /*! |
14085 | | @brief pre-decrement (--it) |
14086 | | @pre The iterator is initialized; i.e. `m_object != nullptr`. |
14087 | | */ |
14088 | | iter_impl& operator--() |
14089 | | { |
14090 | | JSON_ASSERT(m_object != nullptr); |
14091 | | |
14092 | | switch (m_object->m_data.m_type) |
14093 | | { |
14094 | | case value_t::object: |
14095 | | { |
14096 | | std::advance(m_it.object_iterator, -1); |
14097 | | break; |
14098 | | } |
14099 | | |
14100 | | case value_t::array: |
14101 | | { |
14102 | | std::advance(m_it.array_iterator, -1); |
14103 | | break; |
14104 | | } |
14105 | | |
14106 | | case value_t::null: |
14107 | | case value_t::string: |
14108 | | case value_t::boolean: |
14109 | | case value_t::number_integer: |
14110 | | case value_t::number_unsigned: |
14111 | | case value_t::number_float: |
14112 | | case value_t::binary: |
14113 | | case value_t::discarded: |
14114 | | default: |
14115 | | { |
14116 | | --m_it.primitive_iterator; |
14117 | | break; |
14118 | | } |
14119 | | } |
14120 | | |
14121 | | return *this; |
14122 | | } |
14123 | | |
14124 | | /*! |
14125 | | @brief comparison: equal |
14126 | | @pre (1) Both iterators are initialized to point to the same object, or (2) both iterators are value-initialized. |
14127 | | */ |
14128 | | template < typename IterImpl, detail::enable_if_t < (std::is_same<IterImpl, iter_impl>::value || std::is_same<IterImpl, other_iter_impl>::value), std::nullptr_t > = nullptr > |
14129 | | bool operator==(const IterImpl& other) const |
14130 | 0 | { |
14131 | | // if objects are not the same, the comparison is undefined |
14132 | 0 | if (JSON_HEDLEY_UNLIKELY(m_object != other.m_object)) |
14133 | 0 | { |
14134 | 0 | JSON_THROW(invalid_iterator::create(212, "cannot compare iterators of different containers", m_object)); |
14135 | 0 | } |
14136 | | |
14137 | | // value-initialized forward iterators can be compared, and must compare equal to other value-initialized iterators of the same type #4493 |
14138 | 0 | if (m_object == nullptr) |
14139 | 0 | { |
14140 | 0 | return true; |
14141 | 0 | } |
14142 | | |
14143 | 0 | switch (m_object->m_data.m_type) |
14144 | 0 | { |
14145 | 0 | case value_t::object: |
14146 | 0 | return (m_it.object_iterator == other.m_it.object_iterator); |
14147 | | |
14148 | 0 | case value_t::array: |
14149 | 0 | return (m_it.array_iterator == other.m_it.array_iterator); |
14150 | | |
14151 | 0 | case value_t::null: |
14152 | 0 | case value_t::string: |
14153 | 0 | case value_t::boolean: |
14154 | 0 | case value_t::number_integer: |
14155 | 0 | case value_t::number_unsigned: |
14156 | 0 | case value_t::number_float: |
14157 | 0 | case value_t::binary: |
14158 | 0 | case value_t::discarded: |
14159 | 0 | default: |
14160 | 0 | return (m_it.primitive_iterator == other.m_it.primitive_iterator); |
14161 | 0 | } |
14162 | 0 | } Unexecuted instantiation: _ZNK8nlohmann16json_abi_v3_12_06detail9iter_implINS0_10basic_jsonINSt3__13mapENS4_6vectorENS4_12basic_stringIcNS4_11char_traitsIcEENS4_9allocatorIcEEEEblmdSA_NS0_14adl_serializerENS6_IhNSA_IhEEEEvEEEeqISH_TnNS4_9enable_ifIXoosr3std7is_sameIT_SH_EE5valuesr3std7is_sameISK_NS2_IKSG_EEEE5valueEDnE4typeELDn0EEEbRKSK_ Unexecuted instantiation: _ZNK8nlohmann16json_abi_v3_12_06detail9iter_implIKNS0_10basic_jsonINSt3__13mapENS4_6vectorENS4_12basic_stringIcNS4_11char_traitsIcEENS4_9allocatorIcEEEEblmdSA_NS0_14adl_serializerENS6_IhNSA_IhEEEEvEEEeqISI_TnNS4_9enable_ifIXoosr3std7is_sameIT_SI_EE5valuesr3std7is_sameISL_NS2_ISG_EEEE5valueEDnE4typeELDn0EEEbRKSL_ |
14163 | | |
14164 | | /*! |
14165 | | @brief comparison: not equal |
14166 | | @pre (1) Both iterators are initialized to point to the same object, or (2) both iterators are value-initialized. |
14167 | | */ |
14168 | | template < typename IterImpl, detail::enable_if_t < (std::is_same<IterImpl, iter_impl>::value || std::is_same<IterImpl, other_iter_impl>::value), std::nullptr_t > = nullptr > |
14169 | | bool operator!=(const IterImpl& other) const |
14170 | 0 | { |
14171 | 0 | return !operator==(other); |
14172 | 0 | } Unexecuted instantiation: _ZNK8nlohmann16json_abi_v3_12_06detail9iter_implINS0_10basic_jsonINSt3__13mapENS4_6vectorENS4_12basic_stringIcNS4_11char_traitsIcEENS4_9allocatorIcEEEEblmdSA_NS0_14adl_serializerENS6_IhNSA_IhEEEEvEEEneISH_TnNS4_9enable_ifIXoosr3std7is_sameIT_SH_EE5valuesr3std7is_sameISK_NS2_IKSG_EEEE5valueEDnE4typeELDn0EEEbRKSK_ Unexecuted instantiation: _ZNK8nlohmann16json_abi_v3_12_06detail9iter_implIKNS0_10basic_jsonINSt3__13mapENS4_6vectorENS4_12basic_stringIcNS4_11char_traitsIcEENS4_9allocatorIcEEEEblmdSA_NS0_14adl_serializerENS6_IhNSA_IhEEEEvEEEneISI_TnNS4_9enable_ifIXoosr3std7is_sameIT_SI_EE5valuesr3std7is_sameISL_NS2_ISG_EEEE5valueEDnE4typeELDn0EEEbRKSL_ |
14173 | | |
14174 | | /*! |
14175 | | @brief comparison: smaller |
14176 | | @pre (1) Both iterators are initialized to point to the same object, or (2) both iterators are value-initialized. |
14177 | | */ |
14178 | | bool operator<(const iter_impl& other) const |
14179 | | { |
14180 | | // if objects are not the same, the comparison is undefined |
14181 | | if (JSON_HEDLEY_UNLIKELY(m_object != other.m_object)) |
14182 | | { |
14183 | | JSON_THROW(invalid_iterator::create(212, "cannot compare iterators of different containers", m_object)); |
14184 | | } |
14185 | | |
14186 | | // value-initialized forward iterators can be compared, and must compare equal to other value-initialized iterators of the same type #4493 |
14187 | | if (m_object == nullptr) |
14188 | | { |
14189 | | // the iterators are both value-initialized and are to be considered equal, but this function checks for smaller, so we return false |
14190 | | return false; |
14191 | | } |
14192 | | |
14193 | | switch (m_object->m_data.m_type) |
14194 | | { |
14195 | | case value_t::object: |
14196 | | JSON_THROW(invalid_iterator::create(213, "cannot compare order of object iterators", m_object)); |
14197 | | |
14198 | | case value_t::array: |
14199 | | return (m_it.array_iterator < other.m_it.array_iterator); |
14200 | | |
14201 | | case value_t::null: |
14202 | | case value_t::string: |
14203 | | case value_t::boolean: |
14204 | | case value_t::number_integer: |
14205 | | case value_t::number_unsigned: |
14206 | | case value_t::number_float: |
14207 | | case value_t::binary: |
14208 | | case value_t::discarded: |
14209 | | default: |
14210 | | return (m_it.primitive_iterator < other.m_it.primitive_iterator); |
14211 | | } |
14212 | | } |
14213 | | |
14214 | | /*! |
14215 | | @brief comparison: less than or equal |
14216 | | @pre (1) Both iterators are initialized to point to the same object, or (2) both iterators are value-initialized. |
14217 | | */ |
14218 | | bool operator<=(const iter_impl& other) const |
14219 | | { |
14220 | | return !other.operator < (*this); |
14221 | | } |
14222 | | |
14223 | | /*! |
14224 | | @brief comparison: greater than |
14225 | | @pre (1) Both iterators are initialized to point to the same object, or (2) both iterators are value-initialized. |
14226 | | */ |
14227 | | bool operator>(const iter_impl& other) const |
14228 | | { |
14229 | | return !operator<=(other); |
14230 | | } |
14231 | | |
14232 | | /*! |
14233 | | @brief comparison: greater than or equal |
14234 | | @pre (1) The iterator is initialized; i.e. `m_object != nullptr`, or (2) both iterators are value-initialized. |
14235 | | */ |
14236 | | bool operator>=(const iter_impl& other) const |
14237 | | { |
14238 | | return !operator<(other); |
14239 | | } |
14240 | | |
14241 | | /*! |
14242 | | @brief add to iterator |
14243 | | @pre The iterator is initialized; i.e. `m_object != nullptr`. |
14244 | | */ |
14245 | | iter_impl& operator+=(difference_type i) |
14246 | | { |
14247 | | JSON_ASSERT(m_object != nullptr); |
14248 | | |
14249 | | switch (m_object->m_data.m_type) |
14250 | | { |
14251 | | case value_t::object: |
14252 | | JSON_THROW(invalid_iterator::create(209, "cannot use offsets with object iterators", m_object)); |
14253 | | |
14254 | | case value_t::array: |
14255 | | { |
14256 | | std::advance(m_it.array_iterator, i); |
14257 | | break; |
14258 | | } |
14259 | | |
14260 | | case value_t::null: |
14261 | | case value_t::string: |
14262 | | case value_t::boolean: |
14263 | | case value_t::number_integer: |
14264 | | case value_t::number_unsigned: |
14265 | | case value_t::number_float: |
14266 | | case value_t::binary: |
14267 | | case value_t::discarded: |
14268 | | default: |
14269 | | { |
14270 | | m_it.primitive_iterator += i; |
14271 | | break; |
14272 | | } |
14273 | | } |
14274 | | |
14275 | | return *this; |
14276 | | } |
14277 | | |
14278 | | /*! |
14279 | | @brief subtract from iterator |
14280 | | @pre The iterator is initialized; i.e. `m_object != nullptr`. |
14281 | | */ |
14282 | | iter_impl& operator-=(difference_type i) |
14283 | | { |
14284 | | return operator+=(-i); |
14285 | | } |
14286 | | |
14287 | | /*! |
14288 | | @brief add to iterator |
14289 | | @pre The iterator is initialized; i.e. `m_object != nullptr`. |
14290 | | */ |
14291 | | iter_impl operator+(difference_type i) const |
14292 | | { |
14293 | | auto result = *this; |
14294 | | result += i; |
14295 | | return result; |
14296 | | } |
14297 | | |
14298 | | /*! |
14299 | | @brief addition of distance and iterator |
14300 | | @pre The iterator is initialized; i.e. `m_object != nullptr`. |
14301 | | */ |
14302 | | friend iter_impl operator+(difference_type i, const iter_impl& it) |
14303 | | { |
14304 | | auto result = it; |
14305 | | result += i; |
14306 | | return result; |
14307 | | } |
14308 | | |
14309 | | /*! |
14310 | | @brief subtract from iterator |
14311 | | @pre The iterator is initialized; i.e. `m_object != nullptr`. |
14312 | | */ |
14313 | | iter_impl operator-(difference_type i) const |
14314 | | { |
14315 | | auto result = *this; |
14316 | | result -= i; |
14317 | | return result; |
14318 | | } |
14319 | | |
14320 | | /*! |
14321 | | @brief return difference |
14322 | | @pre The iterator is initialized; i.e. `m_object != nullptr`. |
14323 | | */ |
14324 | | difference_type operator-(const iter_impl& other) const |
14325 | | { |
14326 | | JSON_ASSERT(m_object != nullptr); |
14327 | | |
14328 | | switch (m_object->m_data.m_type) |
14329 | | { |
14330 | | case value_t::object: |
14331 | | JSON_THROW(invalid_iterator::create(209, "cannot use offsets with object iterators", m_object)); |
14332 | | |
14333 | | case value_t::array: |
14334 | | return m_it.array_iterator - other.m_it.array_iterator; |
14335 | | |
14336 | | case value_t::null: |
14337 | | case value_t::string: |
14338 | | case value_t::boolean: |
14339 | | case value_t::number_integer: |
14340 | | case value_t::number_unsigned: |
14341 | | case value_t::number_float: |
14342 | | case value_t::binary: |
14343 | | case value_t::discarded: |
14344 | | default: |
14345 | | return m_it.primitive_iterator - other.m_it.primitive_iterator; |
14346 | | } |
14347 | | } |
14348 | | |
14349 | | /*! |
14350 | | @brief access to successor |
14351 | | @pre The iterator is initialized; i.e. `m_object != nullptr`. |
14352 | | */ |
14353 | | reference operator[](difference_type n) const |
14354 | | { |
14355 | | JSON_ASSERT(m_object != nullptr); |
14356 | | |
14357 | | switch (m_object->m_data.m_type) |
14358 | | { |
14359 | | case value_t::object: |
14360 | | JSON_THROW(invalid_iterator::create(208, "cannot use operator[] for object iterators", m_object)); |
14361 | | |
14362 | | case value_t::array: |
14363 | | return *std::next(m_it.array_iterator, n); |
14364 | | |
14365 | | case value_t::null: |
14366 | | JSON_THROW(invalid_iterator::create(214, "cannot get value", m_object)); |
14367 | | |
14368 | | case value_t::string: |
14369 | | case value_t::boolean: |
14370 | | case value_t::number_integer: |
14371 | | case value_t::number_unsigned: |
14372 | | case value_t::number_float: |
14373 | | case value_t::binary: |
14374 | | case value_t::discarded: |
14375 | | default: |
14376 | | { |
14377 | | if (JSON_HEDLEY_LIKELY(m_it.primitive_iterator.get_value() == -n)) |
14378 | | { |
14379 | | return *m_object; |
14380 | | } |
14381 | | |
14382 | | JSON_THROW(invalid_iterator::create(214, "cannot get value", m_object)); |
14383 | | } |
14384 | | } |
14385 | | } |
14386 | | |
14387 | | /*! |
14388 | | @brief return the key of an object iterator |
14389 | | @pre The iterator is initialized; i.e. `m_object != nullptr`. |
14390 | | */ |
14391 | | const typename object_t::key_type& key() const |
14392 | | { |
14393 | | JSON_ASSERT(m_object != nullptr); |
14394 | | |
14395 | | if (JSON_HEDLEY_LIKELY(m_object->is_object())) |
14396 | | { |
14397 | | return m_it.object_iterator->first; |
14398 | | } |
14399 | | |
14400 | | JSON_THROW(invalid_iterator::create(207, "cannot use key() for non-object iterators", m_object)); |
14401 | | } |
14402 | | |
14403 | | /*! |
14404 | | @brief return the value of an iterator |
14405 | | @pre The iterator is initialized; i.e. `m_object != nullptr`. |
14406 | | */ |
14407 | | reference value() const |
14408 | | { |
14409 | | return operator*(); |
14410 | | } |
14411 | | |
14412 | | JSON_PRIVATE_UNLESS_TESTED: |
14413 | | /// associated JSON instance |
14414 | | pointer m_object = nullptr; |
14415 | | /// the actual iterator of the associated instance |
14416 | | internal_iterator<typename std::remove_const<BasicJsonType>::type> m_it {}; |
14417 | | }; |
14418 | | |
14419 | | } // namespace detail |
14420 | | NLOHMANN_JSON_NAMESPACE_END |
14421 | | |
14422 | | // #include <nlohmann/detail/iterators/iteration_proxy.hpp> |
14423 | | |
14424 | | // #include <nlohmann/detail/iterators/json_reverse_iterator.hpp> |
14425 | | // __ _____ _____ _____ |
14426 | | // __| | __| | | | JSON for Modern C++ |
14427 | | // | | |__ | | | | | | version 3.12.0 |
14428 | | // |_____|_____|_____|_|___| https://github.com/nlohmann/json |
14429 | | // |
14430 | | // SPDX-FileCopyrightText: 2013-2026 Niels Lohmann <https://nlohmann.me> |
14431 | | // SPDX-License-Identifier: MIT |
14432 | | |
14433 | | |
14434 | | |
14435 | | #include <cstddef> // ptrdiff_t |
14436 | | #include <iterator> // reverse_iterator |
14437 | | #include <utility> // declval |
14438 | | |
14439 | | // #include <nlohmann/detail/abi_macros.hpp> |
14440 | | |
14441 | | |
14442 | | NLOHMANN_JSON_NAMESPACE_BEGIN |
14443 | | namespace detail |
14444 | | { |
14445 | | |
14446 | | ////////////////////// |
14447 | | // reverse_iterator // |
14448 | | ////////////////////// |
14449 | | |
14450 | | /*! |
14451 | | @brief a template for a reverse iterator class |
14452 | | |
14453 | | @tparam Base the base iterator type to reverse. Valid types are @ref |
14454 | | iterator (to create @ref reverse_iterator) and @ref const_iterator (to |
14455 | | create @ref const_reverse_iterator). |
14456 | | |
14457 | | @requirement The class satisfies the following concept requirements: |
14458 | | - |
14459 | | [BidirectionalIterator](https://en.cppreference.com/w/cpp/named_req/BidirectionalIterator): |
14460 | | The iterator that can be moved can be moved in both directions (i.e. |
14461 | | incremented and decremented). |
14462 | | - [OutputIterator](https://en.cppreference.com/w/cpp/named_req/OutputIterator): |
14463 | | It is possible to write to the pointed-to element (only if @a Base is |
14464 | | @ref iterator). |
14465 | | |
14466 | | @since version 1.0.0 |
14467 | | */ |
14468 | | template<typename Base> |
14469 | | class json_reverse_iterator : public std::reverse_iterator<Base> |
14470 | | { |
14471 | | public: |
14472 | | using difference_type = std::ptrdiff_t; |
14473 | | /// shortcut to the reverse iterator adapter |
14474 | | using base_iterator = std::reverse_iterator<Base>; |
14475 | | /// the reference type for the pointed-to element |
14476 | | using reference = typename Base::reference; |
14477 | | |
14478 | | /// create reverse iterator from iterator |
14479 | | explicit json_reverse_iterator(const typename base_iterator::iterator_type& it) noexcept |
14480 | | : base_iterator(it) {} |
14481 | | |
14482 | | /// create reverse iterator from base class |
14483 | | explicit json_reverse_iterator(const base_iterator& it) noexcept : base_iterator(it) {} |
14484 | | |
14485 | | /// post-increment (it++) |
14486 | | json_reverse_iterator operator++(int)& // NOLINT(cert-dcl21-cpp) |
14487 | | { |
14488 | | return static_cast<json_reverse_iterator>(base_iterator::operator++(1)); |
14489 | | } |
14490 | | |
14491 | | /// pre-increment (++it) |
14492 | | json_reverse_iterator& operator++() |
14493 | | { |
14494 | | return static_cast<json_reverse_iterator&>(base_iterator::operator++()); |
14495 | | } |
14496 | | |
14497 | | /// post-decrement (it--) |
14498 | | json_reverse_iterator operator--(int)& // NOLINT(cert-dcl21-cpp) |
14499 | | { |
14500 | | return static_cast<json_reverse_iterator>(base_iterator::operator--(1)); |
14501 | | } |
14502 | | |
14503 | | /// pre-decrement (--it) |
14504 | | json_reverse_iterator& operator--() |
14505 | | { |
14506 | | return static_cast<json_reverse_iterator&>(base_iterator::operator--()); |
14507 | | } |
14508 | | |
14509 | | /// add to iterator |
14510 | | json_reverse_iterator& operator+=(difference_type i) |
14511 | | { |
14512 | | return static_cast<json_reverse_iterator&>(base_iterator::operator+=(i)); |
14513 | | } |
14514 | | |
14515 | | /// add to iterator |
14516 | | json_reverse_iterator operator+(difference_type i) const |
14517 | | { |
14518 | | return static_cast<json_reverse_iterator>(base_iterator::operator+(i)); |
14519 | | } |
14520 | | |
14521 | | /// subtract from iterator |
14522 | | json_reverse_iterator operator-(difference_type i) const |
14523 | | { |
14524 | | return static_cast<json_reverse_iterator>(base_iterator::operator-(i)); |
14525 | | } |
14526 | | |
14527 | | /// return difference |
14528 | | difference_type operator-(const json_reverse_iterator& other) const |
14529 | | { |
14530 | | return base_iterator(*this) - base_iterator(other); |
14531 | | } |
14532 | | |
14533 | | /// access to successor |
14534 | | reference operator[](difference_type n) const |
14535 | | { |
14536 | | return *(this->operator+(n)); |
14537 | | } |
14538 | | |
14539 | | /// return the key of an object iterator |
14540 | | auto key() const -> decltype(std::declval<Base>().key()) |
14541 | | { |
14542 | | auto it = --this->base(); |
14543 | | return it.key(); |
14544 | | } |
14545 | | |
14546 | | /// return the value of an iterator |
14547 | | reference value() const |
14548 | | { |
14549 | | auto it = --this->base(); |
14550 | | return it.operator * (); |
14551 | | } |
14552 | | }; |
14553 | | |
14554 | | } // namespace detail |
14555 | | NLOHMANN_JSON_NAMESPACE_END |
14556 | | |
14557 | | // #include <nlohmann/detail/iterators/primitive_iterator.hpp> |
14558 | | |
14559 | | // #include <nlohmann/detail/json_custom_base_class.hpp> |
14560 | | // __ _____ _____ _____ |
14561 | | // __| | __| | | | JSON for Modern C++ |
14562 | | // | | |__ | | | | | | version 3.12.0 |
14563 | | // |_____|_____|_____|_|___| https://github.com/nlohmann/json |
14564 | | // |
14565 | | // SPDX-FileCopyrightText: 2013-2026 Niels Lohmann <https://nlohmann.me> |
14566 | | // SPDX-License-Identifier: MIT |
14567 | | |
14568 | | |
14569 | | |
14570 | | #include <type_traits> // conditional, is_same |
14571 | | |
14572 | | // #include <nlohmann/detail/abi_macros.hpp> |
14573 | | |
14574 | | |
14575 | | NLOHMANN_JSON_NAMESPACE_BEGIN |
14576 | | namespace detail |
14577 | | { |
14578 | | |
14579 | | /*! |
14580 | | @brief Default base class of the @ref basic_json class. |
14581 | | |
14582 | | So that the correct implementations of the copy / move ctors / assign operators |
14583 | | of @ref basic_json do not require complex case distinctions |
14584 | | (no base class / custom base class used as customization point), |
14585 | | @ref basic_json always has a base class. |
14586 | | By default, this class is used because it is empty and thus has no effect |
14587 | | on the behavior of @ref basic_json. |
14588 | | */ |
14589 | | struct json_default_base {}; |
14590 | | |
14591 | | template<class T> |
14592 | | using json_base_class = typename std::conditional < |
14593 | | std::is_same<T, void>::value, |
14594 | | json_default_base, |
14595 | | T |
14596 | | >::type; |
14597 | | |
14598 | | } // namespace detail |
14599 | | NLOHMANN_JSON_NAMESPACE_END |
14600 | | |
14601 | | // #include <nlohmann/detail/json_pointer.hpp> |
14602 | | // __ _____ _____ _____ |
14603 | | // __| | __| | | | JSON for Modern C++ |
14604 | | // | | |__ | | | | | | version 3.12.0 |
14605 | | // |_____|_____|_____|_|___| https://github.com/nlohmann/json |
14606 | | // |
14607 | | // SPDX-FileCopyrightText: 2013-2026 Niels Lohmann <https://nlohmann.me> |
14608 | | // SPDX-License-Identifier: MIT |
14609 | | |
14610 | | |
14611 | | |
14612 | | #include <algorithm> // all_of |
14613 | | #include <cctype> // isdigit |
14614 | | #include <cerrno> // errno, ERANGE |
14615 | | #include <cstdlib> // strtoull |
14616 | | #ifndef JSON_NO_IO |
14617 | | #include <iosfwd> // ostream |
14618 | | #endif // JSON_NO_IO |
14619 | | #include <limits> // max |
14620 | | #include <numeric> // accumulate |
14621 | | #include <string> // string |
14622 | | #include <utility> // move |
14623 | | #include <vector> // vector |
14624 | | |
14625 | | // #include <nlohmann/detail/exceptions.hpp> |
14626 | | |
14627 | | // #include <nlohmann/detail/macro_scope.hpp> |
14628 | | |
14629 | | // #include <nlohmann/detail/string_concat.hpp> |
14630 | | |
14631 | | // #include <nlohmann/detail/string_escape.hpp> |
14632 | | |
14633 | | // #include <nlohmann/detail/value_t.hpp> |
14634 | | |
14635 | | |
14636 | | NLOHMANN_JSON_NAMESPACE_BEGIN |
14637 | | |
14638 | | /// @brief JSON Pointer defines a string syntax for identifying a specific value within a JSON document |
14639 | | /// @sa https://json.nlohmann.me/api/json_pointer/ |
14640 | | template<typename RefStringType> |
14641 | | class json_pointer |
14642 | | { |
14643 | | // allow basic_json to access private members |
14644 | | NLOHMANN_BASIC_JSON_TPL_DECLARATION |
14645 | | friend class basic_json; |
14646 | | |
14647 | | template<typename> |
14648 | | friend class json_pointer; |
14649 | | |
14650 | | template<typename T> |
14651 | | struct string_t_helper |
14652 | | { |
14653 | | using type = T; |
14654 | | }; |
14655 | | |
14656 | | NLOHMANN_BASIC_JSON_TPL_DECLARATION |
14657 | | struct string_t_helper<NLOHMANN_BASIC_JSON_TPL> |
14658 | | { |
14659 | | using type = StringType; |
14660 | | }; |
14661 | | |
14662 | | public: |
14663 | | // for backwards compatibility accept BasicJsonType |
14664 | | using string_t = typename string_t_helper<RefStringType>::type; |
14665 | | |
14666 | | /// @brief create JSON pointer |
14667 | | /// @sa https://json.nlohmann.me/api/json_pointer/json_pointer/ |
14668 | | explicit json_pointer(const string_t& s = "") |
14669 | | : reference_tokens(split(s)) |
14670 | | {} |
14671 | | |
14672 | | /// @brief return a string representation of the JSON pointer |
14673 | | /// @sa https://json.nlohmann.me/api/json_pointer/to_string/ |
14674 | | string_t to_string() const |
14675 | | { |
14676 | | return std::accumulate(reference_tokens.begin(), reference_tokens.end(), |
14677 | | string_t{}, |
14678 | | [](const string_t& a, const string_t& b) |
14679 | | { |
14680 | | return detail::concat(a, '/', detail::escape(b)); |
14681 | | }); |
14682 | | } |
14683 | | |
14684 | | /// @brief return a string representation of the JSON pointer |
14685 | | /// @sa https://json.nlohmann.me/api/json_pointer/operator_string/ |
14686 | | JSON_HEDLEY_DEPRECATED_FOR(3.11.0, to_string()) |
14687 | | operator string_t() const |
14688 | | { |
14689 | | return to_string(); |
14690 | | } |
14691 | | |
14692 | | #ifndef JSON_NO_IO |
14693 | | /// @brief write string representation of the JSON pointer to stream |
14694 | | /// @sa https://json.nlohmann.me/api/basic_json/operator_ltlt/ |
14695 | | friend std::ostream& operator<<(std::ostream& o, const json_pointer& ptr) |
14696 | | { |
14697 | | o << ptr.to_string(); |
14698 | | return o; |
14699 | | } |
14700 | | #endif |
14701 | | |
14702 | | /// @brief append another JSON pointer at the end of this JSON pointer |
14703 | | /// @sa https://json.nlohmann.me/api/json_pointer/operator_slasheq/ |
14704 | | json_pointer& operator/=(const json_pointer& ptr) |
14705 | | { |
14706 | | reference_tokens.insert(reference_tokens.end(), |
14707 | | ptr.reference_tokens.begin(), |
14708 | | ptr.reference_tokens.end()); |
14709 | | return *this; |
14710 | | } |
14711 | | |
14712 | | /// @brief append an unescaped reference token at the end of this JSON pointer |
14713 | | /// @sa https://json.nlohmann.me/api/json_pointer/operator_slasheq/ |
14714 | | json_pointer& operator/=(string_t token) |
14715 | | { |
14716 | | push_back(std::move(token)); |
14717 | | return *this; |
14718 | | } |
14719 | | |
14720 | | /// @brief append an array index at the end of this JSON pointer |
14721 | | /// @sa https://json.nlohmann.me/api/json_pointer/operator_slasheq/ |
14722 | | json_pointer& operator/=(std::size_t array_idx) |
14723 | | { |
14724 | | return *this /= std::to_string(array_idx); |
14725 | | } |
14726 | | |
14727 | | /// @brief create a new JSON pointer by appending the right JSON pointer at the end of the left JSON pointer |
14728 | | /// @sa https://json.nlohmann.me/api/json_pointer/operator_slash/ |
14729 | | friend json_pointer operator/(const json_pointer& lhs, |
14730 | | const json_pointer& rhs) |
14731 | | { |
14732 | | return json_pointer(lhs) /= rhs; |
14733 | | } |
14734 | | |
14735 | | /// @brief create a new JSON pointer by appending the unescaped token at the end of the JSON pointer |
14736 | | /// @sa https://json.nlohmann.me/api/json_pointer/operator_slash/ |
14737 | | friend json_pointer operator/(const json_pointer& lhs, string_t token) // NOLINT(performance-unnecessary-value-param) |
14738 | | { |
14739 | | return json_pointer(lhs) /= std::move(token); |
14740 | | } |
14741 | | |
14742 | | /// @brief create a new JSON pointer by appending the array-index-token at the end of the JSON pointer |
14743 | | /// @sa https://json.nlohmann.me/api/json_pointer/operator_slash/ |
14744 | | friend json_pointer operator/(const json_pointer& lhs, std::size_t array_idx) |
14745 | | { |
14746 | | return json_pointer(lhs) /= array_idx; |
14747 | | } |
14748 | | |
14749 | | /// @brief returns the parent of this JSON pointer |
14750 | | /// @sa https://json.nlohmann.me/api/json_pointer/parent_pointer/ |
14751 | | json_pointer parent_pointer() const |
14752 | | { |
14753 | | if (empty()) |
14754 | | { |
14755 | | return *this; |
14756 | | } |
14757 | | |
14758 | | json_pointer res = *this; |
14759 | | res.pop_back(); |
14760 | | return res; |
14761 | | } |
14762 | | |
14763 | | /// @brief remove last reference token |
14764 | | /// @sa https://json.nlohmann.me/api/json_pointer/pop_back/ |
14765 | | void pop_back() |
14766 | | { |
14767 | | if (JSON_HEDLEY_UNLIKELY(empty())) |
14768 | | { |
14769 | | JSON_THROW(detail::out_of_range::create(405, "JSON pointer has no parent", nullptr)); |
14770 | | } |
14771 | | |
14772 | | reference_tokens.pop_back(); |
14773 | | } |
14774 | | |
14775 | | /// @brief return last reference token |
14776 | | /// @sa https://json.nlohmann.me/api/json_pointer/back/ |
14777 | | const string_t& back() const |
14778 | | { |
14779 | | if (JSON_HEDLEY_UNLIKELY(empty())) |
14780 | | { |
14781 | | JSON_THROW(detail::out_of_range::create(405, "JSON pointer has no parent", nullptr)); |
14782 | | } |
14783 | | |
14784 | | return reference_tokens.back(); |
14785 | | } |
14786 | | |
14787 | | /// @brief append an unescaped token at the end of the reference pointer |
14788 | | /// @sa https://json.nlohmann.me/api/json_pointer/push_back/ |
14789 | | void push_back(const string_t& token) |
14790 | | { |
14791 | | reference_tokens.push_back(token); |
14792 | | } |
14793 | | |
14794 | | /// @brief append an unescaped token at the end of the reference pointer |
14795 | | /// @sa https://json.nlohmann.me/api/json_pointer/push_back/ |
14796 | | void push_back(string_t&& token) |
14797 | | { |
14798 | | reference_tokens.push_back(std::move(token)); |
14799 | | } |
14800 | | |
14801 | | /// @brief return whether pointer points to the root document |
14802 | | /// @sa https://json.nlohmann.me/api/json_pointer/empty/ |
14803 | | bool empty() const noexcept |
14804 | | { |
14805 | | return reference_tokens.empty(); |
14806 | | } |
14807 | | |
14808 | | private: |
14809 | | /*! |
14810 | | @param[in] s reference token to be converted into an array index |
14811 | | |
14812 | | @return integer representation of @a s |
14813 | | |
14814 | | @throw parse_error.106 if an array index begins with '0' |
14815 | | @throw parse_error.109 if an array index begins not with a digit |
14816 | | @throw out_of_range.404 if string @a s could not be converted to an integer |
14817 | | @throw out_of_range.410 if an array index exceeds size_type |
14818 | | */ |
14819 | | template<typename BasicJsonType> |
14820 | | static typename BasicJsonType::size_type array_index(const string_t& s) |
14821 | | { |
14822 | | using size_type = typename BasicJsonType::size_type; |
14823 | | |
14824 | | // error condition (cf. RFC 6901, Sect. 4) |
14825 | | if (JSON_HEDLEY_UNLIKELY(s.size() > 1 && s[0] == '0')) |
14826 | | { |
14827 | | JSON_THROW(detail::parse_error::create(106, 0, detail::concat("array index '", s, "' must not begin with '0'"), nullptr)); |
14828 | | } |
14829 | | |
14830 | | // error condition (cf. RFC 6901, Sect. 4) |
14831 | | if (JSON_HEDLEY_UNLIKELY(s.size() > 1 && !(s[0] >= '1' && s[0] <= '9'))) |
14832 | | { |
14833 | | JSON_THROW(detail::parse_error::create(109, 0, detail::concat("array index '", s, "' is not a number"), nullptr)); |
14834 | | } |
14835 | | |
14836 | | const char* p = s.c_str(); |
14837 | | char* p_end = nullptr; // NOLINT(misc-const-correctness) |
14838 | | errno = 0; // strtoull doesn't reset errno |
14839 | | const unsigned long long res = std::strtoull(p, &p_end, 10); // NOLINT(runtime/int) |
14840 | | if (p == p_end // invalid input or empty string |
14841 | | || errno == ERANGE // out of range |
14842 | | || JSON_HEDLEY_UNLIKELY(static_cast<std::size_t>(p_end - p) != s.size())) // incomplete read |
14843 | | { |
14844 | | JSON_THROW(detail::out_of_range::create(404, detail::concat("unresolved reference token '", s, "'"), nullptr)); |
14845 | | } |
14846 | | |
14847 | | // only triggered on special platforms (like 32bit), see also |
14848 | | // https://github.com/nlohmann/json/pull/2203 |
14849 | | if (res >= static_cast<unsigned long long>((std::numeric_limits<size_type>::max)())) // NOLINT(runtime/int) |
14850 | | { |
14851 | | JSON_THROW(detail::out_of_range::create(410, detail::concat("array index ", s, " exceeds size_type"), nullptr)); // LCOV_EXCL_LINE |
14852 | | } |
14853 | | |
14854 | | return static_cast<size_type>(res); |
14855 | | } |
14856 | | |
14857 | | JSON_PRIVATE_UNLESS_TESTED: |
14858 | | json_pointer top() const |
14859 | | { |
14860 | | if (JSON_HEDLEY_UNLIKELY(empty())) |
14861 | | { |
14862 | | JSON_THROW(detail::out_of_range::create(405, "JSON pointer has no parent", nullptr)); |
14863 | | } |
14864 | | |
14865 | | json_pointer result = *this; |
14866 | | result.reference_tokens = {reference_tokens[0]}; |
14867 | | return result; |
14868 | | } |
14869 | | |
14870 | | private: |
14871 | | /*! |
14872 | | @brief create and return a reference to the pointed to value |
14873 | | |
14874 | | @complexity Linear in the number of reference tokens. |
14875 | | |
14876 | | @throw parse_error.109 if array index is not a number |
14877 | | @throw type_error.313 if value cannot be unflattened |
14878 | | */ |
14879 | | template<typename BasicJsonType> |
14880 | | BasicJsonType& get_and_create(BasicJsonType& j) const |
14881 | | { |
14882 | | auto* result = &j; |
14883 | | |
14884 | | // in case no reference tokens exist, return a reference to the JSON value |
14885 | | // j which will be overwritten by a primitive value |
14886 | | for (const auto& reference_token : reference_tokens) |
14887 | | { |
14888 | | switch (result->type()) |
14889 | | { |
14890 | | case detail::value_t::null: |
14891 | | { |
14892 | | if (reference_token == "0") |
14893 | | { |
14894 | | // start a new array if the reference token is 0 |
14895 | | result = &result->operator[](0); |
14896 | | } |
14897 | | else |
14898 | | { |
14899 | | // start a new object otherwise |
14900 | | result = &result->operator[](reference_token); |
14901 | | } |
14902 | | break; |
14903 | | } |
14904 | | |
14905 | | case detail::value_t::object: |
14906 | | { |
14907 | | // create an entry in the object |
14908 | | result = &result->operator[](reference_token); |
14909 | | break; |
14910 | | } |
14911 | | |
14912 | | case detail::value_t::array: |
14913 | | { |
14914 | | // create an entry in the array |
14915 | | result = &result->operator[](array_index<BasicJsonType>(reference_token)); |
14916 | | break; |
14917 | | } |
14918 | | |
14919 | | /* |
14920 | | The following code is only reached if there exists a reference |
14921 | | token _and_ the current value is primitive. In this case, we have |
14922 | | an error situation, because primitive values may only occur as |
14923 | | a single value; that is, with an empty list of reference tokens. |
14924 | | */ |
14925 | | case detail::value_t::string: |
14926 | | case detail::value_t::boolean: |
14927 | | case detail::value_t::number_integer: |
14928 | | case detail::value_t::number_unsigned: |
14929 | | case detail::value_t::number_float: |
14930 | | case detail::value_t::binary: |
14931 | | case detail::value_t::discarded: |
14932 | | default: |
14933 | | JSON_THROW(detail::type_error::create(313, "invalid value to unflatten", &j)); |
14934 | | } |
14935 | | } |
14936 | | |
14937 | | return *result; |
14938 | | } |
14939 | | |
14940 | | /*! |
14941 | | @brief return a reference to the pointed to value |
14942 | | |
14943 | | @note This version does not throw if a value is not present, but tries to |
14944 | | create nested values instead. For instance, calling this function |
14945 | | with pointer `"/this/that"` on a null value is equivalent to calling |
14946 | | `operator[]("this").operator[]("that")` on that value, effectively |
14947 | | changing the null value to an object. |
14948 | | |
14949 | | @param[in] ptr a JSON value |
14950 | | |
14951 | | @return reference to the JSON value pointed to by the JSON pointer |
14952 | | |
14953 | | @complexity Linear in the length of the JSON pointer. |
14954 | | |
14955 | | @throw parse_error.106 if an array index begins with '0' |
14956 | | @throw parse_error.109 if an array index was not a number |
14957 | | @throw out_of_range.404 if the JSON pointer can not be resolved |
14958 | | */ |
14959 | | template<typename BasicJsonType> |
14960 | | BasicJsonType& get_unchecked(BasicJsonType* ptr) const |
14961 | | { |
14962 | | for (const auto& reference_token : reference_tokens) |
14963 | | { |
14964 | | // convert null values to arrays or objects before continuing |
14965 | | if (ptr->is_null()) |
14966 | | { |
14967 | | // check if the reference token is a number |
14968 | | const bool nums = |
14969 | | std::all_of(reference_token.begin(), reference_token.end(), |
14970 | | [](const unsigned char x) |
14971 | | { |
14972 | | return std::isdigit(x); |
14973 | | }); |
14974 | | |
14975 | | // change value to an array for numbers or "-" or to object otherwise |
14976 | | *ptr = (nums || reference_token == "-") |
14977 | | ? detail::value_t::array |
14978 | | : detail::value_t::object; |
14979 | | } |
14980 | | |
14981 | | switch (ptr->type()) |
14982 | | { |
14983 | | case detail::value_t::object: |
14984 | | { |
14985 | | // use unchecked object access |
14986 | | ptr = &ptr->operator[](reference_token); |
14987 | | break; |
14988 | | } |
14989 | | |
14990 | | case detail::value_t::array: |
14991 | | { |
14992 | | if (reference_token == "-") |
14993 | | { |
14994 | | // explicitly treat "-" as index beyond the end |
14995 | | ptr = &ptr->operator[](ptr->m_data.m_value.array->size()); |
14996 | | } |
14997 | | else |
14998 | | { |
14999 | | // convert array index to number; unchecked access |
15000 | | ptr = &ptr->operator[](array_index<BasicJsonType>(reference_token)); |
15001 | | } |
15002 | | break; |
15003 | | } |
15004 | | |
15005 | | case detail::value_t::null: |
15006 | | case detail::value_t::string: |
15007 | | case detail::value_t::boolean: |
15008 | | case detail::value_t::number_integer: |
15009 | | case detail::value_t::number_unsigned: |
15010 | | case detail::value_t::number_float: |
15011 | | case detail::value_t::binary: |
15012 | | case detail::value_t::discarded: |
15013 | | default: |
15014 | | JSON_THROW(detail::out_of_range::create(404, detail::concat("unresolved reference token '", reference_token, "'"), ptr)); |
15015 | | } |
15016 | | } |
15017 | | |
15018 | | return *ptr; |
15019 | | } |
15020 | | |
15021 | | /*! |
15022 | | @throw parse_error.106 if an array index begins with '0' |
15023 | | @throw parse_error.109 if an array index was not a number |
15024 | | @throw out_of_range.402 if the array index '-' is used |
15025 | | @throw out_of_range.404 if the JSON pointer can not be resolved |
15026 | | */ |
15027 | | template<typename BasicJsonType> |
15028 | | BasicJsonType& get_checked(BasicJsonType* ptr) const |
15029 | | { |
15030 | | for (const auto& reference_token : reference_tokens) |
15031 | | { |
15032 | | switch (ptr->type()) |
15033 | | { |
15034 | | case detail::value_t::object: |
15035 | | { |
15036 | | // note: at performs range check |
15037 | | ptr = &ptr->at(reference_token); |
15038 | | break; |
15039 | | } |
15040 | | |
15041 | | case detail::value_t::array: |
15042 | | { |
15043 | | if (JSON_HEDLEY_UNLIKELY(reference_token == "-")) |
15044 | | { |
15045 | | // "-" always fails the range check |
15046 | | JSON_THROW(detail::out_of_range::create(402, detail::concat( |
15047 | | "array index '-' (", std::to_string(ptr->m_data.m_value.array->size()), |
15048 | | ") is out of range"), ptr)); |
15049 | | } |
15050 | | |
15051 | | // note: at performs range check |
15052 | | ptr = &ptr->at(array_index<BasicJsonType>(reference_token)); |
15053 | | break; |
15054 | | } |
15055 | | |
15056 | | case detail::value_t::null: |
15057 | | case detail::value_t::string: |
15058 | | case detail::value_t::boolean: |
15059 | | case detail::value_t::number_integer: |
15060 | | case detail::value_t::number_unsigned: |
15061 | | case detail::value_t::number_float: |
15062 | | case detail::value_t::binary: |
15063 | | case detail::value_t::discarded: |
15064 | | default: |
15065 | | JSON_THROW(detail::out_of_range::create(404, detail::concat("unresolved reference token '", reference_token, "'"), ptr)); |
15066 | | } |
15067 | | } |
15068 | | |
15069 | | return *ptr; |
15070 | | } |
15071 | | |
15072 | | /*! |
15073 | | @brief return a const reference to the pointed to value |
15074 | | |
15075 | | @param[in] ptr a JSON value |
15076 | | |
15077 | | @return const reference to the JSON value pointed to by the JSON |
15078 | | pointer |
15079 | | |
15080 | | @throw parse_error.106 if an array index begins with '0' |
15081 | | @throw parse_error.109 if an array index was not a number |
15082 | | @throw out_of_range.402 if the array index '-' is used |
15083 | | @throw out_of_range.404 if the JSON pointer can not be resolved |
15084 | | */ |
15085 | | template<typename BasicJsonType> |
15086 | | const BasicJsonType& get_unchecked(const BasicJsonType* ptr) const |
15087 | | { |
15088 | | for (const auto& reference_token : reference_tokens) |
15089 | | { |
15090 | | switch (ptr->type()) |
15091 | | { |
15092 | | case detail::value_t::object: |
15093 | | { |
15094 | | // use unchecked object access |
15095 | | ptr = &ptr->operator[](reference_token); |
15096 | | break; |
15097 | | } |
15098 | | |
15099 | | case detail::value_t::array: |
15100 | | { |
15101 | | if (JSON_HEDLEY_UNLIKELY(reference_token == "-")) |
15102 | | { |
15103 | | // "-" cannot be used for const access |
15104 | | JSON_THROW(detail::out_of_range::create(402, detail::concat("array index '-' (", std::to_string(ptr->m_data.m_value.array->size()), ") is out of range"), ptr)); |
15105 | | } |
15106 | | |
15107 | | // use unchecked array access |
15108 | | ptr = &ptr->operator[](array_index<BasicJsonType>(reference_token)); |
15109 | | break; |
15110 | | } |
15111 | | |
15112 | | case detail::value_t::null: |
15113 | | case detail::value_t::string: |
15114 | | case detail::value_t::boolean: |
15115 | | case detail::value_t::number_integer: |
15116 | | case detail::value_t::number_unsigned: |
15117 | | case detail::value_t::number_float: |
15118 | | case detail::value_t::binary: |
15119 | | case detail::value_t::discarded: |
15120 | | default: |
15121 | | JSON_THROW(detail::out_of_range::create(404, detail::concat("unresolved reference token '", reference_token, "'"), ptr)); |
15122 | | } |
15123 | | } |
15124 | | |
15125 | | return *ptr; |
15126 | | } |
15127 | | |
15128 | | /*! |
15129 | | @throw parse_error.106 if an array index begins with '0' |
15130 | | @throw parse_error.109 if an array index was not a number |
15131 | | @throw out_of_range.402 if the array index '-' is used |
15132 | | @throw out_of_range.404 if the JSON pointer can not be resolved |
15133 | | */ |
15134 | | template<typename BasicJsonType> |
15135 | | const BasicJsonType& get_checked(const BasicJsonType* ptr) const |
15136 | | { |
15137 | | for (const auto& reference_token : reference_tokens) |
15138 | | { |
15139 | | switch (ptr->type()) |
15140 | | { |
15141 | | case detail::value_t::object: |
15142 | | { |
15143 | | // note: at performs range check |
15144 | | ptr = &ptr->at(reference_token); |
15145 | | break; |
15146 | | } |
15147 | | |
15148 | | case detail::value_t::array: |
15149 | | { |
15150 | | if (JSON_HEDLEY_UNLIKELY(reference_token == "-")) |
15151 | | { |
15152 | | // "-" always fails the range check |
15153 | | JSON_THROW(detail::out_of_range::create(402, detail::concat( |
15154 | | "array index '-' (", std::to_string(ptr->m_data.m_value.array->size()), |
15155 | | ") is out of range"), ptr)); |
15156 | | } |
15157 | | |
15158 | | // note: at performs range check |
15159 | | ptr = &ptr->at(array_index<BasicJsonType>(reference_token)); |
15160 | | break; |
15161 | | } |
15162 | | |
15163 | | case detail::value_t::null: |
15164 | | case detail::value_t::string: |
15165 | | case detail::value_t::boolean: |
15166 | | case detail::value_t::number_integer: |
15167 | | case detail::value_t::number_unsigned: |
15168 | | case detail::value_t::number_float: |
15169 | | case detail::value_t::binary: |
15170 | | case detail::value_t::discarded: |
15171 | | default: |
15172 | | JSON_THROW(detail::out_of_range::create(404, detail::concat("unresolved reference token '", reference_token, "'"), ptr)); |
15173 | | } |
15174 | | } |
15175 | | |
15176 | | return *ptr; |
15177 | | } |
15178 | | |
15179 | | /*! |
15180 | | @throw parse_error.106 if an array index begins with '0' |
15181 | | @throw parse_error.109 if an array index was not a number |
15182 | | */ |
15183 | | template<typename BasicJsonType> |
15184 | | bool contains(const BasicJsonType* ptr) const |
15185 | | { |
15186 | | for (const auto& reference_token : reference_tokens) |
15187 | | { |
15188 | | switch (ptr->type()) |
15189 | | { |
15190 | | case detail::value_t::object: |
15191 | | { |
15192 | | if (!ptr->contains(reference_token)) |
15193 | | { |
15194 | | // we did not find the key in the object |
15195 | | return false; |
15196 | | } |
15197 | | |
15198 | | ptr = &ptr->operator[](reference_token); |
15199 | | break; |
15200 | | } |
15201 | | |
15202 | | case detail::value_t::array: |
15203 | | { |
15204 | | if (JSON_HEDLEY_UNLIKELY(reference_token == "-")) |
15205 | | { |
15206 | | // "-" always fails the range check |
15207 | | return false; |
15208 | | } |
15209 | | if (JSON_HEDLEY_UNLIKELY(reference_token.size() == 1 && !("0" <= reference_token && reference_token <= "9"))) |
15210 | | { |
15211 | | // invalid char |
15212 | | return false; |
15213 | | } |
15214 | | if (JSON_HEDLEY_UNLIKELY(reference_token.size() > 1)) |
15215 | | { |
15216 | | if (JSON_HEDLEY_UNLIKELY(!('1' <= reference_token[0] && reference_token[0] <= '9'))) |
15217 | | { |
15218 | | // the first char should be between '1' and '9' |
15219 | | return false; |
15220 | | } |
15221 | | for (std::size_t i = 1; i < reference_token.size(); i++) |
15222 | | { |
15223 | | if (JSON_HEDLEY_UNLIKELY(!('0' <= reference_token[i] && reference_token[i] <= '9'))) |
15224 | | { |
15225 | | // other char should be between '0' and '9' |
15226 | | return false; |
15227 | | } |
15228 | | } |
15229 | | } |
15230 | | |
15231 | | const auto idx = array_index<BasicJsonType>(reference_token); |
15232 | | if (idx >= ptr->size()) |
15233 | | { |
15234 | | // index out of range |
15235 | | return false; |
15236 | | } |
15237 | | |
15238 | | ptr = &ptr->operator[](idx); |
15239 | | break; |
15240 | | } |
15241 | | |
15242 | | case detail::value_t::null: |
15243 | | case detail::value_t::string: |
15244 | | case detail::value_t::boolean: |
15245 | | case detail::value_t::number_integer: |
15246 | | case detail::value_t::number_unsigned: |
15247 | | case detail::value_t::number_float: |
15248 | | case detail::value_t::binary: |
15249 | | case detail::value_t::discarded: |
15250 | | default: |
15251 | | { |
15252 | | // we do not expect primitive values if there is still a |
15253 | | // reference token to process |
15254 | | return false; |
15255 | | } |
15256 | | } |
15257 | | } |
15258 | | |
15259 | | // no reference token left means we found a primitive value |
15260 | | return true; |
15261 | | } |
15262 | | |
15263 | | /*! |
15264 | | @brief split the string input to reference tokens |
15265 | | |
15266 | | @note This function is only called by the json_pointer constructor. |
15267 | | All exceptions below are documented there. |
15268 | | |
15269 | | @throw parse_error.107 if the pointer is not empty or begins with '/' |
15270 | | @throw parse_error.108 if character '~' is not followed by '0' or '1' |
15271 | | */ |
15272 | | static std::vector<string_t> split(const string_t& reference_string) |
15273 | 0 | { |
15274 | 0 | std::vector<string_t> result; |
15275 | 0 |
|
15276 | 0 | // special case: empty reference string -> no reference tokens |
15277 | 0 | if (reference_string.empty()) |
15278 | 0 | { |
15279 | 0 | return result; |
15280 | 0 | } |
15281 | 0 |
|
15282 | 0 | // check if a nonempty reference string begins with slash |
15283 | 0 | if (JSON_HEDLEY_UNLIKELY(reference_string[0] != '/')) |
15284 | 0 | { |
15285 | 0 | JSON_THROW(detail::parse_error::create(107, 1, detail::concat("JSON pointer must be empty or begin with '/' - was: '", reference_string, "'"), nullptr)); |
15286 | 0 | } |
15287 | 0 |
|
15288 | 0 | // extract the reference tokens: |
15289 | 0 | // - slash: position of the last read slash (or end of string) |
15290 | 0 | // - start: position after the previous slash |
15291 | 0 | for ( |
15292 | 0 | // search for the first slash after the first character |
15293 | 0 | std::size_t slash = reference_string.find_first_of('/', 1), |
15294 | 0 | // set the beginning of the first reference token |
15295 | 0 | start = 1; |
15296 | 0 | // we can stop if start == 0 (if slash == string_t::npos) |
15297 | 0 | start != 0; |
15298 | 0 | // set the beginning of the next reference token |
15299 | 0 | // (will eventually be 0 if slash == string_t::npos) |
15300 | 0 | start = (slash == string_t::npos) ? 0 : slash + 1, |
15301 | 0 | // find next slash |
15302 | 0 | slash = reference_string.find_first_of('/', start)) |
15303 | 0 | { |
15304 | 0 | // use the text between the beginning of the reference token |
15305 | 0 | // (start) and the last slash (slash). |
15306 | 0 | auto reference_token = reference_string.substr(start, slash - start); |
15307 | 0 |
|
15308 | 0 | // check reference tokens are properly escaped |
15309 | 0 | for (std::size_t pos = reference_token.find_first_of('~'); |
15310 | 0 | pos != string_t::npos; |
15311 | 0 | pos = reference_token.find_first_of('~', pos + 1)) |
15312 | 0 | { |
15313 | 0 | JSON_ASSERT(reference_token[pos] == '~'); |
15314 | 0 |
|
15315 | 0 | // ~ must be followed by 0 or 1 |
15316 | 0 | if (JSON_HEDLEY_UNLIKELY(pos == reference_token.size() - 1 || |
15317 | 0 | (reference_token[pos + 1] != '0' && |
15318 | 0 | reference_token[pos + 1] != '1'))) |
15319 | 0 | { |
15320 | 0 | JSON_THROW(detail::parse_error::create(108, 0, "escape character '~' must be followed with '0' or '1'", nullptr)); |
15321 | 0 | } |
15322 | 0 | } |
15323 | 0 |
|
15324 | 0 | // finally, store the reference token |
15325 | 0 | detail::unescape(reference_token); |
15326 | 0 | result.push_back(reference_token); |
15327 | 0 | } |
15328 | 0 |
|
15329 | 0 | return result; |
15330 | 0 | } |
15331 | | |
15332 | | private: |
15333 | | /*! |
15334 | | @param[in] reference_string the reference string to the current value |
15335 | | @param[in] value the value to consider |
15336 | | @param[in,out] result the result object to insert values to |
15337 | | |
15338 | | @note Empty objects or arrays are flattened to `null`. |
15339 | | */ |
15340 | | template<typename BasicJsonType> |
15341 | | static void flatten(const string_t& reference_string, |
15342 | | const BasicJsonType& value, |
15343 | | BasicJsonType& result) |
15344 | | { |
15345 | | switch (value.type()) |
15346 | | { |
15347 | | case detail::value_t::array: |
15348 | | { |
15349 | | if (value.m_data.m_value.array->empty()) |
15350 | | { |
15351 | | // flatten empty array as null |
15352 | | result[reference_string] = nullptr; |
15353 | | } |
15354 | | else |
15355 | | { |
15356 | | // iterate array and use index as a reference string |
15357 | | for (std::size_t i = 0; i < value.m_data.m_value.array->size(); ++i) |
15358 | | { |
15359 | | flatten(detail::concat<string_t>(reference_string, '/', std::to_string(i)), |
15360 | | value.m_data.m_value.array->operator[](i), result); |
15361 | | } |
15362 | | } |
15363 | | break; |
15364 | | } |
15365 | | |
15366 | | case detail::value_t::object: |
15367 | | { |
15368 | | if (value.m_data.m_value.object->empty()) |
15369 | | { |
15370 | | // flatten empty object as null |
15371 | | result[reference_string] = nullptr; |
15372 | | } |
15373 | | else |
15374 | | { |
15375 | | // iterate object and use keys as reference string |
15376 | | for (const auto& element : *value.m_data.m_value.object) |
15377 | | { |
15378 | | flatten(detail::concat<string_t>(reference_string, '/', detail::escape(element.first)), element.second, result); |
15379 | | } |
15380 | | } |
15381 | | break; |
15382 | | } |
15383 | | |
15384 | | case detail::value_t::null: |
15385 | | case detail::value_t::string: |
15386 | | case detail::value_t::boolean: |
15387 | | case detail::value_t::number_integer: |
15388 | | case detail::value_t::number_unsigned: |
15389 | | case detail::value_t::number_float: |
15390 | | case detail::value_t::binary: |
15391 | | case detail::value_t::discarded: |
15392 | | default: |
15393 | | { |
15394 | | // add a primitive value with its reference string |
15395 | | result[reference_string] = value; |
15396 | | break; |
15397 | | } |
15398 | | } |
15399 | | } |
15400 | | |
15401 | | /*! |
15402 | | @param[in] value flattened JSON |
15403 | | |
15404 | | @return unflattened JSON |
15405 | | |
15406 | | @throw parse_error.109 if array index is not a number |
15407 | | @throw type_error.314 if value is not an object |
15408 | | @throw type_error.315 if object values are not primitive |
15409 | | @throw type_error.313 if value cannot be unflattened |
15410 | | */ |
15411 | | template<typename BasicJsonType> |
15412 | | static BasicJsonType |
15413 | | unflatten(const BasicJsonType& value) |
15414 | | { |
15415 | | if (JSON_HEDLEY_UNLIKELY(!value.is_object())) |
15416 | | { |
15417 | | JSON_THROW(detail::type_error::create(314, "only objects can be unflattened", &value)); |
15418 | | } |
15419 | | |
15420 | | BasicJsonType result; |
15421 | | |
15422 | | // iterate the JSON object values |
15423 | | for (const auto& element : *value.m_data.m_value.object) |
15424 | | { |
15425 | | if (JSON_HEDLEY_UNLIKELY(!element.second.is_primitive())) |
15426 | | { |
15427 | | JSON_THROW(detail::type_error::create(315, "values in object must be primitive", &element.second)); |
15428 | | } |
15429 | | |
15430 | | // Assign the value to the reference pointed to by JSON pointer. Note |
15431 | | // that if the JSON pointer is "" (i.e., points to the whole value), |
15432 | | // function get_and_create returns a reference to the result itself. |
15433 | | // An assignment will then create a primitive value. |
15434 | | json_pointer(element.first).get_and_create(result) = element.second; |
15435 | | } |
15436 | | |
15437 | | return result; |
15438 | | } |
15439 | | |
15440 | | // can't use the conversion operator because of ambiguity |
15441 | | json_pointer<string_t> convert() const& |
15442 | | { |
15443 | | json_pointer<string_t> result; |
15444 | | result.reference_tokens = reference_tokens; |
15445 | | return result; |
15446 | | } |
15447 | | |
15448 | | json_pointer<string_t> convert()&& |
15449 | | { |
15450 | | json_pointer<string_t> result; |
15451 | | result.reference_tokens = std::move(reference_tokens); |
15452 | | return result; |
15453 | | } |
15454 | | |
15455 | | public: |
15456 | | #if JSON_HAS_THREE_WAY_COMPARISON |
15457 | | /// @brief compares two JSON pointers for equality |
15458 | | /// @sa https://json.nlohmann.me/api/json_pointer/operator_eq/ |
15459 | | template<typename RefStringTypeRhs> |
15460 | | bool operator==(const json_pointer<RefStringTypeRhs>& rhs) const noexcept |
15461 | | { |
15462 | | return reference_tokens == rhs.reference_tokens; |
15463 | | } |
15464 | | |
15465 | | /// @brief compares JSON pointer and string for equality |
15466 | | /// @sa https://json.nlohmann.me/api/json_pointer/operator_eq/ |
15467 | | JSON_HEDLEY_DEPRECATED_FOR(3.11.2, operator==(json_pointer)) |
15468 | | bool operator==(const string_t& rhs) const |
15469 | | { |
15470 | | return *this == json_pointer(rhs); |
15471 | | } |
15472 | | |
15473 | | /// @brief 3-way compares two JSON pointers |
15474 | | template<typename RefStringTypeRhs> |
15475 | | std::strong_ordering operator<=>(const json_pointer<RefStringTypeRhs>& rhs) const noexcept // *NOPAD* |
15476 | | { |
15477 | | return reference_tokens <=> rhs.reference_tokens; // *NOPAD* |
15478 | | } |
15479 | | #else |
15480 | | /// @brief compares two JSON pointers for equality |
15481 | | /// @sa https://json.nlohmann.me/api/json_pointer/operator_eq/ |
15482 | | template<typename RefStringTypeLhs, typename RefStringTypeRhs> |
15483 | | // NOLINTNEXTLINE(readability-redundant-declaration) |
15484 | | friend bool operator==(const json_pointer<RefStringTypeLhs>& lhs, |
15485 | | const json_pointer<RefStringTypeRhs>& rhs) noexcept; |
15486 | | |
15487 | | /// @brief compares JSON pointer and string for equality |
15488 | | /// @sa https://json.nlohmann.me/api/json_pointer/operator_eq/ |
15489 | | template<typename RefStringTypeLhs, typename StringType> |
15490 | | // NOLINTNEXTLINE(readability-redundant-declaration) |
15491 | | friend bool operator==(const json_pointer<RefStringTypeLhs>& lhs, |
15492 | | const StringType& rhs); |
15493 | | |
15494 | | /// @brief compares string and JSON pointer for equality |
15495 | | /// @sa https://json.nlohmann.me/api/json_pointer/operator_eq/ |
15496 | | template<typename RefStringTypeRhs, typename StringType> |
15497 | | // NOLINTNEXTLINE(readability-redundant-declaration) |
15498 | | friend bool operator==(const StringType& lhs, |
15499 | | const json_pointer<RefStringTypeRhs>& rhs); |
15500 | | |
15501 | | /// @brief compares two JSON pointers for inequality |
15502 | | /// @sa https://json.nlohmann.me/api/json_pointer/operator_ne/ |
15503 | | template<typename RefStringTypeLhs, typename RefStringTypeRhs> |
15504 | | // NOLINTNEXTLINE(readability-redundant-declaration) |
15505 | | friend bool operator!=(const json_pointer<RefStringTypeLhs>& lhs, |
15506 | | const json_pointer<RefStringTypeRhs>& rhs) noexcept; |
15507 | | |
15508 | | /// @brief compares JSON pointer and string for inequality |
15509 | | /// @sa https://json.nlohmann.me/api/json_pointer/operator_ne/ |
15510 | | template<typename RefStringTypeLhs, typename StringType> |
15511 | | // NOLINTNEXTLINE(readability-redundant-declaration) |
15512 | | friend bool operator!=(const json_pointer<RefStringTypeLhs>& lhs, |
15513 | | const StringType& rhs); |
15514 | | |
15515 | | /// @brief compares string and JSON pointer for inequality |
15516 | | /// @sa https://json.nlohmann.me/api/json_pointer/operator_ne/ |
15517 | | template<typename RefStringTypeRhs, typename StringType> |
15518 | | // NOLINTNEXTLINE(readability-redundant-declaration) |
15519 | | friend bool operator!=(const StringType& lhs, |
15520 | | const json_pointer<RefStringTypeRhs>& rhs); |
15521 | | |
15522 | | /// @brief compares two JSON pointer for less-than |
15523 | | template<typename RefStringTypeLhs, typename RefStringTypeRhs> |
15524 | | // NOLINTNEXTLINE(readability-redundant-declaration) |
15525 | | friend bool operator<(const json_pointer<RefStringTypeLhs>& lhs, |
15526 | | const json_pointer<RefStringTypeRhs>& rhs) noexcept; |
15527 | | #endif |
15528 | | |
15529 | | private: |
15530 | | /// the reference tokens |
15531 | | std::vector<string_t> reference_tokens; |
15532 | | }; |
15533 | | |
15534 | | #if !JSON_HAS_THREE_WAY_COMPARISON |
15535 | | // functions cannot be defined inside the class due to ODR violations |
15536 | | template<typename RefStringTypeLhs, typename RefStringTypeRhs> |
15537 | | inline bool operator==(const json_pointer<RefStringTypeLhs>& lhs, |
15538 | | const json_pointer<RefStringTypeRhs>& rhs) noexcept |
15539 | | { |
15540 | | return lhs.reference_tokens == rhs.reference_tokens; |
15541 | | } |
15542 | | |
15543 | | template<typename RefStringTypeLhs, |
15544 | | typename StringType = typename json_pointer<RefStringTypeLhs>::string_t> |
15545 | | JSON_HEDLEY_DEPRECATED_FOR(3.11.2, operator==(json_pointer, json_pointer)) |
15546 | | inline bool operator==(const json_pointer<RefStringTypeLhs>& lhs, |
15547 | | const StringType& rhs) |
15548 | | { |
15549 | | return lhs == json_pointer<RefStringTypeLhs>(rhs); |
15550 | | } |
15551 | | |
15552 | | template<typename RefStringTypeRhs, |
15553 | | typename StringType = typename json_pointer<RefStringTypeRhs>::string_t> |
15554 | | JSON_HEDLEY_DEPRECATED_FOR(3.11.2, operator==(json_pointer, json_pointer)) |
15555 | | inline bool operator==(const StringType& lhs, |
15556 | | const json_pointer<RefStringTypeRhs>& rhs) |
15557 | | { |
15558 | | return json_pointer<RefStringTypeRhs>(lhs) == rhs; |
15559 | | } |
15560 | | |
15561 | | template<typename RefStringTypeLhs, typename RefStringTypeRhs> |
15562 | | inline bool operator!=(const json_pointer<RefStringTypeLhs>& lhs, |
15563 | | const json_pointer<RefStringTypeRhs>& rhs) noexcept |
15564 | | { |
15565 | | return !(lhs == rhs); |
15566 | | } |
15567 | | |
15568 | | template<typename RefStringTypeLhs, |
15569 | | typename StringType = typename json_pointer<RefStringTypeLhs>::string_t> |
15570 | | JSON_HEDLEY_DEPRECATED_FOR(3.11.2, operator!=(json_pointer, json_pointer)) |
15571 | | inline bool operator!=(const json_pointer<RefStringTypeLhs>& lhs, |
15572 | | const StringType& rhs) |
15573 | | { |
15574 | | return !(lhs == rhs); |
15575 | | } |
15576 | | |
15577 | | template<typename RefStringTypeRhs, |
15578 | | typename StringType = typename json_pointer<RefStringTypeRhs>::string_t> |
15579 | | JSON_HEDLEY_DEPRECATED_FOR(3.11.2, operator!=(json_pointer, json_pointer)) |
15580 | | inline bool operator!=(const StringType& lhs, |
15581 | | const json_pointer<RefStringTypeRhs>& rhs) |
15582 | | { |
15583 | | return !(lhs == rhs); |
15584 | | } |
15585 | | |
15586 | | template<typename RefStringTypeLhs, typename RefStringTypeRhs> |
15587 | | inline bool operator<(const json_pointer<RefStringTypeLhs>& lhs, |
15588 | | const json_pointer<RefStringTypeRhs>& rhs) noexcept |
15589 | | { |
15590 | | return lhs.reference_tokens < rhs.reference_tokens; |
15591 | | } |
15592 | | #endif |
15593 | | |
15594 | | NLOHMANN_JSON_NAMESPACE_END |
15595 | | |
15596 | | // #include <nlohmann/detail/json_ref.hpp> |
15597 | | // __ _____ _____ _____ |
15598 | | // __| | __| | | | JSON for Modern C++ |
15599 | | // | | |__ | | | | | | version 3.12.0 |
15600 | | // |_____|_____|_____|_|___| https://github.com/nlohmann/json |
15601 | | // |
15602 | | // SPDX-FileCopyrightText: 2013-2026 Niels Lohmann <https://nlohmann.me> |
15603 | | // SPDX-License-Identifier: MIT |
15604 | | |
15605 | | |
15606 | | |
15607 | | #include <initializer_list> |
15608 | | #include <utility> |
15609 | | |
15610 | | // #include <nlohmann/detail/abi_macros.hpp> |
15611 | | |
15612 | | // #include <nlohmann/detail/meta/type_traits.hpp> |
15613 | | |
15614 | | |
15615 | | NLOHMANN_JSON_NAMESPACE_BEGIN |
15616 | | namespace detail |
15617 | | { |
15618 | | |
15619 | | template<typename BasicJsonType> |
15620 | | class json_ref |
15621 | | { |
15622 | | public: |
15623 | | using value_type = BasicJsonType; |
15624 | | |
15625 | | json_ref(value_type&& value) |
15626 | 0 | : owned_value(std::move(value)) |
15627 | 0 | {} |
15628 | | |
15629 | | json_ref(const value_type& value) |
15630 | | : value_ref(&value) |
15631 | | {} |
15632 | | |
15633 | | json_ref(std::initializer_list<json_ref> init) |
15634 | | : owned_value(init) |
15635 | | {} |
15636 | | |
15637 | | template < |
15638 | | class... Args, |
15639 | | enable_if_t<std::is_constructible<value_type, Args...>::value, int> = 0 > |
15640 | | json_ref(Args && ... args) |
15641 | | : owned_value(std::forward<Args>(args)...) |
15642 | | {} |
15643 | | |
15644 | | // class should be movable only |
15645 | | json_ref(json_ref&&) noexcept = default; |
15646 | | json_ref(const json_ref&) = delete; |
15647 | | json_ref& operator=(const json_ref&) = delete; |
15648 | | json_ref& operator=(json_ref&&) = delete; |
15649 | 0 | ~json_ref() = default; |
15650 | | |
15651 | | value_type moved_or_copied() const |
15652 | 0 | { |
15653 | 0 | if (value_ref == nullptr) |
15654 | 0 | { |
15655 | 0 | return std::move(owned_value); |
15656 | 0 | } |
15657 | 0 | return *value_ref; |
15658 | 0 | } |
15659 | | |
15660 | | value_type const& operator*() const |
15661 | 0 | { |
15662 | 0 | return value_ref ? *value_ref : owned_value; |
15663 | 0 | } |
15664 | | |
15665 | | value_type const* operator->() const |
15666 | 0 | { |
15667 | 0 | return &** this; |
15668 | 0 | } |
15669 | | |
15670 | | private: |
15671 | | mutable value_type owned_value = nullptr; |
15672 | | value_type const* value_ref = nullptr; |
15673 | | }; |
15674 | | |
15675 | | } // namespace detail |
15676 | | NLOHMANN_JSON_NAMESPACE_END |
15677 | | |
15678 | | // #include <nlohmann/detail/macro_scope.hpp> |
15679 | | |
15680 | | // #include <nlohmann/detail/string_concat.hpp> |
15681 | | |
15682 | | // #include <nlohmann/detail/string_escape.hpp> |
15683 | | |
15684 | | // #include <nlohmann/detail/string_utils.hpp> |
15685 | | |
15686 | | // #include <nlohmann/detail/meta/cpp_future.hpp> |
15687 | | |
15688 | | // #include <nlohmann/detail/meta/type_traits.hpp> |
15689 | | |
15690 | | // #include <nlohmann/detail/output/binary_writer.hpp> |
15691 | | // __ _____ _____ _____ |
15692 | | // __| | __| | | | JSON for Modern C++ |
15693 | | // | | |__ | | | | | | version 3.12.0 |
15694 | | // |_____|_____|_____|_|___| https://github.com/nlohmann/json |
15695 | | // |
15696 | | // SPDX-FileCopyrightText: 2013-2026 Niels Lohmann <https://nlohmann.me> |
15697 | | // SPDX-License-Identifier: MIT |
15698 | | |
15699 | | |
15700 | | |
15701 | | #include <algorithm> // reverse |
15702 | | #include <array> // array |
15703 | | #include <map> // map |
15704 | | #include <cmath> // isnan, isinf |
15705 | | #include <cstdint> // uint8_t, uint16_t, uint32_t, uint64_t |
15706 | | #include <cstring> // memcpy |
15707 | | #include <limits> // numeric_limits |
15708 | | #include <string> // string |
15709 | | #include <utility> // move |
15710 | | #include <vector> // vector |
15711 | | |
15712 | | // #include <nlohmann/detail/input/binary_reader.hpp> |
15713 | | |
15714 | | // #include <nlohmann/detail/macro_scope.hpp> |
15715 | | |
15716 | | // #include <nlohmann/detail/output/output_adapters.hpp> |
15717 | | // __ _____ _____ _____ |
15718 | | // __| | __| | | | JSON for Modern C++ |
15719 | | // | | |__ | | | | | | version 3.12.0 |
15720 | | // |_____|_____|_____|_|___| https://github.com/nlohmann/json |
15721 | | // |
15722 | | // SPDX-FileCopyrightText: 2013-2026 Niels Lohmann <https://nlohmann.me> |
15723 | | // SPDX-License-Identifier: MIT |
15724 | | |
15725 | | |
15726 | | |
15727 | | #include <algorithm> // copy |
15728 | | #include <cstddef> // size_t |
15729 | | #include <iterator> // back_inserter |
15730 | | #include <memory> // shared_ptr, make_shared |
15731 | | #include <string> // basic_string |
15732 | | #include <vector> // vector |
15733 | | |
15734 | | #ifndef JSON_NO_IO |
15735 | | #include <ios> // streamsize |
15736 | | #include <ostream> // basic_ostream |
15737 | | #endif // JSON_NO_IO |
15738 | | |
15739 | | // #include <nlohmann/detail/macro_scope.hpp> |
15740 | | |
15741 | | |
15742 | | NLOHMANN_JSON_NAMESPACE_BEGIN |
15743 | | namespace detail |
15744 | | { |
15745 | | |
15746 | | /// abstract output adapter interface |
15747 | | template<typename CharType> struct output_adapter_protocol |
15748 | | { |
15749 | | virtual void write_character(CharType c) = 0; |
15750 | | virtual void write_characters(const CharType* s, std::size_t length) = 0; |
15751 | 0 | virtual ~output_adapter_protocol() = default; |
15752 | | |
15753 | 0 | output_adapter_protocol() = default; |
15754 | | output_adapter_protocol(const output_adapter_protocol&) = default; |
15755 | | output_adapter_protocol(output_adapter_protocol&&) noexcept = default; |
15756 | | output_adapter_protocol& operator=(const output_adapter_protocol&) = default; |
15757 | | output_adapter_protocol& operator=(output_adapter_protocol&&) noexcept = default; |
15758 | | }; |
15759 | | |
15760 | | /// a type to simplify interfaces |
15761 | | template<typename CharType> |
15762 | | using output_adapter_t = std::shared_ptr<output_adapter_protocol<CharType>>; |
15763 | | |
15764 | | /// output adapter for byte vectors |
15765 | | template<typename CharType, typename AllocatorType = std::allocator<CharType>> |
15766 | | class output_vector_adapter : public output_adapter_protocol<CharType> |
15767 | | { |
15768 | | public: |
15769 | | explicit output_vector_adapter(std::vector<CharType, AllocatorType>& vec) noexcept |
15770 | | : v(vec) |
15771 | | {} |
15772 | | |
15773 | | void write_character(CharType c) override |
15774 | | { |
15775 | | v.push_back(c); |
15776 | | } |
15777 | | |
15778 | | JSON_HEDLEY_NON_NULL(2) |
15779 | | void write_characters(const CharType* s, std::size_t length) override |
15780 | | { |
15781 | | v.insert(v.end(), s, s + length); |
15782 | | } |
15783 | | |
15784 | | private: |
15785 | | std::vector<CharType, AllocatorType>& v; |
15786 | | }; |
15787 | | |
15788 | | #ifndef JSON_NO_IO |
15789 | | /// output adapter for output streams |
15790 | | template<typename CharType> |
15791 | | class output_stream_adapter : public output_adapter_protocol<CharType> |
15792 | | { |
15793 | | public: |
15794 | | explicit output_stream_adapter(std::basic_ostream<CharType>& s) noexcept |
15795 | | : stream(s) |
15796 | | {} |
15797 | | |
15798 | | void write_character(CharType c) override |
15799 | | { |
15800 | | stream.put(c); |
15801 | | } |
15802 | | |
15803 | | JSON_HEDLEY_NON_NULL(2) |
15804 | | void write_characters(const CharType* s, std::size_t length) override |
15805 | | { |
15806 | | stream.write(s, static_cast<std::streamsize>(length)); |
15807 | | } |
15808 | | |
15809 | | private: |
15810 | | std::basic_ostream<CharType>& stream; |
15811 | | }; |
15812 | | #endif // JSON_NO_IO |
15813 | | |
15814 | | /// output adapter for basic_string |
15815 | | template<typename CharType, typename StringType = std::basic_string<CharType>> |
15816 | | class output_string_adapter : public output_adapter_protocol<CharType> |
15817 | | { |
15818 | | public: |
15819 | | explicit output_string_adapter(StringType& s) noexcept |
15820 | 0 | : str(s) |
15821 | 0 | {} |
15822 | | |
15823 | | void write_character(CharType c) override |
15824 | 0 | { |
15825 | 0 | str.push_back(c); |
15826 | 0 | } |
15827 | | |
15828 | | JSON_HEDLEY_NON_NULL(2) |
15829 | | void write_characters(const CharType* s, std::size_t length) override |
15830 | 0 | { |
15831 | 0 | str.append(s, length); |
15832 | 0 | } |
15833 | | |
15834 | | private: |
15835 | | StringType& str; |
15836 | | }; |
15837 | | |
15838 | | template<typename CharType, typename StringType = std::basic_string<CharType>> |
15839 | | class output_adapter |
15840 | | { |
15841 | | public: |
15842 | | template<typename AllocatorType = std::allocator<CharType>> |
15843 | | output_adapter(std::vector<CharType, AllocatorType>& vec) |
15844 | | : oa(std::make_shared<output_vector_adapter<CharType, AllocatorType>>(vec)) {} |
15845 | | |
15846 | | #ifndef JSON_NO_IO |
15847 | | output_adapter(std::basic_ostream<CharType>& s) |
15848 | | : oa(std::make_shared<output_stream_adapter<CharType>>(s)) {} |
15849 | | #endif // JSON_NO_IO |
15850 | | |
15851 | | output_adapter(StringType& s) |
15852 | 0 | : oa(std::make_shared<output_string_adapter<CharType, StringType>>(s)) {} |
15853 | | |
15854 | | operator output_adapter_t<CharType>() |
15855 | 0 | { |
15856 | 0 | return oa; |
15857 | 0 | } |
15858 | | |
15859 | | private: |
15860 | | output_adapter_t<CharType> oa = nullptr; |
15861 | | }; |
15862 | | |
15863 | | } // namespace detail |
15864 | | NLOHMANN_JSON_NAMESPACE_END |
15865 | | |
15866 | | // #include <nlohmann/detail/string_concat.hpp> |
15867 | | |
15868 | | |
15869 | | NLOHMANN_JSON_NAMESPACE_BEGIN |
15870 | | namespace detail |
15871 | | { |
15872 | | |
15873 | | /// how to encode BJData |
15874 | | enum class bjdata_version_t |
15875 | | { |
15876 | | draft2, |
15877 | | draft3, |
15878 | | }; |
15879 | | |
15880 | | /////////////////// |
15881 | | // binary writer // |
15882 | | /////////////////// |
15883 | | |
15884 | | /*! |
15885 | | @brief serialization to CBOR and MessagePack values |
15886 | | */ |
15887 | | template<typename BasicJsonType, typename CharType> |
15888 | | class binary_writer |
15889 | | { |
15890 | | using string_t = typename BasicJsonType::string_t; |
15891 | | using binary_t = typename BasicJsonType::binary_t; |
15892 | | using number_float_t = typename BasicJsonType::number_float_t; |
15893 | | |
15894 | | public: |
15895 | | /*! |
15896 | | @brief create a binary writer |
15897 | | |
15898 | | @param[in] adapter output adapter to write to |
15899 | | */ |
15900 | | explicit binary_writer(output_adapter_t<CharType> adapter) : oa(std::move(adapter)) |
15901 | | { |
15902 | | JSON_ASSERT(oa); |
15903 | | } |
15904 | | |
15905 | | /*! |
15906 | | @param[in] j JSON value to serialize |
15907 | | @pre j.type() == value_t::object |
15908 | | */ |
15909 | | void write_bson(const BasicJsonType& j) |
15910 | | { |
15911 | | switch (j.type()) |
15912 | | { |
15913 | | case value_t::object: |
15914 | | { |
15915 | | write_bson_object(*j.m_data.m_value.object); |
15916 | | break; |
15917 | | } |
15918 | | |
15919 | | case value_t::null: |
15920 | | case value_t::array: |
15921 | | case value_t::string: |
15922 | | case value_t::boolean: |
15923 | | case value_t::number_integer: |
15924 | | case value_t::number_unsigned: |
15925 | | case value_t::number_float: |
15926 | | case value_t::binary: |
15927 | | case value_t::discarded: |
15928 | | default: |
15929 | | { |
15930 | | JSON_THROW(type_error::create(317, concat("to serialize to BSON, top-level type must be object, but is ", j.type_name()), &j)); |
15931 | | } |
15932 | | } |
15933 | | } |
15934 | | |
15935 | | /*! |
15936 | | @param[in] j JSON value to serialize |
15937 | | */ |
15938 | | void write_cbor(const BasicJsonType& j) |
15939 | | { |
15940 | | switch (j.type()) |
15941 | | { |
15942 | | case value_t::null: |
15943 | | { |
15944 | | oa->write_character(to_char_type(0xF6)); |
15945 | | break; |
15946 | | } |
15947 | | |
15948 | | case value_t::boolean: |
15949 | | { |
15950 | | oa->write_character(j.m_data.m_value.boolean |
15951 | | ? to_char_type(0xF5) |
15952 | | : to_char_type(0xF4)); |
15953 | | break; |
15954 | | } |
15955 | | |
15956 | | case value_t::number_integer: |
15957 | | { |
15958 | | if (j.m_data.m_value.number_integer >= 0) |
15959 | | { |
15960 | | // CBOR does not differentiate between positive signed |
15961 | | // integers and unsigned integers. Therefore, we used the |
15962 | | // code from the value_t::number_unsigned case here. |
15963 | | if (j.m_data.m_value.number_integer <= 0x17) |
15964 | | { |
15965 | | write_number(static_cast<std::uint8_t>(j.m_data.m_value.number_integer)); |
15966 | | } |
15967 | | else if (j.m_data.m_value.number_integer <= (std::numeric_limits<std::uint8_t>::max)()) |
15968 | | { |
15969 | | oa->write_character(to_char_type(0x18)); |
15970 | | write_number(static_cast<std::uint8_t>(j.m_data.m_value.number_integer)); |
15971 | | } |
15972 | | else if (j.m_data.m_value.number_integer <= (std::numeric_limits<std::uint16_t>::max)()) |
15973 | | { |
15974 | | oa->write_character(to_char_type(0x19)); |
15975 | | write_number(static_cast<std::uint16_t>(j.m_data.m_value.number_integer)); |
15976 | | } |
15977 | | else if (j.m_data.m_value.number_integer <= (std::numeric_limits<std::uint32_t>::max)()) |
15978 | | { |
15979 | | oa->write_character(to_char_type(0x1A)); |
15980 | | write_number(static_cast<std::uint32_t>(j.m_data.m_value.number_integer)); |
15981 | | } |
15982 | | else |
15983 | | { |
15984 | | oa->write_character(to_char_type(0x1B)); |
15985 | | write_number(static_cast<std::uint64_t>(j.m_data.m_value.number_integer)); |
15986 | | } |
15987 | | } |
15988 | | else |
15989 | | { |
15990 | | // The conversions below encode the sign in the first |
15991 | | // byte, and the value is converted to a positive number. |
15992 | | const auto positive_number = -1 - j.m_data.m_value.number_integer; |
15993 | | if (j.m_data.m_value.number_integer >= -24) |
15994 | | { |
15995 | | write_number(static_cast<std::uint8_t>(0x20 + positive_number)); |
15996 | | } |
15997 | | else if (positive_number <= (std::numeric_limits<std::uint8_t>::max)()) |
15998 | | { |
15999 | | oa->write_character(to_char_type(0x38)); |
16000 | | write_number(static_cast<std::uint8_t>(positive_number)); |
16001 | | } |
16002 | | else if (positive_number <= (std::numeric_limits<std::uint16_t>::max)()) |
16003 | | { |
16004 | | oa->write_character(to_char_type(0x39)); |
16005 | | write_number(static_cast<std::uint16_t>(positive_number)); |
16006 | | } |
16007 | | else if (positive_number <= (std::numeric_limits<std::uint32_t>::max)()) |
16008 | | { |
16009 | | oa->write_character(to_char_type(0x3A)); |
16010 | | write_number(static_cast<std::uint32_t>(positive_number)); |
16011 | | } |
16012 | | else |
16013 | | { |
16014 | | oa->write_character(to_char_type(0x3B)); |
16015 | | write_number(static_cast<std::uint64_t>(positive_number)); |
16016 | | } |
16017 | | } |
16018 | | break; |
16019 | | } |
16020 | | |
16021 | | case value_t::number_unsigned: |
16022 | | { |
16023 | | if (j.m_data.m_value.number_unsigned <= 0x17) |
16024 | | { |
16025 | | write_number(static_cast<std::uint8_t>(j.m_data.m_value.number_unsigned)); |
16026 | | } |
16027 | | else if (j.m_data.m_value.number_unsigned <= (std::numeric_limits<std::uint8_t>::max)()) |
16028 | | { |
16029 | | oa->write_character(to_char_type(0x18)); |
16030 | | write_number(static_cast<std::uint8_t>(j.m_data.m_value.number_unsigned)); |
16031 | | } |
16032 | | else if (j.m_data.m_value.number_unsigned <= (std::numeric_limits<std::uint16_t>::max)()) |
16033 | | { |
16034 | | oa->write_character(to_char_type(0x19)); |
16035 | | write_number(static_cast<std::uint16_t>(j.m_data.m_value.number_unsigned)); |
16036 | | } |
16037 | | else if (j.m_data.m_value.number_unsigned <= (std::numeric_limits<std::uint32_t>::max)()) |
16038 | | { |
16039 | | oa->write_character(to_char_type(0x1A)); |
16040 | | write_number(static_cast<std::uint32_t>(j.m_data.m_value.number_unsigned)); |
16041 | | } |
16042 | | else |
16043 | | { |
16044 | | oa->write_character(to_char_type(0x1B)); |
16045 | | write_number(static_cast<std::uint64_t>(j.m_data.m_value.number_unsigned)); |
16046 | | } |
16047 | | break; |
16048 | | } |
16049 | | |
16050 | | case value_t::number_float: |
16051 | | { |
16052 | | if (std::isnan(j.m_data.m_value.number_float)) |
16053 | | { |
16054 | | // NaN is 0xf97e00 in CBOR |
16055 | | oa->write_character(to_char_type(0xF9)); |
16056 | | oa->write_character(to_char_type(0x7E)); |
16057 | | oa->write_character(to_char_type(0x00)); |
16058 | | } |
16059 | | else if (std::isinf(j.m_data.m_value.number_float)) |
16060 | | { |
16061 | | // Infinity is 0xf97c00, -Infinity is 0xf9fc00 |
16062 | | oa->write_character(to_char_type(0xf9)); |
16063 | | oa->write_character(j.m_data.m_value.number_float > 0 ? to_char_type(0x7C) : to_char_type(0xFC)); |
16064 | | oa->write_character(to_char_type(0x00)); |
16065 | | } |
16066 | | else |
16067 | | { |
16068 | | write_compact_float(j.m_data.m_value.number_float, detail::input_format_t::cbor); |
16069 | | } |
16070 | | break; |
16071 | | } |
16072 | | |
16073 | | case value_t::string: |
16074 | | { |
16075 | | // step 1: write control byte and the string length |
16076 | | const auto N = j.m_data.m_value.string->size(); |
16077 | | if (N <= 0x17) |
16078 | | { |
16079 | | write_number(static_cast<std::uint8_t>(0x60 + N)); |
16080 | | } |
16081 | | else if (N <= (std::numeric_limits<std::uint8_t>::max)()) |
16082 | | { |
16083 | | oa->write_character(to_char_type(0x78)); |
16084 | | write_number(static_cast<std::uint8_t>(N)); |
16085 | | } |
16086 | | else if (N <= (std::numeric_limits<std::uint16_t>::max)()) |
16087 | | { |
16088 | | oa->write_character(to_char_type(0x79)); |
16089 | | write_number(static_cast<std::uint16_t>(N)); |
16090 | | } |
16091 | | else if (N <= (std::numeric_limits<std::uint32_t>::max)()) |
16092 | | { |
16093 | | oa->write_character(to_char_type(0x7A)); |
16094 | | write_number(static_cast<std::uint32_t>(N)); |
16095 | | } |
16096 | | // LCOV_EXCL_START |
16097 | | else if (N <= (std::numeric_limits<std::uint64_t>::max)()) |
16098 | | { |
16099 | | oa->write_character(to_char_type(0x7B)); |
16100 | | write_number(static_cast<std::uint64_t>(N)); |
16101 | | } |
16102 | | // LCOV_EXCL_STOP |
16103 | | |
16104 | | // step 2: write the string |
16105 | | oa->write_characters( |
16106 | | reinterpret_cast<const CharType*>(j.m_data.m_value.string->c_str()), |
16107 | | j.m_data.m_value.string->size()); |
16108 | | break; |
16109 | | } |
16110 | | |
16111 | | case value_t::array: |
16112 | | { |
16113 | | // step 1: write control byte and the array size |
16114 | | const auto N = j.m_data.m_value.array->size(); |
16115 | | if (N <= 0x17) |
16116 | | { |
16117 | | write_number(static_cast<std::uint8_t>(0x80 + N)); |
16118 | | } |
16119 | | else if (N <= (std::numeric_limits<std::uint8_t>::max)()) |
16120 | | { |
16121 | | oa->write_character(to_char_type(0x98)); |
16122 | | write_number(static_cast<std::uint8_t>(N)); |
16123 | | } |
16124 | | else if (N <= (std::numeric_limits<std::uint16_t>::max)()) |
16125 | | { |
16126 | | oa->write_character(to_char_type(0x99)); |
16127 | | write_number(static_cast<std::uint16_t>(N)); |
16128 | | } |
16129 | | else if (N <= (std::numeric_limits<std::uint32_t>::max)()) |
16130 | | { |
16131 | | oa->write_character(to_char_type(0x9A)); |
16132 | | write_number(static_cast<std::uint32_t>(N)); |
16133 | | } |
16134 | | // LCOV_EXCL_START |
16135 | | else if (N <= (std::numeric_limits<std::uint64_t>::max)()) |
16136 | | { |
16137 | | oa->write_character(to_char_type(0x9B)); |
16138 | | write_number(static_cast<std::uint64_t>(N)); |
16139 | | } |
16140 | | // LCOV_EXCL_STOP |
16141 | | |
16142 | | // step 2: write each element |
16143 | | for (const auto& el : *j.m_data.m_value.array) |
16144 | | { |
16145 | | write_cbor(el); |
16146 | | } |
16147 | | break; |
16148 | | } |
16149 | | |
16150 | | case value_t::binary: |
16151 | | { |
16152 | | if (j.m_data.m_value.binary->has_subtype()) |
16153 | | { |
16154 | | if (j.m_data.m_value.binary->subtype() <= (std::numeric_limits<std::uint8_t>::max)()) |
16155 | | { |
16156 | | write_number(static_cast<std::uint8_t>(0xd8)); |
16157 | | write_number(static_cast<std::uint8_t>(j.m_data.m_value.binary->subtype())); |
16158 | | } |
16159 | | else if (j.m_data.m_value.binary->subtype() <= (std::numeric_limits<std::uint16_t>::max)()) |
16160 | | { |
16161 | | write_number(static_cast<std::uint8_t>(0xd9)); |
16162 | | write_number(static_cast<std::uint16_t>(j.m_data.m_value.binary->subtype())); |
16163 | | } |
16164 | | else if (j.m_data.m_value.binary->subtype() <= (std::numeric_limits<std::uint32_t>::max)()) |
16165 | | { |
16166 | | write_number(static_cast<std::uint8_t>(0xda)); |
16167 | | write_number(static_cast<std::uint32_t>(j.m_data.m_value.binary->subtype())); |
16168 | | } |
16169 | | else if (j.m_data.m_value.binary->subtype() <= (std::numeric_limits<std::uint64_t>::max)()) |
16170 | | { |
16171 | | write_number(static_cast<std::uint8_t>(0xdb)); |
16172 | | write_number(static_cast<std::uint64_t>(j.m_data.m_value.binary->subtype())); |
16173 | | } |
16174 | | } |
16175 | | |
16176 | | // step 1: write control byte and the binary array size |
16177 | | const auto N = j.m_data.m_value.binary->size(); |
16178 | | if (N <= 0x17) |
16179 | | { |
16180 | | write_number(static_cast<std::uint8_t>(0x40 + N)); |
16181 | | } |
16182 | | else if (N <= (std::numeric_limits<std::uint8_t>::max)()) |
16183 | | { |
16184 | | oa->write_character(to_char_type(0x58)); |
16185 | | write_number(static_cast<std::uint8_t>(N)); |
16186 | | } |
16187 | | else if (N <= (std::numeric_limits<std::uint16_t>::max)()) |
16188 | | { |
16189 | | oa->write_character(to_char_type(0x59)); |
16190 | | write_number(static_cast<std::uint16_t>(N)); |
16191 | | } |
16192 | | else if (N <= (std::numeric_limits<std::uint32_t>::max)()) |
16193 | | { |
16194 | | oa->write_character(to_char_type(0x5A)); |
16195 | | write_number(static_cast<std::uint32_t>(N)); |
16196 | | } |
16197 | | // LCOV_EXCL_START |
16198 | | else if (N <= (std::numeric_limits<std::uint64_t>::max)()) |
16199 | | { |
16200 | | oa->write_character(to_char_type(0x5B)); |
16201 | | write_number(static_cast<std::uint64_t>(N)); |
16202 | | } |
16203 | | // LCOV_EXCL_STOP |
16204 | | |
16205 | | // step 2: write each element |
16206 | | oa->write_characters( |
16207 | | reinterpret_cast<const CharType*>(j.m_data.m_value.binary->data()), |
16208 | | N); |
16209 | | |
16210 | | break; |
16211 | | } |
16212 | | |
16213 | | case value_t::object: |
16214 | | { |
16215 | | // step 1: write control byte and the object size |
16216 | | const auto N = j.m_data.m_value.object->size(); |
16217 | | if (N <= 0x17) |
16218 | | { |
16219 | | write_number(static_cast<std::uint8_t>(0xA0 + N)); |
16220 | | } |
16221 | | else if (N <= (std::numeric_limits<std::uint8_t>::max)()) |
16222 | | { |
16223 | | oa->write_character(to_char_type(0xB8)); |
16224 | | write_number(static_cast<std::uint8_t>(N)); |
16225 | | } |
16226 | | else if (N <= (std::numeric_limits<std::uint16_t>::max)()) |
16227 | | { |
16228 | | oa->write_character(to_char_type(0xB9)); |
16229 | | write_number(static_cast<std::uint16_t>(N)); |
16230 | | } |
16231 | | else if (N <= (std::numeric_limits<std::uint32_t>::max)()) |
16232 | | { |
16233 | | oa->write_character(to_char_type(0xBA)); |
16234 | | write_number(static_cast<std::uint32_t>(N)); |
16235 | | } |
16236 | | // LCOV_EXCL_START |
16237 | | else if (N <= (std::numeric_limits<std::uint64_t>::max)()) |
16238 | | { |
16239 | | oa->write_character(to_char_type(0xBB)); |
16240 | | write_number(static_cast<std::uint64_t>(N)); |
16241 | | } |
16242 | | // LCOV_EXCL_STOP |
16243 | | |
16244 | | // step 2: write each element |
16245 | | for (const auto& el : *j.m_data.m_value.object) |
16246 | | { |
16247 | | write_cbor(el.first); |
16248 | | write_cbor(el.second); |
16249 | | } |
16250 | | break; |
16251 | | } |
16252 | | |
16253 | | case value_t::discarded: |
16254 | | default: |
16255 | | break; |
16256 | | } |
16257 | | } |
16258 | | |
16259 | | /*! |
16260 | | @param[in] j JSON value to serialize |
16261 | | */ |
16262 | | void write_msgpack(const BasicJsonType& j) |
16263 | | { |
16264 | | switch (j.type()) |
16265 | | { |
16266 | | case value_t::null: // nil |
16267 | | { |
16268 | | oa->write_character(to_char_type(0xC0)); |
16269 | | break; |
16270 | | } |
16271 | | |
16272 | | case value_t::boolean: // true and false |
16273 | | { |
16274 | | oa->write_character(j.m_data.m_value.boolean |
16275 | | ? to_char_type(0xC3) |
16276 | | : to_char_type(0xC2)); |
16277 | | break; |
16278 | | } |
16279 | | |
16280 | | case value_t::number_integer: |
16281 | | { |
16282 | | if (j.m_data.m_value.number_integer >= 0) |
16283 | | { |
16284 | | // MessagePack does not differentiate between positive |
16285 | | // signed integers and unsigned integers. Therefore, we used |
16286 | | // the code from the value_t::number_unsigned case here. |
16287 | | if (j.m_data.m_value.number_unsigned < 128) |
16288 | | { |
16289 | | // positive fixnum |
16290 | | write_number(static_cast<std::uint8_t>(j.m_data.m_value.number_integer)); |
16291 | | } |
16292 | | else if (j.m_data.m_value.number_unsigned <= (std::numeric_limits<std::uint8_t>::max)()) |
16293 | | { |
16294 | | // uint 8 |
16295 | | oa->write_character(to_char_type(0xCC)); |
16296 | | write_number(static_cast<std::uint8_t>(j.m_data.m_value.number_integer)); |
16297 | | } |
16298 | | else if (j.m_data.m_value.number_unsigned <= (std::numeric_limits<std::uint16_t>::max)()) |
16299 | | { |
16300 | | // uint 16 |
16301 | | oa->write_character(to_char_type(0xCD)); |
16302 | | write_number(static_cast<std::uint16_t>(j.m_data.m_value.number_integer)); |
16303 | | } |
16304 | | else if (j.m_data.m_value.number_unsigned <= (std::numeric_limits<std::uint32_t>::max)()) |
16305 | | { |
16306 | | // uint 32 |
16307 | | oa->write_character(to_char_type(0xCE)); |
16308 | | write_number(static_cast<std::uint32_t>(j.m_data.m_value.number_integer)); |
16309 | | } |
16310 | | else if (j.m_data.m_value.number_unsigned <= (std::numeric_limits<std::uint64_t>::max)()) |
16311 | | { |
16312 | | // uint 64 |
16313 | | oa->write_character(to_char_type(0xCF)); |
16314 | | write_number(static_cast<std::uint64_t>(j.m_data.m_value.number_integer)); |
16315 | | } |
16316 | | } |
16317 | | else |
16318 | | { |
16319 | | if (j.m_data.m_value.number_integer >= -32) |
16320 | | { |
16321 | | // negative fixnum |
16322 | | write_number(static_cast<std::int8_t>(j.m_data.m_value.number_integer)); |
16323 | | } |
16324 | | else if (j.m_data.m_value.number_integer >= (std::numeric_limits<std::int8_t>::min)() && |
16325 | | j.m_data.m_value.number_integer <= (std::numeric_limits<std::int8_t>::max)()) |
16326 | | { |
16327 | | // int 8 |
16328 | | oa->write_character(to_char_type(0xD0)); |
16329 | | write_number(static_cast<std::int8_t>(j.m_data.m_value.number_integer)); |
16330 | | } |
16331 | | else if (j.m_data.m_value.number_integer >= (std::numeric_limits<std::int16_t>::min)() && |
16332 | | j.m_data.m_value.number_integer <= (std::numeric_limits<std::int16_t>::max)()) |
16333 | | { |
16334 | | // int 16 |
16335 | | oa->write_character(to_char_type(0xD1)); |
16336 | | write_number(static_cast<std::int16_t>(j.m_data.m_value.number_integer)); |
16337 | | } |
16338 | | else if (j.m_data.m_value.number_integer >= (std::numeric_limits<std::int32_t>::min)() && |
16339 | | j.m_data.m_value.number_integer <= (std::numeric_limits<std::int32_t>::max)()) |
16340 | | { |
16341 | | // int 32 |
16342 | | oa->write_character(to_char_type(0xD2)); |
16343 | | write_number(static_cast<std::int32_t>(j.m_data.m_value.number_integer)); |
16344 | | } |
16345 | | else if (j.m_data.m_value.number_integer >= (std::numeric_limits<std::int64_t>::min)() && |
16346 | | j.m_data.m_value.number_integer <= (std::numeric_limits<std::int64_t>::max)()) |
16347 | | { |
16348 | | // int 64 |
16349 | | oa->write_character(to_char_type(0xD3)); |
16350 | | write_number(static_cast<std::int64_t>(j.m_data.m_value.number_integer)); |
16351 | | } |
16352 | | } |
16353 | | break; |
16354 | | } |
16355 | | |
16356 | | case value_t::number_unsigned: |
16357 | | { |
16358 | | if (j.m_data.m_value.number_unsigned < 128) |
16359 | | { |
16360 | | // positive fixnum |
16361 | | write_number(static_cast<std::uint8_t>(j.m_data.m_value.number_integer)); |
16362 | | } |
16363 | | else if (j.m_data.m_value.number_unsigned <= (std::numeric_limits<std::uint8_t>::max)()) |
16364 | | { |
16365 | | // uint 8 |
16366 | | oa->write_character(to_char_type(0xCC)); |
16367 | | write_number(static_cast<std::uint8_t>(j.m_data.m_value.number_integer)); |
16368 | | } |
16369 | | else if (j.m_data.m_value.number_unsigned <= (std::numeric_limits<std::uint16_t>::max)()) |
16370 | | { |
16371 | | // uint 16 |
16372 | | oa->write_character(to_char_type(0xCD)); |
16373 | | write_number(static_cast<std::uint16_t>(j.m_data.m_value.number_integer)); |
16374 | | } |
16375 | | else if (j.m_data.m_value.number_unsigned <= (std::numeric_limits<std::uint32_t>::max)()) |
16376 | | { |
16377 | | // uint 32 |
16378 | | oa->write_character(to_char_type(0xCE)); |
16379 | | write_number(static_cast<std::uint32_t>(j.m_data.m_value.number_integer)); |
16380 | | } |
16381 | | else if (j.m_data.m_value.number_unsigned <= (std::numeric_limits<std::uint64_t>::max)()) |
16382 | | { |
16383 | | // uint 64 |
16384 | | oa->write_character(to_char_type(0xCF)); |
16385 | | write_number(static_cast<std::uint64_t>(j.m_data.m_value.number_integer)); |
16386 | | } |
16387 | | break; |
16388 | | } |
16389 | | |
16390 | | case value_t::number_float: |
16391 | | { |
16392 | | write_compact_float(j.m_data.m_value.number_float, detail::input_format_t::msgpack); |
16393 | | break; |
16394 | | } |
16395 | | |
16396 | | case value_t::string: |
16397 | | { |
16398 | | // step 1: write control byte and the string length |
16399 | | const auto N = j.m_data.m_value.string->size(); |
16400 | | if (N <= 31) |
16401 | | { |
16402 | | // fixstr |
16403 | | write_number(static_cast<std::uint8_t>(0xA0 | N)); |
16404 | | } |
16405 | | else if (N <= (std::numeric_limits<std::uint8_t>::max)()) |
16406 | | { |
16407 | | // str 8 |
16408 | | oa->write_character(to_char_type(0xD9)); |
16409 | | write_number(static_cast<std::uint8_t>(N)); |
16410 | | } |
16411 | | else if (N <= (std::numeric_limits<std::uint16_t>::max)()) |
16412 | | { |
16413 | | // str 16 |
16414 | | oa->write_character(to_char_type(0xDA)); |
16415 | | write_number(static_cast<std::uint16_t>(N)); |
16416 | | } |
16417 | | else if (N <= (std::numeric_limits<std::uint32_t>::max)()) |
16418 | | { |
16419 | | // str 32 |
16420 | | oa->write_character(to_char_type(0xDB)); |
16421 | | write_number(static_cast<std::uint32_t>(N)); |
16422 | | } |
16423 | | |
16424 | | // step 2: write the string |
16425 | | oa->write_characters( |
16426 | | reinterpret_cast<const CharType*>(j.m_data.m_value.string->c_str()), |
16427 | | j.m_data.m_value.string->size()); |
16428 | | break; |
16429 | | } |
16430 | | |
16431 | | case value_t::array: |
16432 | | { |
16433 | | // step 1: write control byte and the array size |
16434 | | const auto N = j.m_data.m_value.array->size(); |
16435 | | if (N <= 15) |
16436 | | { |
16437 | | // fixarray |
16438 | | write_number(static_cast<std::uint8_t>(0x90 | N)); |
16439 | | } |
16440 | | else if (N <= (std::numeric_limits<std::uint16_t>::max)()) |
16441 | | { |
16442 | | // array 16 |
16443 | | oa->write_character(to_char_type(0xDC)); |
16444 | | write_number(static_cast<std::uint16_t>(N)); |
16445 | | } |
16446 | | else if (N <= (std::numeric_limits<std::uint32_t>::max)()) |
16447 | | { |
16448 | | // array 32 |
16449 | | oa->write_character(to_char_type(0xDD)); |
16450 | | write_number(static_cast<std::uint32_t>(N)); |
16451 | | } |
16452 | | |
16453 | | // step 2: write each element |
16454 | | for (const auto& el : *j.m_data.m_value.array) |
16455 | | { |
16456 | | write_msgpack(el); |
16457 | | } |
16458 | | break; |
16459 | | } |
16460 | | |
16461 | | case value_t::binary: |
16462 | | { |
16463 | | // step 0: determine if the binary type has a set subtype to |
16464 | | // determine whether to use the ext or fixext types |
16465 | | const bool use_ext = j.m_data.m_value.binary->has_subtype(); |
16466 | | |
16467 | | // step 1: write control byte and the byte string length |
16468 | | const auto N = j.m_data.m_value.binary->size(); |
16469 | | if (N <= (std::numeric_limits<std::uint8_t>::max)()) |
16470 | | { |
16471 | | std::uint8_t output_type{}; |
16472 | | bool fixed = true; |
16473 | | if (use_ext) |
16474 | | { |
16475 | | switch (N) |
16476 | | { |
16477 | | case 1: |
16478 | | output_type = 0xD4; // fixext 1 |
16479 | | break; |
16480 | | case 2: |
16481 | | output_type = 0xD5; // fixext 2 |
16482 | | break; |
16483 | | case 4: |
16484 | | output_type = 0xD6; // fixext 4 |
16485 | | break; |
16486 | | case 8: |
16487 | | output_type = 0xD7; // fixext 8 |
16488 | | break; |
16489 | | case 16: |
16490 | | output_type = 0xD8; // fixext 16 |
16491 | | break; |
16492 | | default: |
16493 | | output_type = 0xC7; // ext 8 |
16494 | | fixed = false; |
16495 | | break; |
16496 | | } |
16497 | | |
16498 | | } |
16499 | | else |
16500 | | { |
16501 | | output_type = 0xC4; // bin 8 |
16502 | | fixed = false; |
16503 | | } |
16504 | | |
16505 | | oa->write_character(to_char_type(output_type)); |
16506 | | if (!fixed) |
16507 | | { |
16508 | | write_number(static_cast<std::uint8_t>(N)); |
16509 | | } |
16510 | | } |
16511 | | else if (N <= (std::numeric_limits<std::uint16_t>::max)()) |
16512 | | { |
16513 | | const std::uint8_t output_type = use_ext |
16514 | | ? 0xC8 // ext 16 |
16515 | | : 0xC5; // bin 16 |
16516 | | |
16517 | | oa->write_character(to_char_type(output_type)); |
16518 | | write_number(static_cast<std::uint16_t>(N)); |
16519 | | } |
16520 | | else if (N <= (std::numeric_limits<std::uint32_t>::max)()) |
16521 | | { |
16522 | | const std::uint8_t output_type = use_ext |
16523 | | ? 0xC9 // ext 32 |
16524 | | : 0xC6; // bin 32 |
16525 | | |
16526 | | oa->write_character(to_char_type(output_type)); |
16527 | | write_number(static_cast<std::uint32_t>(N)); |
16528 | | } |
16529 | | |
16530 | | // step 1.5: if this is an ext type, write the subtype |
16531 | | if (use_ext) |
16532 | | { |
16533 | | write_number(static_cast<std::int8_t>(j.m_data.m_value.binary->subtype())); |
16534 | | } |
16535 | | |
16536 | | // step 2: write the byte string |
16537 | | oa->write_characters( |
16538 | | reinterpret_cast<const CharType*>(j.m_data.m_value.binary->data()), |
16539 | | N); |
16540 | | |
16541 | | break; |
16542 | | } |
16543 | | |
16544 | | case value_t::object: |
16545 | | { |
16546 | | // step 1: write control byte and the object size |
16547 | | const auto N = j.m_data.m_value.object->size(); |
16548 | | if (N <= 15) |
16549 | | { |
16550 | | // fixmap |
16551 | | write_number(static_cast<std::uint8_t>(0x80 | (N & 0xF))); |
16552 | | } |
16553 | | else if (N <= (std::numeric_limits<std::uint16_t>::max)()) |
16554 | | { |
16555 | | // map 16 |
16556 | | oa->write_character(to_char_type(0xDE)); |
16557 | | write_number(static_cast<std::uint16_t>(N)); |
16558 | | } |
16559 | | else if (N <= (std::numeric_limits<std::uint32_t>::max)()) |
16560 | | { |
16561 | | // map 32 |
16562 | | oa->write_character(to_char_type(0xDF)); |
16563 | | write_number(static_cast<std::uint32_t>(N)); |
16564 | | } |
16565 | | |
16566 | | // step 2: write each element |
16567 | | for (const auto& el : *j.m_data.m_value.object) |
16568 | | { |
16569 | | write_msgpack(el.first); |
16570 | | write_msgpack(el.second); |
16571 | | } |
16572 | | break; |
16573 | | } |
16574 | | |
16575 | | case value_t::discarded: |
16576 | | default: |
16577 | | break; |
16578 | | } |
16579 | | } |
16580 | | |
16581 | | /*! |
16582 | | @param[in] j JSON value to serialize |
16583 | | @param[in] use_count whether to use '#' prefixes (optimized format) |
16584 | | @param[in] use_type whether to use '$' prefixes (optimized format) |
16585 | | @param[in] add_prefix whether prefixes need to be used for this value |
16586 | | @param[in] use_bjdata whether write in BJData format, default is false |
16587 | | @param[in] bjdata_version which BJData version to use, default is draft2 |
16588 | | */ |
16589 | | void write_ubjson(const BasicJsonType& j, const bool use_count, |
16590 | | const bool use_type, const bool add_prefix = true, |
16591 | | const bool use_bjdata = false, const bjdata_version_t bjdata_version = bjdata_version_t::draft2) |
16592 | | { |
16593 | | const bool bjdata_draft3 = use_bjdata && bjdata_version == bjdata_version_t::draft3; |
16594 | | |
16595 | | switch (j.type()) |
16596 | | { |
16597 | | case value_t::null: |
16598 | | { |
16599 | | if (add_prefix) |
16600 | | { |
16601 | | oa->write_character(to_char_type('Z')); |
16602 | | } |
16603 | | break; |
16604 | | } |
16605 | | |
16606 | | case value_t::boolean: |
16607 | | { |
16608 | | if (add_prefix) |
16609 | | { |
16610 | | oa->write_character(j.m_data.m_value.boolean |
16611 | | ? to_char_type('T') |
16612 | | : to_char_type('F')); |
16613 | | } |
16614 | | break; |
16615 | | } |
16616 | | |
16617 | | case value_t::number_integer: |
16618 | | { |
16619 | | write_number_with_ubjson_prefix(j.m_data.m_value.number_integer, add_prefix, use_bjdata); |
16620 | | break; |
16621 | | } |
16622 | | |
16623 | | case value_t::number_unsigned: |
16624 | | { |
16625 | | write_number_with_ubjson_prefix(j.m_data.m_value.number_unsigned, add_prefix, use_bjdata); |
16626 | | break; |
16627 | | } |
16628 | | |
16629 | | case value_t::number_float: |
16630 | | { |
16631 | | write_number_with_ubjson_prefix(j.m_data.m_value.number_float, add_prefix, use_bjdata); |
16632 | | break; |
16633 | | } |
16634 | | |
16635 | | case value_t::string: |
16636 | | { |
16637 | | if (add_prefix) |
16638 | | { |
16639 | | oa->write_character(to_char_type('S')); |
16640 | | } |
16641 | | write_number_with_ubjson_prefix(j.m_data.m_value.string->size(), true, use_bjdata); |
16642 | | oa->write_characters( |
16643 | | reinterpret_cast<const CharType*>(j.m_data.m_value.string->c_str()), |
16644 | | j.m_data.m_value.string->size()); |
16645 | | break; |
16646 | | } |
16647 | | |
16648 | | case value_t::array: |
16649 | | { |
16650 | | if (add_prefix) |
16651 | | { |
16652 | | oa->write_character(to_char_type('[')); |
16653 | | } |
16654 | | |
16655 | | bool prefix_required = true; |
16656 | | if (use_type && !j.m_data.m_value.array->empty()) |
16657 | | { |
16658 | | JSON_ASSERT(use_count); |
16659 | | const CharType first_prefix = ubjson_prefix(j.front(), use_bjdata); |
16660 | | const bool same_prefix = std::all_of(j.begin() + 1, j.end(), |
16661 | | [this, first_prefix, use_bjdata](const BasicJsonType & v) |
16662 | | { |
16663 | | return ubjson_prefix(v, use_bjdata) == first_prefix; |
16664 | | }); |
16665 | | |
16666 | | std::vector<CharType> bjdx = {'[', '{', 'S', 'H', 'T', 'F', 'N', 'Z'}; // excluded markers in bjdata optimized type |
16667 | | |
16668 | | if (same_prefix && !(use_bjdata && std::find(bjdx.begin(), bjdx.end(), first_prefix) != bjdx.end())) |
16669 | | { |
16670 | | prefix_required = false; |
16671 | | oa->write_character(to_char_type('$')); |
16672 | | oa->write_character(first_prefix); |
16673 | | } |
16674 | | } |
16675 | | |
16676 | | if (use_count) |
16677 | | { |
16678 | | oa->write_character(to_char_type('#')); |
16679 | | write_number_with_ubjson_prefix(j.m_data.m_value.array->size(), true, use_bjdata); |
16680 | | } |
16681 | | |
16682 | | for (const auto& el : *j.m_data.m_value.array) |
16683 | | { |
16684 | | write_ubjson(el, use_count, use_type, prefix_required, use_bjdata, bjdata_version); |
16685 | | } |
16686 | | |
16687 | | if (!use_count) |
16688 | | { |
16689 | | oa->write_character(to_char_type(']')); |
16690 | | } |
16691 | | |
16692 | | break; |
16693 | | } |
16694 | | |
16695 | | case value_t::binary: |
16696 | | { |
16697 | | if (add_prefix) |
16698 | | { |
16699 | | oa->write_character(to_char_type('[')); |
16700 | | } |
16701 | | |
16702 | | if (use_type && (bjdata_draft3 || !j.m_data.m_value.binary->empty())) |
16703 | | { |
16704 | | JSON_ASSERT(use_count); |
16705 | | oa->write_character(to_char_type('$')); |
16706 | | oa->write_character(bjdata_draft3 ? 'B' : 'U'); |
16707 | | } |
16708 | | |
16709 | | if (use_count) |
16710 | | { |
16711 | | oa->write_character(to_char_type('#')); |
16712 | | write_number_with_ubjson_prefix(j.m_data.m_value.binary->size(), true, use_bjdata); |
16713 | | } |
16714 | | |
16715 | | if (use_type) |
16716 | | { |
16717 | | oa->write_characters( |
16718 | | reinterpret_cast<const CharType*>(j.m_data.m_value.binary->data()), |
16719 | | j.m_data.m_value.binary->size()); |
16720 | | } |
16721 | | else |
16722 | | { |
16723 | | for (size_t i = 0; i < j.m_data.m_value.binary->size(); ++i) |
16724 | | { |
16725 | | oa->write_character(to_char_type(bjdata_draft3 ? 'B' : 'U')); |
16726 | | oa->write_character(j.m_data.m_value.binary->data()[i]); |
16727 | | } |
16728 | | } |
16729 | | |
16730 | | if (!use_count) |
16731 | | { |
16732 | | oa->write_character(to_char_type(']')); |
16733 | | } |
16734 | | |
16735 | | break; |
16736 | | } |
16737 | | |
16738 | | case value_t::object: |
16739 | | { |
16740 | | if (use_bjdata && j.m_data.m_value.object->size() == 3 && j.m_data.m_value.object->find("_ArrayType_") != j.m_data.m_value.object->end() && j.m_data.m_value.object->find("_ArraySize_") != j.m_data.m_value.object->end() && j.m_data.m_value.object->find("_ArrayData_") != j.m_data.m_value.object->end()) |
16741 | | { |
16742 | | if (!write_bjdata_ndarray(*j.m_data.m_value.object, use_count, use_type, bjdata_version)) // decode bjdata ndarray in the JData format (https://github.com/NeuroJSON/jdata) |
16743 | | { |
16744 | | break; |
16745 | | } |
16746 | | } |
16747 | | |
16748 | | if (add_prefix) |
16749 | | { |
16750 | | oa->write_character(to_char_type('{')); |
16751 | | } |
16752 | | |
16753 | | bool prefix_required = true; |
16754 | | if (use_type && !j.m_data.m_value.object->empty()) |
16755 | | { |
16756 | | JSON_ASSERT(use_count); |
16757 | | const CharType first_prefix = ubjson_prefix(j.front(), use_bjdata); |
16758 | | const bool same_prefix = std::all_of(j.begin(), j.end(), |
16759 | | [this, first_prefix, use_bjdata](const BasicJsonType & v) |
16760 | | { |
16761 | | return ubjson_prefix(v, use_bjdata) == first_prefix; |
16762 | | }); |
16763 | | |
16764 | | std::vector<CharType> bjdx = {'[', '{', 'S', 'H', 'T', 'F', 'N', 'Z'}; // excluded markers in bjdata optimized type |
16765 | | |
16766 | | if (same_prefix && !(use_bjdata && std::find(bjdx.begin(), bjdx.end(), first_prefix) != bjdx.end())) |
16767 | | { |
16768 | | prefix_required = false; |
16769 | | oa->write_character(to_char_type('$')); |
16770 | | oa->write_character(first_prefix); |
16771 | | } |
16772 | | } |
16773 | | |
16774 | | if (use_count) |
16775 | | { |
16776 | | oa->write_character(to_char_type('#')); |
16777 | | write_number_with_ubjson_prefix(j.m_data.m_value.object->size(), true, use_bjdata); |
16778 | | } |
16779 | | |
16780 | | for (const auto& el : *j.m_data.m_value.object) |
16781 | | { |
16782 | | write_number_with_ubjson_prefix(el.first.size(), true, use_bjdata); |
16783 | | oa->write_characters( |
16784 | | reinterpret_cast<const CharType*>(el.first.c_str()), |
16785 | | el.first.size()); |
16786 | | write_ubjson(el.second, use_count, use_type, prefix_required, use_bjdata, bjdata_version); |
16787 | | } |
16788 | | |
16789 | | if (!use_count) |
16790 | | { |
16791 | | oa->write_character(to_char_type('}')); |
16792 | | } |
16793 | | |
16794 | | break; |
16795 | | } |
16796 | | |
16797 | | case value_t::discarded: |
16798 | | default: |
16799 | | break; |
16800 | | } |
16801 | | } |
16802 | | |
16803 | | private: |
16804 | | ////////// |
16805 | | // BSON // |
16806 | | ////////// |
16807 | | |
16808 | | /*! |
16809 | | @return The size of a BSON document entry header, including the id marker |
16810 | | and the entry name size (and its null-terminator). |
16811 | | */ |
16812 | | static std::size_t calc_bson_entry_header_size(const string_t& name, const BasicJsonType& j) |
16813 | | { |
16814 | | const auto it = name.find(static_cast<typename string_t::value_type>(0)); |
16815 | | if (JSON_HEDLEY_UNLIKELY(it != BasicJsonType::string_t::npos)) |
16816 | | { |
16817 | | JSON_THROW(out_of_range::create(409, concat("BSON key cannot contain code point U+0000 (at byte ", std::to_string(it), ")"), &j)); |
16818 | | } |
16819 | | |
16820 | | static_cast<void>(j); |
16821 | | return /*id*/ 1ul + name.size() + /*zero-terminator*/1u; |
16822 | | } |
16823 | | |
16824 | | /*! |
16825 | | @brief Writes the given @a element_type and @a name to the output adapter |
16826 | | */ |
16827 | | void write_bson_entry_header(const string_t& name, |
16828 | | const std::uint8_t element_type) |
16829 | | { |
16830 | | oa->write_character(to_char_type(element_type)); // boolean |
16831 | | oa->write_characters( |
16832 | | reinterpret_cast<const CharType*>(name.c_str()), |
16833 | | name.size() + 1u); |
16834 | | } |
16835 | | |
16836 | | /*! |
16837 | | @brief Writes a BSON element with key @a name and boolean value @a value |
16838 | | */ |
16839 | | void write_bson_boolean(const string_t& name, |
16840 | | const bool value) |
16841 | | { |
16842 | | write_bson_entry_header(name, 0x08); |
16843 | | oa->write_character(value ? to_char_type(0x01) : to_char_type(0x00)); |
16844 | | } |
16845 | | |
16846 | | /*! |
16847 | | @brief Writes a BSON element with key @a name and double value @a value |
16848 | | */ |
16849 | | void write_bson_double(const string_t& name, |
16850 | | const double value) |
16851 | | { |
16852 | | write_bson_entry_header(name, 0x01); |
16853 | | write_number<double>(value, true); |
16854 | | } |
16855 | | |
16856 | | /*! |
16857 | | @return The size of the BSON-encoded string in @a value |
16858 | | */ |
16859 | | static std::size_t calc_bson_string_size(const string_t& value) |
16860 | | { |
16861 | | return sizeof(std::int32_t) + value.size() + 1ul; |
16862 | | } |
16863 | | |
16864 | | /*! |
16865 | | @brief Writes a BSON element with key @a name and string value @a value |
16866 | | */ |
16867 | | void write_bson_string(const string_t& name, |
16868 | | const string_t& value) |
16869 | | { |
16870 | | write_bson_entry_header(name, 0x02); |
16871 | | |
16872 | | write_number<std::int32_t>(static_cast<std::int32_t>(value.size() + 1ul), true); |
16873 | | oa->write_characters( |
16874 | | reinterpret_cast<const CharType*>(value.c_str()), |
16875 | | value.size() + 1); |
16876 | | } |
16877 | | |
16878 | | /*! |
16879 | | @brief Writes a BSON element with key @a name and null value |
16880 | | */ |
16881 | | void write_bson_null(const string_t& name) |
16882 | | { |
16883 | | write_bson_entry_header(name, 0x0A); |
16884 | | } |
16885 | | |
16886 | | /*! |
16887 | | @return The size of the BSON-encoded integer @a value |
16888 | | */ |
16889 | | static std::size_t calc_bson_integer_size(const std::int64_t value) |
16890 | | { |
16891 | | return (std::numeric_limits<std::int32_t>::min)() <= value && value <= (std::numeric_limits<std::int32_t>::max)() |
16892 | | ? sizeof(std::int32_t) |
16893 | | : sizeof(std::int64_t); |
16894 | | } |
16895 | | |
16896 | | /*! |
16897 | | @brief Writes a BSON element with key @a name and integer @a value |
16898 | | */ |
16899 | | void write_bson_integer(const string_t& name, |
16900 | | const std::int64_t value) |
16901 | | { |
16902 | | if ((std::numeric_limits<std::int32_t>::min)() <= value && value <= (std::numeric_limits<std::int32_t>::max)()) |
16903 | | { |
16904 | | write_bson_entry_header(name, 0x10); // int32 |
16905 | | write_number<std::int32_t>(static_cast<std::int32_t>(value), true); |
16906 | | } |
16907 | | else |
16908 | | { |
16909 | | write_bson_entry_header(name, 0x12); // int64 |
16910 | | write_number<std::int64_t>(static_cast<std::int64_t>(value), true); |
16911 | | } |
16912 | | } |
16913 | | |
16914 | | /*! |
16915 | | @return The size of the BSON-encoded unsigned integer in @a j |
16916 | | */ |
16917 | | static constexpr std::size_t calc_bson_unsigned_size(const std::uint64_t value) noexcept |
16918 | | { |
16919 | | return (value <= static_cast<std::uint64_t>((std::numeric_limits<std::int32_t>::max)())) |
16920 | | ? sizeof(std::int32_t) |
16921 | | : sizeof(std::int64_t); |
16922 | | } |
16923 | | |
16924 | | /*! |
16925 | | @brief Writes a BSON element with key @a name and unsigned @a value |
16926 | | */ |
16927 | | void write_bson_unsigned(const string_t& name, |
16928 | | const BasicJsonType& j) |
16929 | | { |
16930 | | if (j.m_data.m_value.number_unsigned <= static_cast<std::uint64_t>((std::numeric_limits<std::int32_t>::max)())) |
16931 | | { |
16932 | | write_bson_entry_header(name, 0x10 /* int32 */); |
16933 | | write_number<std::int32_t>(static_cast<std::int32_t>(j.m_data.m_value.number_unsigned), true); |
16934 | | } |
16935 | | else if (j.m_data.m_value.number_unsigned <= static_cast<std::uint64_t>((std::numeric_limits<std::int64_t>::max)())) |
16936 | | { |
16937 | | write_bson_entry_header(name, 0x12 /* int64 */); |
16938 | | write_number<std::int64_t>(static_cast<std::int64_t>(j.m_data.m_value.number_unsigned), true); |
16939 | | } |
16940 | | else |
16941 | | { |
16942 | | write_bson_entry_header(name, 0x11 /* uint64 */); |
16943 | | write_number<std::uint64_t>(static_cast<std::uint64_t>(j.m_data.m_value.number_unsigned), true); |
16944 | | } |
16945 | | } |
16946 | | |
16947 | | /*! |
16948 | | @brief Writes a BSON element with key @a name and object @a value |
16949 | | */ |
16950 | | void write_bson_object_entry(const string_t& name, |
16951 | | const typename BasicJsonType::object_t& value) |
16952 | | { |
16953 | | write_bson_entry_header(name, 0x03); // object |
16954 | | write_bson_object(value); |
16955 | | } |
16956 | | |
16957 | | /*! |
16958 | | @return The size of the BSON-encoded array @a value |
16959 | | */ |
16960 | | static std::size_t calc_bson_array_size(const typename BasicJsonType::array_t& value) |
16961 | | { |
16962 | | std::size_t array_index = 0ul; |
16963 | | |
16964 | | const std::size_t embedded_document_size = std::accumulate(std::begin(value), std::end(value), static_cast<std::size_t>(0), [&array_index](std::size_t result, const typename BasicJsonType::array_t::value_type & el) |
16965 | | { |
16966 | | return result + calc_bson_element_size(std::to_string(array_index++), el); |
16967 | | }); |
16968 | | |
16969 | | return sizeof(std::int32_t) + embedded_document_size + 1ul; |
16970 | | } |
16971 | | |
16972 | | /*! |
16973 | | @return The size of the BSON-encoded binary array @a value |
16974 | | */ |
16975 | | static std::size_t calc_bson_binary_size(const typename BasicJsonType::binary_t& value) |
16976 | | { |
16977 | | return sizeof(std::int32_t) + value.size() + 1ul; |
16978 | | } |
16979 | | |
16980 | | /*! |
16981 | | @brief Writes a BSON element with key @a name and array @a value |
16982 | | */ |
16983 | | void write_bson_array(const string_t& name, |
16984 | | const typename BasicJsonType::array_t& value) |
16985 | | { |
16986 | | write_bson_entry_header(name, 0x04); // array |
16987 | | write_number<std::int32_t>(static_cast<std::int32_t>(calc_bson_array_size(value)), true); |
16988 | | |
16989 | | std::size_t array_index = 0ul; |
16990 | | |
16991 | | for (const auto& el : value) |
16992 | | { |
16993 | | write_bson_element(std::to_string(array_index++), el); |
16994 | | } |
16995 | | |
16996 | | oa->write_character(to_char_type(0x00)); |
16997 | | } |
16998 | | |
16999 | | /*! |
17000 | | @brief Writes a BSON element with key @a name and binary value @a value |
17001 | | */ |
17002 | | void write_bson_binary(const string_t& name, |
17003 | | const binary_t& value) |
17004 | | { |
17005 | | write_bson_entry_header(name, 0x05); |
17006 | | |
17007 | | write_number<std::int32_t>(static_cast<std::int32_t>(value.size()), true); |
17008 | | write_number(value.has_subtype() ? static_cast<std::uint8_t>(value.subtype()) : static_cast<std::uint8_t>(0x00)); |
17009 | | |
17010 | | oa->write_characters(reinterpret_cast<const CharType*>(value.data()), value.size()); |
17011 | | } |
17012 | | |
17013 | | /*! |
17014 | | @brief Calculates the size necessary to serialize the JSON value @a j with its @a name |
17015 | | @return The calculated size for the BSON document entry for @a j with the given @a name. |
17016 | | */ |
17017 | | static std::size_t calc_bson_element_size(const string_t& name, |
17018 | | const BasicJsonType& j) |
17019 | | { |
17020 | | const auto header_size = calc_bson_entry_header_size(name, j); |
17021 | | switch (j.type()) |
17022 | | { |
17023 | | case value_t::object: |
17024 | | return header_size + calc_bson_object_size(*j.m_data.m_value.object); |
17025 | | |
17026 | | case value_t::array: |
17027 | | return header_size + calc_bson_array_size(*j.m_data.m_value.array); |
17028 | | |
17029 | | case value_t::binary: |
17030 | | return header_size + calc_bson_binary_size(*j.m_data.m_value.binary); |
17031 | | |
17032 | | case value_t::boolean: |
17033 | | return header_size + 1ul; |
17034 | | |
17035 | | case value_t::number_float: |
17036 | | return header_size + 8ul; |
17037 | | |
17038 | | case value_t::number_integer: |
17039 | | return header_size + calc_bson_integer_size(j.m_data.m_value.number_integer); |
17040 | | |
17041 | | case value_t::number_unsigned: |
17042 | | return header_size + calc_bson_unsigned_size(j.m_data.m_value.number_unsigned); |
17043 | | |
17044 | | case value_t::string: |
17045 | | return header_size + calc_bson_string_size(*j.m_data.m_value.string); |
17046 | | |
17047 | | case value_t::null: |
17048 | | return header_size + 0ul; |
17049 | | |
17050 | | // LCOV_EXCL_START |
17051 | | case value_t::discarded: |
17052 | | default: |
17053 | | JSON_ASSERT(false); // NOLINT(cert-dcl03-c,hicpp-static-assert,misc-static-assert) |
17054 | | return 0ul; |
17055 | | // LCOV_EXCL_STOP |
17056 | | } |
17057 | | } |
17058 | | |
17059 | | /*! |
17060 | | @brief Serializes the JSON value @a j to BSON and associates it with the |
17061 | | key @a name. |
17062 | | @param name The name to associate with the JSON entity @a j within the |
17063 | | current BSON document |
17064 | | */ |
17065 | | void write_bson_element(const string_t& name, |
17066 | | const BasicJsonType& j) |
17067 | | { |
17068 | | switch (j.type()) |
17069 | | { |
17070 | | case value_t::object: |
17071 | | return write_bson_object_entry(name, *j.m_data.m_value.object); |
17072 | | |
17073 | | case value_t::array: |
17074 | | return write_bson_array(name, *j.m_data.m_value.array); |
17075 | | |
17076 | | case value_t::binary: |
17077 | | return write_bson_binary(name, *j.m_data.m_value.binary); |
17078 | | |
17079 | | case value_t::boolean: |
17080 | | return write_bson_boolean(name, j.m_data.m_value.boolean); |
17081 | | |
17082 | | case value_t::number_float: |
17083 | | return write_bson_double(name, j.m_data.m_value.number_float); |
17084 | | |
17085 | | case value_t::number_integer: |
17086 | | return write_bson_integer(name, j.m_data.m_value.number_integer); |
17087 | | |
17088 | | case value_t::number_unsigned: |
17089 | | return write_bson_unsigned(name, j); |
17090 | | |
17091 | | case value_t::string: |
17092 | | return write_bson_string(name, *j.m_data.m_value.string); |
17093 | | |
17094 | | case value_t::null: |
17095 | | return write_bson_null(name); |
17096 | | |
17097 | | // LCOV_EXCL_START |
17098 | | case value_t::discarded: |
17099 | | default: |
17100 | | JSON_ASSERT(false); // NOLINT(cert-dcl03-c,hicpp-static-assert,misc-static-assert) |
17101 | | return; |
17102 | | // LCOV_EXCL_STOP |
17103 | | } |
17104 | | } |
17105 | | |
17106 | | /*! |
17107 | | @brief Calculates the size of the BSON serialization of the given |
17108 | | JSON-object @a j. |
17109 | | @param[in] value JSON value to serialize |
17110 | | @pre value.type() == value_t::object |
17111 | | */ |
17112 | | static std::size_t calc_bson_object_size(const typename BasicJsonType::object_t& value) |
17113 | | { |
17114 | | const std::size_t document_size = std::accumulate(value.begin(), value.end(), static_cast<std::size_t>(0), |
17115 | | [](size_t result, const typename BasicJsonType::object_t::value_type & el) |
17116 | | { |
17117 | | return result += calc_bson_element_size(el.first, el.second); |
17118 | | }); |
17119 | | |
17120 | | return sizeof(std::int32_t) + document_size + 1ul; |
17121 | | } |
17122 | | |
17123 | | /*! |
17124 | | @param[in] value JSON value to serialize |
17125 | | @pre value.type() == value_t::object |
17126 | | */ |
17127 | | void write_bson_object(const typename BasicJsonType::object_t& value) |
17128 | | { |
17129 | | write_number<std::int32_t>(static_cast<std::int32_t>(calc_bson_object_size(value)), true); |
17130 | | |
17131 | | for (const auto& el : value) |
17132 | | { |
17133 | | write_bson_element(el.first, el.second); |
17134 | | } |
17135 | | |
17136 | | oa->write_character(to_char_type(0x00)); |
17137 | | } |
17138 | | |
17139 | | ////////// |
17140 | | // CBOR // |
17141 | | ////////// |
17142 | | |
17143 | | static constexpr CharType get_cbor_float_prefix(float /*unused*/) |
17144 | | { |
17145 | | return to_char_type(0xFA); // Single-Precision Float |
17146 | | } |
17147 | | |
17148 | | static constexpr CharType get_cbor_float_prefix(double /*unused*/) |
17149 | | { |
17150 | | return to_char_type(0xFB); // Double-Precision Float |
17151 | | } |
17152 | | |
17153 | | ///////////// |
17154 | | // MsgPack // |
17155 | | ///////////// |
17156 | | |
17157 | | static constexpr CharType get_msgpack_float_prefix(float /*unused*/) |
17158 | | { |
17159 | | return to_char_type(0xCA); // float 32 |
17160 | | } |
17161 | | |
17162 | | static constexpr CharType get_msgpack_float_prefix(double /*unused*/) |
17163 | | { |
17164 | | return to_char_type(0xCB); // float 64 |
17165 | | } |
17166 | | |
17167 | | //////////// |
17168 | | // UBJSON // |
17169 | | //////////// |
17170 | | |
17171 | | // UBJSON: write number (floating point) |
17172 | | template<typename NumberType, typename std::enable_if< |
17173 | | std::is_floating_point<NumberType>::value, int>::type = 0> |
17174 | | void write_number_with_ubjson_prefix(const NumberType n, |
17175 | | const bool add_prefix, |
17176 | | const bool use_bjdata) |
17177 | | { |
17178 | | if (add_prefix) |
17179 | | { |
17180 | | oa->write_character(get_ubjson_float_prefix(n)); |
17181 | | } |
17182 | | write_number(n, use_bjdata); |
17183 | | } |
17184 | | |
17185 | | // UBJSON: write number (unsigned integer) |
17186 | | template<typename NumberType, typename std::enable_if< |
17187 | | std::is_unsigned<NumberType>::value, int>::type = 0> |
17188 | | void write_number_with_ubjson_prefix(const NumberType n, |
17189 | | const bool add_prefix, |
17190 | | const bool use_bjdata) |
17191 | | { |
17192 | | if (n <= static_cast<std::uint64_t>((std::numeric_limits<std::int8_t>::max)())) |
17193 | | { |
17194 | | if (add_prefix) |
17195 | | { |
17196 | | oa->write_character(to_char_type('i')); // int8 |
17197 | | } |
17198 | | write_number(static_cast<std::uint8_t>(n), use_bjdata); |
17199 | | } |
17200 | | else if (n <= (std::numeric_limits<std::uint8_t>::max)()) |
17201 | | { |
17202 | | if (add_prefix) |
17203 | | { |
17204 | | oa->write_character(to_char_type('U')); // uint8 |
17205 | | } |
17206 | | write_number(static_cast<std::uint8_t>(n), use_bjdata); |
17207 | | } |
17208 | | else if (n <= static_cast<std::uint64_t>((std::numeric_limits<std::int16_t>::max)())) |
17209 | | { |
17210 | | if (add_prefix) |
17211 | | { |
17212 | | oa->write_character(to_char_type('I')); // int16 |
17213 | | } |
17214 | | write_number(static_cast<std::int16_t>(n), use_bjdata); |
17215 | | } |
17216 | | else if (use_bjdata && n <= static_cast<uint64_t>((std::numeric_limits<uint16_t>::max)())) |
17217 | | { |
17218 | | if (add_prefix) |
17219 | | { |
17220 | | oa->write_character(to_char_type('u')); // uint16 - bjdata only |
17221 | | } |
17222 | | write_number(static_cast<std::uint16_t>(n), use_bjdata); |
17223 | | } |
17224 | | else if (n <= static_cast<std::uint64_t>((std::numeric_limits<std::int32_t>::max)())) |
17225 | | { |
17226 | | if (add_prefix) |
17227 | | { |
17228 | | oa->write_character(to_char_type('l')); // int32 |
17229 | | } |
17230 | | write_number(static_cast<std::int32_t>(n), use_bjdata); |
17231 | | } |
17232 | | else if (use_bjdata && n <= static_cast<uint64_t>((std::numeric_limits<uint32_t>::max)())) |
17233 | | { |
17234 | | if (add_prefix) |
17235 | | { |
17236 | | oa->write_character(to_char_type('m')); // uint32 - bjdata only |
17237 | | } |
17238 | | write_number(static_cast<std::uint32_t>(n), use_bjdata); |
17239 | | } |
17240 | | else if (n <= static_cast<std::uint64_t>((std::numeric_limits<std::int64_t>::max)())) |
17241 | | { |
17242 | | if (add_prefix) |
17243 | | { |
17244 | | oa->write_character(to_char_type('L')); // int64 |
17245 | | } |
17246 | | write_number(static_cast<std::int64_t>(n), use_bjdata); |
17247 | | } |
17248 | | else if (use_bjdata && n <= (std::numeric_limits<uint64_t>::max)()) |
17249 | | { |
17250 | | if (add_prefix) |
17251 | | { |
17252 | | oa->write_character(to_char_type('M')); // uint64 - bjdata only |
17253 | | } |
17254 | | write_number(static_cast<std::uint64_t>(n), use_bjdata); |
17255 | | } |
17256 | | else |
17257 | | { |
17258 | | if (add_prefix) |
17259 | | { |
17260 | | oa->write_character(to_char_type('H')); // high-precision number |
17261 | | } |
17262 | | |
17263 | | const auto number = BasicJsonType(n).dump(); |
17264 | | write_number_with_ubjson_prefix(number.size(), true, use_bjdata); |
17265 | | for (std::size_t i = 0; i < number.size(); ++i) |
17266 | | { |
17267 | | oa->write_character(to_char_type(static_cast<std::uint8_t>(number[i]))); |
17268 | | } |
17269 | | } |
17270 | | } |
17271 | | |
17272 | | // UBJSON: write number (signed integer) |
17273 | | template < typename NumberType, typename std::enable_if < |
17274 | | std::is_signed<NumberType>::value&& |
17275 | | !std::is_floating_point<NumberType>::value, int >::type = 0 > |
17276 | | void write_number_with_ubjson_prefix(const NumberType n, |
17277 | | const bool add_prefix, |
17278 | | const bool use_bjdata) |
17279 | | { |
17280 | | if ((std::numeric_limits<std::int8_t>::min)() <= n && n <= (std::numeric_limits<std::int8_t>::max)()) |
17281 | | { |
17282 | | if (add_prefix) |
17283 | | { |
17284 | | oa->write_character(to_char_type('i')); // int8 |
17285 | | } |
17286 | | write_number(static_cast<std::int8_t>(n), use_bjdata); |
17287 | | } |
17288 | | else if (static_cast<std::int64_t>((std::numeric_limits<std::uint8_t>::min)()) <= n && n <= static_cast<std::int64_t>((std::numeric_limits<std::uint8_t>::max)())) |
17289 | | { |
17290 | | if (add_prefix) |
17291 | | { |
17292 | | oa->write_character(to_char_type('U')); // uint8 |
17293 | | } |
17294 | | write_number(static_cast<std::uint8_t>(n), use_bjdata); |
17295 | | } |
17296 | | else if ((std::numeric_limits<std::int16_t>::min)() <= n && n <= (std::numeric_limits<std::int16_t>::max)()) |
17297 | | { |
17298 | | if (add_prefix) |
17299 | | { |
17300 | | oa->write_character(to_char_type('I')); // int16 |
17301 | | } |
17302 | | write_number(static_cast<std::int16_t>(n), use_bjdata); |
17303 | | } |
17304 | | else if (use_bjdata && (static_cast<std::int64_t>((std::numeric_limits<std::uint16_t>::min)()) <= n && n <= static_cast<std::int64_t>((std::numeric_limits<std::uint16_t>::max)()))) |
17305 | | { |
17306 | | if (add_prefix) |
17307 | | { |
17308 | | oa->write_character(to_char_type('u')); // uint16 - bjdata only |
17309 | | } |
17310 | | write_number(static_cast<uint16_t>(n), use_bjdata); |
17311 | | } |
17312 | | else if ((std::numeric_limits<std::int32_t>::min)() <= n && n <= (std::numeric_limits<std::int32_t>::max)()) |
17313 | | { |
17314 | | if (add_prefix) |
17315 | | { |
17316 | | oa->write_character(to_char_type('l')); // int32 |
17317 | | } |
17318 | | write_number(static_cast<std::int32_t>(n), use_bjdata); |
17319 | | } |
17320 | | else if (use_bjdata && (static_cast<std::int64_t>((std::numeric_limits<std::uint32_t>::min)()) <= n && n <= static_cast<std::int64_t>((std::numeric_limits<std::uint32_t>::max)()))) |
17321 | | { |
17322 | | if (add_prefix) |
17323 | | { |
17324 | | oa->write_character(to_char_type('m')); // uint32 - bjdata only |
17325 | | } |
17326 | | write_number(static_cast<uint32_t>(n), use_bjdata); |
17327 | | } |
17328 | | else if ((std::numeric_limits<std::int64_t>::min)() <= n && n <= (std::numeric_limits<std::int64_t>::max)()) |
17329 | | { |
17330 | | if (add_prefix) |
17331 | | { |
17332 | | oa->write_character(to_char_type('L')); // int64 |
17333 | | } |
17334 | | write_number(static_cast<std::int64_t>(n), use_bjdata); |
17335 | | } |
17336 | | // LCOV_EXCL_START |
17337 | | else |
17338 | | { |
17339 | | if (add_prefix) |
17340 | | { |
17341 | | oa->write_character(to_char_type('H')); // high-precision number |
17342 | | } |
17343 | | |
17344 | | const auto number = BasicJsonType(n).dump(); |
17345 | | write_number_with_ubjson_prefix(number.size(), true, use_bjdata); |
17346 | | for (std::size_t i = 0; i < number.size(); ++i) |
17347 | | { |
17348 | | oa->write_character(to_char_type(static_cast<std::uint8_t>(number[i]))); |
17349 | | } |
17350 | | } |
17351 | | // LCOV_EXCL_STOP |
17352 | | } |
17353 | | |
17354 | | /*! |
17355 | | @brief determine the type prefix of container values |
17356 | | */ |
17357 | | CharType ubjson_prefix(const BasicJsonType& j, const bool use_bjdata) const noexcept |
17358 | | { |
17359 | | switch (j.type()) |
17360 | | { |
17361 | | case value_t::null: |
17362 | | return 'Z'; |
17363 | | |
17364 | | case value_t::boolean: |
17365 | | return j.m_data.m_value.boolean ? 'T' : 'F'; |
17366 | | |
17367 | | case value_t::number_integer: |
17368 | | { |
17369 | | if ((std::numeric_limits<std::int8_t>::min)() <= j.m_data.m_value.number_integer && j.m_data.m_value.number_integer <= (std::numeric_limits<std::int8_t>::max)()) |
17370 | | { |
17371 | | return 'i'; |
17372 | | } |
17373 | | if ((std::numeric_limits<std::uint8_t>::min)() <= j.m_data.m_value.number_integer && j.m_data.m_value.number_integer <= (std::numeric_limits<std::uint8_t>::max)()) |
17374 | | { |
17375 | | return 'U'; |
17376 | | } |
17377 | | if ((std::numeric_limits<std::int16_t>::min)() <= j.m_data.m_value.number_integer && j.m_data.m_value.number_integer <= (std::numeric_limits<std::int16_t>::max)()) |
17378 | | { |
17379 | | return 'I'; |
17380 | | } |
17381 | | if (use_bjdata && ((std::numeric_limits<std::uint16_t>::min)() <= j.m_data.m_value.number_integer && j.m_data.m_value.number_integer <= (std::numeric_limits<std::uint16_t>::max)())) |
17382 | | { |
17383 | | return 'u'; |
17384 | | } |
17385 | | if ((std::numeric_limits<std::int32_t>::min)() <= j.m_data.m_value.number_integer && j.m_data.m_value.number_integer <= (std::numeric_limits<std::int32_t>::max)()) |
17386 | | { |
17387 | | return 'l'; |
17388 | | } |
17389 | | if (use_bjdata && ((std::numeric_limits<std::uint32_t>::min)() <= j.m_data.m_value.number_integer && j.m_data.m_value.number_integer <= (std::numeric_limits<std::uint32_t>::max)())) |
17390 | | { |
17391 | | return 'm'; |
17392 | | } |
17393 | | if ((std::numeric_limits<std::int64_t>::min)() <= j.m_data.m_value.number_integer && j.m_data.m_value.number_integer <= (std::numeric_limits<std::int64_t>::max)()) |
17394 | | { |
17395 | | return 'L'; |
17396 | | } |
17397 | | // anything else is treated as a high-precision number |
17398 | | return 'H'; // LCOV_EXCL_LINE |
17399 | | } |
17400 | | |
17401 | | case value_t::number_unsigned: |
17402 | | { |
17403 | | if (j.m_data.m_value.number_unsigned <= static_cast<std::uint64_t>((std::numeric_limits<std::int8_t>::max)())) |
17404 | | { |
17405 | | return 'i'; |
17406 | | } |
17407 | | if (j.m_data.m_value.number_unsigned <= static_cast<std::uint64_t>((std::numeric_limits<std::uint8_t>::max)())) |
17408 | | { |
17409 | | return 'U'; |
17410 | | } |
17411 | | if (j.m_data.m_value.number_unsigned <= static_cast<std::uint64_t>((std::numeric_limits<std::int16_t>::max)())) |
17412 | | { |
17413 | | return 'I'; |
17414 | | } |
17415 | | if (use_bjdata && j.m_data.m_value.number_unsigned <= static_cast<std::uint64_t>((std::numeric_limits<std::uint16_t>::max)())) |
17416 | | { |
17417 | | return 'u'; |
17418 | | } |
17419 | | if (j.m_data.m_value.number_unsigned <= static_cast<std::uint64_t>((std::numeric_limits<std::int32_t>::max)())) |
17420 | | { |
17421 | | return 'l'; |
17422 | | } |
17423 | | if (use_bjdata && j.m_data.m_value.number_unsigned <= static_cast<std::uint64_t>((std::numeric_limits<std::uint32_t>::max)())) |
17424 | | { |
17425 | | return 'm'; |
17426 | | } |
17427 | | if (j.m_data.m_value.number_unsigned <= static_cast<std::uint64_t>((std::numeric_limits<std::int64_t>::max)())) |
17428 | | { |
17429 | | return 'L'; |
17430 | | } |
17431 | | if (use_bjdata && j.m_data.m_value.number_unsigned <= (std::numeric_limits<std::uint64_t>::max)()) |
17432 | | { |
17433 | | return 'M'; |
17434 | | } |
17435 | | // anything else is treated as a high-precision number |
17436 | | return 'H'; // LCOV_EXCL_LINE |
17437 | | } |
17438 | | |
17439 | | case value_t::number_float: |
17440 | | return get_ubjson_float_prefix(j.m_data.m_value.number_float); |
17441 | | |
17442 | | case value_t::string: |
17443 | | return 'S'; |
17444 | | |
17445 | | case value_t::array: // fallthrough |
17446 | | case value_t::binary: |
17447 | | return '['; |
17448 | | |
17449 | | case value_t::object: |
17450 | | return '{'; |
17451 | | |
17452 | | case value_t::discarded: |
17453 | | default: // discarded values |
17454 | | return 'N'; |
17455 | | } |
17456 | | } |
17457 | | |
17458 | | static constexpr CharType get_ubjson_float_prefix(float /*unused*/) |
17459 | | { |
17460 | | return 'd'; // float 32 |
17461 | | } |
17462 | | |
17463 | | static constexpr CharType get_ubjson_float_prefix(double /*unused*/) |
17464 | | { |
17465 | | return 'D'; // float 64 |
17466 | | } |
17467 | | |
17468 | | /*! |
17469 | | @return false if the object is successfully converted to a bjdata ndarray, true if the type or size is invalid |
17470 | | */ |
17471 | | bool write_bjdata_ndarray(const typename BasicJsonType::object_t& value, const bool use_count, const bool use_type, const bjdata_version_t bjdata_version) |
17472 | | { |
17473 | | std::map<string_t, CharType> bjdtype = {{"uint8", 'U'}, {"int8", 'i'}, {"uint16", 'u'}, {"int16", 'I'}, |
17474 | | {"uint32", 'm'}, {"int32", 'l'}, {"uint64", 'M'}, {"int64", 'L'}, {"single", 'd'}, {"double", 'D'}, |
17475 | | {"char", 'C'}, {"byte", 'B'} |
17476 | | }; |
17477 | | |
17478 | | string_t key = "_ArrayType_"; |
17479 | | auto it = bjdtype.find(static_cast<string_t>(value.at(key))); |
17480 | | if (it == bjdtype.end()) |
17481 | | { |
17482 | | return true; |
17483 | | } |
17484 | | CharType dtype = it->second; |
17485 | | |
17486 | | key = "_ArraySize_"; |
17487 | | std::size_t len = (value.at(key).empty() ? 0 : 1); |
17488 | | for (const auto& el : value.at(key)) |
17489 | | { |
17490 | | len *= static_cast<std::size_t>(el.m_data.m_value.number_unsigned); |
17491 | | } |
17492 | | |
17493 | | key = "_ArrayData_"; |
17494 | | if (value.at(key).size() != len) |
17495 | | { |
17496 | | return true; |
17497 | | } |
17498 | | |
17499 | | oa->write_character('['); |
17500 | | oa->write_character('$'); |
17501 | | oa->write_character(dtype); |
17502 | | oa->write_character('#'); |
17503 | | |
17504 | | key = "_ArraySize_"; |
17505 | | write_ubjson(value.at(key), use_count, use_type, true, true, bjdata_version); |
17506 | | |
17507 | | key = "_ArrayData_"; |
17508 | | if (dtype == 'U' || dtype == 'C' || dtype == 'B') |
17509 | | { |
17510 | | for (const auto& el : value.at(key)) |
17511 | | { |
17512 | | write_number(static_cast<std::uint8_t>(el.m_data.m_value.number_unsigned), true); |
17513 | | } |
17514 | | } |
17515 | | else if (dtype == 'i') |
17516 | | { |
17517 | | for (const auto& el : value.at(key)) |
17518 | | { |
17519 | | write_number(static_cast<std::int8_t>(el.m_data.m_value.number_integer), true); |
17520 | | } |
17521 | | } |
17522 | | else if (dtype == 'u') |
17523 | | { |
17524 | | for (const auto& el : value.at(key)) |
17525 | | { |
17526 | | write_number(static_cast<std::uint16_t>(el.m_data.m_value.number_unsigned), true); |
17527 | | } |
17528 | | } |
17529 | | else if (dtype == 'I') |
17530 | | { |
17531 | | for (const auto& el : value.at(key)) |
17532 | | { |
17533 | | write_number(static_cast<std::int16_t>(el.m_data.m_value.number_integer), true); |
17534 | | } |
17535 | | } |
17536 | | else if (dtype == 'm') |
17537 | | { |
17538 | | for (const auto& el : value.at(key)) |
17539 | | { |
17540 | | write_number(static_cast<std::uint32_t>(el.m_data.m_value.number_unsigned), true); |
17541 | | } |
17542 | | } |
17543 | | else if (dtype == 'l') |
17544 | | { |
17545 | | for (const auto& el : value.at(key)) |
17546 | | { |
17547 | | write_number(static_cast<std::int32_t>(el.m_data.m_value.number_integer), true); |
17548 | | } |
17549 | | } |
17550 | | else if (dtype == 'M') |
17551 | | { |
17552 | | for (const auto& el : value.at(key)) |
17553 | | { |
17554 | | write_number(static_cast<std::uint64_t>(el.m_data.m_value.number_unsigned), true); |
17555 | | } |
17556 | | } |
17557 | | else if (dtype == 'L') |
17558 | | { |
17559 | | for (const auto& el : value.at(key)) |
17560 | | { |
17561 | | write_number(static_cast<std::int64_t>(el.m_data.m_value.number_integer), true); |
17562 | | } |
17563 | | } |
17564 | | else if (dtype == 'd') |
17565 | | { |
17566 | | for (const auto& el : value.at(key)) |
17567 | | { |
17568 | | write_number(static_cast<float>(el.m_data.m_value.number_float), true); |
17569 | | } |
17570 | | } |
17571 | | else if (dtype == 'D') |
17572 | | { |
17573 | | for (const auto& el : value.at(key)) |
17574 | | { |
17575 | | write_number(static_cast<double>(el.m_data.m_value.number_float), true); |
17576 | | } |
17577 | | } |
17578 | | return false; |
17579 | | } |
17580 | | |
17581 | | /////////////////////// |
17582 | | // Utility functions // |
17583 | | /////////////////////// |
17584 | | |
17585 | | /* |
17586 | | @brief write a number to output input |
17587 | | @param[in] n number of type @a NumberType |
17588 | | @param[in] OutputIsLittleEndian Set to true if output data is |
17589 | | required to be little endian |
17590 | | @tparam NumberType the type of the number |
17591 | | |
17592 | | @note This function needs to respect the system's endianness, because bytes |
17593 | | in CBOR, MessagePack, and UBJSON are stored in network order (big |
17594 | | endian) and therefore need reordering on little endian systems. |
17595 | | On the other hand, BSON and BJData use little endian and should reorder |
17596 | | on big endian systems. |
17597 | | */ |
17598 | | template<typename NumberType> |
17599 | | void write_number(const NumberType n, const bool OutputIsLittleEndian = false) |
17600 | | { |
17601 | | // step 1: write the number to an array of length NumberType |
17602 | | std::array<CharType, sizeof(NumberType)> vec{}; |
17603 | | std::memcpy(vec.data(), &n, sizeof(NumberType)); |
17604 | | |
17605 | | // step 2: write the array to output (with possible reordering) |
17606 | | if (is_little_endian != OutputIsLittleEndian) |
17607 | | { |
17608 | | // reverse byte order prior to conversion if necessary |
17609 | | std::reverse(vec.begin(), vec.end()); |
17610 | | } |
17611 | | |
17612 | | oa->write_characters(vec.data(), sizeof(NumberType)); |
17613 | | } |
17614 | | |
17615 | | void write_compact_float(const number_float_t n, detail::input_format_t format) |
17616 | | { |
17617 | | #ifdef __GNUC__ |
17618 | | #pragma GCC diagnostic push |
17619 | | #pragma GCC diagnostic ignored "-Wfloat-equal" |
17620 | | #endif |
17621 | | if (!std::isfinite(n) || ((static_cast<double>(n) >= static_cast<double>(std::numeric_limits<float>::lowest()) && |
17622 | | static_cast<double>(n) <= static_cast<double>((std::numeric_limits<float>::max)()) && |
17623 | | static_cast<double>(static_cast<float>(n)) == static_cast<double>(n)))) |
17624 | | { |
17625 | | oa->write_character(format == detail::input_format_t::cbor |
17626 | | ? get_cbor_float_prefix(static_cast<float>(n)) |
17627 | | : get_msgpack_float_prefix(static_cast<float>(n))); |
17628 | | write_number(static_cast<float>(n)); |
17629 | | } |
17630 | | else |
17631 | | { |
17632 | | oa->write_character(format == detail::input_format_t::cbor |
17633 | | ? get_cbor_float_prefix(n) |
17634 | | : get_msgpack_float_prefix(n)); |
17635 | | write_number(n); |
17636 | | } |
17637 | | #ifdef __GNUC__ |
17638 | | #pragma GCC diagnostic pop |
17639 | | #endif |
17640 | | } |
17641 | | |
17642 | | public: |
17643 | | // The following to_char_type functions are implement the conversion |
17644 | | // between uint8_t and CharType. In case CharType is not unsigned, |
17645 | | // such a conversion is required to allow values greater than 128. |
17646 | | // See <https://github.com/nlohmann/json/issues/1286> for a discussion. |
17647 | | template < typename C = CharType, |
17648 | | enable_if_t < std::is_signed<C>::value && std::is_signed<char>::value > * = nullptr > |
17649 | | static constexpr CharType to_char_type(std::uint8_t x) noexcept |
17650 | | { |
17651 | | return *reinterpret_cast<char*>(&x); |
17652 | | } |
17653 | | |
17654 | | template < typename C = CharType, |
17655 | | enable_if_t < std::is_signed<C>::value && std::is_unsigned<char>::value > * = nullptr > |
17656 | | static CharType to_char_type(std::uint8_t x) noexcept |
17657 | | { |
17658 | | // The std::is_trivial trait is deprecated in C++26. The replacement is to use |
17659 | | // std::is_trivially_copyable and std::is_trivially_default_constructible. |
17660 | | // However, some older library implementations support std::is_trivial |
17661 | | // but not all the std::is_trivially_* traits. |
17662 | | // Since detecting full support across all libraries is difficult, |
17663 | | // we use std::is_trivial unless we are using a standard where it has been deprecated. |
17664 | | // For more details, see: https://github.com/nlohmann/json/pull/4775#issuecomment-2884361627 |
17665 | | #ifdef JSON_HAS_CPP_26 |
17666 | | static_assert(std::is_trivially_copyable<CharType>::value, "CharType must be trivially copyable"); |
17667 | | static_assert(std::is_trivially_default_constructible<CharType>::value, "CharType must be trivially default constructible"); |
17668 | | #else |
17669 | | static_assert(std::is_trivial<CharType>::value, "CharType must be trivial"); |
17670 | | #endif |
17671 | | |
17672 | | static_assert(sizeof(std::uint8_t) == sizeof(CharType), "size of CharType must be equal to std::uint8_t"); |
17673 | | CharType result; |
17674 | | std::memcpy(&result, &x, sizeof(x)); |
17675 | | return result; |
17676 | | } |
17677 | | |
17678 | | template<typename C = CharType, |
17679 | | enable_if_t<std::is_unsigned<C>::value>* = nullptr> |
17680 | | static constexpr CharType to_char_type(std::uint8_t x) noexcept |
17681 | | { |
17682 | | return x; |
17683 | | } |
17684 | | |
17685 | | template < typename InputCharType, typename C = CharType, |
17686 | | enable_if_t < |
17687 | | std::is_signed<C>::value && |
17688 | | std::is_signed<char>::value && |
17689 | | std::is_same<char, typename std::remove_cv<InputCharType>::type>::value |
17690 | | > * = nullptr > |
17691 | | static constexpr CharType to_char_type(InputCharType x) noexcept |
17692 | 0 | { |
17693 | 0 | return x; |
17694 | 0 | } |
17695 | | |
17696 | | private: |
17697 | | /// whether we can assume little endianness |
17698 | | const bool is_little_endian = little_endianness(); |
17699 | | |
17700 | | /// the output |
17701 | | output_adapter_t<CharType> oa = nullptr; |
17702 | | }; |
17703 | | |
17704 | | } // namespace detail |
17705 | | NLOHMANN_JSON_NAMESPACE_END |
17706 | | |
17707 | | // #include <nlohmann/detail/output/output_adapters.hpp> |
17708 | | |
17709 | | // #include <nlohmann/detail/output/serializer.hpp> |
17710 | | // __ _____ _____ _____ |
17711 | | // __| | __| | | | JSON for Modern C++ |
17712 | | // | | |__ | | | | | | version 3.12.0 |
17713 | | // |_____|_____|_____|_|___| https://github.com/nlohmann/json |
17714 | | // |
17715 | | // SPDX-FileCopyrightText: 2008, 2009 Björn Hoehrmann <bjoern@hoehrmann.de> |
17716 | | // SPDX-FileCopyrightText: 2013-2026 Niels Lohmann <https://nlohmann.me> |
17717 | | // SPDX-License-Identifier: MIT |
17718 | | |
17719 | | |
17720 | | |
17721 | | #include <algorithm> // reverse, remove, fill, find, none_of |
17722 | | #include <array> // array |
17723 | | #include <clocale> // localeconv, lconv |
17724 | | #include <cmath> // labs, isfinite, isnan, signbit |
17725 | | #include <cstddef> // size_t, ptrdiff_t |
17726 | | #include <cstdint> // uint8_t |
17727 | | #include <cstdio> // snprintf |
17728 | | #include <limits> // numeric_limits |
17729 | | #include <string> // string, char_traits |
17730 | | #include <iomanip> // setfill, setw |
17731 | | #include <type_traits> // is_same |
17732 | | #include <utility> // move |
17733 | | |
17734 | | // #include <nlohmann/detail/conversions/to_chars.hpp> |
17735 | | // __ _____ _____ _____ |
17736 | | // __| | __| | | | JSON for Modern C++ |
17737 | | // | | |__ | | | | | | version 3.12.0 |
17738 | | // |_____|_____|_____|_|___| https://github.com/nlohmann/json |
17739 | | // |
17740 | | // SPDX-FileCopyrightText: 2009 Florian Loitsch <https://florian.loitsch.com/> |
17741 | | // SPDX-FileCopyrightText: 2013-2026 Niels Lohmann <https://nlohmann.me> |
17742 | | // SPDX-License-Identifier: MIT |
17743 | | |
17744 | | |
17745 | | |
17746 | | #include <array> // array |
17747 | | #include <cmath> // signbit, isfinite |
17748 | | #include <cstdint> // intN_t, uintN_t |
17749 | | #include <cstring> // memcpy, memmove |
17750 | | #include <limits> // numeric_limits |
17751 | | #include <type_traits> // conditional |
17752 | | |
17753 | | // #include <nlohmann/detail/macro_scope.hpp> |
17754 | | |
17755 | | |
17756 | | NLOHMANN_JSON_NAMESPACE_BEGIN |
17757 | | namespace detail |
17758 | | { |
17759 | | |
17760 | | /*! |
17761 | | @brief implements the Grisu2 algorithm for binary to decimal floating-point |
17762 | | conversion. |
17763 | | |
17764 | | This implementation is a slightly modified version of the reference |
17765 | | implementation which may be obtained from |
17766 | | http://florian.loitsch.com/publications (bench.tar.gz). |
17767 | | |
17768 | | The code is distributed under the MIT license, Copyright (c) 2009 Florian Loitsch. |
17769 | | |
17770 | | For a detailed description of the algorithm see: |
17771 | | |
17772 | | [1] Loitsch, "Printing Floating-Point Numbers Quickly and Accurately with |
17773 | | Integers", Proceedings of the ACM SIGPLAN 2010 Conference on Programming |
17774 | | Language Design and Implementation, PLDI 2010 |
17775 | | [2] Burger, Dybvig, "Printing Floating-Point Numbers Quickly and Accurately", |
17776 | | Proceedings of the ACM SIGPLAN 1996 Conference on Programming Language |
17777 | | Design and Implementation, PLDI 1996 |
17778 | | */ |
17779 | | namespace dtoa_impl |
17780 | | { |
17781 | | |
17782 | | template<typename Target, typename Source> |
17783 | | Target reinterpret_bits(const Source source) |
17784 | 0 | { |
17785 | 0 | static_assert(sizeof(Target) == sizeof(Source), "size mismatch"); |
17786 | |
|
17787 | 0 | Target target; |
17788 | 0 | std::memcpy(&target, &source, sizeof(Source)); |
17789 | 0 | return target; |
17790 | 0 | } |
17791 | | |
17792 | | struct diyfp // f * 2^e |
17793 | | { |
17794 | | static constexpr int kPrecision = 64; // = q |
17795 | | |
17796 | | std::uint64_t f = 0; |
17797 | | int e = 0; |
17798 | | |
17799 | 0 | constexpr diyfp(std::uint64_t f_, int e_) noexcept : f(f_), e(e_) {} |
17800 | | |
17801 | | /*! |
17802 | | @brief returns x - y |
17803 | | @pre x.e == y.e and x.f >= y.f |
17804 | | */ |
17805 | | static diyfp sub(const diyfp& x, const diyfp& y) noexcept |
17806 | 0 | { |
17807 | 0 | JSON_ASSERT(x.e == y.e); |
17808 | 0 | JSON_ASSERT(x.f >= y.f); |
17809 | | |
17810 | 0 | return {x.f - y.f, x.e}; |
17811 | 0 | } |
17812 | | |
17813 | | /*! |
17814 | | @brief returns x * y |
17815 | | @note The result is rounded. (Only the upper q bits are returned.) |
17816 | | */ |
17817 | | static diyfp mul(const diyfp& x, const diyfp& y) noexcept |
17818 | 0 | { |
17819 | 0 | static_assert(kPrecision == 64, "internal error"); |
17820 | | |
17821 | | // Computes: |
17822 | | // f = round((x.f * y.f) / 2^q) |
17823 | | // e = x.e + y.e + q |
17824 | | |
17825 | | // Emulate the 64-bit * 64-bit multiplication: |
17826 | | // |
17827 | | // p = u * v |
17828 | | // = (u_lo + 2^32 u_hi) (v_lo + 2^32 v_hi) |
17829 | | // = (u_lo v_lo ) + 2^32 ((u_lo v_hi ) + (u_hi v_lo )) + 2^64 (u_hi v_hi ) |
17830 | | // = (p0 ) + 2^32 ((p1 ) + (p2 )) + 2^64 (p3 ) |
17831 | | // = (p0_lo + 2^32 p0_hi) + 2^32 ((p1_lo + 2^32 p1_hi) + (p2_lo + 2^32 p2_hi)) + 2^64 (p3 ) |
17832 | | // = (p0_lo ) + 2^32 (p0_hi + p1_lo + p2_lo ) + 2^64 (p1_hi + p2_hi + p3) |
17833 | | // = (p0_lo ) + 2^32 (Q ) + 2^64 (H ) |
17834 | | // = (p0_lo ) + 2^32 (Q_lo + 2^32 Q_hi ) + 2^64 (H ) |
17835 | | // |
17836 | | // (Since Q might be larger than 2^32 - 1) |
17837 | | // |
17838 | | // = (p0_lo + 2^32 Q_lo) + 2^64 (Q_hi + H) |
17839 | | // |
17840 | | // (Q_hi + H does not overflow a 64-bit int) |
17841 | | // |
17842 | | // = p_lo + 2^64 p_hi |
17843 | |
|
17844 | 0 | const std::uint64_t u_lo = x.f & 0xFFFFFFFFu; |
17845 | 0 | const std::uint64_t u_hi = x.f >> 32u; |
17846 | 0 | const std::uint64_t v_lo = y.f & 0xFFFFFFFFu; |
17847 | 0 | const std::uint64_t v_hi = y.f >> 32u; |
17848 | |
|
17849 | 0 | const std::uint64_t p0 = u_lo * v_lo; |
17850 | 0 | const std::uint64_t p1 = u_lo * v_hi; |
17851 | 0 | const std::uint64_t p2 = u_hi * v_lo; |
17852 | 0 | const std::uint64_t p3 = u_hi * v_hi; |
17853 | |
|
17854 | 0 | const std::uint64_t p0_hi = p0 >> 32u; |
17855 | 0 | const std::uint64_t p1_lo = p1 & 0xFFFFFFFFu; |
17856 | 0 | const std::uint64_t p1_hi = p1 >> 32u; |
17857 | 0 | const std::uint64_t p2_lo = p2 & 0xFFFFFFFFu; |
17858 | 0 | const std::uint64_t p2_hi = p2 >> 32u; |
17859 | |
|
17860 | 0 | std::uint64_t Q = p0_hi + p1_lo + p2_lo; |
17861 | | |
17862 | | // The full product might now be computed as |
17863 | | // |
17864 | | // p_hi = p3 + p2_hi + p1_hi + (Q >> 32) |
17865 | | // p_lo = p0_lo + (Q << 32) |
17866 | | // |
17867 | | // But in this particular case here, the full p_lo is not required. |
17868 | | // Effectively, we only need to add the highest bit in p_lo to p_hi (and |
17869 | | // Q_hi + 1 does not overflow). |
17870 | |
|
17871 | 0 | Q += std::uint64_t{1} << (64u - 32u - 1u); // round, ties up |
17872 | |
|
17873 | 0 | const std::uint64_t h = p3 + p2_hi + p1_hi + (Q >> 32u); |
17874 | |
|
17875 | 0 | return {h, x.e + y.e + 64}; |
17876 | 0 | } |
17877 | | |
17878 | | /*! |
17879 | | @brief normalize x such that the significand is >= 2^(q-1) |
17880 | | @pre x.f != 0 |
17881 | | */ |
17882 | | static diyfp normalize(diyfp x) noexcept |
17883 | 0 | { |
17884 | 0 | JSON_ASSERT(x.f != 0); |
17885 | | |
17886 | 0 | while ((x.f >> 63u) == 0) |
17887 | 0 | { |
17888 | 0 | x.f <<= 1u; |
17889 | 0 | x.e--; |
17890 | 0 | } |
17891 | |
|
17892 | 0 | return x; |
17893 | 0 | } |
17894 | | |
17895 | | /*! |
17896 | | @brief normalize x such that the result has the exponent E |
17897 | | @pre e >= x.e and the upper e - x.e bits of x.f must be zero. |
17898 | | */ |
17899 | | static diyfp normalize_to(const diyfp& x, const int target_exponent) noexcept |
17900 | 0 | { |
17901 | 0 | const int delta = x.e - target_exponent; |
17902 | |
|
17903 | 0 | JSON_ASSERT(delta >= 0); |
17904 | 0 | JSON_ASSERT(((x.f << delta) >> delta) == x.f); |
17905 | | |
17906 | 0 | return {x.f << delta, target_exponent}; |
17907 | 0 | } |
17908 | | }; |
17909 | | |
17910 | | struct boundaries |
17911 | | { |
17912 | | diyfp w; |
17913 | | diyfp minus; |
17914 | | diyfp plus; |
17915 | | }; |
17916 | | |
17917 | | /*! |
17918 | | Compute the (normalized) diyfp representing the input number 'value' and its |
17919 | | boundaries. |
17920 | | |
17921 | | @pre value must be finite and positive |
17922 | | */ |
17923 | | template<typename FloatType> |
17924 | | boundaries compute_boundaries(FloatType value) |
17925 | 0 | { |
17926 | 0 | JSON_ASSERT(std::isfinite(value)); |
17927 | 0 | JSON_ASSERT(value > 0); |
17928 | | |
17929 | | // Convert the IEEE representation into a diyfp. |
17930 | | // |
17931 | | // If v is denormal: |
17932 | | // value = 0.F * 2^(1 - bias) = ( F) * 2^(1 - bias - (p-1)) |
17933 | | // If v is normalized: |
17934 | | // value = 1.F * 2^(E - bias) = (2^(p-1) + F) * 2^(E - bias - (p-1)) |
17935 | | |
17936 | 0 | static_assert(std::numeric_limits<FloatType>::is_iec559, |
17937 | 0 | "internal error: dtoa_short requires an IEEE-754 floating-point implementation"); |
17938 | |
|
17939 | 0 | constexpr int kPrecision = std::numeric_limits<FloatType>::digits; // = p (includes the hidden bit) |
17940 | 0 | constexpr int kBias = std::numeric_limits<FloatType>::max_exponent - 1 + (kPrecision - 1); |
17941 | 0 | constexpr int kMinExp = 1 - kBias; |
17942 | 0 | constexpr std::uint64_t kHiddenBit = std::uint64_t{1} << (kPrecision - 1); // = 2^(p-1) |
17943 | |
|
17944 | 0 | using bits_type = typename std::conditional<kPrecision == 24, std::uint32_t, std::uint64_t >::type; |
17945 | |
|
17946 | 0 | const auto bits = static_cast<std::uint64_t>(reinterpret_bits<bits_type>(value)); |
17947 | 0 | const std::uint64_t E = bits >> (kPrecision - 1); |
17948 | 0 | const std::uint64_t F = bits & (kHiddenBit - 1); |
17949 | |
|
17950 | 0 | const bool is_denormal = E == 0; |
17951 | 0 | const diyfp v = is_denormal |
17952 | 0 | ? diyfp(F, kMinExp) |
17953 | 0 | : diyfp(F + kHiddenBit, static_cast<int>(E) - kBias); |
17954 | | |
17955 | | // Compute the boundaries m- and m+ of the floating-point value |
17956 | | // v = f * 2^e. |
17957 | | // |
17958 | | // Determine v- and v+, the floating-point predecessor and successor of v, |
17959 | | // respectively. |
17960 | | // |
17961 | | // v- = v - 2^e if f != 2^(p-1) or e == e_min (A) |
17962 | | // = v - 2^(e-1) if f == 2^(p-1) and e > e_min (B) |
17963 | | // |
17964 | | // v+ = v + 2^e |
17965 | | // |
17966 | | // Let m- = (v- + v) / 2 and m+ = (v + v+) / 2. All real numbers _strictly_ |
17967 | | // between m- and m+ round to v, regardless of how the input rounding |
17968 | | // algorithm breaks ties. |
17969 | | // |
17970 | | // ---+-------------+-------------+-------------+-------------+--- (A) |
17971 | | // v- m- v m+ v+ |
17972 | | // |
17973 | | // -----------------+------+------+-------------+-------------+--- (B) |
17974 | | // v- m- v m+ v+ |
17975 | |
|
17976 | 0 | const bool lower_boundary_is_closer = F == 0 && E > 1; |
17977 | 0 | const diyfp m_plus = diyfp((2 * v.f) + 1, v.e - 1); |
17978 | 0 | const diyfp m_minus = lower_boundary_is_closer |
17979 | 0 | ? diyfp((4 * v.f) - 1, v.e - 2) // (B) |
17980 | 0 | : diyfp((2 * v.f) - 1, v.e - 1); // (A) |
17981 | | |
17982 | | // Determine the normalized w+ = m+. |
17983 | 0 | const diyfp w_plus = diyfp::normalize(m_plus); |
17984 | | |
17985 | | // Determine w- = m- such that e_(w-) = e_(w+). |
17986 | 0 | const diyfp w_minus = diyfp::normalize_to(m_minus, w_plus.e); |
17987 | |
|
17988 | 0 | return {diyfp::normalize(v), w_minus, w_plus}; |
17989 | 0 | } |
17990 | | |
17991 | | // Given normalized diyfp w, Grisu needs to find a (normalized) cached |
17992 | | // power-of-ten c, such that the exponent of the product c * w = f * 2^e lies |
17993 | | // within a certain range [alpha, gamma] (Definition 3.2 from [1]) |
17994 | | // |
17995 | | // alpha <= e = e_c + e_w + q <= gamma |
17996 | | // |
17997 | | // or |
17998 | | // |
17999 | | // f_c * f_w * 2^alpha <= f_c 2^(e_c) * f_w 2^(e_w) * 2^q |
18000 | | // <= f_c * f_w * 2^gamma |
18001 | | // |
18002 | | // Since c and w are normalized, i.e. 2^(q-1) <= f < 2^q, this implies |
18003 | | // |
18004 | | // 2^(q-1) * 2^(q-1) * 2^alpha <= c * w * 2^q < 2^q * 2^q * 2^gamma |
18005 | | // |
18006 | | // or |
18007 | | // |
18008 | | // 2^(q - 2 + alpha) <= c * w < 2^(q + gamma) |
18009 | | // |
18010 | | // The choice of (alpha,gamma) determines the size of the table and the form of |
18011 | | // the digit generation procedure. Using (alpha,gamma)=(-60,-32) works out well |
18012 | | // in practice: |
18013 | | // |
18014 | | // The idea is to cut the number c * w = f * 2^e into two parts, which can be |
18015 | | // processed independently: An integral part p1, and a fractional part p2: |
18016 | | // |
18017 | | // f * 2^e = ( (f div 2^-e) * 2^-e + (f mod 2^-e) ) * 2^e |
18018 | | // = (f div 2^-e) + (f mod 2^-e) * 2^e |
18019 | | // = p1 + p2 * 2^e |
18020 | | // |
18021 | | // The conversion of p1 into decimal form requires a series of divisions and |
18022 | | // modulos by (a power of) 10. These operations are faster for 32-bit than for |
18023 | | // 64-bit integers, so p1 should ideally fit into a 32-bit integer. This can be |
18024 | | // achieved by choosing |
18025 | | // |
18026 | | // -e >= 32 or e <= -32 := gamma |
18027 | | // |
18028 | | // In order to convert the fractional part |
18029 | | // |
18030 | | // p2 * 2^e = p2 / 2^-e = d[-1] / 10^1 + d[-2] / 10^2 + ... |
18031 | | // |
18032 | | // into decimal form, the fraction is repeatedly multiplied by 10 and the digits |
18033 | | // d[-i] are extracted in order: |
18034 | | // |
18035 | | // (10 * p2) div 2^-e = d[-1] |
18036 | | // (10 * p2) mod 2^-e = d[-2] / 10^1 + ... |
18037 | | // |
18038 | | // The multiplication by 10 must not overflow. It is sufficient to choose |
18039 | | // |
18040 | | // 10 * p2 < 16 * p2 = 2^4 * p2 <= 2^64. |
18041 | | // |
18042 | | // Since p2 = f mod 2^-e < 2^-e, |
18043 | | // |
18044 | | // -e <= 60 or e >= -60 := alpha |
18045 | | |
18046 | | constexpr int kAlpha = -60; |
18047 | | constexpr int kGamma = -32; |
18048 | | |
18049 | | struct cached_power // c = f * 2^e ~= 10^k |
18050 | | { |
18051 | | std::uint64_t f; |
18052 | | int e; |
18053 | | int k; |
18054 | | }; |
18055 | | |
18056 | | /*! |
18057 | | For a normalized diyfp w = f * 2^e, this function returns a (normalized) cached |
18058 | | power-of-ten c = f_c * 2^e_c, such that the exponent of the product w * c |
18059 | | satisfies (Definition 3.2 from [1]) |
18060 | | |
18061 | | alpha <= e_c + e + q <= gamma. |
18062 | | */ |
18063 | | inline cached_power get_cached_power_for_binary_exponent(int e) |
18064 | 0 | { |
18065 | | // Now |
18066 | | // |
18067 | | // alpha <= e_c + e + q <= gamma (1) |
18068 | | // ==> f_c * 2^alpha <= c * 2^e * 2^q |
18069 | | // |
18070 | | // and since the c's are normalized, 2^(q-1) <= f_c, |
18071 | | // |
18072 | | // ==> 2^(q - 1 + alpha) <= c * 2^(e + q) |
18073 | | // ==> 2^(alpha - e - 1) <= c |
18074 | | // |
18075 | | // If c were an exact power of ten, i.e. c = 10^k, one may determine k as |
18076 | | // |
18077 | | // k = ceil( log_10( 2^(alpha - e - 1) ) ) |
18078 | | // = ceil( (alpha - e - 1) * log_10(2) ) |
18079 | | // |
18080 | | // From the paper: |
18081 | | // "In theory the result of the procedure could be wrong since c is rounded, |
18082 | | // and the computation itself is approximated [...]. In practice, however, |
18083 | | // this simple function is sufficient." |
18084 | | // |
18085 | | // For IEEE double precision floating-point numbers converted into |
18086 | | // normalized diyfp's w = f * 2^e, with q = 64, |
18087 | | // |
18088 | | // e >= -1022 (min IEEE exponent) |
18089 | | // -52 (p - 1) |
18090 | | // -52 (p - 1, possibly normalize denormal IEEE numbers) |
18091 | | // -11 (normalize the diyfp) |
18092 | | // = -1137 |
18093 | | // |
18094 | | // and |
18095 | | // |
18096 | | // e <= +1023 (max IEEE exponent) |
18097 | | // -52 (p - 1) |
18098 | | // -11 (normalize the diyfp) |
18099 | | // = 960 |
18100 | | // |
18101 | | // This binary exponent range [-1137,960] results in a decimal exponent |
18102 | | // range [-307,324]. One does not need to store a cached power for each |
18103 | | // k in this range. For each such k it suffices to find a cached power |
18104 | | // such that the exponent of the product lies in [alpha,gamma]. |
18105 | | // This implies that the difference of the decimal exponents of adjacent |
18106 | | // table entries must be less than or equal to |
18107 | | // |
18108 | | // floor( (gamma - alpha) * log_10(2) ) = 8. |
18109 | | // |
18110 | | // (A smaller distance gamma-alpha would require a larger table.) |
18111 | | |
18112 | | // NB: |
18113 | | // Actually, this function returns c, such that -60 <= e_c + e + 64 <= -34. |
18114 | |
|
18115 | 0 | constexpr int kCachedPowersMinDecExp = -300; |
18116 | 0 | constexpr int kCachedPowersDecStep = 8; |
18117 | |
|
18118 | 0 | static constexpr std::array<cached_power, 79> kCachedPowers = |
18119 | 0 | { |
18120 | 0 | { |
18121 | 0 | { 0xAB70FE17C79AC6CA, -1060, -300 }, |
18122 | 0 | { 0xFF77B1FCBEBCDC4F, -1034, -292 }, |
18123 | 0 | { 0xBE5691EF416BD60C, -1007, -284 }, |
18124 | 0 | { 0x8DD01FAD907FFC3C, -980, -276 }, |
18125 | 0 | { 0xD3515C2831559A83, -954, -268 }, |
18126 | 0 | { 0x9D71AC8FADA6C9B5, -927, -260 }, |
18127 | 0 | { 0xEA9C227723EE8BCB, -901, -252 }, |
18128 | 0 | { 0xAECC49914078536D, -874, -244 }, |
18129 | 0 | { 0x823C12795DB6CE57, -847, -236 }, |
18130 | 0 | { 0xC21094364DFB5637, -821, -228 }, |
18131 | 0 | { 0x9096EA6F3848984F, -794, -220 }, |
18132 | 0 | { 0xD77485CB25823AC7, -768, -212 }, |
18133 | 0 | { 0xA086CFCD97BF97F4, -741, -204 }, |
18134 | 0 | { 0xEF340A98172AACE5, -715, -196 }, |
18135 | 0 | { 0xB23867FB2A35B28E, -688, -188 }, |
18136 | 0 | { 0x84C8D4DFD2C63F3B, -661, -180 }, |
18137 | 0 | { 0xC5DD44271AD3CDBA, -635, -172 }, |
18138 | 0 | { 0x936B9FCEBB25C996, -608, -164 }, |
18139 | 0 | { 0xDBAC6C247D62A584, -582, -156 }, |
18140 | 0 | { 0xA3AB66580D5FDAF6, -555, -148 }, |
18141 | 0 | { 0xF3E2F893DEC3F126, -529, -140 }, |
18142 | 0 | { 0xB5B5ADA8AAFF80B8, -502, -132 }, |
18143 | 0 | { 0x87625F056C7C4A8B, -475, -124 }, |
18144 | 0 | { 0xC9BCFF6034C13053, -449, -116 }, |
18145 | 0 | { 0x964E858C91BA2655, -422, -108 }, |
18146 | 0 | { 0xDFF9772470297EBD, -396, -100 }, |
18147 | 0 | { 0xA6DFBD9FB8E5B88F, -369, -92 }, |
18148 | 0 | { 0xF8A95FCF88747D94, -343, -84 }, |
18149 | 0 | { 0xB94470938FA89BCF, -316, -76 }, |
18150 | 0 | { 0x8A08F0F8BF0F156B, -289, -68 }, |
18151 | 0 | { 0xCDB02555653131B6, -263, -60 }, |
18152 | 0 | { 0x993FE2C6D07B7FAC, -236, -52 }, |
18153 | 0 | { 0xE45C10C42A2B3B06, -210, -44 }, |
18154 | 0 | { 0xAA242499697392D3, -183, -36 }, |
18155 | 0 | { 0xFD87B5F28300CA0E, -157, -28 }, |
18156 | 0 | { 0xBCE5086492111AEB, -130, -20 }, |
18157 | 0 | { 0x8CBCCC096F5088CC, -103, -12 }, |
18158 | 0 | { 0xD1B71758E219652C, -77, -4 }, |
18159 | 0 | { 0x9C40000000000000, -50, 4 }, |
18160 | 0 | { 0xE8D4A51000000000, -24, 12 }, |
18161 | 0 | { 0xAD78EBC5AC620000, 3, 20 }, |
18162 | 0 | { 0x813F3978F8940984, 30, 28 }, |
18163 | 0 | { 0xC097CE7BC90715B3, 56, 36 }, |
18164 | 0 | { 0x8F7E32CE7BEA5C70, 83, 44 }, |
18165 | 0 | { 0xD5D238A4ABE98068, 109, 52 }, |
18166 | 0 | { 0x9F4F2726179A2245, 136, 60 }, |
18167 | 0 | { 0xED63A231D4C4FB27, 162, 68 }, |
18168 | 0 | { 0xB0DE65388CC8ADA8, 189, 76 }, |
18169 | 0 | { 0x83C7088E1AAB65DB, 216, 84 }, |
18170 | 0 | { 0xC45D1DF942711D9A, 242, 92 }, |
18171 | 0 | { 0x924D692CA61BE758, 269, 100 }, |
18172 | 0 | { 0xDA01EE641A708DEA, 295, 108 }, |
18173 | 0 | { 0xA26DA3999AEF774A, 322, 116 }, |
18174 | 0 | { 0xF209787BB47D6B85, 348, 124 }, |
18175 | 0 | { 0xB454E4A179DD1877, 375, 132 }, |
18176 | 0 | { 0x865B86925B9BC5C2, 402, 140 }, |
18177 | 0 | { 0xC83553C5C8965D3D, 428, 148 }, |
18178 | 0 | { 0x952AB45CFA97A0B3, 455, 156 }, |
18179 | 0 | { 0xDE469FBD99A05FE3, 481, 164 }, |
18180 | 0 | { 0xA59BC234DB398C25, 508, 172 }, |
18181 | 0 | { 0xF6C69A72A3989F5C, 534, 180 }, |
18182 | 0 | { 0xB7DCBF5354E9BECE, 561, 188 }, |
18183 | 0 | { 0x88FCF317F22241E2, 588, 196 }, |
18184 | 0 | { 0xCC20CE9BD35C78A5, 614, 204 }, |
18185 | 0 | { 0x98165AF37B2153DF, 641, 212 }, |
18186 | 0 | { 0xE2A0B5DC971F303A, 667, 220 }, |
18187 | 0 | { 0xA8D9D1535CE3B396, 694, 228 }, |
18188 | 0 | { 0xFB9B7CD9A4A7443C, 720, 236 }, |
18189 | 0 | { 0xBB764C4CA7A44410, 747, 244 }, |
18190 | 0 | { 0x8BAB8EEFB6409C1A, 774, 252 }, |
18191 | 0 | { 0xD01FEF10A657842C, 800, 260 }, |
18192 | 0 | { 0x9B10A4E5E9913129, 827, 268 }, |
18193 | 0 | { 0xE7109BFBA19C0C9D, 853, 276 }, |
18194 | 0 | { 0xAC2820D9623BF429, 880, 284 }, |
18195 | 0 | { 0x80444B5E7AA7CF85, 907, 292 }, |
18196 | 0 | { 0xBF21E44003ACDD2D, 933, 300 }, |
18197 | 0 | { 0x8E679C2F5E44FF8F, 960, 308 }, |
18198 | 0 | { 0xD433179D9C8CB841, 986, 316 }, |
18199 | 0 | { 0x9E19DB92B4E31BA9, 1013, 324 }, |
18200 | 0 | } |
18201 | 0 | }; |
18202 | | |
18203 | | // This computation gives exactly the same results for k as |
18204 | | // k = ceil((kAlpha - e - 1) * 0.30102999566398114) |
18205 | | // for |e| <= 1500, but doesn't require floating-point operations. |
18206 | | // NB: log_10(2) ~= 78913 / 2^18 |
18207 | 0 | JSON_ASSERT(e >= -1500); |
18208 | 0 | JSON_ASSERT(e <= 1500); |
18209 | 0 | const int f = kAlpha - e - 1; |
18210 | 0 | const int k = ((f * 78913) / (1 << 18)) + static_cast<int>(f > 0); |
18211 | |
|
18212 | 0 | const int index = (-kCachedPowersMinDecExp + k + (kCachedPowersDecStep - 1)) / kCachedPowersDecStep; |
18213 | 0 | JSON_ASSERT(index >= 0); |
18214 | 0 | JSON_ASSERT(static_cast<std::size_t>(index) < kCachedPowers.size()); |
18215 | | |
18216 | 0 | const cached_power cached = kCachedPowers[static_cast<std::size_t>(index)]; |
18217 | 0 | JSON_ASSERT(kAlpha <= cached.e + e + 64); |
18218 | 0 | JSON_ASSERT(kGamma >= cached.e + e + 64); |
18219 | | |
18220 | 0 | return cached; |
18221 | 0 | } |
18222 | | |
18223 | | /*! |
18224 | | For n != 0, returns k, such that pow10 := 10^(k-1) <= n < 10^k. |
18225 | | For n == 0, returns 1 and sets pow10 := 1. |
18226 | | */ |
18227 | | inline int find_largest_pow10(const std::uint32_t n, std::uint32_t& pow10) |
18228 | 0 | { |
18229 | | // LCOV_EXCL_START |
18230 | 0 | if (n >= 1000000000) |
18231 | 0 | { |
18232 | 0 | pow10 = 1000000000; |
18233 | 0 | return 10; |
18234 | 0 | } |
18235 | | // LCOV_EXCL_STOP |
18236 | 0 | if (n >= 100000000) |
18237 | 0 | { |
18238 | 0 | pow10 = 100000000; |
18239 | 0 | return 9; |
18240 | 0 | } |
18241 | 0 | if (n >= 10000000) |
18242 | 0 | { |
18243 | 0 | pow10 = 10000000; |
18244 | 0 | return 8; |
18245 | 0 | } |
18246 | 0 | if (n >= 1000000) |
18247 | 0 | { |
18248 | 0 | pow10 = 1000000; |
18249 | 0 | return 7; |
18250 | 0 | } |
18251 | 0 | if (n >= 100000) |
18252 | 0 | { |
18253 | 0 | pow10 = 100000; |
18254 | 0 | return 6; |
18255 | 0 | } |
18256 | 0 | if (n >= 10000) |
18257 | 0 | { |
18258 | 0 | pow10 = 10000; |
18259 | 0 | return 5; |
18260 | 0 | } |
18261 | 0 | if (n >= 1000) |
18262 | 0 | { |
18263 | 0 | pow10 = 1000; |
18264 | 0 | return 4; |
18265 | 0 | } |
18266 | 0 | if (n >= 100) |
18267 | 0 | { |
18268 | 0 | pow10 = 100; |
18269 | 0 | return 3; |
18270 | 0 | } |
18271 | 0 | if (n >= 10) |
18272 | 0 | { |
18273 | 0 | pow10 = 10; |
18274 | 0 | return 2; |
18275 | 0 | } |
18276 | | |
18277 | 0 | pow10 = 1; |
18278 | 0 | return 1; |
18279 | 0 | } |
18280 | | |
18281 | | inline void grisu2_round(char* buf, int len, std::uint64_t dist, std::uint64_t delta, |
18282 | | std::uint64_t rest, std::uint64_t ten_k) |
18283 | 0 | { |
18284 | 0 | JSON_ASSERT(len >= 1); |
18285 | 0 | JSON_ASSERT(dist <= delta); |
18286 | 0 | JSON_ASSERT(rest <= delta); |
18287 | 0 | JSON_ASSERT(ten_k > 0); |
18288 | | |
18289 | | // <--------------------------- delta ----> |
18290 | | // <---- dist ---------> |
18291 | | // --------------[------------------+-------------------]-------------- |
18292 | | // M- w M+ |
18293 | | // |
18294 | | // ten_k |
18295 | | // <------> |
18296 | | // <---- rest ----> |
18297 | | // --------------[------------------+----+--------------]-------------- |
18298 | | // w V |
18299 | | // = buf * 10^k |
18300 | | // |
18301 | | // ten_k represents a unit-in-the-last-place in the decimal representation |
18302 | | // stored in buf. |
18303 | | // Decrement buf by ten_k while this takes buf closer to w. |
18304 | | |
18305 | | // The tests are written in this order to avoid overflow in unsigned |
18306 | | // integer arithmetic. |
18307 | | |
18308 | 0 | while (rest < dist |
18309 | 0 | && delta - rest >= ten_k |
18310 | 0 | && (rest + ten_k < dist || dist - rest > rest + ten_k - dist)) |
18311 | 0 | { |
18312 | 0 | JSON_ASSERT(buf[len - 1] != '0'); |
18313 | 0 | buf[len - 1]--; |
18314 | 0 | rest += ten_k; |
18315 | 0 | } |
18316 | 0 | } |
18317 | | |
18318 | | /*! |
18319 | | Generates V = buffer * 10^decimal_exponent, such that M- <= V <= M+. |
18320 | | M- and M+ must be normalized and share the same exponent -60 <= e <= -32. |
18321 | | */ |
18322 | | inline void grisu2_digit_gen(char* buffer, int& length, int& decimal_exponent, |
18323 | | diyfp M_minus, diyfp w, diyfp M_plus) |
18324 | 0 | { |
18325 | 0 | static_assert(kAlpha >= -60, "internal error"); |
18326 | 0 | static_assert(kGamma <= -32, "internal error"); |
18327 | | |
18328 | | // Generates the digits (and the exponent) of a decimal floating-point |
18329 | | // number V = buffer * 10^decimal_exponent in the range [M-, M+]. The diyfp's |
18330 | | // w, M- and M+ share the same exponent e, which satisfies alpha <= e <= gamma. |
18331 | | // |
18332 | | // <--------------------------- delta ----> |
18333 | | // <---- dist ---------> |
18334 | | // --------------[------------------+-------------------]-------------- |
18335 | | // M- w M+ |
18336 | | // |
18337 | | // Grisu2 generates the digits of M+ from left to right and stops as soon as |
18338 | | // V is in [M-,M+]. |
18339 | |
|
18340 | 0 | JSON_ASSERT(M_plus.e >= kAlpha); |
18341 | 0 | JSON_ASSERT(M_plus.e <= kGamma); |
18342 | | |
18343 | 0 | std::uint64_t delta = diyfp::sub(M_plus, M_minus).f; // (significand of (M+ - M-), implicit exponent is e) |
18344 | 0 | std::uint64_t dist = diyfp::sub(M_plus, w ).f; // (significand of (M+ - w ), implicit exponent is e) |
18345 | | |
18346 | | // Split M+ = f * 2^e into two parts p1 and p2 (note: e < 0): |
18347 | | // |
18348 | | // M+ = f * 2^e |
18349 | | // = ((f div 2^-e) * 2^-e + (f mod 2^-e)) * 2^e |
18350 | | // = ((p1 ) * 2^-e + (p2 )) * 2^e |
18351 | | // = p1 + p2 * 2^e |
18352 | |
|
18353 | 0 | const diyfp one(std::uint64_t{1} << -M_plus.e, M_plus.e); |
18354 | |
|
18355 | 0 | auto p1 = static_cast<std::uint32_t>(M_plus.f >> -one.e); // p1 = f div 2^-e (Since -e >= 32, p1 fits into a 32-bit int.) |
18356 | 0 | std::uint64_t p2 = M_plus.f & (one.f - 1); // p2 = f mod 2^-e |
18357 | | |
18358 | | // 1) |
18359 | | // |
18360 | | // Generate the digits of the integral part p1 = d[n-1]...d[1]d[0] |
18361 | |
|
18362 | 0 | JSON_ASSERT(p1 > 0); |
18363 | | |
18364 | 0 | std::uint32_t pow10{}; |
18365 | 0 | const int k = find_largest_pow10(p1, pow10); |
18366 | | |
18367 | | // 10^(k-1) <= p1 < 10^k, pow10 = 10^(k-1) |
18368 | | // |
18369 | | // p1 = (p1 div 10^(k-1)) * 10^(k-1) + (p1 mod 10^(k-1)) |
18370 | | // = (d[k-1] ) * 10^(k-1) + (p1 mod 10^(k-1)) |
18371 | | // |
18372 | | // M+ = p1 + p2 * 2^e |
18373 | | // = d[k-1] * 10^(k-1) + (p1 mod 10^(k-1)) + p2 * 2^e |
18374 | | // = d[k-1] * 10^(k-1) + ((p1 mod 10^(k-1)) * 2^-e + p2) * 2^e |
18375 | | // = d[k-1] * 10^(k-1) + ( rest) * 2^e |
18376 | | // |
18377 | | // Now generate the digits d[n] of p1 from left to right (n = k-1,...,0) |
18378 | | // |
18379 | | // p1 = d[k-1]...d[n] * 10^n + d[n-1]...d[0] |
18380 | | // |
18381 | | // but stop as soon as |
18382 | | // |
18383 | | // rest * 2^e = (d[n-1]...d[0] * 2^-e + p2) * 2^e <= delta * 2^e |
18384 | |
|
18385 | 0 | int n = k; |
18386 | 0 | while (n > 0) |
18387 | 0 | { |
18388 | | // Invariants: |
18389 | | // M+ = buffer * 10^n + (p1 + p2 * 2^e) (buffer = 0 for n = k) |
18390 | | // pow10 = 10^(n-1) <= p1 < 10^n |
18391 | | // |
18392 | 0 | const std::uint32_t d = p1 / pow10; // d = p1 div 10^(n-1) |
18393 | 0 | const std::uint32_t r = p1 % pow10; // r = p1 mod 10^(n-1) |
18394 | | // |
18395 | | // M+ = buffer * 10^n + (d * 10^(n-1) + r) + p2 * 2^e |
18396 | | // = (buffer * 10 + d) * 10^(n-1) + (r + p2 * 2^e) |
18397 | | // |
18398 | 0 | JSON_ASSERT(d <= 9); |
18399 | 0 | buffer[length++] = static_cast<char>('0' + d); // buffer := buffer * 10 + d |
18400 | | // |
18401 | | // M+ = buffer * 10^(n-1) + (r + p2 * 2^e) |
18402 | | // |
18403 | 0 | p1 = r; |
18404 | 0 | n--; |
18405 | | // |
18406 | | // M+ = buffer * 10^n + (p1 + p2 * 2^e) |
18407 | | // pow10 = 10^n |
18408 | | // |
18409 | | |
18410 | | // Now check if enough digits have been generated. |
18411 | | // Compute |
18412 | | // |
18413 | | // p1 + p2 * 2^e = (p1 * 2^-e + p2) * 2^e = rest * 2^e |
18414 | | // |
18415 | | // Note: |
18416 | | // Since rest and delta share the same exponent e, it suffices to |
18417 | | // compare the significands. |
18418 | 0 | const std::uint64_t rest = (std::uint64_t{p1} << -one.e) + p2; |
18419 | 0 | if (rest <= delta) |
18420 | 0 | { |
18421 | | // V = buffer * 10^n, with M- <= V <= M+. |
18422 | |
|
18423 | 0 | decimal_exponent += n; |
18424 | | |
18425 | | // We may now just stop. But instead, it looks as if the buffer |
18426 | | // could be decremented to bring V closer to w. |
18427 | | // |
18428 | | // pow10 = 10^n is now 1 ulp in the decimal representation V. |
18429 | | // The rounding procedure works with diyfp's with an implicit |
18430 | | // exponent of e. |
18431 | | // |
18432 | | // 10^n = (10^n * 2^-e) * 2^e = ulp * 2^e |
18433 | | // |
18434 | 0 | const std::uint64_t ten_n = std::uint64_t{pow10} << -one.e; |
18435 | 0 | grisu2_round(buffer, length, dist, delta, rest, ten_n); |
18436 | |
|
18437 | 0 | return; |
18438 | 0 | } |
18439 | | |
18440 | 0 | pow10 /= 10; |
18441 | | // |
18442 | | // pow10 = 10^(n-1) <= p1 < 10^n |
18443 | | // Invariants restored. |
18444 | 0 | } |
18445 | | |
18446 | | // 2) |
18447 | | // |
18448 | | // The digits of the integral part have been generated: |
18449 | | // |
18450 | | // M+ = d[k-1]...d[1]d[0] + p2 * 2^e |
18451 | | // = buffer + p2 * 2^e |
18452 | | // |
18453 | | // Now generate the digits of the fractional part p2 * 2^e. |
18454 | | // |
18455 | | // Note: |
18456 | | // No decimal point is generated: the exponent is adjusted instead. |
18457 | | // |
18458 | | // p2 actually represents the fraction |
18459 | | // |
18460 | | // p2 * 2^e |
18461 | | // = p2 / 2^-e |
18462 | | // = d[-1] / 10^1 + d[-2] / 10^2 + ... |
18463 | | // |
18464 | | // Now generate the digits d[-m] of p1 from left to right (m = 1,2,...) |
18465 | | // |
18466 | | // p2 * 2^e = d[-1]d[-2]...d[-m] * 10^-m |
18467 | | // + 10^-m * (d[-m-1] / 10^1 + d[-m-2] / 10^2 + ...) |
18468 | | // |
18469 | | // using |
18470 | | // |
18471 | | // 10^m * p2 = ((10^m * p2) div 2^-e) * 2^-e + ((10^m * p2) mod 2^-e) |
18472 | | // = ( d) * 2^-e + ( r) |
18473 | | // |
18474 | | // or |
18475 | | // 10^m * p2 * 2^e = d + r * 2^e |
18476 | | // |
18477 | | // i.e. |
18478 | | // |
18479 | | // M+ = buffer + p2 * 2^e |
18480 | | // = buffer + 10^-m * (d + r * 2^e) |
18481 | | // = (buffer * 10^m + d) * 10^-m + 10^-m * r * 2^e |
18482 | | // |
18483 | | // and stop as soon as 10^-m * r * 2^e <= delta * 2^e |
18484 | | |
18485 | 0 | JSON_ASSERT(p2 > delta); |
18486 | | |
18487 | 0 | int m = 0; |
18488 | 0 | for (;;) |
18489 | 0 | { |
18490 | | // Invariant: |
18491 | | // M+ = buffer * 10^-m + 10^-m * (d[-m-1] / 10 + d[-m-2] / 10^2 + ...) * 2^e |
18492 | | // = buffer * 10^-m + 10^-m * (p2 ) * 2^e |
18493 | | // = buffer * 10^-m + 10^-m * (1/10 * (10 * p2) ) * 2^e |
18494 | | // = buffer * 10^-m + 10^-m * (1/10 * ((10*p2 div 2^-e) * 2^-e + (10*p2 mod 2^-e)) * 2^e |
18495 | | // |
18496 | 0 | JSON_ASSERT(p2 <= (std::numeric_limits<std::uint64_t>::max)() / 10); |
18497 | 0 | p2 *= 10; |
18498 | 0 | const std::uint64_t d = p2 >> -one.e; // d = (10 * p2) div 2^-e |
18499 | 0 | const std::uint64_t r = p2 & (one.f - 1); // r = (10 * p2) mod 2^-e |
18500 | | // |
18501 | | // M+ = buffer * 10^-m + 10^-m * (1/10 * (d * 2^-e + r) * 2^e |
18502 | | // = buffer * 10^-m + 10^-m * (1/10 * (d + r * 2^e)) |
18503 | | // = (buffer * 10 + d) * 10^(-m-1) + 10^(-m-1) * r * 2^e |
18504 | | // |
18505 | 0 | JSON_ASSERT(d <= 9); |
18506 | 0 | buffer[length++] = static_cast<char>('0' + d); // buffer := buffer * 10 + d |
18507 | | // |
18508 | | // M+ = buffer * 10^(-m-1) + 10^(-m-1) * r * 2^e |
18509 | | // |
18510 | 0 | p2 = r; |
18511 | 0 | m++; |
18512 | | // |
18513 | | // M+ = buffer * 10^-m + 10^-m * p2 * 2^e |
18514 | | // Invariant restored. |
18515 | | |
18516 | | // Check if enough digits have been generated. |
18517 | | // |
18518 | | // 10^-m * p2 * 2^e <= delta * 2^e |
18519 | | // p2 * 2^e <= 10^m * delta * 2^e |
18520 | | // p2 <= 10^m * delta |
18521 | 0 | delta *= 10; |
18522 | 0 | dist *= 10; |
18523 | 0 | if (p2 <= delta) |
18524 | 0 | { |
18525 | 0 | break; |
18526 | 0 | } |
18527 | 0 | } |
18528 | | |
18529 | | // V = buffer * 10^-m, with M- <= V <= M+. |
18530 | | |
18531 | 0 | decimal_exponent -= m; |
18532 | | |
18533 | | // 1 ulp in the decimal representation is now 10^-m. |
18534 | | // Since delta and dist are now scaled by 10^m, we need to do the |
18535 | | // same with ulp in order to keep the units in sync. |
18536 | | // |
18537 | | // 10^m * 10^-m = 1 = 2^-e * 2^e = ten_m * 2^e |
18538 | | // |
18539 | 0 | const std::uint64_t ten_m = one.f; |
18540 | 0 | grisu2_round(buffer, length, dist, delta, p2, ten_m); |
18541 | | |
18542 | | // By construction this algorithm generates the shortest possible decimal |
18543 | | // number (Loitsch, Theorem 6.2) which rounds back to w. |
18544 | | // For an input number of precision p, at least |
18545 | | // |
18546 | | // N = 1 + ceil(p * log_10(2)) |
18547 | | // |
18548 | | // decimal digits are sufficient to identify all binary floating-point |
18549 | | // numbers (Matula, "In-and-Out conversions"). |
18550 | | // This implies that the algorithm does not produce more than N decimal |
18551 | | // digits. |
18552 | | // |
18553 | | // N = 17 for p = 53 (IEEE double precision) |
18554 | | // N = 9 for p = 24 (IEEE single precision) |
18555 | 0 | } |
18556 | | |
18557 | | /*! |
18558 | | v = buf * 10^decimal_exponent |
18559 | | len is the length of the buffer (number of decimal digits) |
18560 | | The buffer must be large enough, i.e. >= max_digits10. |
18561 | | */ |
18562 | | JSON_HEDLEY_NON_NULL(1) |
18563 | | inline void grisu2(char* buf, int& len, int& decimal_exponent, |
18564 | | diyfp m_minus, diyfp v, diyfp m_plus) |
18565 | 0 | { |
18566 | 0 | JSON_ASSERT(m_plus.e == m_minus.e); |
18567 | 0 | JSON_ASSERT(m_plus.e == v.e); |
18568 | | |
18569 | | // --------(-----------------------+-----------------------)-------- (A) |
18570 | | // m- v m+ |
18571 | | // |
18572 | | // --------------------(-----------+-----------------------)-------- (B) |
18573 | | // m- v m+ |
18574 | | // |
18575 | | // First scale v (and m- and m+) such that the exponent is in the range |
18576 | | // [alpha, gamma]. |
18577 | | |
18578 | 0 | const cached_power cached = get_cached_power_for_binary_exponent(m_plus.e); |
18579 | |
|
18580 | 0 | const diyfp c_minus_k(cached.f, cached.e); // = c ~= 10^-k |
18581 | | |
18582 | | // The exponent of the products is = v.e + c_minus_k.e + q and is in the range [alpha,gamma] |
18583 | 0 | const diyfp w = diyfp::mul(v, c_minus_k); |
18584 | 0 | const diyfp w_minus = diyfp::mul(m_minus, c_minus_k); |
18585 | 0 | const diyfp w_plus = diyfp::mul(m_plus, c_minus_k); |
18586 | | |
18587 | | // ----(---+---)---------------(---+---)---------------(---+---)---- |
18588 | | // w- w w+ |
18589 | | // = c*m- = c*v = c*m+ |
18590 | | // |
18591 | | // diyfp::mul rounds its result and c_minus_k is approximated too. w, w- and |
18592 | | // w+ are now off by a small amount. |
18593 | | // In fact: |
18594 | | // |
18595 | | // w - v * 10^k < 1 ulp |
18596 | | // |
18597 | | // To account for this inaccuracy, add resp. subtract 1 ulp. |
18598 | | // |
18599 | | // --------+---[---------------(---+---)---------------]---+-------- |
18600 | | // w- M- w M+ w+ |
18601 | | // |
18602 | | // Now any number in [M-, M+] (bounds included) will round to w when input, |
18603 | | // regardless of how the input rounding algorithm breaks ties. |
18604 | | // |
18605 | | // And digit_gen generates the shortest possible such number in [M-, M+]. |
18606 | | // Note that this does not mean that Grisu2 always generates the shortest |
18607 | | // possible number in the interval (m-, m+). |
18608 | 0 | const diyfp M_minus(w_minus.f + 1, w_minus.e); |
18609 | 0 | const diyfp M_plus (w_plus.f - 1, w_plus.e ); |
18610 | |
|
18611 | 0 | decimal_exponent = -cached.k; // = -(-k) = k |
18612 | |
|
18613 | 0 | grisu2_digit_gen(buf, len, decimal_exponent, M_minus, w, M_plus); |
18614 | 0 | } |
18615 | | |
18616 | | /*! |
18617 | | v = buf * 10^decimal_exponent |
18618 | | len is the length of the buffer (number of decimal digits) |
18619 | | The buffer must be large enough, i.e. >= max_digits10. |
18620 | | */ |
18621 | | template<typename FloatType> |
18622 | | JSON_HEDLEY_NON_NULL(1) |
18623 | | void grisu2(char* buf, int& len, int& decimal_exponent, FloatType value) |
18624 | 0 | { |
18625 | 0 | static_assert(diyfp::kPrecision >= std::numeric_limits<FloatType>::digits + 3, |
18626 | 0 | "internal error: not enough precision"); |
18627 | |
|
18628 | 0 | JSON_ASSERT(std::isfinite(value)); |
18629 | 0 | JSON_ASSERT(value > 0); |
18630 | | |
18631 | | // If the neighbors (and boundaries) of 'value' are always computed for double-precision |
18632 | | // numbers, all float's can be recovered using strtod (and strtof). However, the resulting |
18633 | | // decimal representations are not exactly "short". |
18634 | | // |
18635 | | // The documentation for 'std::to_chars' (https://en.cppreference.com/w/cpp/utility/to_chars) |
18636 | | // says "value is converted to a string as if by std::sprintf in the default ("C") locale" |
18637 | | // and since sprintf promotes floats to doubles, I think this is exactly what 'std::to_chars' |
18638 | | // does. |
18639 | | // On the other hand, the documentation for 'std::to_chars' requires that "parsing the |
18640 | | // representation using the corresponding std::from_chars function recovers value exactly". That |
18641 | | // indicates that single precision floating-point numbers should be recovered using |
18642 | | // 'std::strtof'. |
18643 | | // |
18644 | | // NB: If the neighbors are computed for single-precision numbers, there is a single float |
18645 | | // (7.0385307e-26f) which can't be recovered using strtod. The resulting double precision |
18646 | | // value is off by 1 ulp. |
18647 | | #if 0 // NOLINT(readability-avoid-unconditional-preprocessor-if) |
18648 | | const boundaries w = compute_boundaries(static_cast<double>(value)); |
18649 | | #else |
18650 | 0 | const boundaries w = compute_boundaries(value); |
18651 | 0 | #endif |
18652 | |
|
18653 | 0 | grisu2(buf, len, decimal_exponent, w.minus, w.w, w.plus); |
18654 | 0 | } |
18655 | | |
18656 | | /*! |
18657 | | @brief appends a decimal representation of e to buf |
18658 | | @return a pointer to the element following the exponent. |
18659 | | @pre -1000 < e < 1000 |
18660 | | */ |
18661 | | JSON_HEDLEY_NON_NULL(1) |
18662 | | JSON_HEDLEY_RETURNS_NON_NULL |
18663 | | inline char* append_exponent(char* buf, int e) |
18664 | 0 | { |
18665 | 0 | JSON_ASSERT(e > -1000); |
18666 | 0 | JSON_ASSERT(e < 1000); |
18667 | | |
18668 | 0 | if (e < 0) |
18669 | 0 | { |
18670 | 0 | e = -e; |
18671 | 0 | *buf++ = '-'; |
18672 | 0 | } |
18673 | 0 | else |
18674 | 0 | { |
18675 | 0 | *buf++ = '+'; |
18676 | 0 | } |
18677 | |
|
18678 | 0 | auto k = static_cast<std::uint32_t>(e); |
18679 | 0 | if (k < 10) |
18680 | 0 | { |
18681 | | // Always print at least two digits in the exponent. |
18682 | | // This is for compatibility with printf("%g"). |
18683 | 0 | *buf++ = '0'; |
18684 | 0 | *buf++ = static_cast<char>('0' + k); |
18685 | 0 | } |
18686 | 0 | else if (k < 100) |
18687 | 0 | { |
18688 | 0 | *buf++ = static_cast<char>('0' + (k / 10)); |
18689 | 0 | k %= 10; |
18690 | 0 | *buf++ = static_cast<char>('0' + k); |
18691 | 0 | } |
18692 | 0 | else |
18693 | 0 | { |
18694 | 0 | *buf++ = static_cast<char>('0' + (k / 100)); |
18695 | 0 | k %= 100; |
18696 | 0 | *buf++ = static_cast<char>('0' + (k / 10)); |
18697 | 0 | k %= 10; |
18698 | 0 | *buf++ = static_cast<char>('0' + k); |
18699 | 0 | } |
18700 | |
|
18701 | 0 | return buf; |
18702 | 0 | } |
18703 | | |
18704 | | /*! |
18705 | | @brief prettify v = buf * 10^decimal_exponent |
18706 | | |
18707 | | If v is in the range [10^min_exp, 10^max_exp) it will be printed in fixed-point |
18708 | | notation. Otherwise it will be printed in exponential notation. |
18709 | | |
18710 | | @pre min_exp < 0 |
18711 | | @pre max_exp > 0 |
18712 | | */ |
18713 | | JSON_HEDLEY_NON_NULL(1) |
18714 | | JSON_HEDLEY_RETURNS_NON_NULL |
18715 | | inline char* format_buffer(char* buf, int len, int decimal_exponent, |
18716 | | int min_exp, int max_exp) |
18717 | 0 | { |
18718 | 0 | JSON_ASSERT(min_exp < 0); |
18719 | 0 | JSON_ASSERT(max_exp > 0); |
18720 | | |
18721 | 0 | const int k = len; |
18722 | 0 | const int n = len + decimal_exponent; |
18723 | | |
18724 | | // v = buf * 10^(n-k) |
18725 | | // k is the length of the buffer (number of decimal digits) |
18726 | | // n is the position of the decimal point relative to the start of the buffer. |
18727 | |
|
18728 | 0 | if (k <= n && n <= max_exp) |
18729 | 0 | { |
18730 | | // digits[000] |
18731 | | // len <= max_exp + 2 |
18732 | |
|
18733 | 0 | std::memset(buf + k, '0', static_cast<size_t>(n) - static_cast<size_t>(k)); |
18734 | | // Make it look like a floating-point number (#362, #378) |
18735 | 0 | buf[n + 0] = '.'; |
18736 | 0 | buf[n + 1] = '0'; |
18737 | 0 | return buf + (static_cast<size_t>(n) + 2); |
18738 | 0 | } |
18739 | | |
18740 | 0 | if (0 < n && n <= max_exp) |
18741 | 0 | { |
18742 | | // dig.its |
18743 | | // len <= max_digits10 + 1 |
18744 | |
|
18745 | 0 | JSON_ASSERT(k > n); |
18746 | | |
18747 | 0 | std::memmove(buf + (static_cast<size_t>(n) + 1), buf + n, static_cast<size_t>(k) - static_cast<size_t>(n)); |
18748 | 0 | buf[n] = '.'; |
18749 | 0 | return buf + (static_cast<size_t>(k) + 1U); |
18750 | 0 | } |
18751 | | |
18752 | 0 | if (min_exp < n && n <= 0) |
18753 | 0 | { |
18754 | | // 0.[000]digits |
18755 | | // len <= 2 + (-min_exp - 1) + max_digits10 |
18756 | |
|
18757 | 0 | std::memmove(buf + (2 + static_cast<size_t>(-n)), buf, static_cast<size_t>(k)); |
18758 | 0 | buf[0] = '0'; |
18759 | 0 | buf[1] = '.'; |
18760 | 0 | std::memset(buf + 2, '0', static_cast<size_t>(-n)); |
18761 | 0 | return buf + (2U + static_cast<size_t>(-n) + static_cast<size_t>(k)); |
18762 | 0 | } |
18763 | | |
18764 | 0 | if (k == 1) |
18765 | 0 | { |
18766 | | // dE+123 |
18767 | | // len <= 1 + 5 |
18768 | |
|
18769 | 0 | buf += 1; |
18770 | 0 | } |
18771 | 0 | else |
18772 | 0 | { |
18773 | | // d.igitsE+123 |
18774 | | // len <= max_digits10 + 1 + 5 |
18775 | |
|
18776 | 0 | std::memmove(buf + 2, buf + 1, static_cast<size_t>(k) - 1); |
18777 | 0 | buf[1] = '.'; |
18778 | 0 | buf += 1 + static_cast<size_t>(k); |
18779 | 0 | } |
18780 | |
|
18781 | 0 | *buf++ = 'e'; |
18782 | 0 | return append_exponent(buf, n - 1); |
18783 | 0 | } |
18784 | | |
18785 | | } // namespace dtoa_impl |
18786 | | |
18787 | | /*! |
18788 | | @brief generates a decimal representation of the floating-point number value in [first, last). |
18789 | | |
18790 | | The format of the resulting decimal representation is similar to printf's %g |
18791 | | format. Returns an iterator pointing past-the-end of the decimal representation. |
18792 | | |
18793 | | @note The input number must be finite, i.e. NaN's and Inf's are not supported. |
18794 | | @note The buffer must be large enough. |
18795 | | @note The result is NOT null-terminated. |
18796 | | */ |
18797 | | template<typename FloatType> |
18798 | | JSON_HEDLEY_NON_NULL(1, 2) |
18799 | | JSON_HEDLEY_RETURNS_NON_NULL |
18800 | | char* to_chars(char* first, const char* last, FloatType value) |
18801 | 0 | { |
18802 | 0 | static_cast<void>(last); // maybe unused - fix warning |
18803 | 0 | JSON_ASSERT(std::isfinite(value)); |
18804 | | |
18805 | | // Use signbit(value) instead of (value < 0) since signbit works for -0. |
18806 | 0 | if (std::signbit(value)) |
18807 | 0 | { |
18808 | 0 | value = -value; |
18809 | 0 | *first++ = '-'; |
18810 | 0 | } |
18811 | |
|
18812 | 0 | #ifdef __GNUC__ |
18813 | 0 | #pragma GCC diagnostic push |
18814 | 0 | #pragma GCC diagnostic ignored "-Wfloat-equal" |
18815 | 0 | #endif |
18816 | 0 | if (value == 0) // +-0 |
18817 | 0 | { |
18818 | 0 | *first++ = '0'; |
18819 | | // Make it look like a floating-point number (#362, #378) |
18820 | 0 | *first++ = '.'; |
18821 | 0 | *first++ = '0'; |
18822 | 0 | return first; |
18823 | 0 | } |
18824 | 0 | #ifdef __GNUC__ |
18825 | 0 | #pragma GCC diagnostic pop |
18826 | 0 | #endif |
18827 | | |
18828 | 0 | JSON_ASSERT(last - first >= std::numeric_limits<FloatType>::max_digits10); |
18829 | | |
18830 | | // Compute v = buffer * 10^decimal_exponent. |
18831 | | // The decimal digits are stored in the buffer, which needs to be interpreted |
18832 | | // as an unsigned decimal integer. |
18833 | | // len is the length of the buffer, i.e., the number of decimal digits. |
18834 | 0 | int len = 0; |
18835 | 0 | int decimal_exponent = 0; |
18836 | 0 | dtoa_impl::grisu2(first, len, decimal_exponent, value); |
18837 | |
|
18838 | 0 | JSON_ASSERT(len <= std::numeric_limits<FloatType>::max_digits10); |
18839 | | |
18840 | | // Format the buffer like printf("%.*g", prec, value) |
18841 | 0 | constexpr int kMinExp = -4; |
18842 | | // Use digits10 here to increase compatibility with version 2. |
18843 | 0 | constexpr int kMaxExp = std::numeric_limits<FloatType>::digits10; |
18844 | |
|
18845 | 0 | JSON_ASSERT(last - first >= kMaxExp + 2); |
18846 | 0 | JSON_ASSERT(last - first >= 2 + (-kMinExp - 1) + std::numeric_limits<FloatType>::max_digits10); |
18847 | 0 | JSON_ASSERT(last - first >= std::numeric_limits<FloatType>::max_digits10 + 6); |
18848 | | |
18849 | 0 | return dtoa_impl::format_buffer(first, len, decimal_exponent, kMinExp, kMaxExp); |
18850 | 0 | } |
18851 | | |
18852 | | } // namespace detail |
18853 | | NLOHMANN_JSON_NAMESPACE_END |
18854 | | |
18855 | | // #include <nlohmann/detail/exceptions.hpp> |
18856 | | |
18857 | | // #include <nlohmann/detail/macro_scope.hpp> |
18858 | | |
18859 | | // #include <nlohmann/detail/meta/cpp_future.hpp> |
18860 | | |
18861 | | // #include <nlohmann/detail/output/binary_writer.hpp> |
18862 | | |
18863 | | // #include <nlohmann/detail/output/output_adapters.hpp> |
18864 | | |
18865 | | // #include <nlohmann/detail/string_concat.hpp> |
18866 | | |
18867 | | // #include <nlohmann/detail/value_t.hpp> |
18868 | | |
18869 | | |
18870 | | NLOHMANN_JSON_NAMESPACE_BEGIN |
18871 | | namespace detail |
18872 | | { |
18873 | | |
18874 | | /////////////////// |
18875 | | // serialization // |
18876 | | /////////////////// |
18877 | | |
18878 | | /// how to treat decoding errors |
18879 | | enum class error_handler_t |
18880 | | { |
18881 | | strict, ///< throw a type_error exception in case of invalid UTF-8 |
18882 | | replace, ///< replace invalid UTF-8 sequences with U+FFFD |
18883 | | ignore ///< ignore invalid UTF-8 sequences |
18884 | | }; |
18885 | | |
18886 | | template<typename BasicJsonType> |
18887 | | class serializer |
18888 | | { |
18889 | | using string_t = typename BasicJsonType::string_t; |
18890 | | using number_float_t = typename BasicJsonType::number_float_t; |
18891 | | using number_integer_t = typename BasicJsonType::number_integer_t; |
18892 | | using number_unsigned_t = typename BasicJsonType::number_unsigned_t; |
18893 | | using binary_char_t = typename BasicJsonType::binary_t::value_type; |
18894 | | static constexpr std::uint8_t UTF8_ACCEPT = 0; |
18895 | | static constexpr std::uint8_t UTF8_REJECT = 1; |
18896 | | |
18897 | | public: |
18898 | | /*! |
18899 | | @param[in] s output stream to serialize to |
18900 | | @param[in] ichar indentation character to use |
18901 | | @param[in] error_handler_ how to react on decoding errors |
18902 | | */ |
18903 | | serializer(output_adapter_t<char> s, const char ichar, |
18904 | | error_handler_t error_handler_ = error_handler_t::strict) |
18905 | 0 | : o(std::move(s)) |
18906 | 0 | , loc(std::localeconv()) |
18907 | 0 | , thousands_sep(loc->thousands_sep == nullptr ? '\0' : std::char_traits<char>::to_char_type(* (loc->thousands_sep))) |
18908 | 0 | , decimal_point(loc->decimal_point == nullptr ? '\0' : std::char_traits<char>::to_char_type(* (loc->decimal_point))) |
18909 | 0 | , indent_char(ichar) |
18910 | 0 | , indent_string(512, indent_char) |
18911 | 0 | , error_handler(error_handler_) |
18912 | 0 | {} |
18913 | | |
18914 | | // deleted because of pointer members |
18915 | | serializer(const serializer&) = delete; |
18916 | | serializer& operator=(const serializer&) = delete; |
18917 | | serializer(serializer&&) = delete; |
18918 | | serializer& operator=(serializer&&) = delete; |
18919 | 0 | ~serializer() = default; |
18920 | | |
18921 | | /*! |
18922 | | @brief internal implementation of the serialization function |
18923 | | |
18924 | | This function is called by the public member function dump and organizes |
18925 | | the serialization internally. The indentation level is propagated as |
18926 | | additional parameter. In case of arrays and objects, the function is |
18927 | | called recursively. |
18928 | | |
18929 | | - strings and object keys are escaped using `escape_string()` |
18930 | | - integer numbers are converted implicitly via `operator<<` |
18931 | | - floating-point numbers are converted to a string using `"%g"` format |
18932 | | - binary values are serialized as objects containing the subtype and the |
18933 | | byte array |
18934 | | |
18935 | | @param[in] val value to serialize |
18936 | | @param[in] pretty_print whether the output shall be pretty-printed |
18937 | | @param[in] ensure_ascii If @a ensure_ascii is true, all non-ASCII characters |
18938 | | in the output are escaped with `\uXXXX` sequences, and the result consists |
18939 | | of ASCII characters only. |
18940 | | @param[in] indent_step the indent level |
18941 | | @param[in] current_indent the current indent level (only used internally) |
18942 | | */ |
18943 | | void dump(const BasicJsonType& val, |
18944 | | const bool pretty_print, |
18945 | | const bool ensure_ascii, |
18946 | | const unsigned int indent_step, |
18947 | | const unsigned int current_indent = 0) |
18948 | 0 | { |
18949 | 0 | switch (val.m_data.m_type) |
18950 | 0 | { |
18951 | 0 | case value_t::object: |
18952 | 0 | { |
18953 | 0 | if (val.m_data.m_value.object->empty()) |
18954 | 0 | { |
18955 | 0 | o->write_characters("{}", 2); |
18956 | 0 | return; |
18957 | 0 | } |
18958 | | |
18959 | 0 | if (pretty_print) |
18960 | 0 | { |
18961 | 0 | o->write_characters("{\n", 2); |
18962 | | |
18963 | | // variable to hold indentation for recursive calls |
18964 | 0 | const auto new_indent = current_indent + indent_step; |
18965 | 0 | if (JSON_HEDLEY_UNLIKELY(indent_string.size() < new_indent)) |
18966 | 0 | { |
18967 | 0 | indent_string.resize(indent_string.size() * 2, ' '); |
18968 | 0 | } |
18969 | | |
18970 | | // first n-1 elements |
18971 | 0 | auto i = val.m_data.m_value.object->cbegin(); |
18972 | 0 | for (std::size_t cnt = 0; cnt < val.m_data.m_value.object->size() - 1; ++cnt, ++i) |
18973 | 0 | { |
18974 | 0 | o->write_characters(indent_string.c_str(), new_indent); |
18975 | 0 | o->write_character('\"'); |
18976 | 0 | dump_escaped(i->first, ensure_ascii); |
18977 | 0 | o->write_characters("\": ", 3); |
18978 | 0 | dump(i->second, true, ensure_ascii, indent_step, new_indent); |
18979 | 0 | o->write_characters(",\n", 2); |
18980 | 0 | } |
18981 | | |
18982 | | // last element |
18983 | 0 | JSON_ASSERT(i != val.m_data.m_value.object->cend()); |
18984 | 0 | JSON_ASSERT(std::next(i) == val.m_data.m_value.object->cend()); |
18985 | 0 | o->write_characters(indent_string.c_str(), new_indent); |
18986 | 0 | o->write_character('\"'); |
18987 | 0 | dump_escaped(i->first, ensure_ascii); |
18988 | 0 | o->write_characters("\": ", 3); |
18989 | 0 | dump(i->second, true, ensure_ascii, indent_step, new_indent); |
18990 | |
|
18991 | 0 | o->write_character('\n'); |
18992 | 0 | o->write_characters(indent_string.c_str(), current_indent); |
18993 | 0 | o->write_character('}'); |
18994 | 0 | } |
18995 | 0 | else |
18996 | 0 | { |
18997 | 0 | o->write_character('{'); |
18998 | | |
18999 | | // first n-1 elements |
19000 | 0 | auto i = val.m_data.m_value.object->cbegin(); |
19001 | 0 | for (std::size_t cnt = 0; cnt < val.m_data.m_value.object->size() - 1; ++cnt, ++i) |
19002 | 0 | { |
19003 | 0 | o->write_character('\"'); |
19004 | 0 | dump_escaped(i->first, ensure_ascii); |
19005 | 0 | o->write_characters("\":", 2); |
19006 | 0 | dump(i->second, false, ensure_ascii, indent_step, current_indent); |
19007 | 0 | o->write_character(','); |
19008 | 0 | } |
19009 | | |
19010 | | // last element |
19011 | 0 | JSON_ASSERT(i != val.m_data.m_value.object->cend()); |
19012 | 0 | JSON_ASSERT(std::next(i) == val.m_data.m_value.object->cend()); |
19013 | 0 | o->write_character('\"'); |
19014 | 0 | dump_escaped(i->first, ensure_ascii); |
19015 | 0 | o->write_characters("\":", 2); |
19016 | 0 | dump(i->second, false, ensure_ascii, indent_step, current_indent); |
19017 | |
|
19018 | 0 | o->write_character('}'); |
19019 | 0 | } |
19020 | | |
19021 | 0 | return; |
19022 | 0 | } |
19023 | | |
19024 | 0 | case value_t::array: |
19025 | 0 | { |
19026 | 0 | if (val.m_data.m_value.array->empty()) |
19027 | 0 | { |
19028 | 0 | o->write_characters("[]", 2); |
19029 | 0 | return; |
19030 | 0 | } |
19031 | | |
19032 | 0 | if (pretty_print) |
19033 | 0 | { |
19034 | 0 | o->write_characters("[\n", 2); |
19035 | | |
19036 | | // variable to hold indentation for recursive calls |
19037 | 0 | const auto new_indent = current_indent + indent_step; |
19038 | 0 | if (JSON_HEDLEY_UNLIKELY(indent_string.size() < new_indent)) |
19039 | 0 | { |
19040 | 0 | indent_string.resize(indent_string.size() * 2, ' '); |
19041 | 0 | } |
19042 | | |
19043 | | // first n-1 elements |
19044 | 0 | for (auto i = val.m_data.m_value.array->cbegin(); |
19045 | 0 | i != val.m_data.m_value.array->cend() - 1; ++i) |
19046 | 0 | { |
19047 | 0 | o->write_characters(indent_string.c_str(), new_indent); |
19048 | 0 | dump(*i, true, ensure_ascii, indent_step, new_indent); |
19049 | 0 | o->write_characters(",\n", 2); |
19050 | 0 | } |
19051 | | |
19052 | | // last element |
19053 | 0 | JSON_ASSERT(!val.m_data.m_value.array->empty()); |
19054 | 0 | o->write_characters(indent_string.c_str(), new_indent); |
19055 | 0 | dump(val.m_data.m_value.array->back(), true, ensure_ascii, indent_step, new_indent); |
19056 | |
|
19057 | 0 | o->write_character('\n'); |
19058 | 0 | o->write_characters(indent_string.c_str(), current_indent); |
19059 | 0 | o->write_character(']'); |
19060 | 0 | } |
19061 | 0 | else |
19062 | 0 | { |
19063 | 0 | o->write_character('['); |
19064 | | |
19065 | | // first n-1 elements |
19066 | 0 | for (auto i = val.m_data.m_value.array->cbegin(); |
19067 | 0 | i != val.m_data.m_value.array->cend() - 1; ++i) |
19068 | 0 | { |
19069 | 0 | dump(*i, false, ensure_ascii, indent_step, current_indent); |
19070 | 0 | o->write_character(','); |
19071 | 0 | } |
19072 | | |
19073 | | // last element |
19074 | 0 | JSON_ASSERT(!val.m_data.m_value.array->empty()); |
19075 | 0 | dump(val.m_data.m_value.array->back(), false, ensure_ascii, indent_step, current_indent); |
19076 | |
|
19077 | 0 | o->write_character(']'); |
19078 | 0 | } |
19079 | | |
19080 | 0 | return; |
19081 | 0 | } |
19082 | | |
19083 | 0 | case value_t::string: |
19084 | 0 | { |
19085 | 0 | o->write_character('\"'); |
19086 | 0 | dump_escaped(*val.m_data.m_value.string, ensure_ascii); |
19087 | 0 | o->write_character('\"'); |
19088 | 0 | return; |
19089 | 0 | } |
19090 | | |
19091 | 0 | case value_t::binary: |
19092 | 0 | { |
19093 | 0 | if (pretty_print) |
19094 | 0 | { |
19095 | 0 | o->write_characters("{\n", 2); |
19096 | | |
19097 | | // variable to hold indentation for recursive calls |
19098 | 0 | const auto new_indent = current_indent + indent_step; |
19099 | 0 | if (JSON_HEDLEY_UNLIKELY(indent_string.size() < new_indent)) |
19100 | 0 | { |
19101 | 0 | indent_string.resize(indent_string.size() * 2, ' '); |
19102 | 0 | } |
19103 | |
|
19104 | 0 | o->write_characters(indent_string.c_str(), new_indent); |
19105 | |
|
19106 | 0 | o->write_characters("\"bytes\": [", 10); |
19107 | |
|
19108 | 0 | if (!val.m_data.m_value.binary->empty()) |
19109 | 0 | { |
19110 | 0 | for (auto i = val.m_data.m_value.binary->cbegin(); |
19111 | 0 | i != val.m_data.m_value.binary->cend() - 1; ++i) |
19112 | 0 | { |
19113 | 0 | dump_integer(*i); |
19114 | 0 | o->write_characters(", ", 2); |
19115 | 0 | } |
19116 | 0 | dump_integer(val.m_data.m_value.binary->back()); |
19117 | 0 | } |
19118 | |
|
19119 | 0 | o->write_characters("],\n", 3); |
19120 | 0 | o->write_characters(indent_string.c_str(), new_indent); |
19121 | |
|
19122 | 0 | o->write_characters("\"subtype\": ", 11); |
19123 | 0 | if (val.m_data.m_value.binary->has_subtype()) |
19124 | 0 | { |
19125 | 0 | dump_integer(val.m_data.m_value.binary->subtype()); |
19126 | 0 | } |
19127 | 0 | else |
19128 | 0 | { |
19129 | 0 | o->write_characters("null", 4); |
19130 | 0 | } |
19131 | 0 | o->write_character('\n'); |
19132 | 0 | o->write_characters(indent_string.c_str(), current_indent); |
19133 | 0 | o->write_character('}'); |
19134 | 0 | } |
19135 | 0 | else |
19136 | 0 | { |
19137 | 0 | o->write_characters("{\"bytes\":[", 10); |
19138 | |
|
19139 | 0 | if (!val.m_data.m_value.binary->empty()) |
19140 | 0 | { |
19141 | 0 | for (auto i = val.m_data.m_value.binary->cbegin(); |
19142 | 0 | i != val.m_data.m_value.binary->cend() - 1; ++i) |
19143 | 0 | { |
19144 | 0 | dump_integer(*i); |
19145 | 0 | o->write_character(','); |
19146 | 0 | } |
19147 | 0 | dump_integer(val.m_data.m_value.binary->back()); |
19148 | 0 | } |
19149 | |
|
19150 | 0 | o->write_characters("],\"subtype\":", 12); |
19151 | 0 | if (val.m_data.m_value.binary->has_subtype()) |
19152 | 0 | { |
19153 | 0 | dump_integer(val.m_data.m_value.binary->subtype()); |
19154 | 0 | o->write_character('}'); |
19155 | 0 | } |
19156 | 0 | else |
19157 | 0 | { |
19158 | 0 | o->write_characters("null}", 5); |
19159 | 0 | } |
19160 | 0 | } |
19161 | 0 | return; |
19162 | 0 | } |
19163 | | |
19164 | 0 | case value_t::boolean: |
19165 | 0 | { |
19166 | 0 | if (val.m_data.m_value.boolean) |
19167 | 0 | { |
19168 | 0 | o->write_characters("true", 4); |
19169 | 0 | } |
19170 | 0 | else |
19171 | 0 | { |
19172 | 0 | o->write_characters("false", 5); |
19173 | 0 | } |
19174 | 0 | return; |
19175 | 0 | } |
19176 | | |
19177 | 0 | case value_t::number_integer: |
19178 | 0 | { |
19179 | 0 | dump_integer(val.m_data.m_value.number_integer); |
19180 | 0 | return; |
19181 | 0 | } |
19182 | | |
19183 | 0 | case value_t::number_unsigned: |
19184 | 0 | { |
19185 | 0 | dump_integer(val.m_data.m_value.number_unsigned); |
19186 | 0 | return; |
19187 | 0 | } |
19188 | | |
19189 | 0 | case value_t::number_float: |
19190 | 0 | { |
19191 | 0 | dump_float(val.m_data.m_value.number_float); |
19192 | 0 | return; |
19193 | 0 | } |
19194 | | |
19195 | 0 | case value_t::discarded: |
19196 | 0 | { |
19197 | 0 | o->write_characters("<discarded>", 11); |
19198 | 0 | return; |
19199 | 0 | } |
19200 | | |
19201 | 0 | case value_t::null: |
19202 | 0 | { |
19203 | 0 | o->write_characters("null", 4); |
19204 | 0 | return; |
19205 | 0 | } |
19206 | | |
19207 | 0 | default: // LCOV_EXCL_LINE |
19208 | 0 | JSON_ASSERT(false); // NOLINT(cert-dcl03-c,hicpp-static-assert,misc-static-assert) LCOV_EXCL_LINE |
19209 | 0 | } |
19210 | 0 | } |
19211 | | |
19212 | | JSON_PRIVATE_UNLESS_TESTED: |
19213 | | /*! |
19214 | | @brief dump escaped string |
19215 | | |
19216 | | Escape a string by replacing certain special characters by a sequence of an |
19217 | | escape character (backslash) and another character and other control |
19218 | | characters by a sequence of "\u" followed by a four-digit hex |
19219 | | representation. The escaped string is written to output stream @a o. |
19220 | | |
19221 | | @param[in] s the string to escape |
19222 | | @param[in] ensure_ascii whether to escape non-ASCII characters with |
19223 | | \uXXXX sequences |
19224 | | |
19225 | | @complexity Linear in the length of string @a s. |
19226 | | */ |
19227 | | void dump_escaped(const string_t& s, const bool ensure_ascii) |
19228 | 0 | { |
19229 | 0 | std::uint32_t codepoint{}; |
19230 | 0 | std::uint8_t state = UTF8_ACCEPT; |
19231 | 0 | std::size_t bytes = 0; // number of bytes written to string_buffer |
19232 | | |
19233 | | // number of bytes written at the point of the last valid byte |
19234 | 0 | std::size_t bytes_after_last_accept = 0; |
19235 | 0 | std::size_t undumped_chars = 0; |
19236 | |
|
19237 | 0 | for (std::size_t i = 0; i < s.size(); ++i) |
19238 | 0 | { |
19239 | 0 | const auto byte = static_cast<std::uint8_t>(s[i]); |
19240 | |
|
19241 | 0 | switch (decode(state, codepoint, byte)) |
19242 | 0 | { |
19243 | 0 | case UTF8_ACCEPT: // decode found a new code point |
19244 | 0 | { |
19245 | 0 | switch (codepoint) |
19246 | 0 | { |
19247 | 0 | case 0x08: // backspace |
19248 | 0 | { |
19249 | 0 | string_buffer[bytes++] = '\\'; |
19250 | 0 | string_buffer[bytes++] = 'b'; |
19251 | 0 | break; |
19252 | 0 | } |
19253 | | |
19254 | 0 | case 0x09: // horizontal tab |
19255 | 0 | { |
19256 | 0 | string_buffer[bytes++] = '\\'; |
19257 | 0 | string_buffer[bytes++] = 't'; |
19258 | 0 | break; |
19259 | 0 | } |
19260 | | |
19261 | 0 | case 0x0A: // newline |
19262 | 0 | { |
19263 | 0 | string_buffer[bytes++] = '\\'; |
19264 | 0 | string_buffer[bytes++] = 'n'; |
19265 | 0 | break; |
19266 | 0 | } |
19267 | | |
19268 | 0 | case 0x0C: // formfeed |
19269 | 0 | { |
19270 | 0 | string_buffer[bytes++] = '\\'; |
19271 | 0 | string_buffer[bytes++] = 'f'; |
19272 | 0 | break; |
19273 | 0 | } |
19274 | | |
19275 | 0 | case 0x0D: // carriage return |
19276 | 0 | { |
19277 | 0 | string_buffer[bytes++] = '\\'; |
19278 | 0 | string_buffer[bytes++] = 'r'; |
19279 | 0 | break; |
19280 | 0 | } |
19281 | | |
19282 | 0 | case 0x22: // quotation mark |
19283 | 0 | { |
19284 | 0 | string_buffer[bytes++] = '\\'; |
19285 | 0 | string_buffer[bytes++] = '\"'; |
19286 | 0 | break; |
19287 | 0 | } |
19288 | | |
19289 | 0 | case 0x5C: // reverse solidus |
19290 | 0 | { |
19291 | 0 | string_buffer[bytes++] = '\\'; |
19292 | 0 | string_buffer[bytes++] = '\\'; |
19293 | 0 | break; |
19294 | 0 | } |
19295 | | |
19296 | 0 | default: |
19297 | 0 | { |
19298 | | // escape control characters (0x00..0x1F) or, if |
19299 | | // ensure_ascii parameter is used, non-ASCII characters |
19300 | 0 | if ((codepoint <= 0x1F) || (ensure_ascii && (codepoint >= 0x7F))) |
19301 | 0 | { |
19302 | 0 | if (codepoint <= 0xFFFF) |
19303 | 0 | { |
19304 | | // NOLINTNEXTLINE(cppcoreguidelines-pro-type-vararg,hicpp-vararg) |
19305 | 0 | static_cast<void>((std::snprintf)(string_buffer.data() + bytes, 7, "\\u%04x", |
19306 | 0 | static_cast<std::uint16_t>(codepoint))); |
19307 | 0 | bytes += 6; |
19308 | 0 | } |
19309 | 0 | else |
19310 | 0 | { |
19311 | | // NOLINTNEXTLINE(cppcoreguidelines-pro-type-vararg,hicpp-vararg) |
19312 | 0 | static_cast<void>((std::snprintf)(string_buffer.data() + bytes, 13, "\\u%04x\\u%04x", |
19313 | 0 | static_cast<std::uint16_t>(0xD7C0u + (codepoint >> 10u)), |
19314 | 0 | static_cast<std::uint16_t>(0xDC00u + (codepoint & 0x3FFu)))); |
19315 | 0 | bytes += 12; |
19316 | 0 | } |
19317 | 0 | } |
19318 | 0 | else |
19319 | 0 | { |
19320 | | // copy byte to buffer (all previous bytes |
19321 | | // been copied have in default case above) |
19322 | 0 | string_buffer[bytes++] = s[i]; |
19323 | 0 | } |
19324 | 0 | break; |
19325 | 0 | } |
19326 | 0 | } |
19327 | | |
19328 | | // write buffer and reset index; there must be 13 bytes |
19329 | | // left, as this is the maximal number of bytes to be |
19330 | | // written ("\uxxxx\uxxxx\0") for one code point |
19331 | 0 | if (string_buffer.size() - bytes < 13) |
19332 | 0 | { |
19333 | 0 | o->write_characters(string_buffer.data(), bytes); |
19334 | 0 | bytes = 0; |
19335 | 0 | } |
19336 | | |
19337 | | // remember the byte position of this accept |
19338 | 0 | bytes_after_last_accept = bytes; |
19339 | 0 | undumped_chars = 0; |
19340 | 0 | break; |
19341 | 0 | } |
19342 | | |
19343 | 0 | case UTF8_REJECT: // decode found invalid UTF-8 byte |
19344 | 0 | { |
19345 | 0 | switch (error_handler) |
19346 | 0 | { |
19347 | 0 | case error_handler_t::strict: |
19348 | 0 | { |
19349 | 0 | JSON_THROW(type_error::create(316, concat("invalid UTF-8 byte at index ", std::to_string(i), ": 0x", hex_bytes(byte | 0)), nullptr)); |
19350 | 0 | } |
19351 | | |
19352 | 0 | case error_handler_t::ignore: |
19353 | 0 | case error_handler_t::replace: |
19354 | 0 | { |
19355 | | // in case we saw this character the first time, we |
19356 | | // would like to read it again, because the byte |
19357 | | // may be OK for itself, but just not OK for the |
19358 | | // previous sequence |
19359 | 0 | if (undumped_chars > 0) |
19360 | 0 | { |
19361 | 0 | --i; |
19362 | 0 | } |
19363 | | |
19364 | | // reset length buffer to the last accepted index; |
19365 | | // thus removing/ignoring the invalid characters |
19366 | 0 | bytes = bytes_after_last_accept; |
19367 | |
|
19368 | 0 | if (error_handler == error_handler_t::replace) |
19369 | 0 | { |
19370 | | // add a replacement character |
19371 | 0 | if (ensure_ascii) |
19372 | 0 | { |
19373 | 0 | string_buffer[bytes++] = '\\'; |
19374 | 0 | string_buffer[bytes++] = 'u'; |
19375 | 0 | string_buffer[bytes++] = 'f'; |
19376 | 0 | string_buffer[bytes++] = 'f'; |
19377 | 0 | string_buffer[bytes++] = 'f'; |
19378 | 0 | string_buffer[bytes++] = 'd'; |
19379 | 0 | } |
19380 | 0 | else |
19381 | 0 | { |
19382 | 0 | string_buffer[bytes++] = detail::binary_writer<BasicJsonType, char>::to_char_type('\xEF'); |
19383 | 0 | string_buffer[bytes++] = detail::binary_writer<BasicJsonType, char>::to_char_type('\xBF'); |
19384 | 0 | string_buffer[bytes++] = detail::binary_writer<BasicJsonType, char>::to_char_type('\xBD'); |
19385 | 0 | } |
19386 | | |
19387 | | // write buffer and reset index; there must be 13 bytes |
19388 | | // left, as this is the maximal number of bytes to be |
19389 | | // written ("\uxxxx\uxxxx\0") for one code point |
19390 | 0 | if (string_buffer.size() - bytes < 13) |
19391 | 0 | { |
19392 | 0 | o->write_characters(string_buffer.data(), bytes); |
19393 | 0 | bytes = 0; |
19394 | 0 | } |
19395 | |
|
19396 | 0 | bytes_after_last_accept = bytes; |
19397 | 0 | } |
19398 | |
|
19399 | 0 | undumped_chars = 0; |
19400 | | |
19401 | | // continue processing the string |
19402 | 0 | state = UTF8_ACCEPT; |
19403 | 0 | break; |
19404 | 0 | } |
19405 | | |
19406 | 0 | default: // LCOV_EXCL_LINE |
19407 | 0 | JSON_ASSERT(false); // NOLINT(cert-dcl03-c,hicpp-static-assert,misc-static-assert) LCOV_EXCL_LINE |
19408 | 0 | } |
19409 | 0 | break; |
19410 | 0 | } |
19411 | | |
19412 | 0 | default: // decode found yet incomplete multibyte code point |
19413 | 0 | { |
19414 | 0 | if (!ensure_ascii) |
19415 | 0 | { |
19416 | | // code point will not be escaped - copy byte to buffer |
19417 | 0 | string_buffer[bytes++] = s[i]; |
19418 | 0 | } |
19419 | 0 | ++undumped_chars; |
19420 | 0 | break; |
19421 | 0 | } |
19422 | 0 | } |
19423 | 0 | } |
19424 | | |
19425 | | // we finished processing the string |
19426 | 0 | if (JSON_HEDLEY_LIKELY(state == UTF8_ACCEPT)) |
19427 | 0 | { |
19428 | | // write buffer |
19429 | 0 | if (bytes > 0) |
19430 | 0 | { |
19431 | 0 | o->write_characters(string_buffer.data(), bytes); |
19432 | 0 | } |
19433 | 0 | } |
19434 | 0 | else |
19435 | 0 | { |
19436 | | // we finish reading, but do not accept: string was incomplete |
19437 | 0 | switch (error_handler) |
19438 | 0 | { |
19439 | 0 | case error_handler_t::strict: |
19440 | 0 | { |
19441 | 0 | JSON_THROW(type_error::create(316, concat("incomplete UTF-8 string; last byte: 0x", hex_bytes(static_cast<std::uint8_t>(s.back() | 0))), nullptr)); |
19442 | 0 | } |
19443 | | |
19444 | 0 | case error_handler_t::ignore: |
19445 | 0 | { |
19446 | | // write all accepted bytes |
19447 | 0 | o->write_characters(string_buffer.data(), bytes_after_last_accept); |
19448 | 0 | break; |
19449 | 0 | } |
19450 | | |
19451 | 0 | case error_handler_t::replace: |
19452 | 0 | { |
19453 | | // write all accepted bytes |
19454 | 0 | o->write_characters(string_buffer.data(), bytes_after_last_accept); |
19455 | | // add a replacement character |
19456 | 0 | if (ensure_ascii) |
19457 | 0 | { |
19458 | 0 | o->write_characters("\\ufffd", 6); |
19459 | 0 | } |
19460 | 0 | else |
19461 | 0 | { |
19462 | 0 | o->write_characters("\xEF\xBF\xBD", 3); |
19463 | 0 | } |
19464 | 0 | break; |
19465 | 0 | } |
19466 | | |
19467 | 0 | default: // LCOV_EXCL_LINE |
19468 | 0 | JSON_ASSERT(false); // NOLINT(cert-dcl03-c,hicpp-static-assert,misc-static-assert) LCOV_EXCL_LINE |
19469 | 0 | } |
19470 | 0 | } |
19471 | 0 | } |
19472 | | |
19473 | | private: |
19474 | | /*! |
19475 | | @brief count digits |
19476 | | |
19477 | | Count the number of decimal (base 10) digits for an input unsigned integer. |
19478 | | |
19479 | | @param[in] x unsigned integer number to count its digits |
19480 | | @return number of decimal digits |
19481 | | */ |
19482 | | unsigned int count_digits(number_unsigned_t x) noexcept |
19483 | 0 | { |
19484 | 0 | unsigned int n_digits = 1; |
19485 | 0 | for (;;) |
19486 | 0 | { |
19487 | 0 | if (x < 10) |
19488 | 0 | { |
19489 | 0 | return n_digits; |
19490 | 0 | } |
19491 | 0 | if (x < 100) |
19492 | 0 | { |
19493 | 0 | return n_digits + 1; |
19494 | 0 | } |
19495 | 0 | if (x < 1000) |
19496 | 0 | { |
19497 | 0 | return n_digits + 2; |
19498 | 0 | } |
19499 | 0 | if (x < 10000) |
19500 | 0 | { |
19501 | 0 | return n_digits + 3; |
19502 | 0 | } |
19503 | 0 | x = x / 10000u; |
19504 | 0 | n_digits += 4; |
19505 | 0 | } |
19506 | 0 | } |
19507 | | |
19508 | | /*! |
19509 | | * @brief convert a byte to a uppercase hex representation |
19510 | | * @param[in] byte byte to represent |
19511 | | * @return representation ("00".."FF") |
19512 | | */ |
19513 | | static std::string hex_bytes(std::uint8_t byte) |
19514 | 0 | { |
19515 | 0 | std::string result = "FF"; |
19516 | 0 | constexpr const char* nibble_to_hex = "0123456789ABCDEF"; |
19517 | 0 | result[0] = nibble_to_hex[byte / 16]; |
19518 | 0 | result[1] = nibble_to_hex[byte % 16]; |
19519 | 0 | return result; |
19520 | 0 | } |
19521 | | |
19522 | | // templates to avoid warnings about useless casts |
19523 | | template <typename NumberType, enable_if_t<std::is_signed<NumberType>::value, int> = 0> |
19524 | | bool is_negative_number(NumberType x) |
19525 | 0 | { |
19526 | 0 | return x < 0; |
19527 | 0 | } |
19528 | | |
19529 | | template < typename NumberType, enable_if_t <std::is_unsigned<NumberType>::value, int > = 0 > |
19530 | | bool is_negative_number(NumberType /*unused*/) |
19531 | 0 | { |
19532 | 0 | return false; |
19533 | 0 | } Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_06detail10serializerINS0_10basic_jsonINSt3__13mapENS4_6vectorENS4_12basic_stringIcNS4_11char_traitsIcEENS4_9allocatorIcEEEEblmdSA_NS0_14adl_serializerENS6_IhNSA_IhEEEEvEEE18is_negative_numberIhTnNS4_9enable_ifIXsr3std11is_unsignedIT_EE5valueEiE4typeELi0EEEbSK_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_06detail10serializerINS0_10basic_jsonINSt3__13mapENS4_6vectorENS4_12basic_stringIcNS4_11char_traitsIcEENS4_9allocatorIcEEEEblmdSA_NS0_14adl_serializerENS6_IhNSA_IhEEEEvEEE18is_negative_numberImTnNS4_9enable_ifIXsr3std11is_unsignedIT_EE5valueEiE4typeELi0EEEbSK_ |
19534 | | |
19535 | | /*! |
19536 | | @brief dump an integer |
19537 | | |
19538 | | Dump a given integer to output stream @a o. Works internally with |
19539 | | @a number_buffer. |
19540 | | |
19541 | | @param[in] x integer number (signed or unsigned) to dump |
19542 | | @tparam NumberType either @a number_integer_t or @a number_unsigned_t |
19543 | | */ |
19544 | | template < typename NumberType, detail::enable_if_t < |
19545 | | std::is_integral<NumberType>::value || |
19546 | | std::is_same<NumberType, number_unsigned_t>::value || |
19547 | | std::is_same<NumberType, number_integer_t>::value || |
19548 | | std::is_same<NumberType, binary_char_t>::value, |
19549 | | int > = 0 > |
19550 | | void dump_integer(NumberType x) |
19551 | 0 | { |
19552 | 0 | static constexpr std::array<std::array<char, 2>, 100> digits_to_99 |
19553 | 0 | { |
19554 | 0 | { |
19555 | 0 | {{'0', '0'}}, {{'0', '1'}}, {{'0', '2'}}, {{'0', '3'}}, {{'0', '4'}}, {{'0', '5'}}, {{'0', '6'}}, {{'0', '7'}}, {{'0', '8'}}, {{'0', '9'}}, |
19556 | 0 | {{'1', '0'}}, {{'1', '1'}}, {{'1', '2'}}, {{'1', '3'}}, {{'1', '4'}}, {{'1', '5'}}, {{'1', '6'}}, {{'1', '7'}}, {{'1', '8'}}, {{'1', '9'}}, |
19557 | 0 | {{'2', '0'}}, {{'2', '1'}}, {{'2', '2'}}, {{'2', '3'}}, {{'2', '4'}}, {{'2', '5'}}, {{'2', '6'}}, {{'2', '7'}}, {{'2', '8'}}, {{'2', '9'}}, |
19558 | 0 | {{'3', '0'}}, {{'3', '1'}}, {{'3', '2'}}, {{'3', '3'}}, {{'3', '4'}}, {{'3', '5'}}, {{'3', '6'}}, {{'3', '7'}}, {{'3', '8'}}, {{'3', '9'}}, |
19559 | 0 | {{'4', '0'}}, {{'4', '1'}}, {{'4', '2'}}, {{'4', '3'}}, {{'4', '4'}}, {{'4', '5'}}, {{'4', '6'}}, {{'4', '7'}}, {{'4', '8'}}, {{'4', '9'}}, |
19560 | 0 | {{'5', '0'}}, {{'5', '1'}}, {{'5', '2'}}, {{'5', '3'}}, {{'5', '4'}}, {{'5', '5'}}, {{'5', '6'}}, {{'5', '7'}}, {{'5', '8'}}, {{'5', '9'}}, |
19561 | 0 | {{'6', '0'}}, {{'6', '1'}}, {{'6', '2'}}, {{'6', '3'}}, {{'6', '4'}}, {{'6', '5'}}, {{'6', '6'}}, {{'6', '7'}}, {{'6', '8'}}, {{'6', '9'}}, |
19562 | 0 | {{'7', '0'}}, {{'7', '1'}}, {{'7', '2'}}, {{'7', '3'}}, {{'7', '4'}}, {{'7', '5'}}, {{'7', '6'}}, {{'7', '7'}}, {{'7', '8'}}, {{'7', '9'}}, |
19563 | 0 | {{'8', '0'}}, {{'8', '1'}}, {{'8', '2'}}, {{'8', '3'}}, {{'8', '4'}}, {{'8', '5'}}, {{'8', '6'}}, {{'8', '7'}}, {{'8', '8'}}, {{'8', '9'}}, |
19564 | 0 | {{'9', '0'}}, {{'9', '1'}}, {{'9', '2'}}, {{'9', '3'}}, {{'9', '4'}}, {{'9', '5'}}, {{'9', '6'}}, {{'9', '7'}}, {{'9', '8'}}, {{'9', '9'}}, |
19565 | 0 | } |
19566 | 0 | }; |
19567 | | |
19568 | | // special case for "0" |
19569 | 0 | if (x == 0) |
19570 | 0 | { |
19571 | 0 | o->write_character('0'); |
19572 | 0 | return; |
19573 | 0 | } |
19574 | | |
19575 | | // use a pointer to fill the buffer |
19576 | 0 | auto buffer_ptr = number_buffer.begin(); // NOLINT(llvm-qualified-auto,readability-qualified-auto,cppcoreguidelines-pro-type-vararg,hicpp-vararg) |
19577 | |
|
19578 | 0 | number_unsigned_t abs_value; |
19579 | |
|
19580 | 0 | unsigned int n_chars{}; |
19581 | |
|
19582 | 0 | if (is_negative_number(x)) |
19583 | 0 | { |
19584 | 0 | *buffer_ptr = '-'; |
19585 | 0 | abs_value = remove_sign(static_cast<number_integer_t>(x)); |
19586 | | |
19587 | | // account one more byte for the minus sign |
19588 | 0 | n_chars = 1 + count_digits(abs_value); |
19589 | 0 | } |
19590 | 0 | else |
19591 | 0 | { |
19592 | 0 | abs_value = static_cast<number_unsigned_t>(x); |
19593 | 0 | n_chars = count_digits(abs_value); |
19594 | 0 | } |
19595 | | |
19596 | | // spare 1 byte for '\0' |
19597 | 0 | JSON_ASSERT(n_chars < number_buffer.size() - 1); |
19598 | | |
19599 | | // jump to the end to generate the string from backward, |
19600 | | // so we later avoid reversing the result |
19601 | 0 | buffer_ptr += static_cast<typename decltype(number_buffer)::difference_type>(n_chars); |
19602 | | |
19603 | | // Fast int2ascii implementation inspired by "Fastware" talk by Andrei Alexandrescu |
19604 | | // See: https://www.youtube.com/watch?v=o4-CwDo2zpg |
19605 | 0 | while (abs_value >= 100) |
19606 | 0 | { |
19607 | 0 | const auto digits_index = static_cast<unsigned>((abs_value % 100)); |
19608 | 0 | abs_value /= 100; |
19609 | 0 | *(--buffer_ptr) = digits_to_99[digits_index][1]; |
19610 | 0 | *(--buffer_ptr) = digits_to_99[digits_index][0]; |
19611 | 0 | } |
19612 | |
|
19613 | 0 | if (abs_value >= 10) |
19614 | 0 | { |
19615 | 0 | const auto digits_index = static_cast<unsigned>(abs_value); |
19616 | 0 | *(--buffer_ptr) = digits_to_99[digits_index][1]; |
19617 | 0 | *(--buffer_ptr) = digits_to_99[digits_index][0]; |
19618 | 0 | } |
19619 | 0 | else |
19620 | 0 | { |
19621 | 0 | *(--buffer_ptr) = static_cast<char>('0' + abs_value); |
19622 | 0 | } |
19623 | |
|
19624 | 0 | o->write_characters(number_buffer.data(), n_chars); |
19625 | 0 | } Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_06detail10serializerINS0_10basic_jsonINSt3__13mapENS4_6vectorENS4_12basic_stringIcNS4_11char_traitsIcEENS4_9allocatorIcEEEEblmdSA_NS0_14adl_serializerENS6_IhNSA_IhEEEEvEEE12dump_integerIhTnNS4_9enable_ifIXoooooosr3std11is_integralIT_EE5valuesr3std7is_sameISK_mEE5valuesr3std7is_sameISK_lEE5valuesr3std7is_sameISK_hEE5valueEiE4typeELi0EEEvSK_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_06detail10serializerINS0_10basic_jsonINSt3__13mapENS4_6vectorENS4_12basic_stringIcNS4_11char_traitsIcEENS4_9allocatorIcEEEEblmdSA_NS0_14adl_serializerENS6_IhNSA_IhEEEEvEEE12dump_integerImTnNS4_9enable_ifIXoooooosr3std11is_integralIT_EE5valuesr3std7is_sameISK_mEE5valuesr3std7is_sameISK_lEE5valuesr3std7is_sameISK_hEE5valueEiE4typeELi0EEEvSK_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_06detail10serializerINS0_10basic_jsonINSt3__13mapENS4_6vectorENS4_12basic_stringIcNS4_11char_traitsIcEENS4_9allocatorIcEEEEblmdSA_NS0_14adl_serializerENS6_IhNSA_IhEEEEvEEE12dump_integerIlTnNS4_9enable_ifIXoooooosr3std11is_integralIT_EE5valuesr3std7is_sameISK_mEE5valuesr3std7is_sameISK_lEE5valuesr3std7is_sameISK_hEE5valueEiE4typeELi0EEEvSK_ |
19626 | | |
19627 | | /*! |
19628 | | @brief dump a floating-point number |
19629 | | |
19630 | | Dump a given floating-point number to output stream @a o. Works internally |
19631 | | with @a number_buffer. |
19632 | | |
19633 | | @param[in] x floating-point number to dump |
19634 | | */ |
19635 | | void dump_float(number_float_t x) |
19636 | 0 | { |
19637 | | // NaN / inf |
19638 | 0 | if (!std::isfinite(x)) |
19639 | 0 | { |
19640 | 0 | o->write_characters("null", 4); |
19641 | 0 | return; |
19642 | 0 | } |
19643 | | |
19644 | | // If number_float_t is an IEEE-754 single or double precision number, |
19645 | | // use the Grisu2 algorithm to produce short numbers which are |
19646 | | // guaranteed to round-trip, using strtof and strtod, resp. |
19647 | | // |
19648 | | // NB: The test below works if <long double> == <double>. |
19649 | 0 | static constexpr bool is_ieee_single_or_double |
19650 | 0 | = (std::numeric_limits<number_float_t>::is_iec559 && std::numeric_limits<number_float_t>::digits == 24 && std::numeric_limits<number_float_t>::max_exponent == 128) || |
19651 | 0 | (std::numeric_limits<number_float_t>::is_iec559 && std::numeric_limits<number_float_t>::digits == 53 && std::numeric_limits<number_float_t>::max_exponent == 1024); |
19652 | |
|
19653 | 0 | dump_float(x, std::integral_constant<bool, is_ieee_single_or_double>()); |
19654 | 0 | } |
19655 | | |
19656 | | void dump_float(number_float_t x, std::true_type /*is_ieee_single_or_double*/) |
19657 | 0 | { |
19658 | 0 | auto* begin = number_buffer.data(); |
19659 | 0 | auto* end = ::nlohmann::detail::to_chars(begin, begin + number_buffer.size(), x); |
19660 | |
|
19661 | 0 | o->write_characters(begin, static_cast<size_t>(end - begin)); |
19662 | 0 | } |
19663 | | |
19664 | | void dump_float(number_float_t x, std::false_type /*is_ieee_single_or_double*/) |
19665 | | { |
19666 | | // get the number of digits for a float -> text -> float round-trip |
19667 | | static constexpr auto d = std::numeric_limits<number_float_t>::max_digits10; |
19668 | | |
19669 | | // the actual conversion |
19670 | | // NOLINTNEXTLINE(cppcoreguidelines-pro-type-vararg,hicpp-vararg) |
19671 | | std::ptrdiff_t len = (std::snprintf)(number_buffer.data(), number_buffer.size(), "%.*g", d, x); |
19672 | | |
19673 | | // negative value indicates an error |
19674 | | JSON_ASSERT(len > 0); |
19675 | | // check if the buffer was large enough |
19676 | | JSON_ASSERT(static_cast<std::size_t>(len) < number_buffer.size()); |
19677 | | |
19678 | | // erase thousands separators |
19679 | | if (thousands_sep != '\0') |
19680 | | { |
19681 | | // NOLINTNEXTLINE(readability-qualified-auto,llvm-qualified-auto): std::remove returns an iterator, see https://github.com/nlohmann/json/issues/3081 |
19682 | | const auto end = std::remove(number_buffer.begin(), number_buffer.begin() + len, thousands_sep); |
19683 | | std::fill(end, number_buffer.end(), '\0'); |
19684 | | JSON_ASSERT((end - number_buffer.begin()) <= len); |
19685 | | len = (end - number_buffer.begin()); |
19686 | | } |
19687 | | |
19688 | | // convert decimal point to '.' |
19689 | | if (decimal_point != '\0' && decimal_point != '.') |
19690 | | { |
19691 | | // NOLINTNEXTLINE(readability-qualified-auto,llvm-qualified-auto): std::find returns an iterator, see https://github.com/nlohmann/json/issues/3081 |
19692 | | const auto dec_pos = std::find(number_buffer.begin(), number_buffer.end(), decimal_point); |
19693 | | if (dec_pos != number_buffer.end()) |
19694 | | { |
19695 | | *dec_pos = '.'; |
19696 | | } |
19697 | | } |
19698 | | |
19699 | | o->write_characters(number_buffer.data(), static_cast<std::size_t>(len)); |
19700 | | |
19701 | | // determine if we need to append ".0" |
19702 | | const bool value_is_int_like = |
19703 | | std::none_of(number_buffer.begin(), number_buffer.begin() + len + 1, |
19704 | | [](char c) |
19705 | | { |
19706 | | return c == '.' || c == 'e'; |
19707 | | }); |
19708 | | |
19709 | | if (value_is_int_like) |
19710 | | { |
19711 | | o->write_characters(".0", 2); |
19712 | | } |
19713 | | } |
19714 | | |
19715 | | /*! |
19716 | | @brief check whether a string is UTF-8 encoded |
19717 | | |
19718 | | The function checks each byte of a string whether it is UTF-8 encoded. The |
19719 | | result of the check is stored in the @a state parameter. The function must |
19720 | | be called initially with state 0 (accept). State 1 means the string must |
19721 | | be rejected, because the current byte is not allowed. If the string is |
19722 | | completely processed, but the state is non-zero, the string ended |
19723 | | prematurely; that is, the last byte indicated more bytes should have |
19724 | | followed. |
19725 | | |
19726 | | @param[in,out] state the state of the decoding |
19727 | | @param[in,out] codep codepoint (valid only if resulting state is UTF8_ACCEPT) |
19728 | | @param[in] byte next byte to decode |
19729 | | @return new state |
19730 | | |
19731 | | @note The function has been edited: a std::array is used. |
19732 | | |
19733 | | @copyright Copyright (c) 2008-2009 Bjoern Hoehrmann <bjoern@hoehrmann.de> |
19734 | | @sa http://bjoern.hoehrmann.de/utf-8/decoder/dfa/ |
19735 | | */ |
19736 | | static std::uint8_t decode(std::uint8_t& state, std::uint32_t& codep, const std::uint8_t byte) noexcept |
19737 | 0 | { |
19738 | 0 | static const std::array<std::uint8_t, 400> utf8d = |
19739 | 0 | { |
19740 | 0 | { |
19741 | 0 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 00..1F |
19742 | 0 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 20..3F |
19743 | 0 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 40..5F |
19744 | 0 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 60..7F |
19745 | 0 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, // 80..9F |
19746 | 0 | 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, // A0..BF |
19747 | 0 | 8, 8, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, // C0..DF |
19748 | 0 | 0xA, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x4, 0x3, 0x3, // E0..EF |
19749 | 0 | 0xB, 0x6, 0x6, 0x6, 0x5, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, // F0..FF |
19750 | 0 | 0x0, 0x1, 0x2, 0x3, 0x5, 0x8, 0x7, 0x1, 0x1, 0x1, 0x4, 0x6, 0x1, 0x1, 0x1, 0x1, // s0..s0 |
19751 | 0 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, // s1..s2 |
19752 | 0 | 1, 2, 1, 1, 1, 1, 1, 2, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, // s3..s4 |
19753 | 0 | 1, 2, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 1, 3, 1, 1, 1, 1, 1, 1, // s5..s6 |
19754 | 0 | 1, 3, 1, 1, 1, 1, 1, 3, 1, 3, 1, 1, 1, 1, 1, 1, 1, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 // s7..s8 |
19755 | 0 | } |
19756 | 0 | }; |
19757 | |
|
19758 | 0 | JSON_ASSERT(static_cast<std::size_t>(byte) < utf8d.size()); |
19759 | 0 | const std::uint8_t type = utf8d[byte]; |
19760 | |
|
19761 | 0 | codep = (state != UTF8_ACCEPT) |
19762 | 0 | ? (byte & 0x3fu) | (codep << 6u) |
19763 | 0 | : (0xFFu >> type) & (byte); |
19764 | |
|
19765 | 0 | const std::size_t index = 256u + (static_cast<size_t>(state) * 16u) + static_cast<size_t>(type); |
19766 | 0 | JSON_ASSERT(index < utf8d.size()); |
19767 | 0 | state = utf8d[index]; |
19768 | 0 | return state; |
19769 | 0 | } |
19770 | | |
19771 | | /* |
19772 | | * Overload to make the compiler happy while it is instantiating |
19773 | | * dump_integer for number_unsigned_t. |
19774 | | * Must never be called. |
19775 | | */ |
19776 | | number_unsigned_t remove_sign(number_unsigned_t x) |
19777 | | { |
19778 | | JSON_ASSERT(false); // NOLINT(cert-dcl03-c,hicpp-static-assert,misc-static-assert) LCOV_EXCL_LINE |
19779 | | return x; // LCOV_EXCL_LINE |
19780 | | } |
19781 | | |
19782 | | /* |
19783 | | * Helper function for dump_integer |
19784 | | * |
19785 | | * This function takes a negative signed integer and returns its absolute |
19786 | | * value as an unsigned integer. The plus/minus shuffling is necessary as we |
19787 | | * cannot directly remove the sign of an arbitrary signed integer as the |
19788 | | * absolute values of INT_MIN and INT_MAX are usually not the same. See |
19789 | | * #1708 for details. |
19790 | | */ |
19791 | | number_unsigned_t remove_sign(number_integer_t x) noexcept |
19792 | 0 | { |
19793 | 0 | JSON_ASSERT(x < 0 && x < (std::numeric_limits<number_integer_t>::max)()); // NOLINT(misc-redundant-expression) |
19794 | 0 | return static_cast<number_unsigned_t>(-(x + 1)) + 1; |
19795 | 0 | } |
19796 | | |
19797 | | private: |
19798 | | /// the output of the serializer |
19799 | | output_adapter_t<char> o = nullptr; |
19800 | | |
19801 | | /// a (hopefully) large enough character buffer |
19802 | | std::array<char, 64> number_buffer{{}}; |
19803 | | |
19804 | | /// the locale |
19805 | | const std::lconv* loc = nullptr; |
19806 | | /// the locale's thousand separator character |
19807 | | const char thousands_sep = '\0'; |
19808 | | /// the locale's decimal point character |
19809 | | const char decimal_point = '\0'; |
19810 | | |
19811 | | /// string buffer |
19812 | | std::array<char, 512> string_buffer{{}}; |
19813 | | |
19814 | | /// the indentation character |
19815 | | const char indent_char; |
19816 | | /// the indentation string |
19817 | | string_t indent_string; |
19818 | | |
19819 | | /// error_handler how to react on decoding errors |
19820 | | const error_handler_t error_handler; |
19821 | | }; |
19822 | | |
19823 | | } // namespace detail |
19824 | | NLOHMANN_JSON_NAMESPACE_END |
19825 | | |
19826 | | // #include <nlohmann/detail/value_t.hpp> |
19827 | | |
19828 | | // #include <nlohmann/json_fwd.hpp> |
19829 | | |
19830 | | // #include <nlohmann/ordered_map.hpp> |
19831 | | // __ _____ _____ _____ |
19832 | | // __| | __| | | | JSON for Modern C++ |
19833 | | // | | |__ | | | | | | version 3.12.0 |
19834 | | // |_____|_____|_____|_|___| https://github.com/nlohmann/json |
19835 | | // |
19836 | | // SPDX-FileCopyrightText: 2013-2026 Niels Lohmann <https://nlohmann.me> |
19837 | | // SPDX-License-Identifier: MIT |
19838 | | |
19839 | | |
19840 | | |
19841 | | #include <functional> // equal_to, less |
19842 | | #include <initializer_list> // initializer_list |
19843 | | #include <iterator> // input_iterator_tag, iterator_traits |
19844 | | #include <memory> // allocator |
19845 | | #include <stdexcept> // for out_of_range |
19846 | | #include <type_traits> // enable_if, is_convertible |
19847 | | #include <utility> // pair |
19848 | | #include <vector> // vector |
19849 | | |
19850 | | // #include <nlohmann/detail/macro_scope.hpp> |
19851 | | |
19852 | | // #include <nlohmann/detail/meta/type_traits.hpp> |
19853 | | |
19854 | | |
19855 | | NLOHMANN_JSON_NAMESPACE_BEGIN |
19856 | | |
19857 | | /// ordered_map: a minimal map-like container that preserves insertion order |
19858 | | /// for use within nlohmann::basic_json<ordered_map> |
19859 | | template <class Key, class T, class IgnoredLess = std::less<Key>, |
19860 | | class Allocator = std::allocator<std::pair<const Key, T>>> |
19861 | | struct ordered_map : std::vector<std::pair<const Key, T>, Allocator> |
19862 | | { |
19863 | | using key_type = Key; |
19864 | | using mapped_type = T; |
19865 | | using Container = std::vector<std::pair<const Key, T>, Allocator>; |
19866 | | using iterator = typename Container::iterator; |
19867 | | using const_iterator = typename Container::const_iterator; |
19868 | | using size_type = typename Container::size_type; |
19869 | | using value_type = typename Container::value_type; |
19870 | | #ifdef JSON_HAS_CPP_14 |
19871 | | using key_compare = std::equal_to<>; |
19872 | | #else |
19873 | | using key_compare = std::equal_to<Key>; |
19874 | | #endif |
19875 | | |
19876 | | // Explicit constructors instead of `using Container::Container` |
19877 | | // otherwise older compilers choke on it (GCC <= 5.5, xcode <= 9.4) |
19878 | | ordered_map() noexcept(noexcept(Container())) : Container{} {} |
19879 | | explicit ordered_map(const Allocator& alloc) noexcept(noexcept(Container(alloc))) : Container{alloc} {} |
19880 | | template <class It> |
19881 | | ordered_map(It first, It last, const Allocator& alloc = Allocator()) |
19882 | | : Container{first, last, alloc} {} |
19883 | | ordered_map(std::initializer_list<value_type> init, const Allocator& alloc = Allocator() ) |
19884 | | : Container{init, alloc} {} |
19885 | | |
19886 | | std::pair<iterator, bool> emplace(const key_type& key, T&& t) |
19887 | | { |
19888 | | for (auto it = this->begin(); it != this->end(); ++it) |
19889 | | { |
19890 | | if (m_compare(it->first, key)) |
19891 | | { |
19892 | | return {it, false}; |
19893 | | } |
19894 | | } |
19895 | | Container::emplace_back(key, std::forward<T>(t)); |
19896 | | return {std::prev(this->end()), true}; |
19897 | | } |
19898 | | |
19899 | | template<class KeyType, detail::enable_if_t< |
19900 | | detail::is_usable_as_key_type<key_compare, key_type, KeyType>::value, int> = 0> |
19901 | | std::pair<iterator, bool> emplace(KeyType && key, T && t) |
19902 | | { |
19903 | | for (auto it = this->begin(); it != this->end(); ++it) |
19904 | | { |
19905 | | if (m_compare(it->first, key)) |
19906 | | { |
19907 | | return {it, false}; |
19908 | | } |
19909 | | } |
19910 | | Container::emplace_back(std::forward<KeyType>(key), std::forward<T>(t)); |
19911 | | return {std::prev(this->end()), true}; |
19912 | | } |
19913 | | |
19914 | | T& operator[](const key_type& key) |
19915 | | { |
19916 | | return emplace(key, T{}).first->second; |
19917 | | } |
19918 | | |
19919 | | template<class KeyType, detail::enable_if_t< |
19920 | | detail::is_usable_as_key_type<key_compare, key_type, KeyType>::value, int> = 0> |
19921 | | T & operator[](KeyType && key) |
19922 | | { |
19923 | | return emplace(std::forward<KeyType>(key), T{}).first->second; |
19924 | | } |
19925 | | |
19926 | | const T& operator[](const key_type& key) const |
19927 | | { |
19928 | | return at(key); |
19929 | | } |
19930 | | |
19931 | | template<class KeyType, detail::enable_if_t< |
19932 | | detail::is_usable_as_key_type<key_compare, key_type, KeyType>::value, int> = 0> |
19933 | | const T & operator[](KeyType && key) const |
19934 | | { |
19935 | | return at(std::forward<KeyType>(key)); |
19936 | | } |
19937 | | |
19938 | | T& at(const key_type& key) |
19939 | | { |
19940 | | for (auto it = this->begin(); it != this->end(); ++it) |
19941 | | { |
19942 | | if (m_compare(it->first, key)) |
19943 | | { |
19944 | | return it->second; |
19945 | | } |
19946 | | } |
19947 | | |
19948 | | JSON_THROW(std::out_of_range("key not found")); |
19949 | | } |
19950 | | |
19951 | | template<class KeyType, detail::enable_if_t< |
19952 | | detail::is_usable_as_key_type<key_compare, key_type, KeyType>::value, int> = 0> |
19953 | | T & at(KeyType && key) // NOLINT(cppcoreguidelines-missing-std-forward) |
19954 | | { |
19955 | | for (auto it = this->begin(); it != this->end(); ++it) |
19956 | | { |
19957 | | if (m_compare(it->first, key)) |
19958 | | { |
19959 | | return it->second; |
19960 | | } |
19961 | | } |
19962 | | |
19963 | | JSON_THROW(std::out_of_range("key not found")); |
19964 | | } |
19965 | | |
19966 | | const T& at(const key_type& key) const |
19967 | | { |
19968 | | for (auto it = this->begin(); it != this->end(); ++it) |
19969 | | { |
19970 | | if (m_compare(it->first, key)) |
19971 | | { |
19972 | | return it->second; |
19973 | | } |
19974 | | } |
19975 | | |
19976 | | JSON_THROW(std::out_of_range("key not found")); |
19977 | | } |
19978 | | |
19979 | | template<class KeyType, detail::enable_if_t< |
19980 | | detail::is_usable_as_key_type<key_compare, key_type, KeyType>::value, int> = 0> |
19981 | | const T & at(KeyType && key) const // NOLINT(cppcoreguidelines-missing-std-forward) |
19982 | | { |
19983 | | for (auto it = this->begin(); it != this->end(); ++it) |
19984 | | { |
19985 | | if (m_compare(it->first, key)) |
19986 | | { |
19987 | | return it->second; |
19988 | | } |
19989 | | } |
19990 | | |
19991 | | JSON_THROW(std::out_of_range("key not found")); |
19992 | | } |
19993 | | |
19994 | | size_type erase(const key_type& key) |
19995 | | { |
19996 | | for (auto it = this->begin(); it != this->end(); ++it) |
19997 | | { |
19998 | | if (m_compare(it->first, key)) |
19999 | | { |
20000 | | // Since we cannot move const Keys, re-construct them in place |
20001 | | for (auto next = it; ++next != this->end(); ++it) |
20002 | | { |
20003 | | it->~value_type(); // Destroy but keep allocation |
20004 | | new (&*it) value_type{std::move(*next)}; |
20005 | | } |
20006 | | Container::pop_back(); |
20007 | | return 1; |
20008 | | } |
20009 | | } |
20010 | | return 0; |
20011 | | } |
20012 | | |
20013 | | template<class KeyType, detail::enable_if_t< |
20014 | | detail::is_usable_as_key_type<key_compare, key_type, KeyType>::value, int> = 0> |
20015 | | size_type erase(KeyType && key) // NOLINT(cppcoreguidelines-missing-std-forward) |
20016 | | { |
20017 | | for (auto it = this->begin(); it != this->end(); ++it) |
20018 | | { |
20019 | | if (m_compare(it->first, key)) |
20020 | | { |
20021 | | // Since we cannot move const Keys, re-construct them in place |
20022 | | for (auto next = it; ++next != this->end(); ++it) |
20023 | | { |
20024 | | it->~value_type(); // Destroy but keep allocation |
20025 | | new (&*it) value_type{std::move(*next)}; |
20026 | | } |
20027 | | Container::pop_back(); |
20028 | | return 1; |
20029 | | } |
20030 | | } |
20031 | | return 0; |
20032 | | } |
20033 | | |
20034 | | iterator erase(iterator pos) |
20035 | | { |
20036 | | return erase(pos, std::next(pos)); |
20037 | | } |
20038 | | |
20039 | | iterator erase(iterator first, iterator last) |
20040 | | { |
20041 | | if (first == last) |
20042 | | { |
20043 | | return first; |
20044 | | } |
20045 | | |
20046 | | const auto elements_affected = std::distance(first, last); |
20047 | | const auto offset = std::distance(Container::begin(), first); |
20048 | | |
20049 | | // This is the start situation. We need to delete elements_affected |
20050 | | // elements (3 in this example: e, f, g), and need to return an |
20051 | | // iterator past the last deleted element (h in this example). |
20052 | | // Note that offset is the distance from the start of the vector |
20053 | | // to first. We will need this later. |
20054 | | |
20055 | | // [ a, b, c, d, e, f, g, h, i, j ] |
20056 | | // ^ ^ |
20057 | | // first last |
20058 | | |
20059 | | // Since we cannot move const Keys, we re-construct them in place. |
20060 | | // We start at first and re-construct (viz. copy) the elements from |
20061 | | // the back of the vector. Example for the first iteration: |
20062 | | |
20063 | | // ,--------. |
20064 | | // v | destroy e and re-construct with h |
20065 | | // [ a, b, c, d, e, f, g, h, i, j ] |
20066 | | // ^ ^ |
20067 | | // it it + elements_affected |
20068 | | |
20069 | | for (auto it = first; std::next(it, elements_affected) != Container::end(); ++it) |
20070 | | { |
20071 | | it->~value_type(); // destroy but keep allocation |
20072 | | new (&*it) value_type{std::move(*std::next(it, elements_affected))}; // "move" next element to it |
20073 | | } |
20074 | | |
20075 | | // [ a, b, c, d, h, i, j, h, i, j ] |
20076 | | // ^ ^ |
20077 | | // first last |
20078 | | |
20079 | | // remove the unneeded elements at the end of the vector |
20080 | | Container::resize(this->size() - static_cast<size_type>(elements_affected)); |
20081 | | |
20082 | | // [ a, b, c, d, h, i, j ] |
20083 | | // ^ ^ |
20084 | | // first last |
20085 | | |
20086 | | // first is now pointing past the last deleted element, but we cannot |
20087 | | // use this iterator, because it may have been invalidated by the |
20088 | | // resize call. Instead, we can return begin() + offset. |
20089 | | return Container::begin() + offset; |
20090 | | } |
20091 | | |
20092 | | size_type count(const key_type& key) const |
20093 | | { |
20094 | | for (auto it = this->begin(); it != this->end(); ++it) |
20095 | | { |
20096 | | if (m_compare(it->first, key)) |
20097 | | { |
20098 | | return 1; |
20099 | | } |
20100 | | } |
20101 | | return 0; |
20102 | | } |
20103 | | |
20104 | | template<class KeyType, detail::enable_if_t< |
20105 | | detail::is_usable_as_key_type<key_compare, key_type, KeyType>::value, int> = 0> |
20106 | | size_type count(KeyType && key) const // NOLINT(cppcoreguidelines-missing-std-forward) |
20107 | | { |
20108 | | for (auto it = this->begin(); it != this->end(); ++it) |
20109 | | { |
20110 | | if (m_compare(it->first, key)) |
20111 | | { |
20112 | | return 1; |
20113 | | } |
20114 | | } |
20115 | | return 0; |
20116 | | } |
20117 | | |
20118 | | iterator find(const key_type& key) |
20119 | | { |
20120 | | for (auto it = this->begin(); it != this->end(); ++it) |
20121 | | { |
20122 | | if (m_compare(it->first, key)) |
20123 | | { |
20124 | | return it; |
20125 | | } |
20126 | | } |
20127 | | return Container::end(); |
20128 | | } |
20129 | | |
20130 | | template<class KeyType, detail::enable_if_t< |
20131 | | detail::is_usable_as_key_type<key_compare, key_type, KeyType>::value, int> = 0> |
20132 | | iterator find(KeyType && key) // NOLINT(cppcoreguidelines-missing-std-forward) |
20133 | | { |
20134 | | for (auto it = this->begin(); it != this->end(); ++it) |
20135 | | { |
20136 | | if (m_compare(it->first, key)) |
20137 | | { |
20138 | | return it; |
20139 | | } |
20140 | | } |
20141 | | return Container::end(); |
20142 | | } |
20143 | | |
20144 | | const_iterator find(const key_type& key) const |
20145 | | { |
20146 | | for (auto it = this->begin(); it != this->end(); ++it) |
20147 | | { |
20148 | | if (m_compare(it->first, key)) |
20149 | | { |
20150 | | return it; |
20151 | | } |
20152 | | } |
20153 | | return Container::end(); |
20154 | | } |
20155 | | |
20156 | | std::pair<iterator, bool> insert( value_type&& value ) |
20157 | | { |
20158 | | return emplace(value.first, std::move(value.second)); |
20159 | | } |
20160 | | |
20161 | | std::pair<iterator, bool> insert( const value_type& value ) |
20162 | | { |
20163 | | for (auto it = this->begin(); it != this->end(); ++it) |
20164 | | { |
20165 | | if (m_compare(it->first, value.first)) |
20166 | | { |
20167 | | return {it, false}; |
20168 | | } |
20169 | | } |
20170 | | Container::push_back(value); |
20171 | | return {--this->end(), true}; |
20172 | | } |
20173 | | |
20174 | | template<typename InputIt> |
20175 | | using require_input_iter = typename std::enable_if<std::is_convertible<typename std::iterator_traits<InputIt>::iterator_category, |
20176 | | std::input_iterator_tag>::value>::type; |
20177 | | |
20178 | | template<typename InputIt, typename = require_input_iter<InputIt>> |
20179 | | void insert(InputIt first, InputIt last) |
20180 | | { |
20181 | | for (auto it = first; it != last; ++it) |
20182 | | { |
20183 | | insert(*it); |
20184 | | } |
20185 | | } |
20186 | | |
20187 | | private: |
20188 | | JSON_NO_UNIQUE_ADDRESS key_compare m_compare = key_compare(); |
20189 | | }; |
20190 | | |
20191 | | NLOHMANN_JSON_NAMESPACE_END |
20192 | | |
20193 | | |
20194 | | #if defined(JSON_HAS_CPP_17) |
20195 | | #if JSON_HAS_STATIC_RTTI |
20196 | | #include <any> |
20197 | | #endif |
20198 | | #include <string_view> |
20199 | | #endif |
20200 | | |
20201 | | /*! |
20202 | | @brief namespace for Niels Lohmann |
20203 | | @see https://github.com/nlohmann |
20204 | | @since version 1.0.0 |
20205 | | */ |
20206 | | NLOHMANN_JSON_NAMESPACE_BEGIN |
20207 | | |
20208 | | /*! |
20209 | | @brief a class to store JSON values |
20210 | | |
20211 | | @internal |
20212 | | @invariant The member variables @a m_value and @a m_type have the following |
20213 | | relationship: |
20214 | | - If `m_type == value_t::object`, then `m_value.object != nullptr`. |
20215 | | - If `m_type == value_t::array`, then `m_value.array != nullptr`. |
20216 | | - If `m_type == value_t::string`, then `m_value.string != nullptr`. |
20217 | | The invariants are checked by member function assert_invariant(). |
20218 | | |
20219 | | @note ObjectType trick from https://stackoverflow.com/a/9860911 |
20220 | | @endinternal |
20221 | | |
20222 | | @since version 1.0.0 |
20223 | | |
20224 | | @nosubgrouping |
20225 | | */ |
20226 | | NLOHMANN_BASIC_JSON_TPL_DECLARATION |
20227 | | class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-special-member-functions) |
20228 | | : public ::nlohmann::detail::json_base_class<CustomBaseClass> |
20229 | | { |
20230 | | private: |
20231 | | template<detail::value_t> friend struct detail::external_constructor; |
20232 | | |
20233 | | template<typename> |
20234 | | friend class ::nlohmann::json_pointer; |
20235 | | // can be restored when json_pointer backwards compatibility is removed |
20236 | | // friend ::nlohmann::json_pointer<StringType>; |
20237 | | |
20238 | | template<typename BasicJsonType, typename InputType> |
20239 | | friend class ::nlohmann::detail::parser; |
20240 | | friend ::nlohmann::detail::serializer<basic_json>; |
20241 | | template<typename BasicJsonType> |
20242 | | friend class ::nlohmann::detail::iter_impl; |
20243 | | template<typename BasicJsonType, typename CharType> |
20244 | | friend class ::nlohmann::detail::binary_writer; |
20245 | | template<typename BasicJsonType, typename InputType, typename SAX> |
20246 | | friend class ::nlohmann::detail::binary_reader; |
20247 | | template<typename BasicJsonType, typename InputAdapterType> |
20248 | | friend class ::nlohmann::detail::json_sax_dom_parser; |
20249 | | template<typename BasicJsonType, typename InputAdapterType> |
20250 | | friend class ::nlohmann::detail::json_sax_dom_callback_parser; |
20251 | | friend class ::nlohmann::detail::exception; |
20252 | | |
20253 | | /// workaround type for MSVC |
20254 | | using basic_json_t = NLOHMANN_BASIC_JSON_TPL; |
20255 | | using json_base_class_t = ::nlohmann::detail::json_base_class<CustomBaseClass>; |
20256 | | |
20257 | | JSON_PRIVATE_UNLESS_TESTED: |
20258 | | // convenience aliases for types residing in namespace detail; |
20259 | | using lexer = ::nlohmann::detail::lexer_base<basic_json>; |
20260 | | |
20261 | | template<typename InputAdapterType> |
20262 | | static ::nlohmann::detail::parser<basic_json, InputAdapterType> parser( |
20263 | | InputAdapterType adapter, |
20264 | | detail::parser_callback_t<basic_json>cb = nullptr, |
20265 | | const bool allow_exceptions = true, |
20266 | | const bool ignore_comments = false, |
20267 | | const bool ignore_trailing_commas = false |
20268 | | ) |
20269 | 0 | { |
20270 | 0 | return ::nlohmann::detail::parser<basic_json, InputAdapterType>(std::move(adapter), |
20271 | 0 | std::move(cb), allow_exceptions, ignore_comments, ignore_trailing_commas); |
20272 | 0 | } Unexecuted instantiation: nlohmann::json_abi_v3_12_0::detail::parser<nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>, nlohmann::json_abi_v3_12_0::detail::iterator_input_adapter<char const*> > nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>::parser<nlohmann::json_abi_v3_12_0::detail::iterator_input_adapter<char const*> >(nlohmann::json_abi_v3_12_0::detail::iterator_input_adapter<char const*>, std::__1::function<bool (int, nlohmann::json_abi_v3_12_0::detail::parse_event_t, nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>&)>, bool, bool, bool) Unexecuted instantiation: nlohmann::json_abi_v3_12_0::detail::parser<nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>, nlohmann::json_abi_v3_12_0::detail::input_stream_adapter> nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>::parser<nlohmann::json_abi_v3_12_0::detail::input_stream_adapter>(nlohmann::json_abi_v3_12_0::detail::input_stream_adapter, std::__1::function<bool (int, nlohmann::json_abi_v3_12_0::detail::parse_event_t, nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>&)>, bool, bool, bool) |
20273 | | |
20274 | | private: |
20275 | | using primitive_iterator_t = ::nlohmann::detail::primitive_iterator_t; |
20276 | | template<typename BasicJsonType> |
20277 | | using internal_iterator = ::nlohmann::detail::internal_iterator<BasicJsonType>; |
20278 | | template<typename BasicJsonType> |
20279 | | using iter_impl = ::nlohmann::detail::iter_impl<BasicJsonType>; |
20280 | | template<typename Iterator> |
20281 | | using iteration_proxy = ::nlohmann::detail::iteration_proxy<Iterator>; |
20282 | | template<typename Base> using json_reverse_iterator = ::nlohmann::detail::json_reverse_iterator<Base>; |
20283 | | |
20284 | | template<typename CharType> |
20285 | | using output_adapter_t = ::nlohmann::detail::output_adapter_t<CharType>; |
20286 | | |
20287 | | template<typename InputType> |
20288 | | using binary_reader = ::nlohmann::detail::binary_reader<basic_json, InputType>; |
20289 | | template<typename CharType> using binary_writer = ::nlohmann::detail::binary_writer<basic_json, CharType>; |
20290 | | |
20291 | | JSON_PRIVATE_UNLESS_TESTED: |
20292 | | using serializer = ::nlohmann::detail::serializer<basic_json>; |
20293 | | |
20294 | | public: |
20295 | | using value_t = detail::value_t; |
20296 | | /// JSON Pointer, see @ref nlohmann::json_pointer |
20297 | | using json_pointer = ::nlohmann::json_pointer<StringType>; |
20298 | | template<typename T, typename SFINAE> |
20299 | | using json_serializer = JSONSerializer<T, SFINAE>; |
20300 | | /// how to treat decoding errors |
20301 | | using error_handler_t = detail::error_handler_t; |
20302 | | /// how to treat CBOR tags |
20303 | | using cbor_tag_handler_t = detail::cbor_tag_handler_t; |
20304 | | /// how to encode BJData |
20305 | | using bjdata_version_t = detail::bjdata_version_t; |
20306 | | /// helper type for initializer lists of basic_json values |
20307 | | using initializer_list_t = std::initializer_list<detail::json_ref<basic_json>>; |
20308 | | |
20309 | | using input_format_t = detail::input_format_t; |
20310 | | /// SAX interface type, see @ref nlohmann::json_sax |
20311 | | using json_sax_t = json_sax<basic_json>; |
20312 | | |
20313 | | //////////////// |
20314 | | // exceptions // |
20315 | | //////////////// |
20316 | | |
20317 | | /// @name exceptions |
20318 | | /// Classes to implement user-defined exceptions. |
20319 | | /// @{ |
20320 | | |
20321 | | using exception = detail::exception; |
20322 | | using parse_error = detail::parse_error; |
20323 | | using invalid_iterator = detail::invalid_iterator; |
20324 | | using type_error = detail::type_error; |
20325 | | using out_of_range = detail::out_of_range; |
20326 | | using other_error = detail::other_error; |
20327 | | |
20328 | | /// @} |
20329 | | |
20330 | | ///////////////////// |
20331 | | // container types // |
20332 | | ///////////////////// |
20333 | | |
20334 | | /// @name container types |
20335 | | /// The canonic container types to use @ref basic_json like any other STL |
20336 | | /// container. |
20337 | | /// @{ |
20338 | | |
20339 | | /// the type of elements in a basic_json container |
20340 | | using value_type = basic_json; |
20341 | | |
20342 | | /// the type of an element reference |
20343 | | using reference = value_type&; |
20344 | | /// the type of an element const reference |
20345 | | using const_reference = const value_type&; |
20346 | | |
20347 | | /// a type to represent differences between iterators |
20348 | | using difference_type = std::ptrdiff_t; |
20349 | | /// a type to represent container sizes |
20350 | | using size_type = std::size_t; |
20351 | | |
20352 | | /// the allocator type |
20353 | | using allocator_type = AllocatorType<basic_json>; |
20354 | | |
20355 | | /// the type of an element pointer |
20356 | | using pointer = typename std::allocator_traits<allocator_type>::pointer; |
20357 | | /// the type of an element const pointer |
20358 | | using const_pointer = typename std::allocator_traits<allocator_type>::const_pointer; |
20359 | | |
20360 | | /// an iterator for a basic_json container |
20361 | | using iterator = iter_impl<basic_json>; |
20362 | | /// a const iterator for a basic_json container |
20363 | | using const_iterator = iter_impl<const basic_json>; |
20364 | | /// a reverse iterator for a basic_json container |
20365 | | using reverse_iterator = json_reverse_iterator<typename basic_json::iterator>; |
20366 | | /// a const reverse iterator for a basic_json container |
20367 | | using const_reverse_iterator = json_reverse_iterator<typename basic_json::const_iterator>; |
20368 | | |
20369 | | /// @} |
20370 | | |
20371 | | /// @brief returns the allocator associated with the container |
20372 | | /// @sa https://json.nlohmann.me/api/basic_json/get_allocator/ |
20373 | | static allocator_type get_allocator() |
20374 | | { |
20375 | | return allocator_type(); |
20376 | | } |
20377 | | |
20378 | | /// @brief returns version information on the library |
20379 | | /// @sa https://json.nlohmann.me/api/basic_json/meta/ |
20380 | | JSON_HEDLEY_WARN_UNUSED_RESULT |
20381 | | static basic_json meta() |
20382 | | { |
20383 | | basic_json result; |
20384 | | |
20385 | | result["copyright"] = "(C) 2013-2026 Niels Lohmann"; |
20386 | | result["name"] = "JSON for Modern C++"; |
20387 | | result["url"] = "https://github.com/nlohmann/json"; |
20388 | | result["version"]["string"] = |
20389 | | detail::concat(std::to_string(NLOHMANN_JSON_VERSION_MAJOR), '.', |
20390 | | std::to_string(NLOHMANN_JSON_VERSION_MINOR), '.', |
20391 | | std::to_string(NLOHMANN_JSON_VERSION_PATCH)); |
20392 | | result["version"]["major"] = NLOHMANN_JSON_VERSION_MAJOR; |
20393 | | result["version"]["minor"] = NLOHMANN_JSON_VERSION_MINOR; |
20394 | | result["version"]["patch"] = NLOHMANN_JSON_VERSION_PATCH; |
20395 | | |
20396 | | #ifdef _WIN32 |
20397 | | result["platform"] = "win32"; |
20398 | | #elif defined __linux__ |
20399 | | result["platform"] = "linux"; |
20400 | | #elif defined __APPLE__ |
20401 | | result["platform"] = "apple"; |
20402 | | #elif defined __unix__ |
20403 | | result["platform"] = "unix"; |
20404 | | #else |
20405 | | result["platform"] = "unknown"; |
20406 | | #endif |
20407 | | |
20408 | | #if defined(__ICC) || defined(__INTEL_COMPILER) |
20409 | | result["compiler"] = {{"family", "icc"}, {"version", __INTEL_COMPILER}}; |
20410 | | #elif defined(__clang__) |
20411 | | result["compiler"] = {{"family", "clang"}, {"version", __clang_version__}}; |
20412 | | #elif defined(__GNUC__) || defined(__GNUG__) |
20413 | | result["compiler"] = {{"family", "gcc"}, {"version", detail::concat( |
20414 | | std::to_string(__GNUC__), '.', |
20415 | | std::to_string(__GNUC_MINOR__), '.', |
20416 | | std::to_string(__GNUC_PATCHLEVEL__)) |
20417 | | } |
20418 | | }; |
20419 | | #elif defined(__HP_cc) || defined(__HP_aCC) |
20420 | | result["compiler"] = "hp" |
20421 | | #elif defined(__IBMCPP__) |
20422 | | result["compiler"] = {{"family", "ilecpp"}, {"version", __IBMCPP__}}; |
20423 | | #elif defined(_MSC_VER) |
20424 | | result["compiler"] = {{"family", "msvc"}, {"version", _MSC_VER}}; |
20425 | | #elif defined(__PGI) |
20426 | | result["compiler"] = {{"family", "pgcpp"}, {"version", __PGI}}; |
20427 | | #elif defined(__SUNPRO_CC) |
20428 | | result["compiler"] = {{"family", "sunpro"}, {"version", __SUNPRO_CC}}; |
20429 | | #else |
20430 | | result["compiler"] = {{"family", "unknown"}, {"version", "unknown"}}; |
20431 | | #endif |
20432 | | |
20433 | | #if defined(_MSVC_LANG) |
20434 | | result["compiler"]["c++"] = std::to_string(_MSVC_LANG); |
20435 | | #elif defined(__cplusplus) |
20436 | | result["compiler"]["c++"] = std::to_string(__cplusplus); |
20437 | | #else |
20438 | | result["compiler"]["c++"] = "unknown"; |
20439 | | #endif |
20440 | | return result; |
20441 | | } |
20442 | | |
20443 | | /////////////////////////// |
20444 | | // JSON value data types // |
20445 | | /////////////////////////// |
20446 | | |
20447 | | /// @name JSON value data types |
20448 | | /// The data types to store a JSON value. These types are derived from |
20449 | | /// the template arguments passed to class @ref basic_json. |
20450 | | /// @{ |
20451 | | |
20452 | | /// @brief default object key comparator type |
20453 | | /// The actual object key comparator type (@ref object_comparator_t) may be |
20454 | | /// different. |
20455 | | /// @sa https://json.nlohmann.me/api/basic_json/default_object_comparator_t/ |
20456 | | #if defined(JSON_HAS_CPP_14) |
20457 | | // use of transparent comparator avoids unnecessary repeated construction of temporaries |
20458 | | // in functions involving lookup by key with types other than object_t::key_type (aka. StringType) |
20459 | | using default_object_comparator_t = std::less<>; |
20460 | | #else |
20461 | | using default_object_comparator_t = std::less<StringType>; |
20462 | | #endif |
20463 | | |
20464 | | /// @brief a type for an object |
20465 | | /// @sa https://json.nlohmann.me/api/basic_json/object_t/ |
20466 | | using object_t = ObjectType<StringType, |
20467 | | basic_json, |
20468 | | default_object_comparator_t, |
20469 | | AllocatorType<std::pair<const StringType, |
20470 | | basic_json>>>; |
20471 | | |
20472 | | /// @brief a type for an array |
20473 | | /// @sa https://json.nlohmann.me/api/basic_json/array_t/ |
20474 | | using array_t = ArrayType<basic_json, AllocatorType<basic_json>>; |
20475 | | |
20476 | | /// @brief a type for a string |
20477 | | /// @sa https://json.nlohmann.me/api/basic_json/string_t/ |
20478 | | using string_t = StringType; |
20479 | | |
20480 | | /// @brief a type for a boolean |
20481 | | /// @sa https://json.nlohmann.me/api/basic_json/boolean_t/ |
20482 | | using boolean_t = BooleanType; |
20483 | | |
20484 | | /// @brief a type for a number (integer) |
20485 | | /// @sa https://json.nlohmann.me/api/basic_json/number_integer_t/ |
20486 | | using number_integer_t = NumberIntegerType; |
20487 | | |
20488 | | /// @brief a type for a number (unsigned) |
20489 | | /// @sa https://json.nlohmann.me/api/basic_json/number_unsigned_t/ |
20490 | | using number_unsigned_t = NumberUnsignedType; |
20491 | | |
20492 | | /// @brief a type for a number (floating-point) |
20493 | | /// @sa https://json.nlohmann.me/api/basic_json/number_float_t/ |
20494 | | using number_float_t = NumberFloatType; |
20495 | | |
20496 | | /// @brief a type for a packed binary type |
20497 | | /// @sa https://json.nlohmann.me/api/basic_json/binary_t/ |
20498 | | using binary_t = nlohmann::byte_container_with_subtype<BinaryType>; |
20499 | | |
20500 | | /// @brief object key comparator type |
20501 | | /// @sa https://json.nlohmann.me/api/basic_json/object_comparator_t/ |
20502 | | using object_comparator_t = detail::actual_object_comparator_t<basic_json>; |
20503 | | |
20504 | | /// @} |
20505 | | |
20506 | | private: |
20507 | | |
20508 | | /// helper for exception-safe object creation |
20509 | | template<typename T, typename... Args> |
20510 | | JSON_HEDLEY_RETURNS_NON_NULL |
20511 | | static T* create(Args&& ... args) |
20512 | 0 | { |
20513 | 0 | AllocatorType<T> alloc; |
20514 | 0 | using AllocatorTraits = std::allocator_traits<AllocatorType<T>>; |
20515 | |
|
20516 | 0 | auto deleter = [&](T * obj) |
20517 | 0 | { |
20518 | 0 | AllocatorTraits::deallocate(alloc, obj, 1); |
20519 | 0 | }; Unexecuted instantiation: nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>::create<std::__1::map<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>, std::__1::less<void>, std::__1::allocator<std::__1::pair<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const, nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void> > > >, std::__1::map<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>, std::__1::less<void>, std::__1::allocator<std::__1::pair<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const, nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void> > > > const&>(std::__1::map<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>, std::__1::less<void>, std::__1::allocator<std::__1::pair<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const, nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void> > > > const&)::{lambda(std::__1::map<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>, std::__1::less<void>, std::__1::allocator<std::__1::pair<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const, nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void> > > >*)#1}::operator()(std::__1::map<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>, std::__1::less<void>, std::__1::allocator<std::__1::pair<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const, nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void> > > >*) constUnexecuted instantiation: nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>::create<std::__1::vector<nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>, std::__1::allocator<nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void> > >, std::__1::vector<nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>, std::__1::allocator<nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void> > > const&>(std::__1::vector<nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>, std::__1::allocator<nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void> > > const&)::{lambda(std::__1::vector<nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>, std::__1::allocator<nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void> > >*)#1}::operator()(std::__1::vector<nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>, std::__1::allocator<nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void> > >*) constUnexecuted instantiation: nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>::create<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&>(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)::{lambda(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >*)#1}::operator()(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >*) constUnexecuted instantiation: nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>::create<nlohmann::json_abi_v3_12_0::byte_container_with_subtype<std::__1::vector<unsigned char, std::__1::allocator<unsigned char> > >, nlohmann::json_abi_v3_12_0::byte_container_with_subtype<std::__1::vector<unsigned char, std::__1::allocator<unsigned char> > > const&>(nlohmann::json_abi_v3_12_0::byte_container_with_subtype<std::__1::vector<unsigned char, std::__1::allocator<unsigned char> > > const&)::{lambda(nlohmann::json_abi_v3_12_0::byte_container_with_subtype<std::__1::vector<unsigned char, std::__1::allocator<unsigned char> > >*)#1}::operator()(nlohmann::json_abi_v3_12_0::byte_container_with_subtype<std::__1::vector<unsigned char, std::__1::allocator<unsigned char> > >*) constUnexecuted instantiation: nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>::create<std::__1::map<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>, std::__1::less<void>, std::__1::allocator<std::__1::pair<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const, nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void> > > >>()::{lambda(std::__1::map<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>, std::__1::less<void>, std::__1::allocator<std::__1::pair<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const, nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void> > > >*)#1}::operator()(std::__1::map<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>, std::__1::less<void>, std::__1::allocator<std::__1::pair<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const, nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void> > > >*) constUnexecuted instantiation: nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>::create<std::__1::vector<nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>, std::__1::allocator<nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void> > >>()::{lambda(std::__1::vector<nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>, std::__1::allocator<nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void> > >*)#1}::operator()(std::__1::vector<nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>, std::__1::allocator<nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void> > >*) constUnexecuted instantiation: nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>::create<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, char const (&) [1]>(char const (&) [1])::{lambda(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >*)#1}::operator()(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >*) constUnexecuted instantiation: nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>::create<nlohmann::json_abi_v3_12_0::byte_container_with_subtype<std::__1::vector<unsigned char, std::__1::allocator<unsigned char> > >>()::{lambda(nlohmann::json_abi_v3_12_0::byte_container_with_subtype<std::__1::vector<unsigned char, std::__1::allocator<unsigned char> > >*)#1}::operator()(nlohmann::json_abi_v3_12_0::byte_container_with_subtype<std::__1::vector<unsigned char, std::__1::allocator<unsigned char> > >*) constUnexecuted instantiation: nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>::create<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, char const (&) [2]>(char const (&) [2])::{lambda(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >*)#1}::operator()(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >*) constUnexecuted instantiation: nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>::create<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, char const (&) [21]>(char const (&) [21])::{lambda(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >*)#1}::operator()(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >*) constUnexecuted instantiation: nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>::create<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, char const (&) [40]>(char const (&) [40])::{lambda(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >*)#1}::operator()(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >*) constUnexecuted instantiation: nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>::create<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, char const (&) [600]>(char const (&) [600])::{lambda(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >*)#1}::operator()(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >*) constUnexecuted instantiation: nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>::create<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, char const (&) [137]>(char const (&) [137])::{lambda(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >*)#1}::operator()(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >*) constUnexecuted instantiation: nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>::create<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, char const (&) [156]>(char const (&) [156])::{lambda(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >*)#1}::operator()(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >*) constUnexecuted instantiation: nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>::create<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, char const (&) [78]>(char const (&) [78])::{lambda(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >*)#1}::operator()(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >*) constUnexecuted instantiation: nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>::create<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, char const (&) [79]>(char const (&) [79])::{lambda(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >*)#1}::operator()(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >*) constUnexecuted instantiation: nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>::create<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, char const (&) [65]>(char const (&) [65])::{lambda(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >*)#1}::operator()(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >*) constUnexecuted instantiation: nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>::create<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, char const (&) [58]>(char const (&) [58])::{lambda(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >*)#1}::operator()(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >*) constUnexecuted instantiation: nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>::create<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, char const (&) [56]>(char const (&) [56])::{lambda(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >*)#1}::operator()(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >*) constUnexecuted instantiation: nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>::create<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, char const (&) [59]>(char const (&) [59])::{lambda(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >*)#1}::operator()(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >*) constUnexecuted instantiation: nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>::create<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, char const (&) [1679]>(char const (&) [1679])::{lambda(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >*)#1}::operator()(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >*) constUnexecuted instantiation: nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>::create<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, char const (&) [1535]>(char const (&) [1535])::{lambda(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >*)#1}::operator()(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >*) constUnexecuted instantiation: nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>::create<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, char const (&) [714]>(char const (&) [714])::{lambda(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >*)#1}::operator()(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >*) constUnexecuted instantiation: nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>::create<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, char const (&) [3238]>(char const (&) [3238])::{lambda(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >*)#1}::operator()(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >*) constUnexecuted instantiation: nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>::create<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, char const (&) [2159]>(char const (&) [2159])::{lambda(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >*)#1}::operator()(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >*) constUnexecuted instantiation: nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>::create<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, char const (&) [77]>(char const (&) [77])::{lambda(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >*)#1}::operator()(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >*) constUnexecuted instantiation: nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>::create<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, char const (&) [16]>(char const (&) [16])::{lambda(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >*)#1}::operator()(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >*) constUnexecuted instantiation: nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>::create<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, char const (&) [64]>(char const (&) [64])::{lambda(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >*)#1}::operator()(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >*) constUnexecuted instantiation: nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>::create<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, char const (&) [923]>(char const (&) [923])::{lambda(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >*)#1}::operator()(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >*) constUnexecuted instantiation: nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>::create<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, char const (&) [150]>(char const (&) [150])::{lambda(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >*)#1}::operator()(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >*) constUnexecuted instantiation: nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>::create<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, char const (&) [309]>(char const (&) [309])::{lambda(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >*)#1}::operator()(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >*) constUnexecuted instantiation: nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>::create<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, char const (&) [310]>(char const (&) [310])::{lambda(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >*)#1}::operator()(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >*) constUnexecuted instantiation: nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>::create<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, char const (&) [155]>(char const (&) [155])::{lambda(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >*)#1}::operator()(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >*) constUnexecuted instantiation: nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>::create<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, char const (&) [117]>(char const (&) [117])::{lambda(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >*)#1}::operator()(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >*) constUnexecuted instantiation: nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>::create<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, char const (&) [50]>(char const (&) [50])::{lambda(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >*)#1}::operator()(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >*) constUnexecuted instantiation: nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>::create<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, char const (&) [61]>(char const (&) [61])::{lambda(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >*)#1}::operator()(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >*) constUnexecuted instantiation: nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>::create<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, char const (&) [158]>(char const (&) [158])::{lambda(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >*)#1}::operator()(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >*) constUnexecuted instantiation: nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>::create<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, char const (&) [30]>(char const (&) [30])::{lambda(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >*)#1}::operator()(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >*) constUnexecuted instantiation: nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>::create<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, char const (&) [69]>(char const (&) [69])::{lambda(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >*)#1}::operator()(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >*) constUnexecuted instantiation: nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>::create<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, char const (&) [3]>(char const (&) [3])::{lambda(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >*)#1}::operator()(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >*) constUnexecuted instantiation: nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>::create<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, char const (&) [114]>(char const (&) [114])::{lambda(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >*)#1}::operator()(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >*) constUnexecuted instantiation: nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>::create<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, char const (&) [113]>(char const (&) [113])::{lambda(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >*)#1}::operator()(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >*) constUnexecuted instantiation: nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>::create<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, char const (&) [39]>(char const (&) [39])::{lambda(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >*)#1}::operator()(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >*) constUnexecuted instantiation: nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>::create<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, char const (&) [41]>(char const (&) [41])::{lambda(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >*)#1}::operator()(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >*) constUnexecuted instantiation: nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>::create<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, char const (&) [86]>(char const (&) [86])::{lambda(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >*)#1}::operator()(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >*) constUnexecuted instantiation: nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>::create<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, char const (&) [135]>(char const (&) [135])::{lambda(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >*)#1}::operator()(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >*) constUnexecuted instantiation: nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>::create<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, char const (&) [20]>(char const (&) [20])::{lambda(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >*)#1}::operator()(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >*) constUnexecuted instantiation: nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>::create<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, char const (&) [24]>(char const (&) [24])::{lambda(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >*)#1}::operator()(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >*) constUnexecuted instantiation: nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>::create<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, char const (&) [11]>(char const (&) [11])::{lambda(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >*)#1}::operator()(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >*) constUnexecuted instantiation: nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>::create<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, char const (&) [35]>(char const (&) [35])::{lambda(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >*)#1}::operator()(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >*) constUnexecuted instantiation: nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>::create<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, char const (&) [4]>(char const (&) [4])::{lambda(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >*)#1}::operator()(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >*) constUnexecuted instantiation: nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>::create<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, char const (&) [116]>(char const (&) [116])::{lambda(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >*)#1}::operator()(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >*) constUnexecuted instantiation: nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>::create<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, char const (&) [115]>(char const (&) [115])::{lambda(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >*)#1}::operator()(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >*) constUnexecuted instantiation: nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>::create<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, char const (&) [619]>(char const (&) [619])::{lambda(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >*)#1}::operator()(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >*) constUnexecuted instantiation: nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>::create<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, char const (&) [9]>(char const (&) [9])::{lambda(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >*)#1}::operator()(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >*) constUnexecuted instantiation: nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>::create<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&&)::{lambda(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >*)#1}::operator()(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >*) constUnexecuted instantiation: nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>::create<std::__1::vector<nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>, std::__1::allocator<nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void> > >, std::__1::vector<nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>, std::__1::allocator<nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void> > > >(std::__1::vector<nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>, std::__1::allocator<nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void> > >&&)::{lambda(std::__1::vector<nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>, std::__1::allocator<nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void> > >*)#1}::operator()(std::__1::vector<nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>, std::__1::allocator<nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void> > >*) constUnexecuted instantiation: nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>::create<std::__1::vector<nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>, std::__1::allocator<nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void> > >, nlohmann::json_abi_v3_12_0::detail::json_ref<nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void> > const*, nlohmann::json_abi_v3_12_0::detail::json_ref<nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void> > const*>(nlohmann::json_abi_v3_12_0::detail::json_ref<nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void> > const*&&, nlohmann::json_abi_v3_12_0::detail::json_ref<nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void> > const*&&)::{lambda(std::__1::vector<nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>, std::__1::allocator<nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void> > >*)#1}::operator()(std::__1::vector<nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>, std::__1::allocator<nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void> > >*) constUnexecuted instantiation: nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>::create<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, char const (&) [7]>(char const (&) [7])::{lambda(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >*)#1}::operator()(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >*) constUnexecuted instantiation: nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>::create<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, char const (&) [5]>(char const (&) [5])::{lambda(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >*)#1}::operator()(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >*) constUnexecuted instantiation: nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>::create<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, char const (&) [17]>(char const (&) [17])::{lambda(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >*)#1}::operator()(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >*) constUnexecuted instantiation: nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>::create<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, char const (&) [13]>(char const (&) [13])::{lambda(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >*)#1}::operator()(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >*) constUnexecuted instantiation: nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>::create<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, char const (&) [10]>(char const (&) [10])::{lambda(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >*)#1}::operator()(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >*) constUnexecuted instantiation: nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>::create<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, char const (&) [8]>(char const (&) [8])::{lambda(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >*)#1}::operator()(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >*) constUnexecuted instantiation: nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>::create<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, char const (&) [15]>(char const (&) [15])::{lambda(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >*)#1}::operator()(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >*) constUnexecuted instantiation: nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>::create<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, char const (&) [19]>(char const (&) [19])::{lambda(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >*)#1}::operator()(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >*) constUnexecuted instantiation: nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>::create<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, char const (&) [12]>(char const (&) [12])::{lambda(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >*)#1}::operator()(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >*) constUnexecuted instantiation: nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>::create<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, char const (&) [14]>(char const (&) [14])::{lambda(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >*)#1}::operator()(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >*) constUnexecuted instantiation: nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>::create<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, char const (&) [23]>(char const (&) [23])::{lambda(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >*)#1}::operator()(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >*) constUnexecuted instantiation: nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>::create<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, char const (&) [18]>(char const (&) [18])::{lambda(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >*)#1}::operator()(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >*) constUnexecuted instantiation: nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>::create<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, char const* const&>(char const* const&)::{lambda(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >*)#1}::operator()(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >*) const |
20520 | 0 | std::unique_ptr<T, decltype(deleter)> obj(AllocatorTraits::allocate(alloc, 1), deleter); |
20521 | 0 | AllocatorTraits::construct(alloc, obj.get(), std::forward<Args>(args)...); |
20522 | 0 | JSON_ASSERT(obj != nullptr); |
20523 | 0 | return obj.release(); |
20524 | 0 | } Unexecuted instantiation: std::__1::map<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>, std::__1::less<void>, std::__1::allocator<std::__1::pair<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const, nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void> > > >* nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>::create<std::__1::map<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>, std::__1::less<void>, std::__1::allocator<std::__1::pair<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const, nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void> > > >, std::__1::map<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>, std::__1::less<void>, std::__1::allocator<std::__1::pair<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const, nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void> > > > const&>(std::__1::map<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>, std::__1::less<void>, std::__1::allocator<std::__1::pair<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const, nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void> > > > const&) Unexecuted instantiation: std::__1::vector<nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>, std::__1::allocator<nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void> > >* nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>::create<std::__1::vector<nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>, std::__1::allocator<nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void> > >, std::__1::vector<nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>, std::__1::allocator<nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void> > > const&>(std::__1::vector<nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>, std::__1::allocator<nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void> > > const&) Unexecuted instantiation: std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >* nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>::create<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&>(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) Unexecuted instantiation: nlohmann::json_abi_v3_12_0::byte_container_with_subtype<std::__1::vector<unsigned char, std::__1::allocator<unsigned char> > >* nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>::create<nlohmann::json_abi_v3_12_0::byte_container_with_subtype<std::__1::vector<unsigned char, std::__1::allocator<unsigned char> > >, nlohmann::json_abi_v3_12_0::byte_container_with_subtype<std::__1::vector<unsigned char, std::__1::allocator<unsigned char> > > const&>(nlohmann::json_abi_v3_12_0::byte_container_with_subtype<std::__1::vector<unsigned char, std::__1::allocator<unsigned char> > > const&) Unexecuted instantiation: std::__1::map<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>, std::__1::less<void>, std::__1::allocator<std::__1::pair<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const, nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void> > > >* nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>::create<std::__1::map<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>, std::__1::less<void>, std::__1::allocator<std::__1::pair<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const, nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void> > > >>() Unexecuted instantiation: std::__1::vector<nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>, std::__1::allocator<nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void> > >* nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>::create<std::__1::vector<nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>, std::__1::allocator<nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void> > >>() Unexecuted instantiation: std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >* nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>::create<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, char const (&) [1]>(char const (&) [1]) Unexecuted instantiation: nlohmann::json_abi_v3_12_0::byte_container_with_subtype<std::__1::vector<unsigned char, std::__1::allocator<unsigned char> > >* nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>::create<nlohmann::json_abi_v3_12_0::byte_container_with_subtype<std::__1::vector<unsigned char, std::__1::allocator<unsigned char> > >>() Unexecuted instantiation: std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >* nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>::create<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, char const (&) [2]>(char const (&) [2]) Unexecuted instantiation: std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >* nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>::create<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, char const (&) [21]>(char const (&) [21]) Unexecuted instantiation: std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >* nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>::create<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, char const (&) [40]>(char const (&) [40]) Unexecuted instantiation: std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >* nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>::create<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, char const (&) [600]>(char const (&) [600]) Unexecuted instantiation: std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >* nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>::create<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, char const (&) [137]>(char const (&) [137]) Unexecuted instantiation: std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >* nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>::create<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, char const (&) [156]>(char const (&) [156]) Unexecuted instantiation: std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >* nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>::create<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, char const (&) [78]>(char const (&) [78]) Unexecuted instantiation: std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >* nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>::create<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, char const (&) [79]>(char const (&) [79]) Unexecuted instantiation: std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >* nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>::create<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, char const (&) [65]>(char const (&) [65]) Unexecuted instantiation: std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >* nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>::create<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, char const (&) [58]>(char const (&) [58]) Unexecuted instantiation: std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >* nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>::create<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, char const (&) [56]>(char const (&) [56]) Unexecuted instantiation: std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >* nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>::create<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, char const (&) [59]>(char const (&) [59]) Unexecuted instantiation: std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >* nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>::create<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, char const (&) [1679]>(char const (&) [1679]) Unexecuted instantiation: std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >* nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>::create<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, char const (&) [1535]>(char const (&) [1535]) Unexecuted instantiation: std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >* nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>::create<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, char const (&) [714]>(char const (&) [714]) Unexecuted instantiation: std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >* nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>::create<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, char const (&) [3238]>(char const (&) [3238]) Unexecuted instantiation: std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >* nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>::create<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, char const (&) [2159]>(char const (&) [2159]) Unexecuted instantiation: std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >* nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>::create<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, char const (&) [77]>(char const (&) [77]) Unexecuted instantiation: std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >* nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>::create<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, char const (&) [16]>(char const (&) [16]) Unexecuted instantiation: std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >* nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>::create<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, char const (&) [64]>(char const (&) [64]) Unexecuted instantiation: std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >* nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>::create<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, char const (&) [923]>(char const (&) [923]) Unexecuted instantiation: std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >* nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>::create<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, char const (&) [150]>(char const (&) [150]) Unexecuted instantiation: std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >* nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>::create<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, char const (&) [309]>(char const (&) [309]) Unexecuted instantiation: std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >* nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>::create<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, char const (&) [310]>(char const (&) [310]) Unexecuted instantiation: std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >* nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>::create<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, char const (&) [155]>(char const (&) [155]) Unexecuted instantiation: std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >* nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>::create<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, char const (&) [117]>(char const (&) [117]) Unexecuted instantiation: std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >* nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>::create<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, char const (&) [50]>(char const (&) [50]) Unexecuted instantiation: std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >* nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>::create<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, char const (&) [61]>(char const (&) [61]) Unexecuted instantiation: std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >* nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>::create<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, char const (&) [158]>(char const (&) [158]) Unexecuted instantiation: std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >* nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>::create<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, char const (&) [30]>(char const (&) [30]) Unexecuted instantiation: std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >* nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>::create<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, char const (&) [69]>(char const (&) [69]) Unexecuted instantiation: std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >* nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>::create<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, char const (&) [3]>(char const (&) [3]) Unexecuted instantiation: std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >* nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>::create<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, char const (&) [114]>(char const (&) [114]) Unexecuted instantiation: std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >* nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>::create<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, char const (&) [113]>(char const (&) [113]) Unexecuted instantiation: std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >* nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>::create<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, char const (&) [39]>(char const (&) [39]) Unexecuted instantiation: std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >* nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>::create<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, char const (&) [41]>(char const (&) [41]) Unexecuted instantiation: std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >* nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>::create<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, char const (&) [86]>(char const (&) [86]) Unexecuted instantiation: std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >* nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>::create<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, char const (&) [135]>(char const (&) [135]) Unexecuted instantiation: std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >* nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>::create<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, char const (&) [20]>(char const (&) [20]) Unexecuted instantiation: std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >* nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>::create<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, char const (&) [24]>(char const (&) [24]) Unexecuted instantiation: std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >* nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>::create<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, char const (&) [11]>(char const (&) [11]) Unexecuted instantiation: std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >* nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>::create<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, char const (&) [35]>(char const (&) [35]) Unexecuted instantiation: std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >* nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>::create<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, char const (&) [4]>(char const (&) [4]) Unexecuted instantiation: std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >* nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>::create<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, char const (&) [116]>(char const (&) [116]) Unexecuted instantiation: std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >* nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>::create<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, char const (&) [115]>(char const (&) [115]) Unexecuted instantiation: std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >* nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>::create<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, char const (&) [619]>(char const (&) [619]) Unexecuted instantiation: std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >* nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>::create<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, char const (&) [9]>(char const (&) [9]) Unexecuted instantiation: std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >* nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>::create<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&&) Unexecuted instantiation: std::__1::vector<nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>, std::__1::allocator<nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void> > >* nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>::create<std::__1::vector<nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>, std::__1::allocator<nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void> > >, std::__1::vector<nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>, std::__1::allocator<nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void> > > >(std::__1::vector<nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>, std::__1::allocator<nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void> > >&&) Unexecuted instantiation: std::__1::vector<nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>, std::__1::allocator<nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void> > >* nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>::create<std::__1::vector<nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>, std::__1::allocator<nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void> > >, nlohmann::json_abi_v3_12_0::detail::json_ref<nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void> > const*, nlohmann::json_abi_v3_12_0::detail::json_ref<nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void> > const*>(nlohmann::json_abi_v3_12_0::detail::json_ref<nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void> > const*&&, nlohmann::json_abi_v3_12_0::detail::json_ref<nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void> > const*&&) Unexecuted instantiation: std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >* nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>::create<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, char const (&) [7]>(char const (&) [7]) Unexecuted instantiation: std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >* nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>::create<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, char const (&) [5]>(char const (&) [5]) Unexecuted instantiation: std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >* nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>::create<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, char const (&) [17]>(char const (&) [17]) Unexecuted instantiation: std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >* nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>::create<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, char const (&) [13]>(char const (&) [13]) Unexecuted instantiation: std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >* nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>::create<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, char const (&) [10]>(char const (&) [10]) Unexecuted instantiation: std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >* nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>::create<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, char const (&) [8]>(char const (&) [8]) Unexecuted instantiation: std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >* nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>::create<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, char const (&) [15]>(char const (&) [15]) Unexecuted instantiation: std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >* nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>::create<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, char const (&) [19]>(char const (&) [19]) Unexecuted instantiation: std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >* nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>::create<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, char const (&) [12]>(char const (&) [12]) Unexecuted instantiation: std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >* nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>::create<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, char const (&) [14]>(char const (&) [14]) Unexecuted instantiation: std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >* nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>::create<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, char const (&) [23]>(char const (&) [23]) Unexecuted instantiation: std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >* nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>::create<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, char const (&) [18]>(char const (&) [18]) Unexecuted instantiation: std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >* nlohmann::json_abi_v3_12_0::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long, unsigned long, double, std::__1::allocator, nlohmann::json_abi_v3_12_0::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >, void>::create<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, char const* const&>(char const* const&) |
20525 | | |
20526 | | //////////////////////// |
20527 | | // JSON value storage // |
20528 | | //////////////////////// |
20529 | | |
20530 | | JSON_PRIVATE_UNLESS_TESTED: |
20531 | | /*! |
20532 | | @brief a JSON value |
20533 | | |
20534 | | The actual storage for a JSON value of the @ref basic_json class. This |
20535 | | union combines the different storage types for the JSON value types |
20536 | | defined in @ref value_t. |
20537 | | |
20538 | | JSON type | value_t type | used type |
20539 | | --------- | --------------- | ------------------------ |
20540 | | object | object | pointer to @ref object_t |
20541 | | array | array | pointer to @ref array_t |
20542 | | string | string | pointer to @ref string_t |
20543 | | boolean | boolean | @ref boolean_t |
20544 | | number | number_integer | @ref number_integer_t |
20545 | | number | number_unsigned | @ref number_unsigned_t |
20546 | | number | number_float | @ref number_float_t |
20547 | | binary | binary | pointer to @ref binary_t |
20548 | | null | null | *no value is stored* |
20549 | | |
20550 | | @note Variable-length types (objects, arrays, and strings) are stored as |
20551 | | pointers. The size of the union should not exceed 64 bits if the default |
20552 | | value types are used. |
20553 | | |
20554 | | @since version 1.0.0 |
20555 | | */ |
20556 | | union json_value |
20557 | | { |
20558 | | /// object (stored with pointer to save storage) |
20559 | | object_t* object; |
20560 | | /// array (stored with pointer to save storage) |
20561 | | array_t* array; |
20562 | | /// string (stored with pointer to save storage) |
20563 | | string_t* string; |
20564 | | /// binary (stored with pointer to save storage) |
20565 | | binary_t* binary; |
20566 | | /// boolean |
20567 | | boolean_t boolean; |
20568 | | /// number (integer) |
20569 | | number_integer_t number_integer; |
20570 | | /// number (unsigned integer) |
20571 | | number_unsigned_t number_unsigned; |
20572 | | /// number (floating-point) |
20573 | | number_float_t number_float; |
20574 | | |
20575 | | /// default constructor (for null values) |
20576 | | json_value() = default; |
20577 | | /// constructor for booleans |
20578 | 0 | json_value(boolean_t v) noexcept : boolean(v) {} |
20579 | | /// constructor for numbers (integer) |
20580 | 0 | json_value(number_integer_t v) noexcept : number_integer(v) {} |
20581 | | /// constructor for numbers (unsigned) |
20582 | 0 | json_value(number_unsigned_t v) noexcept : number_unsigned(v) {} |
20583 | | /// constructor for numbers (floating-point) |
20584 | 0 | json_value(number_float_t v) noexcept : number_float(v) {} |
20585 | | /// constructor for empty values of a given type |
20586 | | json_value(value_t t) |
20587 | 0 | { |
20588 | 0 | switch (t) |
20589 | 0 | { |
20590 | 0 | case value_t::object: |
20591 | 0 | { |
20592 | 0 | object = create<object_t>(); |
20593 | 0 | break; |
20594 | 0 | } |
20595 | | |
20596 | 0 | case value_t::array: |
20597 | 0 | { |
20598 | 0 | array = create<array_t>(); |
20599 | 0 | break; |
20600 | 0 | } |
20601 | | |
20602 | 0 | case value_t::string: |
20603 | 0 | { |
20604 | 0 | string = create<string_t>(""); |
20605 | 0 | break; |
20606 | 0 | } |
20607 | | |
20608 | 0 | case value_t::binary: |
20609 | 0 | { |
20610 | 0 | binary = create<binary_t>(); |
20611 | 0 | break; |
20612 | 0 | } |
20613 | | |
20614 | 0 | case value_t::boolean: |
20615 | 0 | { |
20616 | 0 | boolean = static_cast<boolean_t>(false); |
20617 | 0 | break; |
20618 | 0 | } |
20619 | | |
20620 | 0 | case value_t::number_integer: |
20621 | 0 | { |
20622 | 0 | number_integer = static_cast<number_integer_t>(0); |
20623 | 0 | break; |
20624 | 0 | } |
20625 | | |
20626 | 0 | case value_t::number_unsigned: |
20627 | 0 | { |
20628 | 0 | number_unsigned = static_cast<number_unsigned_t>(0); |
20629 | 0 | break; |
20630 | 0 | } |
20631 | | |
20632 | 0 | case value_t::number_float: |
20633 | 0 | { |
20634 | 0 | number_float = static_cast<number_float_t>(0.0); |
20635 | 0 | break; |
20636 | 0 | } |
20637 | | |
20638 | 0 | case value_t::null: |
20639 | 0 | { |
20640 | 0 | object = nullptr; // silence warning, see #821 |
20641 | 0 | break; |
20642 | 0 | } |
20643 | | |
20644 | 0 | case value_t::discarded: |
20645 | 0 | default: |
20646 | 0 | { |
20647 | 0 | object = nullptr; // silence warning, see #821 |
20648 | 0 | if (JSON_HEDLEY_UNLIKELY(t == value_t::null)) |
20649 | 0 | { |
20650 | 0 | JSON_THROW(other_error::create(500, "961c151d2e87f2686a955a9be24d316f1362bf21 3.12.0", nullptr)); // LCOV_EXCL_LINE |
20651 | 0 | } |
20652 | 0 | break; |
20653 | 0 | } |
20654 | 0 | } |
20655 | 0 | } |
20656 | | |
20657 | | /// constructor for strings |
20658 | 0 | json_value(const string_t& value) : string(create<string_t>(value)) {} |
20659 | | |
20660 | | /// constructor for rvalue strings |
20661 | 0 | json_value(string_t&& value) : string(create<string_t>(std::move(value))) {} |
20662 | | |
20663 | | /// constructor for objects |
20664 | 0 | json_value(const object_t& value) : object(create<object_t>(value)) {} |
20665 | | |
20666 | | /// constructor for rvalue objects |
20667 | | json_value(object_t&& value) : object(create<object_t>(std::move(value))) {} |
20668 | | |
20669 | | /// constructor for arrays |
20670 | 0 | json_value(const array_t& value) : array(create<array_t>(value)) {} |
20671 | | |
20672 | | /// constructor for rvalue arrays |
20673 | 0 | json_value(array_t&& value) : array(create<array_t>(std::move(value))) {} |
20674 | | |
20675 | | /// constructor for binary arrays |
20676 | | json_value(const typename binary_t::container_type& value) : binary(create<binary_t>(value)) {} |
20677 | | |
20678 | | /// constructor for rvalue binary arrays |
20679 | | json_value(typename binary_t::container_type&& value) : binary(create<binary_t>(std::move(value))) {} |
20680 | | |
20681 | | /// constructor for binary arrays (internal type) |
20682 | 0 | json_value(const binary_t& value) : binary(create<binary_t>(value)) {} |
20683 | | |
20684 | | /// constructor for rvalue binary arrays (internal type) |
20685 | | json_value(binary_t&& value) : binary(create<binary_t>(std::move(value))) {} |
20686 | | |
20687 | | void destroy(value_t t) |
20688 | 0 | { |
20689 | 0 | if ( |
20690 | 0 | (t == value_t::object && object == nullptr) || |
20691 | 0 | (t == value_t::array && array == nullptr) || |
20692 | 0 | (t == value_t::string && string == nullptr) || |
20693 | 0 | (t == value_t::binary && binary == nullptr) |
20694 | 0 | ) |
20695 | 0 | { |
20696 | | // not initialized (e.g., due to exception in the ctor) |
20697 | 0 | return; |
20698 | 0 | } |
20699 | 0 | if (t == value_t::array || t == value_t::object) |
20700 | 0 | { |
20701 | | // flatten the current json_value to a heap-allocated stack |
20702 | 0 | std::vector<basic_json> stack; |
20703 | | |
20704 | | // move the top-level items to stack |
20705 | 0 | if (t == value_t::array) |
20706 | 0 | { |
20707 | 0 | stack.reserve(array->size()); |
20708 | 0 | std::move(array->begin(), array->end(), std::back_inserter(stack)); |
20709 | 0 | } |
20710 | 0 | else |
20711 | 0 | { |
20712 | 0 | stack.reserve(object->size()); |
20713 | 0 | for (auto&& it : *object) |
20714 | 0 | { |
20715 | 0 | stack.push_back(std::move(it.second)); |
20716 | 0 | } |
20717 | 0 | } |
20718 | |
|
20719 | 0 | while (!stack.empty()) |
20720 | 0 | { |
20721 | | // move the last item to a local variable to be processed |
20722 | 0 | basic_json current_item(std::move(stack.back())); |
20723 | 0 | stack.pop_back(); |
20724 | | |
20725 | | // if current_item is array/object, move |
20726 | | // its children to the stack to be processed later |
20727 | 0 | if (current_item.is_array()) |
20728 | 0 | { |
20729 | 0 | std::move(current_item.m_data.m_value.array->begin(), current_item.m_data.m_value.array->end(), std::back_inserter(stack)); |
20730 | |
|
20731 | 0 | current_item.m_data.m_value.array->clear(); |
20732 | 0 | } |
20733 | 0 | else if (current_item.is_object()) |
20734 | 0 | { |
20735 | 0 | for (auto&& it : *current_item.m_data.m_value.object) |
20736 | 0 | { |
20737 | 0 | stack.push_back(std::move(it.second)); |
20738 | 0 | } |
20739 | |
|
20740 | 0 | current_item.m_data.m_value.object->clear(); |
20741 | 0 | } |
20742 | | |
20743 | | // it's now safe that current_item gets destructed |
20744 | | // since it doesn't have any children |
20745 | 0 | } |
20746 | 0 | } |
20747 | |
|
20748 | 0 | switch (t) |
20749 | 0 | { |
20750 | 0 | case value_t::object: |
20751 | 0 | { |
20752 | 0 | AllocatorType<object_t> alloc; |
20753 | 0 | std::allocator_traits<decltype(alloc)>::destroy(alloc, object); |
20754 | 0 | std::allocator_traits<decltype(alloc)>::deallocate(alloc, object, 1); |
20755 | 0 | break; |
20756 | 0 | } |
20757 | | |
20758 | 0 | case value_t::array: |
20759 | 0 | { |
20760 | 0 | AllocatorType<array_t> alloc; |
20761 | 0 | std::allocator_traits<decltype(alloc)>::destroy(alloc, array); |
20762 | 0 | std::allocator_traits<decltype(alloc)>::deallocate(alloc, array, 1); |
20763 | 0 | break; |
20764 | 0 | } |
20765 | | |
20766 | 0 | case value_t::string: |
20767 | 0 | { |
20768 | 0 | AllocatorType<string_t> alloc; |
20769 | 0 | std::allocator_traits<decltype(alloc)>::destroy(alloc, string); |
20770 | 0 | std::allocator_traits<decltype(alloc)>::deallocate(alloc, string, 1); |
20771 | 0 | break; |
20772 | 0 | } |
20773 | | |
20774 | 0 | case value_t::binary: |
20775 | 0 | { |
20776 | 0 | AllocatorType<binary_t> alloc; |
20777 | 0 | std::allocator_traits<decltype(alloc)>::destroy(alloc, binary); |
20778 | 0 | std::allocator_traits<decltype(alloc)>::deallocate(alloc, binary, 1); |
20779 | 0 | break; |
20780 | 0 | } |
20781 | | |
20782 | 0 | case value_t::null: |
20783 | 0 | case value_t::boolean: |
20784 | 0 | case value_t::number_integer: |
20785 | 0 | case value_t::number_unsigned: |
20786 | 0 | case value_t::number_float: |
20787 | 0 | case value_t::discarded: |
20788 | 0 | default: |
20789 | 0 | { |
20790 | 0 | break; |
20791 | 0 | } |
20792 | 0 | } |
20793 | 0 | } |
20794 | | }; |
20795 | | |
20796 | | private: |
20797 | | /*! |
20798 | | @brief checks the class invariants |
20799 | | |
20800 | | This function asserts the class invariants. It needs to be called at the |
20801 | | end of every constructor to make sure that created objects respect the |
20802 | | invariant. Furthermore, it has to be called each time the type of a JSON |
20803 | | value is changed, because the invariant expresses a relationship between |
20804 | | @a m_type and @a m_value. |
20805 | | |
20806 | | Furthermore, the parent relation is checked for arrays and objects: If |
20807 | | @a check_parents true and the value is an array or object, then the |
20808 | | container's elements must have the current value as parent. |
20809 | | |
20810 | | @param[in] check_parents whether the parent relation should be checked. |
20811 | | The value is true by default and should only be set to false |
20812 | | during destruction of objects when the invariant does not |
20813 | | need to hold. |
20814 | | */ |
20815 | | void assert_invariant(bool check_parents = true) const noexcept |
20816 | 0 | { |
20817 | 0 | JSON_ASSERT(m_data.m_type != value_t::object || m_data.m_value.object != nullptr); |
20818 | 0 | JSON_ASSERT(m_data.m_type != value_t::array || m_data.m_value.array != nullptr); |
20819 | 0 | JSON_ASSERT(m_data.m_type != value_t::string || m_data.m_value.string != nullptr); |
20820 | 0 | JSON_ASSERT(m_data.m_type != value_t::binary || m_data.m_value.binary != nullptr); |
20821 | | |
20822 | | #if JSON_DIAGNOSTICS |
20823 | | JSON_TRY |
20824 | | { |
20825 | | // cppcheck-suppress assertWithSideEffect |
20826 | | JSON_ASSERT(!check_parents || !is_structured() || std::all_of(begin(), end(), [this](const basic_json & j) |
20827 | | { |
20828 | | return j.m_parent == this; |
20829 | | })); |
20830 | | } |
20831 | | JSON_CATCH(...) {} // LCOV_EXCL_LINE |
20832 | | #endif |
20833 | 0 | static_cast<void>(check_parents); |
20834 | 0 | } |
20835 | | |
20836 | | void set_parents() |
20837 | 0 | { |
20838 | | #if JSON_DIAGNOSTICS |
20839 | | switch (m_data.m_type) |
20840 | | { |
20841 | | case value_t::array: |
20842 | | { |
20843 | | for (auto& element : *m_data.m_value.array) |
20844 | | { |
20845 | | element.m_parent = this; |
20846 | | } |
20847 | | break; |
20848 | | } |
20849 | | |
20850 | | case value_t::object: |
20851 | | { |
20852 | | for (auto& element : *m_data.m_value.object) |
20853 | | { |
20854 | | element.second.m_parent = this; |
20855 | | } |
20856 | | break; |
20857 | | } |
20858 | | |
20859 | | case value_t::null: |
20860 | | case value_t::string: |
20861 | | case value_t::boolean: |
20862 | | case value_t::number_integer: |
20863 | | case value_t::number_unsigned: |
20864 | | case value_t::number_float: |
20865 | | case value_t::binary: |
20866 | | case value_t::discarded: |
20867 | | default: |
20868 | | break; |
20869 | | } |
20870 | | #endif |
20871 | 0 | } |
20872 | | |
20873 | | iterator set_parents(iterator it, typename iterator::difference_type count_set_parents) |
20874 | | { |
20875 | | #if JSON_DIAGNOSTICS |
20876 | | for (typename iterator::difference_type i = 0; i < count_set_parents; ++i) |
20877 | | { |
20878 | | (it + i)->m_parent = this; |
20879 | | } |
20880 | | #else |
20881 | | static_cast<void>(count_set_parents); |
20882 | | #endif |
20883 | | return it; |
20884 | | } |
20885 | | |
20886 | | reference set_parent(reference j, std::size_t old_capacity = detail::unknown_size()) |
20887 | 0 | { |
20888 | | #if JSON_DIAGNOSTICS |
20889 | | if (old_capacity != detail::unknown_size()) |
20890 | | { |
20891 | | // see https://github.com/nlohmann/json/issues/2838 |
20892 | | JSON_ASSERT(type() == value_t::array); |
20893 | | if (JSON_HEDLEY_UNLIKELY(m_data.m_value.array->capacity() != old_capacity)) |
20894 | | { |
20895 | | // capacity has changed: update all parents |
20896 | | set_parents(); |
20897 | | return j; |
20898 | | } |
20899 | | } |
20900 | | |
20901 | | // ordered_json uses a vector internally, so pointers could have |
20902 | | // been invalidated; see https://github.com/nlohmann/json/issues/2962 |
20903 | | #ifdef JSON_HEDLEY_MSVC_VERSION |
20904 | | #pragma warning(push ) |
20905 | | #pragma warning(disable : 4127) // ignore warning to replace if with if constexpr |
20906 | | #endif |
20907 | | if (detail::is_ordered_map<object_t>::value) |
20908 | | { |
20909 | | set_parents(); |
20910 | | return j; |
20911 | | } |
20912 | | #ifdef JSON_HEDLEY_MSVC_VERSION |
20913 | | #pragma warning( pop ) |
20914 | | #endif |
20915 | | |
20916 | | j.m_parent = this; |
20917 | | #else |
20918 | 0 | static_cast<void>(j); |
20919 | 0 | static_cast<void>(old_capacity); |
20920 | 0 | #endif |
20921 | 0 | return j; |
20922 | 0 | } |
20923 | | |
20924 | | public: |
20925 | | ////////////////////////// |
20926 | | // JSON parser callback // |
20927 | | ////////////////////////// |
20928 | | |
20929 | | /// @brief parser event types |
20930 | | /// @sa https://json.nlohmann.me/api/basic_json/parse_event_t/ |
20931 | | using parse_event_t = detail::parse_event_t; |
20932 | | |
20933 | | /// @brief per-element parser callback type |
20934 | | /// @sa https://json.nlohmann.me/api/basic_json/parser_callback_t/ |
20935 | | using parser_callback_t = detail::parser_callback_t<basic_json>; |
20936 | | |
20937 | | ////////////////// |
20938 | | // constructors // |
20939 | | ////////////////// |
20940 | | |
20941 | | /// @name constructors and destructors |
20942 | | /// Constructors of class @ref basic_json, copy/move constructor, copy |
20943 | | /// assignment, static functions creating objects, and the destructor. |
20944 | | /// @{ |
20945 | | |
20946 | | /// @brief create an empty value with a given type |
20947 | | /// @sa https://json.nlohmann.me/api/basic_json/basic_json/ |
20948 | | basic_json(const value_t v) |
20949 | 0 | : m_data(v) |
20950 | 0 | { |
20951 | 0 | assert_invariant(); |
20952 | 0 | } |
20953 | | |
20954 | | /// @brief create a null object |
20955 | | /// @sa https://json.nlohmann.me/api/basic_json/basic_json/ |
20956 | | basic_json(std::nullptr_t = nullptr) noexcept // NOLINT(bugprone-exception-escape) |
20957 | 0 | : basic_json(value_t::null) |
20958 | 0 | { |
20959 | 0 | assert_invariant(); |
20960 | 0 | } |
20961 | | |
20962 | | /// @brief create a JSON value from compatible types |
20963 | | /// @sa https://json.nlohmann.me/api/basic_json/basic_json/ |
20964 | | template < typename CompatibleType, |
20965 | | typename U = detail::uncvref_t<CompatibleType>, |
20966 | | detail::enable_if_t < |
20967 | | !detail::is_basic_json<U>::value && detail::is_compatible_type<basic_json_t, U>::value, int > = 0 > |
20968 | | basic_json(CompatibleType && val) noexcept(noexcept( // NOLINT(bugprone-forwarding-reference-overload,bugprone-exception-escape) |
20969 | | JSONSerializer<U>::to_json(std::declval<basic_json_t&>(), |
20970 | | std::forward<CompatibleType>(val)))) |
20971 | 0 | { |
20972 | 0 | JSONSerializer<U>::to_json(*this, std::forward<CompatibleType>(val)); |
20973 | 0 | set_parents(); |
20974 | 0 | assert_invariant(); |
20975 | 0 | } Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_010basic_jsonINSt3__13mapENS2_6vectorENS2_12basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEEblmdS8_NS0_14adl_serializerENS4_IhNS8_IhEEEEvEC2IRA1_KcA1_cTnNS2_9enable_ifIXaantsr6detail13is_basic_jsonIT0_EE5valuesr6detail18is_compatible_typeISE_SL_EE5valueEiE4typeELi0EEEOT_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_010basic_jsonINSt3__13mapENS2_6vectorENS2_12basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEEblmdS8_NS0_14adl_serializerENS4_IhNS8_IhEEEEvEC2IRKmmTnNS2_9enable_ifIXaantsr6detail13is_basic_jsonIT0_EE5valuesr6detail18is_compatible_typeISE_SJ_EE5valueEiE4typeELi0EEEOT_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_010basic_jsonINSt3__13mapENS2_6vectorENS2_12basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEEblmdS8_NS0_14adl_serializerENS4_IhNS8_IhEEEEvEC2IRKSA_SA_TnNS2_9enable_ifIXaantsr6detail13is_basic_jsonIT0_EE5valuesr6detail18is_compatible_typeISE_SJ_EE5valueEiE4typeELi0EEEOT_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_010basic_jsonINSt3__13mapENS2_6vectorENS2_12basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEEblmdS8_NS0_14adl_serializerENS4_IhNS8_IhEEEEvEC2IRA2_KcA2_cTnNS2_9enable_ifIXaantsr6detail13is_basic_jsonIT0_EE5valuesr6detail18is_compatible_typeISE_SL_EE5valueEiE4typeELi0EEEOT_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_010basic_jsonINSt3__13mapENS2_6vectorENS2_12basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEEblmdS8_NS0_14adl_serializerENS4_IhNS8_IhEEEEvEC2IRSA_SA_TnNS2_9enable_ifIXaantsr6detail13is_basic_jsonIT0_EE5valuesr6detail18is_compatible_typeISE_SI_EE5valueEiE4typeELi0EEEOT_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_010basic_jsonINSt3__13mapENS2_6vectorENS2_12basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEEblmdS8_NS0_14adl_serializerENS4_IhNS8_IhEEEEvEC2ImmTnNS2_9enable_ifIXaantsr6detail13is_basic_jsonIT0_EE5valuesr6detail18is_compatible_typeISE_SH_EE5valueEiE4typeELi0EEEOT_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_010basic_jsonINSt3__13mapENS2_6vectorENS2_12basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEEblmdS8_NS0_14adl_serializerENS4_IhNS8_IhEEEEvEC2IRA21_KcA21_cTnNS2_9enable_ifIXaantsr6detail13is_basic_jsonIT0_EE5valuesr6detail18is_compatible_typeISE_SL_EE5valueEiE4typeELi0EEEOT_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_010basic_jsonINSt3__13mapENS2_6vectorENS2_12basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEEblmdS8_NS0_14adl_serializerENS4_IhNS8_IhEEEEvEC2IRA40_KcA40_cTnNS2_9enable_ifIXaantsr6detail13is_basic_jsonIT0_EE5valuesr6detail18is_compatible_typeISE_SL_EE5valueEiE4typeELi0EEEOT_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_010basic_jsonINSt3__13mapENS2_6vectorENS2_12basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEEblmdS8_NS0_14adl_serializerENS4_IhNS8_IhEEEEvEC2IRA600_KcA600_cTnNS2_9enable_ifIXaantsr6detail13is_basic_jsonIT0_EE5valuesr6detail18is_compatible_typeISE_SL_EE5valueEiE4typeELi0EEEOT_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_010basic_jsonINSt3__13mapENS2_6vectorENS2_12basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEEblmdS8_NS0_14adl_serializerENS4_IhNS8_IhEEEEvEC2IRA137_KcA137_cTnNS2_9enable_ifIXaantsr6detail13is_basic_jsonIT0_EE5valuesr6detail18is_compatible_typeISE_SL_EE5valueEiE4typeELi0EEEOT_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_010basic_jsonINSt3__13mapENS2_6vectorENS2_12basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEEblmdS8_NS0_14adl_serializerENS4_IhNS8_IhEEEEvEC2IRA156_KcA156_cTnNS2_9enable_ifIXaantsr6detail13is_basic_jsonIT0_EE5valuesr6detail18is_compatible_typeISE_SL_EE5valueEiE4typeELi0EEEOT_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_010basic_jsonINSt3__13mapENS2_6vectorENS2_12basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEEblmdS8_NS0_14adl_serializerENS4_IhNS8_IhEEEEvEC2IRA78_KcA78_cTnNS2_9enable_ifIXaantsr6detail13is_basic_jsonIT0_EE5valuesr6detail18is_compatible_typeISE_SL_EE5valueEiE4typeELi0EEEOT_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_010basic_jsonINSt3__13mapENS2_6vectorENS2_12basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEEblmdS8_NS0_14adl_serializerENS4_IhNS8_IhEEEEvEC2IRA79_KcA79_cTnNS2_9enable_ifIXaantsr6detail13is_basic_jsonIT0_EE5valuesr6detail18is_compatible_typeISE_SL_EE5valueEiE4typeELi0EEEOT_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_010basic_jsonINSt3__13mapENS2_6vectorENS2_12basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEEblmdS8_NS0_14adl_serializerENS4_IhNS8_IhEEEEvEC2IRA65_KcA65_cTnNS2_9enable_ifIXaantsr6detail13is_basic_jsonIT0_EE5valuesr6detail18is_compatible_typeISE_SL_EE5valueEiE4typeELi0EEEOT_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_010basic_jsonINSt3__13mapENS2_6vectorENS2_12basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEEblmdS8_NS0_14adl_serializerENS4_IhNS8_IhEEEEvEC2IRA58_KcA58_cTnNS2_9enable_ifIXaantsr6detail13is_basic_jsonIT0_EE5valuesr6detail18is_compatible_typeISE_SL_EE5valueEiE4typeELi0EEEOT_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_010basic_jsonINSt3__13mapENS2_6vectorENS2_12basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEEblmdS8_NS0_14adl_serializerENS4_IhNS8_IhEEEEvEC2IRA56_KcA56_cTnNS2_9enable_ifIXaantsr6detail13is_basic_jsonIT0_EE5valuesr6detail18is_compatible_typeISE_SL_EE5valueEiE4typeELi0EEEOT_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_010basic_jsonINSt3__13mapENS2_6vectorENS2_12basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEEblmdS8_NS0_14adl_serializerENS4_IhNS8_IhEEEEvEC2IRA59_KcA59_cTnNS2_9enable_ifIXaantsr6detail13is_basic_jsonIT0_EE5valuesr6detail18is_compatible_typeISE_SL_EE5valueEiE4typeELi0EEEOT_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_010basic_jsonINSt3__13mapENS2_6vectorENS2_12basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEEblmdS8_NS0_14adl_serializerENS4_IhNS8_IhEEEEvEC2IRA1679_KcA1679_cTnNS2_9enable_ifIXaantsr6detail13is_basic_jsonIT0_EE5valuesr6detail18is_compatible_typeISE_SL_EE5valueEiE4typeELi0EEEOT_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_010basic_jsonINSt3__13mapENS2_6vectorENS2_12basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEEblmdS8_NS0_14adl_serializerENS4_IhNS8_IhEEEEvEC2IRA1535_KcA1535_cTnNS2_9enable_ifIXaantsr6detail13is_basic_jsonIT0_EE5valuesr6detail18is_compatible_typeISE_SL_EE5valueEiE4typeELi0EEEOT_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_010basic_jsonINSt3__13mapENS2_6vectorENS2_12basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEEblmdS8_NS0_14adl_serializerENS4_IhNS8_IhEEEEvEC2IRA714_KcA714_cTnNS2_9enable_ifIXaantsr6detail13is_basic_jsonIT0_EE5valuesr6detail18is_compatible_typeISE_SL_EE5valueEiE4typeELi0EEEOT_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_010basic_jsonINSt3__13mapENS2_6vectorENS2_12basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEEblmdS8_NS0_14adl_serializerENS4_IhNS8_IhEEEEvEC2IRA3238_KcA3238_cTnNS2_9enable_ifIXaantsr6detail13is_basic_jsonIT0_EE5valuesr6detail18is_compatible_typeISE_SL_EE5valueEiE4typeELi0EEEOT_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_010basic_jsonINSt3__13mapENS2_6vectorENS2_12basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEEblmdS8_NS0_14adl_serializerENS4_IhNS8_IhEEEEvEC2IRA2159_KcA2159_cTnNS2_9enable_ifIXaantsr6detail13is_basic_jsonIT0_EE5valuesr6detail18is_compatible_typeISE_SL_EE5valueEiE4typeELi0EEEOT_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_010basic_jsonINSt3__13mapENS2_6vectorENS2_12basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEEblmdS8_NS0_14adl_serializerENS4_IhNS8_IhEEEEvEC2IRA77_KcA77_cTnNS2_9enable_ifIXaantsr6detail13is_basic_jsonIT0_EE5valuesr6detail18is_compatible_typeISE_SL_EE5valueEiE4typeELi0EEEOT_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_010basic_jsonINSt3__13mapENS2_6vectorENS2_12basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEEblmdS8_NS0_14adl_serializerENS4_IhNS8_IhEEEEvEC2IRA16_KcA16_cTnNS2_9enable_ifIXaantsr6detail13is_basic_jsonIT0_EE5valuesr6detail18is_compatible_typeISE_SL_EE5valueEiE4typeELi0EEEOT_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_010basic_jsonINSt3__13mapENS2_6vectorENS2_12basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEEblmdS8_NS0_14adl_serializerENS4_IhNS8_IhEEEEvEC2IRA64_KcA64_cTnNS2_9enable_ifIXaantsr6detail13is_basic_jsonIT0_EE5valuesr6detail18is_compatible_typeISE_SL_EE5valueEiE4typeELi0EEEOT_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_010basic_jsonINSt3__13mapENS2_6vectorENS2_12basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEEblmdS8_NS0_14adl_serializerENS4_IhNS8_IhEEEEvEC2IRA923_KcA923_cTnNS2_9enable_ifIXaantsr6detail13is_basic_jsonIT0_EE5valuesr6detail18is_compatible_typeISE_SL_EE5valueEiE4typeELi0EEEOT_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_010basic_jsonINSt3__13mapENS2_6vectorENS2_12basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEEblmdS8_NS0_14adl_serializerENS4_IhNS8_IhEEEEvEC2IRA150_KcA150_cTnNS2_9enable_ifIXaantsr6detail13is_basic_jsonIT0_EE5valuesr6detail18is_compatible_typeISE_SL_EE5valueEiE4typeELi0EEEOT_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_010basic_jsonINSt3__13mapENS2_6vectorENS2_12basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEEblmdS8_NS0_14adl_serializerENS4_IhNS8_IhEEEEvEC2IRA309_KcA309_cTnNS2_9enable_ifIXaantsr6detail13is_basic_jsonIT0_EE5valuesr6detail18is_compatible_typeISE_SL_EE5valueEiE4typeELi0EEEOT_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_010basic_jsonINSt3__13mapENS2_6vectorENS2_12basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEEblmdS8_NS0_14adl_serializerENS4_IhNS8_IhEEEEvEC2IRA310_KcA310_cTnNS2_9enable_ifIXaantsr6detail13is_basic_jsonIT0_EE5valuesr6detail18is_compatible_typeISE_SL_EE5valueEiE4typeELi0EEEOT_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_010basic_jsonINSt3__13mapENS2_6vectorENS2_12basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEEblmdS8_NS0_14adl_serializerENS4_IhNS8_IhEEEEvEC2IRA155_KcA155_cTnNS2_9enable_ifIXaantsr6detail13is_basic_jsonIT0_EE5valuesr6detail18is_compatible_typeISE_SL_EE5valueEiE4typeELi0EEEOT_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_010basic_jsonINSt3__13mapENS2_6vectorENS2_12basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEEblmdS8_NS0_14adl_serializerENS4_IhNS8_IhEEEEvEC2IRA117_KcA117_cTnNS2_9enable_ifIXaantsr6detail13is_basic_jsonIT0_EE5valuesr6detail18is_compatible_typeISE_SL_EE5valueEiE4typeELi0EEEOT_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_010basic_jsonINSt3__13mapENS2_6vectorENS2_12basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEEblmdS8_NS0_14adl_serializerENS4_IhNS8_IhEEEEvEC2IRA50_KcA50_cTnNS2_9enable_ifIXaantsr6detail13is_basic_jsonIT0_EE5valuesr6detail18is_compatible_typeISE_SL_EE5valueEiE4typeELi0EEEOT_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_010basic_jsonINSt3__13mapENS2_6vectorENS2_12basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEEblmdS8_NS0_14adl_serializerENS4_IhNS8_IhEEEEvEC2IRA61_KcA61_cTnNS2_9enable_ifIXaantsr6detail13is_basic_jsonIT0_EE5valuesr6detail18is_compatible_typeISE_SL_EE5valueEiE4typeELi0EEEOT_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_010basic_jsonINSt3__13mapENS2_6vectorENS2_12basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEEblmdS8_NS0_14adl_serializerENS4_IhNS8_IhEEEEvEC2IRA158_KcA158_cTnNS2_9enable_ifIXaantsr6detail13is_basic_jsonIT0_EE5valuesr6detail18is_compatible_typeISE_SL_EE5valueEiE4typeELi0EEEOT_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_010basic_jsonINSt3__13mapENS2_6vectorENS2_12basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEEblmdS8_NS0_14adl_serializerENS4_IhNS8_IhEEEEvEC2IRA30_KcA30_cTnNS2_9enable_ifIXaantsr6detail13is_basic_jsonIT0_EE5valuesr6detail18is_compatible_typeISE_SL_EE5valueEiE4typeELi0EEEOT_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_010basic_jsonINSt3__13mapENS2_6vectorENS2_12basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEEblmdS8_NS0_14adl_serializerENS4_IhNS8_IhEEEEvEC2IRA69_KcA69_cTnNS2_9enable_ifIXaantsr6detail13is_basic_jsonIT0_EE5valuesr6detail18is_compatible_typeISE_SL_EE5valueEiE4typeELi0EEEOT_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_010basic_jsonINSt3__13mapENS2_6vectorENS2_12basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEEblmdS8_NS0_14adl_serializerENS4_IhNS8_IhEEEEvEC2IRA3_KcA3_cTnNS2_9enable_ifIXaantsr6detail13is_basic_jsonIT0_EE5valuesr6detail18is_compatible_typeISE_SL_EE5valueEiE4typeELi0EEEOT_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_010basic_jsonINSt3__13mapENS2_6vectorENS2_12basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEEblmdS8_NS0_14adl_serializerENS4_IhNS8_IhEEEEvEC2IiiTnNS2_9enable_ifIXaantsr6detail13is_basic_jsonIT0_EE5valuesr6detail18is_compatible_typeISE_SH_EE5valueEiE4typeELi0EEEOT_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_010basic_jsonINSt3__13mapENS2_6vectorENS2_12basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEEblmdS8_NS0_14adl_serializerENS4_IhNS8_IhEEEEvEC2IRA114_KcA114_cTnNS2_9enable_ifIXaantsr6detail13is_basic_jsonIT0_EE5valuesr6detail18is_compatible_typeISE_SL_EE5valueEiE4typeELi0EEEOT_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_010basic_jsonINSt3__13mapENS2_6vectorENS2_12basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEEblmdS8_NS0_14adl_serializerENS4_IhNS8_IhEEEEvEC2IRA113_KcA113_cTnNS2_9enable_ifIXaantsr6detail13is_basic_jsonIT0_EE5valuesr6detail18is_compatible_typeISE_SL_EE5valueEiE4typeELi0EEEOT_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_010basic_jsonINSt3__13mapENS2_6vectorENS2_12basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEEblmdS8_NS0_14adl_serializerENS4_IhNS8_IhEEEEvEC2IRA39_KcA39_cTnNS2_9enable_ifIXaantsr6detail13is_basic_jsonIT0_EE5valuesr6detail18is_compatible_typeISE_SL_EE5valueEiE4typeELi0EEEOT_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_010basic_jsonINSt3__13mapENS2_6vectorENS2_12basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEEblmdS8_NS0_14adl_serializerENS4_IhNS8_IhEEEEvEC2IRA41_KcA41_cTnNS2_9enable_ifIXaantsr6detail13is_basic_jsonIT0_EE5valuesr6detail18is_compatible_typeISE_SL_EE5valueEiE4typeELi0EEEOT_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_010basic_jsonINSt3__13mapENS2_6vectorENS2_12basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEEblmdS8_NS0_14adl_serializerENS4_IhNS8_IhEEEEvEC2IRA86_KcA86_cTnNS2_9enable_ifIXaantsr6detail13is_basic_jsonIT0_EE5valuesr6detail18is_compatible_typeISE_SL_EE5valueEiE4typeELi0EEEOT_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_010basic_jsonINSt3__13mapENS2_6vectorENS2_12basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEEblmdS8_NS0_14adl_serializerENS4_IhNS8_IhEEEEvEC2IRA135_KcA135_cTnNS2_9enable_ifIXaantsr6detail13is_basic_jsonIT0_EE5valuesr6detail18is_compatible_typeISE_SL_EE5valueEiE4typeELi0EEEOT_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_010basic_jsonINSt3__13mapENS2_6vectorENS2_12basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEEblmdS8_NS0_14adl_serializerENS4_IhNS8_IhEEEEvEC2IRA20_KcA20_cTnNS2_9enable_ifIXaantsr6detail13is_basic_jsonIT0_EE5valuesr6detail18is_compatible_typeISE_SL_EE5valueEiE4typeELi0EEEOT_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_010basic_jsonINSt3__13mapENS2_6vectorENS2_12basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEEblmdS8_NS0_14adl_serializerENS4_IhNS8_IhEEEEvEC2IRA24_KcA24_cTnNS2_9enable_ifIXaantsr6detail13is_basic_jsonIT0_EE5valuesr6detail18is_compatible_typeISE_SL_EE5valueEiE4typeELi0EEEOT_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_010basic_jsonINSt3__13mapENS2_6vectorENS2_12basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEEblmdS8_NS0_14adl_serializerENS4_IhNS8_IhEEEEvEC2IRA11_KcA11_cTnNS2_9enable_ifIXaantsr6detail13is_basic_jsonIT0_EE5valuesr6detail18is_compatible_typeISE_SL_EE5valueEiE4typeELi0EEEOT_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_010basic_jsonINSt3__13mapENS2_6vectorENS2_12basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEEblmdS8_NS0_14adl_serializerENS4_IhNS8_IhEEEEvEC2IRA35_KcA35_cTnNS2_9enable_ifIXaantsr6detail13is_basic_jsonIT0_EE5valuesr6detail18is_compatible_typeISE_SL_EE5valueEiE4typeELi0EEEOT_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_010basic_jsonINSt3__13mapENS2_6vectorENS2_12basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEEblmdS8_NS0_14adl_serializerENS4_IhNS8_IhEEEEvEC2IRA4_KcA4_cTnNS2_9enable_ifIXaantsr6detail13is_basic_jsonIT0_EE5valuesr6detail18is_compatible_typeISE_SL_EE5valueEiE4typeELi0EEEOT_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_010basic_jsonINSt3__13mapENS2_6vectorENS2_12basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEEblmdS8_NS0_14adl_serializerENS4_IhNS8_IhEEEEvEC2IRA116_KcA116_cTnNS2_9enable_ifIXaantsr6detail13is_basic_jsonIT0_EE5valuesr6detail18is_compatible_typeISE_SL_EE5valueEiE4typeELi0EEEOT_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_010basic_jsonINSt3__13mapENS2_6vectorENS2_12basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEEblmdS8_NS0_14adl_serializerENS4_IhNS8_IhEEEEvEC2IRA115_KcA115_cTnNS2_9enable_ifIXaantsr6detail13is_basic_jsonIT0_EE5valuesr6detail18is_compatible_typeISE_SL_EE5valueEiE4typeELi0EEEOT_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_010basic_jsonINSt3__13mapENS2_6vectorENS2_12basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEEblmdS8_NS0_14adl_serializerENS4_IhNS8_IhEEEEvEC2IRA619_KcA619_cTnNS2_9enable_ifIXaantsr6detail13is_basic_jsonIT0_EE5valuesr6detail18is_compatible_typeISE_SL_EE5valueEiE4typeELi0EEEOT_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_010basic_jsonINSt3__13mapENS2_6vectorENS2_12basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEEblmdS8_NS0_14adl_serializerENS4_IhNS8_IhEEEEvEC2IRA9_KcA9_cTnNS2_9enable_ifIXaantsr6detail13is_basic_jsonIT0_EE5valuesr6detail18is_compatible_typeISE_SL_EE5valueEiE4typeELi0EEEOT_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_010basic_jsonINSt3__13mapENS2_6vectorENS2_12basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEEblmdS8_NS0_14adl_serializerENS4_IhNS8_IhEEEEvEC2ISA_SA_TnNS2_9enable_ifIXaantsr6detail13is_basic_jsonIT0_EE5valuesr6detail18is_compatible_typeISE_SH_EE5valueEiE4typeELi0EEEOT_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_010basic_jsonINSt3__13mapENS2_6vectorENS2_12basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEEblmdS8_NS0_14adl_serializerENS4_IhNS8_IhEEEEvEC2INS4_ISE_NS8_ISE_EEEESH_TnNS2_9enable_ifIXaantsr6detail13is_basic_jsonIT0_EE5valuesr6detail18is_compatible_typeISE_SJ_EE5valueEiE4typeELi0EEEOT_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_010basic_jsonINSt3__13mapENS2_6vectorENS2_12basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEEblmdS8_NS0_14adl_serializerENS4_IhNS8_IhEEEEvEC2IRKbbTnNS2_9enable_ifIXaantsr6detail13is_basic_jsonIT0_EE5valuesr6detail18is_compatible_typeISE_SJ_EE5valueEiE4typeELi0EEEOT_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_010basic_jsonINSt3__13mapENS2_6vectorENS2_12basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEEblmdS8_NS0_14adl_serializerENS4_IhNS8_IhEEEEvEC2IjjTnNS2_9enable_ifIXaantsr6detail13is_basic_jsonIT0_EE5valuesr6detail18is_compatible_typeISE_SH_EE5valueEiE4typeELi0EEEOT_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_010basic_jsonINSt3__13mapENS2_6vectorENS2_12basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEEblmdS8_NS0_14adl_serializerENS4_IhNS8_IhEEEEvEC2IbbTnNS2_9enable_ifIXaantsr6detail13is_basic_jsonIT0_EE5valuesr6detail18is_compatible_typeISE_SH_EE5valueEiE4typeELi0EEEOT_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_010basic_jsonINSt3__13mapENS2_6vectorENS2_12basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEEblmdS8_NS0_14adl_serializerENS4_IhNS8_IhEEEEvEC2IKSA_SA_TnNS2_9enable_ifIXaantsr6detail13is_basic_jsonIT0_EE5valuesr6detail18is_compatible_typeISE_SI_EE5valueEiE4typeELi0EEEOT_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_010basic_jsonINSt3__13mapENS2_6vectorENS2_12basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEEblmdS8_NS0_14adl_serializerENS4_IhNS8_IhEEEEvEC2IRA7_KcA7_cTnNS2_9enable_ifIXaantsr6detail13is_basic_jsonIT0_EE5valuesr6detail18is_compatible_typeISE_SL_EE5valueEiE4typeELi0EEEOT_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_010basic_jsonINSt3__13mapENS2_6vectorENS2_12basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEEblmdS8_NS0_14adl_serializerENS4_IhNS8_IhEEEEvEC2IRA5_KcA5_cTnNS2_9enable_ifIXaantsr6detail13is_basic_jsonIT0_EE5valuesr6detail18is_compatible_typeISE_SL_EE5valueEiE4typeELi0EEEOT_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_010basic_jsonINSt3__13mapENS2_6vectorENS2_12basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEEblmdS8_NS0_14adl_serializerENS4_IhNS8_IhEEEEvEC2IRKhhTnNS2_9enable_ifIXaantsr6detail13is_basic_jsonIT0_EE5valuesr6detail18is_compatible_typeISE_SJ_EE5valueEiE4typeELi0EEEOT_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_010basic_jsonINSt3__13mapENS2_6vectorENS2_12basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEEblmdS8_NS0_14adl_serializerENS4_IhNS8_IhEEEEvEC2IRA17_KcA17_cTnNS2_9enable_ifIXaantsr6detail13is_basic_jsonIT0_EE5valuesr6detail18is_compatible_typeISE_SL_EE5valueEiE4typeELi0EEEOT_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_010basic_jsonINSt3__13mapENS2_6vectorENS2_12basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEEblmdS8_NS0_14adl_serializerENS4_IhNS8_IhEEEEvEC2IRA13_KcA13_cTnNS2_9enable_ifIXaantsr6detail13is_basic_jsonIT0_EE5valuesr6detail18is_compatible_typeISE_SL_EE5valueEiE4typeELi0EEEOT_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_010basic_jsonINSt3__13mapENS2_6vectorENS2_12basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEEblmdS8_NS0_14adl_serializerENS4_IhNS8_IhEEEEvEC2IRA10_KcA10_cTnNS2_9enable_ifIXaantsr6detail13is_basic_jsonIT0_EE5valuesr6detail18is_compatible_typeISE_SL_EE5valueEiE4typeELi0EEEOT_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_010basic_jsonINSt3__13mapENS2_6vectorENS2_12basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEEblmdS8_NS0_14adl_serializerENS4_IhNS8_IhEEEEvEC2IRKjjTnNS2_9enable_ifIXaantsr6detail13is_basic_jsonIT0_EE5valuesr6detail18is_compatible_typeISE_SJ_EE5valueEiE4typeELi0EEEOT_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_010basic_jsonINSt3__13mapENS2_6vectorENS2_12basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEEblmdS8_NS0_14adl_serializerENS4_IhNS8_IhEEEEvEC2IRA8_KcA8_cTnNS2_9enable_ifIXaantsr6detail13is_basic_jsonIT0_EE5valuesr6detail18is_compatible_typeISE_SL_EE5valueEiE4typeELi0EEEOT_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_010basic_jsonINSt3__13mapENS2_6vectorENS2_12basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEEblmdS8_NS0_14adl_serializerENS4_IhNS8_IhEEEEvEC2IRA15_KcA15_cTnNS2_9enable_ifIXaantsr6detail13is_basic_jsonIT0_EE5valuesr6detail18is_compatible_typeISE_SL_EE5valueEiE4typeELi0EEEOT_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_010basic_jsonINSt3__13mapENS2_6vectorENS2_12basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEEblmdS8_NS0_14adl_serializerENS4_IhNS8_IhEEEEvEC2IRA19_KcA19_cTnNS2_9enable_ifIXaantsr6detail13is_basic_jsonIT0_EE5valuesr6detail18is_compatible_typeISE_SL_EE5valueEiE4typeELi0EEEOT_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_010basic_jsonINSt3__13mapENS2_6vectorENS2_12basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEEblmdS8_NS0_14adl_serializerENS4_IhNS8_IhEEEEvEC2IRA12_KcA12_cTnNS2_9enable_ifIXaantsr6detail13is_basic_jsonIT0_EE5valuesr6detail18is_compatible_typeISE_SL_EE5valueEiE4typeELi0EEEOT_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_010basic_jsonINSt3__13mapENS2_6vectorENS2_12basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEEblmdS8_NS0_14adl_serializerENS4_IhNS8_IhEEEEvEC2IRA14_KcA14_cTnNS2_9enable_ifIXaantsr6detail13is_basic_jsonIT0_EE5valuesr6detail18is_compatible_typeISE_SL_EE5valueEiE4typeELi0EEEOT_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_010basic_jsonINSt3__13mapENS2_6vectorENS2_12basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEEblmdS8_NS0_14adl_serializerENS4_IhNS8_IhEEEEvEC2IRA23_KcA23_cTnNS2_9enable_ifIXaantsr6detail13is_basic_jsonIT0_EE5valuesr6detail18is_compatible_typeISE_SL_EE5valueEiE4typeELi0EEEOT_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_010basic_jsonINSt3__13mapENS2_6vectorENS2_12basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEEblmdS8_NS0_14adl_serializerENS4_IhNS8_IhEEEEvEC2IRA18_KcA18_cTnNS2_9enable_ifIXaantsr6detail13is_basic_jsonIT0_EE5valuesr6detail18is_compatible_typeISE_SL_EE5valueEiE4typeELi0EEEOT_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_010basic_jsonINSt3__13mapENS2_6vectorENS2_12basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEEblmdS8_NS0_14adl_serializerENS4_IhNS8_IhEEEEvEC2IKbbTnNS2_9enable_ifIXaantsr6detail13is_basic_jsonIT0_EE5valuesr6detail18is_compatible_typeISE_SI_EE5valueEiE4typeELi0EEEOT_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_010basic_jsonINSt3__13mapENS2_6vectorENS2_12basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEEblmdS8_NS0_14adl_serializerENS4_IhNS8_IhEEEEvEC2IRddTnNS2_9enable_ifIXaantsr6detail13is_basic_jsonIT0_EE5valuesr6detail18is_compatible_typeISE_SI_EE5valueEiE4typeELi0EEEOT_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_010basic_jsonINSt3__13mapENS2_6vectorENS2_12basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEEblmdS8_NS0_14adl_serializerENS4_IhNS8_IhEEEEvEC2IRbbTnNS2_9enable_ifIXaantsr6detail13is_basic_jsonIT0_EE5valuesr6detail18is_compatible_typeISE_SI_EE5valueEiE4typeELi0EEEOT_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_010basic_jsonINSt3__13mapENS2_6vectorENS2_12basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEEblmdS8_NS0_14adl_serializerENS4_IhNS8_IhEEEEvEC2IRllTnNS2_9enable_ifIXaantsr6detail13is_basic_jsonIT0_EE5valuesr6detail18is_compatible_typeISE_SI_EE5valueEiE4typeELi0EEEOT_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_010basic_jsonINSt3__13mapENS2_6vectorENS2_12basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEEblmdS8_NS0_14adl_serializerENS4_IhNS8_IhEEEEvEC2IRmmTnNS2_9enable_ifIXaantsr6detail13is_basic_jsonIT0_EE5valuesr6detail18is_compatible_typeISE_SI_EE5valueEiE4typeELi0EEEOT_ Unexecuted instantiation: _ZN8nlohmann16json_abi_v3_12_010basic_jsonINSt3__13mapENS2_6vectorENS2_12basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEEblmdS8_NS0_14adl_serializerENS4_IhNS8_IhEEEEvEC2IRPKcSH_TnNS2_9enable_ifIXaantsr6detail13is_basic_jsonIT0_EE5valuesr6detail18is_compatible_typeISE_SK_EE5valueEiE4typeELi0EEEOT_ |
20976 | | |
20977 | | /// @brief create a JSON value from an existing one |
20978 | | /// @sa https://json.nlohmann.me/api/basic_json/basic_json/ |
20979 | | template < typename BasicJsonType, |
20980 | | detail::enable_if_t < |
20981 | | detail::is_basic_json<BasicJsonType>::value&& !std::is_same<basic_json, BasicJsonType>::value, int > = 0 > |
20982 | | basic_json(const BasicJsonType& val) |
20983 | | #if JSON_DIAGNOSTIC_POSITIONS |
20984 | | : start_position(val.start_pos()), |
20985 | | end_position(val.end_pos()) |
20986 | | #endif |
20987 | | { |
20988 | | using other_boolean_t = typename BasicJsonType::boolean_t; |
20989 | | using other_number_float_t = typename BasicJsonType::number_float_t; |
20990 | | using other_number_integer_t = typename BasicJsonType::number_integer_t; |
20991 | | using other_number_unsigned_t = typename BasicJsonType::number_unsigned_t; |
20992 | | using other_string_t = typename BasicJsonType::string_t; |
20993 | | using other_object_t = typename BasicJsonType::object_t; |
20994 | | using other_array_t = typename BasicJsonType::array_t; |
20995 | | using other_binary_t = typename BasicJsonType::binary_t; |
20996 | | |
20997 | | switch (val.type()) |
20998 | | { |
20999 | | case value_t::boolean: |
21000 | | JSONSerializer<other_boolean_t>::to_json(*this, val.template get<other_boolean_t>()); |
21001 | | break; |
21002 | | case value_t::number_float: |
21003 | | JSONSerializer<other_number_float_t>::to_json(*this, val.template get<other_number_float_t>()); |
21004 | | break; |
21005 | | case value_t::number_integer: |
21006 | | JSONSerializer<other_number_integer_t>::to_json(*this, val.template get<other_number_integer_t>()); |
21007 | | break; |
21008 | | case value_t::number_unsigned: |
21009 | | JSONSerializer<other_number_unsigned_t>::to_json(*this, val.template get<other_number_unsigned_t>()); |
21010 | | break; |
21011 | | case value_t::string: |
21012 | | JSONSerializer<other_string_t>::to_json(*this, val.template get_ref<const other_string_t&>()); |
21013 | | break; |
21014 | | case value_t::object: |
21015 | | JSONSerializer<other_object_t>::to_json(*this, val.template get_ref<const other_object_t&>()); |
21016 | | break; |
21017 | | case value_t::array: |
21018 | | JSONSerializer<other_array_t>::to_json(*this, val.template get_ref<const other_array_t&>()); |
21019 | | break; |
21020 | | case value_t::binary: |
21021 | | JSONSerializer<other_binary_t>::to_json(*this, val.template get_ref<const other_binary_t&>()); |
21022 | | break; |
21023 | | case value_t::null: |
21024 | | *this = nullptr; |
21025 | | break; |
21026 | | case value_t::discarded: |
21027 | | m_data.m_type = value_t::discarded; |
21028 | | break; |
21029 | | default: // LCOV_EXCL_LINE |
21030 | | JSON_ASSERT(false); // NOLINT(cert-dcl03-c,hicpp-static-assert,misc-static-assert) LCOV_EXCL_LINE |
21031 | | } |
21032 | | JSON_ASSERT(m_data.m_type == val.type()); |
21033 | | |
21034 | | set_parents(); |
21035 | | assert_invariant(); |
21036 | | } |
21037 | | |
21038 | | /// @brief create a container (array or object) from an initializer list |
21039 | | /// @sa https://json.nlohmann.me/api/basic_json/basic_json/ |
21040 | | basic_json(initializer_list_t init, |
21041 | | bool type_deduction = true, |
21042 | | value_t manual_type = value_t::array) |
21043 | 0 | { |
21044 | | // check if each element is an array with two elements whose first |
21045 | | // element is a string |
21046 | 0 | bool is_an_object = std::all_of(init.begin(), init.end(), |
21047 | 0 | [](const detail::json_ref<basic_json>& element_ref) |
21048 | 0 | { |
21049 | | // The cast is to ensure op[size_type] is called, bearing in mind size_type may not be int; |
21050 | | // (many string types can be constructed from 0 via its null-pointer guise, so we get a |
21051 | | // broken call to op[key_type], the wrong semantics, and a 4804 warning on Windows) |
21052 | 0 | return element_ref->is_array() && element_ref->size() == 2 && (*element_ref)[static_cast<size_type>(0)].is_string(); |
21053 | 0 | }); |
21054 | | |
21055 | | // adjust type if type deduction is not wanted |
21056 | 0 | if (!type_deduction) |
21057 | 0 | { |
21058 | | // if an array is wanted, do not create an object though possible |
21059 | 0 | if (manual_type == value_t::array) |
21060 | 0 | { |
21061 | 0 | is_an_object = false; |
21062 | 0 | } |
21063 | | |
21064 | | // if an object is wanted but impossible, throw an exception |
21065 | 0 | if (JSON_HEDLEY_UNLIKELY(manual_type == value_t::object && !is_an_object)) |
21066 | 0 | { |
21067 | 0 | JSON_THROW(type_error::create(301, "cannot create object from initializer list", nullptr)); |
21068 | 0 | } |
21069 | 0 | } |
21070 | | |
21071 | 0 | if (is_an_object) |
21072 | 0 | { |
21073 | | // the initializer list is a list of pairs -> create an object |
21074 | 0 | m_data.m_type = value_t::object; |
21075 | 0 | m_data.m_value = value_t::object; |
21076 | |
|
21077 | 0 | for (auto& element_ref : init) |
21078 | 0 | { |
21079 | 0 | auto element = element_ref.moved_or_copied(); |
21080 | 0 | m_data.m_value.object->emplace( |
21081 | 0 | std::move(*((*element.m_data.m_value.array)[0].m_data.m_value.string)), |
21082 | 0 | std::move((*element.m_data.m_value.array)[1])); |
21083 | 0 | } |
21084 | 0 | } |
21085 | 0 | else |
21086 | 0 | { |
21087 | | // the initializer list describes an array -> create an array |
21088 | 0 | m_data.m_type = value_t::array; |
21089 | 0 | m_data.m_value.array = create<array_t>(init.begin(), init.end()); |
21090 | 0 | } |
21091 | |
|
21092 | 0 | set_parents(); |
21093 | 0 | assert_invariant(); |
21094 | 0 | } |
21095 | | |
21096 | | /// @brief explicitly create a binary array (without subtype) |
21097 | | /// @sa https://json.nlohmann.me/api/basic_json/binary/ |
21098 | | JSON_HEDLEY_WARN_UNUSED_RESULT |
21099 | | static basic_json binary(const typename binary_t::container_type& init) |
21100 | | { |
21101 | | auto res = basic_json(); |
21102 | | res.m_data.m_type = value_t::binary; |
21103 | | res.m_data.m_value = init; |
21104 | | return res; |
21105 | | } |
21106 | | |
21107 | | /// @brief explicitly create a binary array (with subtype) |
21108 | | /// @sa https://json.nlohmann.me/api/basic_json/binary/ |
21109 | | JSON_HEDLEY_WARN_UNUSED_RESULT |
21110 | | static basic_json binary(const typename binary_t::container_type& init, typename binary_t::subtype_type subtype) |
21111 | | { |
21112 | | auto res = basic_json(); |
21113 | | res.m_data.m_type = value_t::binary; |
21114 | | res.m_data.m_value = binary_t(init, subtype); |
21115 | | return res; |
21116 | | } |
21117 | | |
21118 | | /// @brief explicitly create a binary array |
21119 | | /// @sa https://json.nlohmann.me/api/basic_json/binary/ |
21120 | | JSON_HEDLEY_WARN_UNUSED_RESULT |
21121 | | static basic_json binary(typename binary_t::container_type&& init) |
21122 | | { |
21123 | | auto res = basic_json(); |
21124 | | res.m_data.m_type = value_t::binary; |
21125 | | res.m_data.m_value = std::move(init); |
21126 | | return res; |
21127 | | } |
21128 | | |
21129 | | /// @brief explicitly create a binary array (with subtype) |
21130 | | /// @sa https://json.nlohmann.me/api/basic_json/binary/ |
21131 | | JSON_HEDLEY_WARN_UNUSED_RESULT |
21132 | | static basic_json binary(typename binary_t::container_type&& init, typename binary_t::subtype_type subtype) |
21133 | | { |
21134 | | auto res = basic_json(); |
21135 | | res.m_data.m_type = value_t::binary; |
21136 | | res.m_data.m_value = binary_t(std::move(init), subtype); |
21137 | | return res; |
21138 | | } |
21139 | | |
21140 | | /// @brief explicitly create an array from an initializer list |
21141 | | /// @sa https://json.nlohmann.me/api/basic_json/array/ |
21142 | | JSON_HEDLEY_WARN_UNUSED_RESULT |
21143 | | static basic_json array(initializer_list_t init = {}) |
21144 | 0 | { |
21145 | 0 | return basic_json(init, false, value_t::array); |
21146 | 0 | } |
21147 | | |
21148 | | /// @brief explicitly create an object from an initializer list |
21149 | | /// @sa https://json.nlohmann.me/api/basic_json/object/ |
21150 | | JSON_HEDLEY_WARN_UNUSED_RESULT |
21151 | | static basic_json object(initializer_list_t init = {}) |
21152 | | { |
21153 | | return basic_json(init, false, value_t::object); |
21154 | | } |
21155 | | |
21156 | | /// @brief construct an array with count copies of given value |
21157 | | /// @sa https://json.nlohmann.me/api/basic_json/basic_json/ |
21158 | | basic_json(size_type cnt, const basic_json& val): |
21159 | | m_data{cnt, val} |
21160 | | { |
21161 | | set_parents(); |
21162 | | assert_invariant(); |
21163 | | } |
21164 | | |
21165 | | /// @brief construct a JSON container given an iterator range |
21166 | | /// @sa https://json.nlohmann.me/api/basic_json/basic_json/ |
21167 | | template < class InputIT, typename std::enable_if < |
21168 | | std::is_same<InputIT, typename basic_json_t::iterator>::value || |
21169 | | std::is_same<InputIT, typename basic_json_t::const_iterator>::value, int >::type = 0 > |
21170 | | basic_json(InputIT first, InputIT last) // NOLINT(performance-unnecessary-value-param) |
21171 | | { |
21172 | | JSON_ASSERT(first.m_object != nullptr); |
21173 | | JSON_ASSERT(last.m_object != nullptr); |
21174 | | |
21175 | | // make sure the iterator fits the current value |
21176 | | if (JSON_HEDLEY_UNLIKELY(first.m_object != last.m_object)) |
21177 | | { |
21178 | | JSON_THROW(invalid_iterator::create(201, "iterators are not compatible", nullptr)); |
21179 | | } |
21180 | | |
21181 | | // copy type from the first iterator |
21182 | | m_data.m_type = first.m_object->m_data.m_type; |
21183 | | |
21184 | | // check if the iterator range is complete for primitive values |
21185 | | switch (m_data.m_type) |
21186 | | { |
21187 | | case value_t::boolean: |
21188 | | case value_t::number_float: |
21189 | | case value_t::number_integer: |
21190 | | case value_t::number_unsigned: |
21191 | | case value_t::string: |
21192 | | { |
21193 | | if (JSON_HEDLEY_UNLIKELY(!first.m_it.primitive_iterator.is_begin() |
21194 | | || !last.m_it.primitive_iterator.is_end())) |
21195 | | { |
21196 | | JSON_THROW(invalid_iterator::create(204, "iterators out of range", first.m_object)); |
21197 | | } |
21198 | | break; |
21199 | | } |
21200 | | |
21201 | | case value_t::null: |
21202 | | case value_t::object: |
21203 | | case value_t::array: |
21204 | | case value_t::binary: |
21205 | | case value_t::discarded: |
21206 | | default: |
21207 | | break; |
21208 | | } |
21209 | | |
21210 | | switch (m_data.m_type) |
21211 | | { |
21212 | | case value_t::number_integer: |
21213 | | { |
21214 | | m_data.m_value.number_integer = first.m_object->m_data.m_value.number_integer; |
21215 | | break; |
21216 | | } |
21217 | | |
21218 | | case value_t::number_unsigned: |
21219 | | { |
21220 | | m_data.m_value.number_unsigned = first.m_object->m_data.m_value.number_unsigned; |
21221 | | break; |
21222 | | } |
21223 | | |
21224 | | case value_t::number_float: |
21225 | | { |
21226 | | m_data.m_value.number_float = first.m_object->m_data.m_value.number_float; |
21227 | | break; |
21228 | | } |
21229 | | |
21230 | | case value_t::boolean: |
21231 | | { |
21232 | | m_data.m_value.boolean = first.m_object->m_data.m_value.boolean; |
21233 | | break; |
21234 | | } |
21235 | | |
21236 | | case value_t::string: |
21237 | | { |
21238 | | m_data.m_value = *first.m_object->m_data.m_value.string; |
21239 | | break; |
21240 | | } |
21241 | | |
21242 | | case value_t::object: |
21243 | | { |
21244 | | m_data.m_value.object = create<object_t>(first.m_it.object_iterator, |
21245 | | last.m_it.object_iterator); |
21246 | | break; |
21247 | | } |
21248 | | |
21249 | | case value_t::array: |
21250 | | { |
21251 | | m_data.m_value.array = create<array_t>(first.m_it.array_iterator, |
21252 | | last.m_it.array_iterator); |
21253 | | break; |
21254 | | } |
21255 | | |
21256 | | case value_t::binary: |
21257 | | { |
21258 | | m_data.m_value = *first.m_object->m_data.m_value.binary; |
21259 | | break; |
21260 | | } |
21261 | | |
21262 | | case value_t::null: |
21263 | | case value_t::discarded: |
21264 | | default: |
21265 | | JSON_THROW(invalid_iterator::create(206, detail::concat("cannot construct with iterators from ", first.m_object->type_name()), first.m_object)); |
21266 | | } |
21267 | | |
21268 | | set_parents(); |
21269 | | assert_invariant(); |
21270 | | } |
21271 | | |
21272 | | /////////////////////////////////////// |
21273 | | // other constructors and destructor // |
21274 | | /////////////////////////////////////// |
21275 | | |
21276 | | template<typename JsonRef, |
21277 | | detail::enable_if_t<detail::conjunction<detail::is_json_ref<JsonRef>, |
21278 | | std::is_same<typename JsonRef::value_type, basic_json>>::value, int> = 0 > |
21279 | 0 | basic_json(const JsonRef& ref) : basic_json(ref.moved_or_copied()) {} |
21280 | | |
21281 | | /// @brief copy constructor |
21282 | | /// @sa https://json.nlohmann.me/api/basic_json/basic_json/ |
21283 | | basic_json(const basic_json& other) |
21284 | 0 | : json_base_class_t(other) |
21285 | | #if JSON_DIAGNOSTIC_POSITIONS |
21286 | | , start_position(other.start_position) |
21287 | | , end_position(other.end_position) |
21288 | | #endif |
21289 | 0 | { |
21290 | 0 | m_data.m_type = other.m_data.m_type; |
21291 | | // check of passed value is valid |
21292 | 0 | other.assert_invariant(); |
21293 | |
|
21294 | 0 | switch (m_data.m_type) |
21295 | 0 | { |
21296 | 0 | case value_t::object: |
21297 | 0 | { |
21298 | 0 | m_data.m_value = *other.m_data.m_value.object; |
21299 | 0 | break; |
21300 | 0 | } |
21301 | | |
21302 | 0 | case value_t::array: |
21303 | 0 | { |
21304 | 0 | m_data.m_value = *other.m_data.m_value.array; |
21305 | 0 | break; |
21306 | 0 | } |
21307 | | |
21308 | 0 | case value_t::string: |
21309 | 0 | { |
21310 | 0 | m_data.m_value = *other.m_data.m_value.string; |
21311 | 0 | break; |
21312 | 0 | } |
21313 | | |
21314 | 0 | case value_t::boolean: |
21315 | 0 | { |
21316 | 0 | m_data.m_value = other.m_data.m_value.boolean; |
21317 | 0 | break; |
21318 | 0 | } |
21319 | | |
21320 | 0 | case value_t::number_integer: |
21321 | 0 | { |
21322 | 0 | m_data.m_value = other.m_data.m_value.number_integer; |
21323 | 0 | break; |
21324 | 0 | } |
21325 | | |
21326 | 0 | case value_t::number_unsigned: |
21327 | 0 | { |
21328 | 0 | m_data.m_value = other.m_data.m_value.number_unsigned; |
21329 | 0 | break; |
21330 | 0 | } |
21331 | | |
21332 | 0 | case value_t::number_float: |
21333 | 0 | { |
21334 | 0 | m_data.m_value = other.m_data.m_value.number_float; |
21335 | 0 | break; |
21336 | 0 | } |
21337 | | |
21338 | 0 | case value_t::binary: |
21339 | 0 | { |
21340 | 0 | m_data.m_value = *other.m_data.m_value.binary; |
21341 | 0 | break; |
21342 | 0 | } |
21343 | | |
21344 | 0 | case value_t::null: |
21345 | 0 | case value_t::discarded: |
21346 | 0 | default: |
21347 | 0 | break; |
21348 | 0 | } |
21349 | | |
21350 | 0 | set_parents(); |
21351 | 0 | assert_invariant(); |
21352 | 0 | } |
21353 | | |
21354 | | /// @brief move constructor |
21355 | | /// @sa https://json.nlohmann.me/api/basic_json/basic_json/ |
21356 | | basic_json(basic_json&& other) noexcept |
21357 | 0 | : json_base_class_t(std::forward<json_base_class_t>(other)), |
21358 | 0 | m_data(std::move(other.m_data)) // cppcheck-suppress[accessForwarded] TODO check |
21359 | | #if JSON_DIAGNOSTIC_POSITIONS |
21360 | | , start_position(other.start_position) // cppcheck-suppress[accessForwarded] TODO check |
21361 | | , end_position(other.end_position) // cppcheck-suppress[accessForwarded] TODO check |
21362 | | #endif |
21363 | 0 | { |
21364 | | // check that the passed value is valid |
21365 | 0 | other.assert_invariant(false); // cppcheck-suppress[accessForwarded] |
21366 | | |
21367 | | // invalidate payload |
21368 | 0 | other.m_data.m_type = value_t::null; |
21369 | 0 | other.m_data.m_value = {}; |
21370 | |
|
21371 | | #if JSON_DIAGNOSTIC_POSITIONS |
21372 | | other.start_position = std::string::npos; |
21373 | | other.end_position = std::string::npos; |
21374 | | #endif |
21375 | |
|
21376 | 0 | set_parents(); |
21377 | 0 | assert_invariant(); |
21378 | 0 | } |
21379 | | |
21380 | | /// @brief copy assignment |
21381 | | /// @sa https://json.nlohmann.me/api/basic_json/operator=/ |
21382 | | basic_json& operator=(basic_json other) noexcept ( // NOLINT(cppcoreguidelines-c-copy-assignment-signature,misc-unconventional-assign-operator) |
21383 | | std::is_nothrow_move_constructible<value_t>::value&& |
21384 | | std::is_nothrow_move_assignable<value_t>::value&& |
21385 | | std::is_nothrow_move_constructible<json_value>::value&& |
21386 | | std::is_nothrow_move_assignable<json_value>::value&& |
21387 | | std::is_nothrow_move_assignable<json_base_class_t>::value |
21388 | | ) |
21389 | 0 | { |
21390 | | // check that the passed value is valid |
21391 | 0 | other.assert_invariant(); |
21392 | |
|
21393 | 0 | using std::swap; |
21394 | 0 | swap(m_data.m_type, other.m_data.m_type); |
21395 | 0 | swap(m_data.m_value, other.m_data.m_value); |
21396 | |
|
21397 | | #if JSON_DIAGNOSTIC_POSITIONS |
21398 | | swap(start_position, other.start_position); |
21399 | | swap(end_position, other.end_position); |
21400 | | #endif |
21401 | |
|
21402 | 0 | json_base_class_t::operator=(std::move(other)); |
21403 | |
|
21404 | 0 | set_parents(); |
21405 | 0 | assert_invariant(); |
21406 | 0 | return *this; |
21407 | 0 | } |
21408 | | |
21409 | | /// @brief destructor |
21410 | | /// @sa https://json.nlohmann.me/api/basic_json/~basic_json/ |
21411 | | ~basic_json() noexcept |
21412 | 0 | { |
21413 | 0 | assert_invariant(false); |
21414 | 0 | } |
21415 | | |
21416 | | /// @} |
21417 | | |
21418 | | public: |
21419 | | /////////////////////// |
21420 | | // object inspection // |
21421 | | /////////////////////// |
21422 | | |
21423 | | /// @name object inspection |
21424 | | /// Functions to inspect the type of a JSON value. |
21425 | | /// @{ |
21426 | | |
21427 | | /// @brief serialization |
21428 | | /// @sa https://json.nlohmann.me/api/basic_json/dump/ |
21429 | | string_t dump(const int indent = -1, |
21430 | | const char indent_char = ' ', |
21431 | | const bool ensure_ascii = false, |
21432 | | const error_handler_t error_handler = error_handler_t::strict) const |
21433 | 0 | { |
21434 | 0 | string_t result; |
21435 | 0 | serializer s(detail::output_adapter<char, string_t>(result), indent_char, error_handler); |
21436 | |
|
21437 | 0 | if (indent >= 0) |
21438 | 0 | { |
21439 | 0 | s.dump(*this, true, ensure_ascii, static_cast<unsigned int>(indent)); |
21440 | 0 | } |
21441 | 0 | else |
21442 | 0 | { |
21443 | 0 | s.dump(*this, false, ensure_ascii, 0); |
21444 | 0 | } |
21445 | |
|
21446 | 0 | return result; |
21447 | 0 | } |
21448 | | |
21449 | | /// @brief return the type of the JSON value (explicit) |
21450 | | /// @sa https://json.nlohmann.me/api/basic_json/type/ |
21451 | | constexpr value_t type() const noexcept |
21452 | 0 | { |
21453 | 0 | return m_data.m_type; |
21454 | 0 | } |
21455 | | |
21456 | | /// @brief return whether type is primitive |
21457 | | /// @sa https://json.nlohmann.me/api/basic_json/is_primitive/ |
21458 | | constexpr bool is_primitive() const noexcept |
21459 | | { |
21460 | | return is_null() || is_string() || is_boolean() || is_number() || is_binary(); |
21461 | | } |
21462 | | |
21463 | | /// @brief return whether type is structured |
21464 | | /// @sa https://json.nlohmann.me/api/basic_json/is_structured/ |
21465 | | constexpr bool is_structured() const noexcept |
21466 | 0 | { |
21467 | 0 | return is_array() || is_object(); |
21468 | 0 | } |
21469 | | |
21470 | | /// @brief return whether value is null |
21471 | | /// @sa https://json.nlohmann.me/api/basic_json/is_null/ |
21472 | | constexpr bool is_null() const noexcept |
21473 | 0 | { |
21474 | 0 | return m_data.m_type == value_t::null; |
21475 | 0 | } |
21476 | | |
21477 | | /// @brief return whether value is a boolean |
21478 | | /// @sa https://json.nlohmann.me/api/basic_json/is_boolean/ |
21479 | | constexpr bool is_boolean() const noexcept |
21480 | 0 | { |
21481 | 0 | return m_data.m_type == value_t::boolean; |
21482 | 0 | } |
21483 | | |
21484 | | /// @brief return whether value is a number |
21485 | | /// @sa https://json.nlohmann.me/api/basic_json/is_number/ |
21486 | | constexpr bool is_number() const noexcept |
21487 | 0 | { |
21488 | 0 | return is_number_integer() || is_number_float(); |
21489 | 0 | } |
21490 | | |
21491 | | /// @brief return whether value is an integer number |
21492 | | /// @sa https://json.nlohmann.me/api/basic_json/is_number_integer/ |
21493 | | constexpr bool is_number_integer() const noexcept |
21494 | 0 | { |
21495 | 0 | return m_data.m_type == value_t::number_integer || m_data.m_type == value_t::number_unsigned; |
21496 | 0 | } |
21497 | | |
21498 | | /// @brief return whether value is an unsigned integer number |
21499 | | /// @sa https://json.nlohmann.me/api/basic_json/is_number_unsigned/ |
21500 | | constexpr bool is_number_unsigned() const noexcept |
21501 | 0 | { |
21502 | 0 | return m_data.m_type == value_t::number_unsigned; |
21503 | 0 | } |
21504 | | |
21505 | | /// @brief return whether value is a floating-point number |
21506 | | /// @sa https://json.nlohmann.me/api/basic_json/is_number_float/ |
21507 | | constexpr bool is_number_float() const noexcept |
21508 | 0 | { |
21509 | 0 | return m_data.m_type == value_t::number_float; |
21510 | 0 | } |
21511 | | |
21512 | | /// @brief return whether value is an object |
21513 | | /// @sa https://json.nlohmann.me/api/basic_json/is_object/ |
21514 | | constexpr bool is_object() const noexcept |
21515 | 0 | { |
21516 | 0 | return m_data.m_type == value_t::object; |
21517 | 0 | } |
21518 | | |
21519 | | /// @brief return whether value is an array |
21520 | | /// @sa https://json.nlohmann.me/api/basic_json/is_array/ |
21521 | | constexpr bool is_array() const noexcept |
21522 | 0 | { |
21523 | 0 | return m_data.m_type == value_t::array; |
21524 | 0 | } |
21525 | | |
21526 | | /// @brief return whether value is a string |
21527 | | /// @sa https://json.nlohmann.me/api/basic_json/is_string/ |
21528 | | constexpr bool is_string() const noexcept |
21529 | 0 | { |
21530 | 0 | return m_data.m_type == value_t::string; |
21531 | 0 | } |
21532 | | |
21533 | | /// @brief return whether value is a binary array |
21534 | | /// @sa https://json.nlohmann.me/api/basic_json/is_binary/ |
21535 | | constexpr bool is_binary() const noexcept |
21536 | 0 | { |
21537 | 0 | return m_data.m_type == value_t::binary; |
21538 | 0 | } |
21539 | | |
21540 | | /// @brief return whether value is discarded |
21541 | | /// @sa https://json.nlohmann.me/api/basic_json/is_discarded/ |
21542 | | constexpr bool is_discarded() const noexcept |
21543 | 0 | { |
21544 | 0 | return m_data.m_type == value_t::discarded; |
21545 | 0 | } |
21546 | | |
21547 | | /// @brief return the type of the JSON value (implicit) |
21548 | | /// @sa https://json.nlohmann.me/api/basic_json/operator_value_t/ |
21549 | | constexpr operator value_t() const noexcept |
21550 | 0 | { |
21551 | 0 | return m_data.m_type; |
21552 | 0 | } |
21553 | | |
21554 | | /// @} |
21555 | | |
21556 | | private: |
21557 | | ////////////////// |
21558 | | // value access // |
21559 | | ////////////////// |
21560 | | |
21561 | | /// get a boolean (explicit) |
21562 | | boolean_t get_impl(boolean_t* /*unused*/) const |
21563 | | { |
21564 | | if (JSON_HEDLEY_LIKELY(is_boolean())) |
21565 | | { |
21566 | | return m_data.m_value.boolean; |
21567 | | } |
21568 | | |
21569 | | JSON_THROW(type_error::create(302, detail::concat("type must be boolean, but is ", type_name()), this)); |
21570 | | } |
21571 | | |
21572 | | /// get a pointer to the value (object) |
21573 | | object_t* get_impl_ptr(object_t* /*unused*/) noexcept |
21574 | | { |
21575 | | return is_object() ? m_data.m_value.object : nullptr; |
21576 | | } |
21577 | | |
21578 | | /// get a pointer to the value (object) |
21579 | | constexpr const object_t* get_impl_ptr(const object_t* /*unused*/) const noexcept |
21580 | | { |
21581 | | return is_object() ? m_data.m_value.object : nullptr; |
21582 | | } |
21583 | | |
21584 | | /// get a pointer to the value (array) |
21585 | | array_t* get_impl_ptr(array_t* /*unused*/) noexcept |
21586 | | { |
21587 | | return is_array() ? m_data.m_value.array : nullptr; |
21588 | | } |
21589 | | |
21590 | | /// get a pointer to the value (array) |
21591 | | constexpr const array_t* get_impl_ptr(const array_t* /*unused*/) const noexcept |
21592 | | { |
21593 | | return is_array() ? m_data.m_value.array : nullptr; |
21594 | | } |
21595 | | |
21596 | | /// get a pointer to the value (string) |
21597 | | string_t* get_impl_ptr(string_t* /*unused*/) noexcept |
21598 | | { |
21599 | | return is_string() ? m_data.m_value.string : nullptr; |
21600 | | } |
21601 | | |
21602 | | /// get a pointer to the value (string) |
21603 | | constexpr const string_t* get_impl_ptr(const string_t* /*unused*/) const noexcept |
21604 | 0 | { |
21605 | 0 | return is_string() ? m_data.m_value.string : nullptr; |
21606 | 0 | } |
21607 | | |
21608 | | /// get a pointer to the value (boolean) |
21609 | | boolean_t* get_impl_ptr(boolean_t* /*unused*/) noexcept |
21610 | | { |
21611 | | return is_boolean() ? &m_data.m_value.boolean : nullptr; |
21612 | | } |
21613 | | |
21614 | | /// get a pointer to the value (boolean) |
21615 | | constexpr const boolean_t* get_impl_ptr(const boolean_t* /*unused*/) const noexcept |
21616 | 0 | { |
21617 | 0 | return is_boolean() ? &m_data.m_value.boolean : nullptr; |
21618 | 0 | } |
21619 | | |
21620 | | /// get a pointer to the value (integer number) |
21621 | | number_integer_t* get_impl_ptr(number_integer_t* /*unused*/) noexcept |
21622 | | { |
21623 | | return m_data.m_type == value_t::number_integer ? &m_data.m_value.number_integer : nullptr; |
21624 | | } |
21625 | | |
21626 | | /// get a pointer to the value (integer number) |
21627 | | constexpr const number_integer_t* get_impl_ptr(const number_integer_t* /*unused*/) const noexcept |
21628 | 0 | { |
21629 | 0 | return m_data.m_type == value_t::number_integer ? &m_data.m_value.number_integer : nullptr; |
21630 | 0 | } |
21631 | | |
21632 | | /// get a pointer to the value (unsigned number) |
21633 | | number_unsigned_t* get_impl_ptr(number_unsigned_t* /*unused*/) noexcept |
21634 | | { |
21635 | | return is_number_unsigned() ? &m_data.m_value.number_unsigned : nullptr; |
21636 | | } |
21637 | | |
21638 | | /// get a pointer to the value (unsigned number) |
21639 | | constexpr const number_unsigned_t* get_impl_ptr(const number_unsigned_t* /*unused*/) const noexcept |
21640 | 0 | { |
21641 | 0 | return is_number_unsigned() ? &m_data.m_value.number_unsigned : nullptr; |
21642 | 0 | } |
21643 | | |
21644 | | /// get a pointer to the value (floating-point number) |
21645 | | number_float_t* get_impl_ptr(number_float_t* /*unused*/) noexcept |
21646 | | { |
21647 | | return is_number_float() ? &m_data.m_value.number_float : nullptr; |
21648 | | } |
21649 | | |
21650 | | /// get a pointer to the value (floating-point number) |
21651 | | constexpr const number_float_t* get_impl_ptr(const number_float_t* /*unused*/) const noexcept |
21652 | 0 | { |
21653 | 0 | return is_number_float() ? &m_data.m_value.number_float : nullptr; |
21654 | 0 | } |
21655 | | |
21656 | | /// get a pointer to the value (binary) |
21657 | | binary_t* get_impl_ptr(binary_t* /*unused*/) noexcept |
21658 | | { |
21659 | | return is_binary() ? m_data.m_value.binary : nullptr; |
21660 | | } |
21661 | | |
21662 | | /// get a pointer to the value (binary) |
21663 | | constexpr const binary_t* get_impl_ptr(const binary_t* /*unused*/) const noexcept |
21664 | | { |
21665 | | return is_binary() ? m_data.m_value.binary : nullptr; |
21666 | | } |
21667 | | |
21668 | | /*! |
21669 | | @brief helper function to implement get_ref() |
21670 | | |
21671 | | This function helps to implement get_ref() without code duplication for |
21672 | | const and non-const overloads |
21673 | | |
21674 | | @tparam ThisType will be deduced as `basic_json` or `const basic_json` |
21675 | | |
21676 | | @throw type_error.303 if ReferenceType does not match underlying value |
21677 | | type of the current JSON |
21678 | | */ |
21679 | | template<typename ReferenceType, typename ThisType> |
21680 | | static ReferenceType get_ref_impl(ThisType& obj) |
21681 | | { |
21682 | | // delegate the call to get_ptr<>() |
21683 | | auto* ptr = obj.template get_ptr<typename std::add_pointer<ReferenceType>::type>(); |
21684 | | |
21685 | | if (JSON_HEDLEY_LIKELY(ptr != nullptr)) |
21686 | | { |
21687 | | return *ptr; |
21688 | | } |
21689 | | |
21690 | | JSON_THROW(type_error::create(303, detail::concat("incompatible ReferenceType for get_ref, actual type is ", obj.type_name()), &obj)); |
21691 | | } |
21692 | | |
21693 | | public: |
21694 | | /// @name value access |
21695 | | /// Direct access to the stored value of a JSON value. |
21696 | | /// @{ |
21697 | | |
21698 | | /// @brief get a pointer value (implicit) |
21699 | | /// @sa https://json.nlohmann.me/api/basic_json/get_ptr/ |
21700 | | template<typename PointerType, typename std::enable_if< |
21701 | | std::is_pointer<PointerType>::value, int>::type = 0> |
21702 | | auto get_ptr() noexcept -> decltype(std::declval<basic_json_t&>().get_impl_ptr(std::declval<PointerType>())) |
21703 | | { |
21704 | | // delegate the call to get_impl_ptr<>() |
21705 | | return get_impl_ptr(static_cast<PointerType>(nullptr)); |
21706 | | } |
21707 | | |
21708 | | /// @brief get a pointer value (implicit) |
21709 | | /// @sa https://json.nlohmann.me/api/basic_json/get_ptr/ |
21710 | | template < typename PointerType, typename std::enable_if < |
21711 | | std::is_pointer<PointerType>::value&& |
21712 | | std::is_const<typename std::remove_pointer<PointerType>::type>::value, int >::type = 0 > |
21713 | | constexpr auto get_ptr() const noexcept -> decltype(std::declval<const basic_json_t&>().get_impl_ptr(std::declval<PointerType>())) |
21714 | 0 | { |
21715 | | // delegate the call to get_impl_ptr<>() const |
21716 | 0 | return get_impl_ptr(static_cast<PointerType>(nullptr)); |
21717 | 0 | } Unexecuted instantiation: _ZNK8nlohmann16json_abi_v3_12_010basic_jsonINSt3__13mapENS2_6vectorENS2_12basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEEblmdS8_NS0_14adl_serializerENS4_IhNS8_IhEEEEvE7get_ptrIPKmTnNS2_9enable_ifIXaasr3std10is_pointerIT_EE5valuesr3std8is_constINS2_14remove_pointerISJ_E4typeEEE5valueEiE4typeELi0EEEDTcldtclL_ZNS2_7declvalB8ne220000IRKSE_EEDTclsr3stdE9__declvalISJ_ELi0EEEvEE12get_impl_ptrclsr3stdE7declvalISJ_EEEEv Unexecuted instantiation: _ZNK8nlohmann16json_abi_v3_12_010basic_jsonINSt3__13mapENS2_6vectorENS2_12basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEEblmdS8_NS0_14adl_serializerENS4_IhNS8_IhEEEEvE7get_ptrIPKlTnNS2_9enable_ifIXaasr3std10is_pointerIT_EE5valuesr3std8is_constINS2_14remove_pointerISJ_E4typeEEE5valueEiE4typeELi0EEEDTcldtclL_ZNS2_7declvalB8ne220000IRKSE_EEDTclsr3stdE9__declvalISJ_ELi0EEEvEE12get_impl_ptrclsr3stdE7declvalISJ_EEEEv Unexecuted instantiation: _ZNK8nlohmann16json_abi_v3_12_010basic_jsonINSt3__13mapENS2_6vectorENS2_12basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEEblmdS8_NS0_14adl_serializerENS4_IhNS8_IhEEEEvE7get_ptrIPKdTnNS2_9enable_ifIXaasr3std10is_pointerIT_EE5valuesr3std8is_constINS2_14remove_pointerISJ_E4typeEEE5valueEiE4typeELi0EEEDTcldtclL_ZNS2_7declvalB8ne220000IRKSE_EEDTclsr3stdE9__declvalISJ_ELi0EEEvEE12get_impl_ptrclsr3stdE7declvalISJ_EEEEv Unexecuted instantiation: _ZNK8nlohmann16json_abi_v3_12_010basic_jsonINSt3__13mapENS2_6vectorENS2_12basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEEblmdS8_NS0_14adl_serializerENS4_IhNS8_IhEEEEvE7get_ptrIPKbTnNS2_9enable_ifIXaasr3std10is_pointerIT_EE5valuesr3std8is_constINS2_14remove_pointerISJ_E4typeEEE5valueEiE4typeELi0EEEDTcldtclL_ZNS2_7declvalB8ne220000IRKSE_EEDTclsr3stdE9__declvalISJ_ELi0EEEvEE12get_impl_ptrclsr3stdE7declvalISJ_EEEEv Unexecuted instantiation: _ZNK8nlohmann16json_abi_v3_12_010basic_jsonINSt3__13mapENS2_6vectorENS2_12basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEEblmdS8_NS0_14adl_serializerENS4_IhNS8_IhEEEEvE7get_ptrIPKSA_TnNS2_9enable_ifIXaasr3std10is_pointerIT_EE5valuesr3std8is_constINS2_14remove_pointerISJ_E4typeEEE5valueEiE4typeELi0EEEDTcldtclL_ZNS2_7declvalB8ne220000IRKSE_EEDTclsr3stdE9__declvalISJ_ELi0EEEvEE12get_impl_ptrclsr3stdE7declvalISJ_EEEEv |
21718 | | |
21719 | | private: |
21720 | | /*! |
21721 | | @brief get a value (explicit) |
21722 | | |
21723 | | Explicit type conversion between the JSON value and a compatible value |
21724 | | which is [CopyConstructible](https://en.cppreference.com/w/cpp/named_req/CopyConstructible) |
21725 | | and [DefaultConstructible](https://en.cppreference.com/w/cpp/named_req/DefaultConstructible). |
21726 | | The value is converted by calling the @ref json_serializer<ValueType> |
21727 | | `from_json()` method. |
21728 | | |
21729 | | The function is equivalent to executing |
21730 | | @code {.cpp} |
21731 | | ValueType ret; |
21732 | | JSONSerializer<ValueType>::from_json(*this, ret); |
21733 | | return ret; |
21734 | | @endcode |
21735 | | |
21736 | | This overloads is chosen if: |
21737 | | - @a ValueType is not @ref basic_json, |
21738 | | - @ref json_serializer<ValueType> has a `from_json()` method of the form |
21739 | | `void from_json(const basic_json&, ValueType&)`, and |
21740 | | - @ref json_serializer<ValueType> does not have a `from_json()` method of |
21741 | | the form `ValueType from_json(const basic_json&)` |
21742 | | |
21743 | | @tparam ValueType the returned value type |
21744 | | |
21745 | | @return copy of the JSON value, converted to @a ValueType |
21746 | | |
21747 | | @throw what @ref json_serializer<ValueType> `from_json()` method throws |
21748 | | |
21749 | | @liveexample{The example below shows several conversions from JSON values |
21750 | | to other types. There a few things to note: (1) Floating-point numbers can |
21751 | | be converted to integers\, (2) A JSON array can be converted to a standard |
21752 | | `std::vector<short>`\, (3) A JSON object can be converted to C++ |
21753 | | associative containers such as `std::unordered_map<std::string\, |
21754 | | json>`.,get__ValueType_const} |
21755 | | |
21756 | | @since version 2.1.0 |
21757 | | */ |
21758 | | template < typename ValueType, |
21759 | | detail::enable_if_t < |
21760 | | detail::is_default_constructible<ValueType>::value&& |
21761 | | detail::has_from_json<basic_json_t, ValueType>::value, |
21762 | | int > = 0 > |
21763 | | ValueType get_impl(detail::priority_tag<0> /*unused*/) const noexcept(noexcept( |
21764 | | JSONSerializer<ValueType>::from_json(std::declval<const basic_json_t&>(), std::declval<ValueType&>()))) |
21765 | 0 | { |
21766 | 0 | auto ret = ValueType(); |
21767 | 0 | JSONSerializer<ValueType>::from_json(*this, ret); |
21768 | 0 | return ret; |
21769 | 0 | } Unexecuted instantiation: _ZNK8nlohmann16json_abi_v3_12_010basic_jsonINSt3__13mapENS2_6vectorENS2_12basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEEblmdS8_NS0_14adl_serializerENS4_IhNS8_IhEEEEvE8get_implImTnNS2_9enable_ifIXaasr6detail24is_default_constructibleIT_EE5valuesr6detail13has_from_jsonISE_SH_EE5valueEiE4typeELi0EEESH_NS0_6detail12priority_tagILj0EEE Unexecuted instantiation: _ZNK8nlohmann16json_abi_v3_12_010basic_jsonINSt3__13mapENS2_6vectorENS2_12basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEEblmdS8_NS0_14adl_serializerENS4_IhNS8_IhEEEEvE8get_implIbTnNS2_9enable_ifIXaasr6detail24is_default_constructibleIT_EE5valuesr6detail13has_from_jsonISE_SH_EE5valueEiE4typeELi0EEESH_NS0_6detail12priority_tagILj0EEE Unexecuted instantiation: _ZNK8nlohmann16json_abi_v3_12_010basic_jsonINSt3__13mapENS2_6vectorENS2_12basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEEblmdS8_NS0_14adl_serializerENS4_IhNS8_IhEEEEvE8get_implIhTnNS2_9enable_ifIXaasr6detail24is_default_constructibleIT_EE5valuesr6detail13has_from_jsonISE_SH_EE5valueEiE4typeELi0EEESH_NS0_6detail12priority_tagILj0EEE Unexecuted instantiation: _ZNK8nlohmann16json_abi_v3_12_010basic_jsonINSt3__13mapENS2_6vectorENS2_12basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEEblmdS8_NS0_14adl_serializerENS4_IhNS8_IhEEEEvE8get_implIjTnNS2_9enable_ifIXaasr6detail24is_default_constructibleIT_EE5valuesr6detail13has_from_jsonISE_SH_EE5valueEiE4typeELi0EEESH_NS0_6detail12priority_tagILj0EEE Unexecuted instantiation: _ZNK8nlohmann16json_abi_v3_12_010basic_jsonINSt3__13mapENS2_6vectorENS2_12basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEEblmdS8_NS0_14adl_serializerENS4_IhNS8_IhEEEEvE8get_implISA_TnNS2_9enable_ifIXaasr6detail24is_default_constructibleIT_EE5valuesr6detail13has_from_jsonISE_SH_EE5valueEiE4typeELi0EEESH_NS0_6detail12priority_tagILj0EEE |
21770 | | |
21771 | | /*! |
21772 | | @brief get a value (explicit); special case |
21773 | | |
21774 | | Explicit type conversion between the JSON value and a compatible value |
21775 | | which is **not** [CopyConstructible](https://en.cppreference.com/w/cpp/named_req/CopyConstructible) |
21776 | | and **not** [DefaultConstructible](https://en.cppreference.com/w/cpp/named_req/DefaultConstructible). |
21777 | | The value is converted by calling the @ref json_serializer<ValueType> |
21778 | | `from_json()` method. |
21779 | | |
21780 | | The function is equivalent to executing |
21781 | | @code {.cpp} |
21782 | | return JSONSerializer<ValueType>::from_json(*this); |
21783 | | @endcode |
21784 | | |
21785 | | This overloads is chosen if: |
21786 | | - @a ValueType is not @ref basic_json and |
21787 | | - @ref json_serializer<ValueType> has a `from_json()` method of the form |
21788 | | `ValueType from_json(const basic_json&)` |
21789 | | |
21790 | | @note If @ref json_serializer<ValueType> has both overloads of |
21791 | | `from_json()`, this one is chosen. |
21792 | | |
21793 | | @tparam ValueType the returned value type |
21794 | | |
21795 | | @return copy of the JSON value, converted to @a ValueType |
21796 | | |
21797 | | @throw what @ref json_serializer<ValueType> `from_json()` method throws |
21798 | | |
21799 | | @since version 2.1.0 |
21800 | | */ |
21801 | | template < typename ValueType, |
21802 | | detail::enable_if_t < |
21803 | | detail::has_non_default_from_json<basic_json_t, ValueType>::value, |
21804 | | int > = 0 > |
21805 | | ValueType get_impl(detail::priority_tag<1> /*unused*/) const noexcept(noexcept( |
21806 | | JSONSerializer<ValueType>::from_json(std::declval<const basic_json_t&>()))) |
21807 | | { |
21808 | | return JSONSerializer<ValueType>::from_json(*this); |
21809 | | } |
21810 | | |
21811 | | /*! |
21812 | | @brief get special-case overload |
21813 | | |
21814 | | This overloads converts the current @ref basic_json in a different |
21815 | | @ref basic_json type |
21816 | | |
21817 | | @tparam BasicJsonType == @ref basic_json |
21818 | | |
21819 | | @return a copy of *this, converted into @a BasicJsonType |
21820 | | |
21821 | | @complexity Depending on the implementation of the called `from_json()` |
21822 | | method. |
21823 | | |
21824 | | @since version 3.2.0 |
21825 | | */ |
21826 | | template < typename BasicJsonType, |
21827 | | detail::enable_if_t < |
21828 | | detail::is_basic_json<BasicJsonType>::value, |
21829 | | int > = 0 > |
21830 | | BasicJsonType get_impl(detail::priority_tag<2> /*unused*/) const |
21831 | | { |
21832 | | return *this; |
21833 | | } |
21834 | | |
21835 | | /*! |
21836 | | @brief get special-case overload |
21837 | | |
21838 | | This overloads avoids a lot of template boilerplate, it can be seen as the |
21839 | | identity method |
21840 | | |
21841 | | @tparam BasicJsonType == @ref basic_json |
21842 | | |
21843 | | @return a copy of *this |
21844 | | |
21845 | | @complexity Constant. |
21846 | | |
21847 | | @since version 2.1.0 |
21848 | | */ |
21849 | | template<typename BasicJsonType, |
21850 | | detail::enable_if_t< |
21851 | | std::is_same<BasicJsonType, basic_json_t>::value, |
21852 | | int> = 0> |
21853 | | basic_json get_impl(detail::priority_tag<3> /*unused*/) const |
21854 | | { |
21855 | | return *this; |
21856 | | } |
21857 | | |
21858 | | /*! |
21859 | | @brief get a pointer value (explicit) |
21860 | | @copydoc get() |
21861 | | */ |
21862 | | template<typename PointerType, |
21863 | | detail::enable_if_t< |
21864 | | std::is_pointer<PointerType>::value, |
21865 | | int> = 0> |
21866 | | constexpr auto get_impl(detail::priority_tag<4> /*unused*/) const noexcept |
21867 | | -> decltype(std::declval<const basic_json_t&>().template get_ptr<PointerType>()) |
21868 | | { |
21869 | | // delegate the call to get_ptr |
21870 | | return get_ptr<PointerType>(); |
21871 | | } |
21872 | | |
21873 | | public: |
21874 | | /*! |
21875 | | @brief get a (pointer) value (explicit) |
21876 | | |
21877 | | Performs explicit type conversion between the JSON value and a compatible value if required. |
21878 | | |
21879 | | - If the requested type is a pointer to the internally stored JSON value that pointer is returned. |
21880 | | No copies are made. |
21881 | | |
21882 | | - If the requested type is the current @ref basic_json, or a different @ref basic_json convertible |
21883 | | from the current @ref basic_json. |
21884 | | |
21885 | | - Otherwise the value is converted by calling the @ref json_serializer<ValueType> `from_json()` |
21886 | | method. |
21887 | | |
21888 | | @tparam ValueTypeCV the provided value type |
21889 | | @tparam ValueType the returned value type |
21890 | | |
21891 | | @return copy of the JSON value, converted to @tparam ValueType if necessary |
21892 | | |
21893 | | @throw what @ref json_serializer<ValueType> `from_json()` method throws if conversion is required |
21894 | | |
21895 | | @since version 2.1.0 |
21896 | | */ |
21897 | | template < typename ValueTypeCV, typename ValueType = detail::uncvref_t<ValueTypeCV>> |
21898 | | #if defined(JSON_HAS_CPP_14) |
21899 | | constexpr |
21900 | | #endif |
21901 | | auto get() const noexcept( |
21902 | | noexcept(std::declval<const basic_json_t&>().template get_impl<ValueType>(detail::priority_tag<4> {}))) |
21903 | | -> decltype(std::declval<const basic_json_t&>().template get_impl<ValueType>(detail::priority_tag<4> {})) |
21904 | 0 | { |
21905 | | // we cannot static_assert on ValueTypeCV being non-const, because |
21906 | | // there is support for get<const basic_json_t>(), which is why we |
21907 | | // still need the uncvref |
21908 | 0 | static_assert(!std::is_reference<ValueTypeCV>::value, |
21909 | 0 | "get() cannot be used with reference types, you might want to use get_ref()"); |
21910 | 0 | return get_impl<ValueType>(detail::priority_tag<4> {}); |
21911 | 0 | } Unexecuted instantiation: _ZNK8nlohmann16json_abi_v3_12_010basic_jsonINSt3__13mapENS2_6vectorENS2_12basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEEblmdS8_NS0_14adl_serializerENS4_IhNS8_IhEEEEvE3getImmEEDTcldtclL_ZNS2_7declvalB8ne220000IRKSE_EEDTclsr3stdE9__declvalIT_ELi0EEEvEE8get_implIT0_EtlNS0_6detail12priority_tagILj4EEEEEEv Unexecuted instantiation: _ZNK8nlohmann16json_abi_v3_12_010basic_jsonINSt3__13mapENS2_6vectorENS2_12basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEEblmdS8_NS0_14adl_serializerENS4_IhNS8_IhEEEEvE3getIbbEEDTcldtclL_ZNS2_7declvalB8ne220000IRKSE_EEDTclsr3stdE9__declvalIT_ELi0EEEvEE8get_implIT0_EtlNS0_6detail12priority_tagILj4EEEEEEv Unexecuted instantiation: _ZNK8nlohmann16json_abi_v3_12_010basic_jsonINSt3__13mapENS2_6vectorENS2_12basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEEblmdS8_NS0_14adl_serializerENS4_IhNS8_IhEEEEvE3getIhhEEDTcldtclL_ZNS2_7declvalB8ne220000IRKSE_EEDTclsr3stdE9__declvalIT_ELi0EEEvEE8get_implIT0_EtlNS0_6detail12priority_tagILj4EEEEEEv Unexecuted instantiation: _ZNK8nlohmann16json_abi_v3_12_010basic_jsonINSt3__13mapENS2_6vectorENS2_12basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEEblmdS8_NS0_14adl_serializerENS4_IhNS8_IhEEEEvE3getIjjEEDTcldtclL_ZNS2_7declvalB8ne220000IRKSE_EEDTclsr3stdE9__declvalIT_ELi0EEEvEE8get_implIT0_EtlNS0_6detail12priority_tagILj4EEEEEEv Unexecuted instantiation: _ZNK8nlohmann16json_abi_v3_12_010basic_jsonINSt3__13mapENS2_6vectorENS2_12basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEEblmdS8_NS0_14adl_serializerENS4_IhNS8_IhEEEEvE3getISA_SA_EEDTcldtclL_ZNS2_7declvalB8ne220000IRKSE_EEDTclsr3stdE9__declvalIT_ELi0EEEvEE8get_implIT0_EtlNS0_6detail12priority_tagILj4EEEEEEv |
21912 | | |
21913 | | /*! |
21914 | | @brief get a pointer value (explicit) |
21915 | | |
21916 | | Explicit pointer access to the internally stored JSON value. No copies are |
21917 | | made. |
21918 | | |
21919 | | @warning The pointer becomes invalid if the underlying JSON object |
21920 | | changes. |
21921 | | |
21922 | | @tparam PointerType pointer type; must be a pointer to @ref array_t, @ref |
21923 | | object_t, @ref string_t, @ref boolean_t, @ref number_integer_t, |
21924 | | @ref number_unsigned_t, or @ref number_float_t. |
21925 | | |
21926 | | @return pointer to the internally stored JSON value if the requested |
21927 | | pointer type @a PointerType fits to the JSON value; `nullptr` otherwise |
21928 | | |
21929 | | @complexity Constant. |
21930 | | |
21931 | | @liveexample{The example below shows how pointers to internal values of a |
21932 | | JSON value can be requested. Note that no type conversions are made and a |
21933 | | `nullptr` is returned if the value and the requested pointer type does not |
21934 | | match.,get__PointerType} |
21935 | | |
21936 | | @sa see @ref get_ptr() for explicit pointer-member access |
21937 | | |
21938 | | @since version 1.0.0 |
21939 | | */ |
21940 | | template<typename PointerType, typename std::enable_if< |
21941 | | std::is_pointer<PointerType>::value, int>::type = 0> |
21942 | | auto get() noexcept -> decltype(std::declval<basic_json_t&>().template get_ptr<PointerType>()) |
21943 | | { |
21944 | | // delegate the call to get_ptr |
21945 | | return get_ptr<PointerType>(); |
21946 | | } |
21947 | | |
21948 | | /// @brief get a value (explicit) |
21949 | | /// @sa https://json.nlohmann.me/api/basic_json/get_to/ |
21950 | | template < typename ValueType, |
21951 | | detail::enable_if_t < |
21952 | | !detail::is_basic_json<ValueType>::value&& |
21953 | | detail::has_from_json<basic_json_t, ValueType>::value, |
21954 | | int > = 0 > |
21955 | | ValueType & get_to(ValueType& v) const noexcept(noexcept( |
21956 | | JSONSerializer<ValueType>::from_json(std::declval<const basic_json_t&>(), v))) |
21957 | | { |
21958 | | JSONSerializer<ValueType>::from_json(*this, v); |
21959 | | return v; |
21960 | | } |
21961 | | |
21962 | | // specialization to allow calling get_to with a basic_json value |
21963 | | // see https://github.com/nlohmann/json/issues/2175 |
21964 | | template<typename ValueType, |
21965 | | detail::enable_if_t < |
21966 | | detail::is_basic_json<ValueType>::value, |
21967 | | int> = 0> |
21968 | | ValueType & get_to(ValueType& v) const |
21969 | | { |
21970 | | v = *this; |
21971 | | return v; |
21972 | | } |
21973 | | |
21974 | | template < |
21975 | | typename T, std::size_t N, |
21976 | | typename Array = T (&)[N], // NOLINT(cppcoreguidelines-avoid-c-arrays,hicpp-avoid-c-arrays,modernize-avoid-c-arrays) |
21977 | | detail::enable_if_t < |
21978 | | detail::has_from_json<basic_json_t, Array>::value, int > = 0 > |
21979 | | Array get_to(T (&v)[N]) const // NOLINT(cppcoreguidelines-avoid-c-arrays,hicpp-avoid-c-arrays,modernize-avoid-c-arrays) |
21980 | | noexcept(noexcept(JSONSerializer<Array>::from_json( |
21981 | | std::declval<const basic_json_t&>(), v))) |
21982 | | { |
21983 | | JSONSerializer<Array>::from_json(*this, v); |
21984 | | return v; |
21985 | | } |
21986 | | |
21987 | | /// @brief get a reference value (implicit) |
21988 | | /// @sa https://json.nlohmann.me/api/basic_json/get_ref/ |
21989 | | template<typename ReferenceType, typename std::enable_if< |
21990 | | std::is_reference<ReferenceType>::value, int>::type = 0> |
21991 | | ReferenceType get_ref() |
21992 | | { |
21993 | | // delegate call to get_ref_impl |
21994 | | return get_ref_impl<ReferenceType>(*this); |
21995 | | } |
21996 | | |
21997 | | /// @brief get a reference value (implicit) |
21998 | | /// @sa https://json.nlohmann.me/api/basic_json/get_ref/ |
21999 | | template < typename ReferenceType, typename std::enable_if < |
22000 | | std::is_reference<ReferenceType>::value&& |
22001 | | std::is_const<typename std::remove_reference<ReferenceType>::type>::value, int >::type = 0 > |
22002 | | ReferenceType get_ref() const |
22003 | | { |
22004 | | // delegate call to get_ref_impl |
22005 | | return get_ref_impl<ReferenceType>(*this); |
22006 | | } |
22007 | | |
22008 | | /*! |
22009 | | @brief get a value (implicit) |
22010 | | |
22011 | | Implicit type conversion between the JSON value and a compatible value. |
22012 | | The call is realized by calling @ref get() const. |
22013 | | |
22014 | | @tparam ValueType non-pointer type compatible to the JSON value, for |
22015 | | instance `int` for JSON integer numbers, `bool` for JSON booleans, or |
22016 | | `std::vector` types for JSON arrays. The character type of @ref string_t |
22017 | | as well as an initializer list of this type is excluded to avoid |
22018 | | ambiguities as these types implicitly convert to `std::string`. |
22019 | | |
22020 | | @return copy of the JSON value, converted to type @a ValueType |
22021 | | |
22022 | | @throw type_error.302 in case passed type @a ValueType is incompatible |
22023 | | to the JSON value type (e.g., the JSON value is of type boolean, but a |
22024 | | string is requested); see example below |
22025 | | |
22026 | | @complexity Linear in the size of the JSON value. |
22027 | | |
22028 | | @liveexample{The example below shows several conversions from JSON values |
22029 | | to other types. There a few things to note: (1) Floating-point numbers can |
22030 | | be converted to integers\, (2) A JSON array can be converted to a standard |
22031 | | `std::vector<short>`\, (3) A JSON object can be converted to C++ |
22032 | | associative containers such as `std::unordered_map<std::string\, |
22033 | | json>`.,operator__ValueType} |
22034 | | |
22035 | | @since version 1.0.0 |
22036 | | */ |
22037 | | template < typename ValueType, typename std::enable_if < |
22038 | | detail::conjunction < |
22039 | | detail::negation<std::is_pointer<ValueType>>, |
22040 | | detail::negation<std::is_same<ValueType, std::nullptr_t>>, |
22041 | | detail::negation<std::is_same<ValueType, detail::json_ref<basic_json>>>, |
22042 | | detail::negation<std::is_same<ValueType, typename string_t::value_type>>, |
22043 | | detail::negation<detail::is_basic_json<ValueType>>, |
22044 | | detail::negation<std::is_same<ValueType, std::initializer_list<typename string_t::value_type>>>, |
22045 | | #if defined(JSON_HAS_CPP_17) && (defined(__GNUC__) || (defined(_MSC_VER) && _MSC_VER >= 1910 && _MSC_VER <= 1914)) |
22046 | | detail::negation<std::is_same<ValueType, std::string_view>>, |
22047 | | #endif |
22048 | | #if defined(JSON_HAS_CPP_17) && JSON_HAS_STATIC_RTTI |
22049 | | detail::negation<std::is_same<ValueType, std::any>>, |
22050 | | #endif |
22051 | | detail::is_detected_lazy<detail::get_template_function, const basic_json_t&, ValueType> |
22052 | | >::value, int >::type = 0 > |
22053 | | JSON_EXPLICIT operator ValueType() const |
22054 | 0 | { |
22055 | | // delegate the call to get<>() const |
22056 | 0 | return get<ValueType>(); |
22057 | 0 | } Unexecuted instantiation: _ZNK8nlohmann16json_abi_v3_12_010basic_jsonINSt3__13mapENS2_6vectorENS2_12basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEEblmdS8_NS0_14adl_serializerENS4_IhNS8_IhEEEEvEcvT_ISA_TnNS2_9enable_ifIXsr6detail11conjunctionINS0_6detail8negationINS2_10is_pointerISF_EEEENSJ_INS2_7is_sameISF_DnEEEENSJ_INSN_ISF_NSI_8json_refISE_EEEEEENSJ_INSN_ISF_cEEEENSJ_INSI_13is_basic_jsonISF_EEEENSJ_INSN_ISF_St16initializer_listIcEEEEENSJ_INSN_ISF_NS2_17basic_string_viewIcS7_EEEEEENSJ_INSN_ISF_NS2_3anyEEEEENSI_16is_detected_lazyINSI_21get_template_functionEJRKSE_SF_EEEEE5valueEiE4typeELi0EEEv Unexecuted instantiation: _ZNK8nlohmann16json_abi_v3_12_010basic_jsonINSt3__13mapENS2_6vectorENS2_12basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEEblmdS8_NS0_14adl_serializerENS4_IhNS8_IhEEEEvEcvT_IbTnNS2_9enable_ifIXsr6detail11conjunctionINS0_6detail8negationINS2_10is_pointerISF_EEEENSJ_INS2_7is_sameISF_DnEEEENSJ_INSN_ISF_NSI_8json_refISE_EEEEEENSJ_INSN_ISF_cEEEENSJ_INSI_13is_basic_jsonISF_EEEENSJ_INSN_ISF_St16initializer_listIcEEEEENSJ_INSN_ISF_NS2_17basic_string_viewIcS7_EEEEEENSJ_INSN_ISF_NS2_3anyEEEEENSI_16is_detected_lazyINSI_21get_template_functionEJRKSE_SF_EEEEE5valueEiE4typeELi0EEEv |
22058 | | |
22059 | | /// @brief get a binary value |
22060 | | /// @sa https://json.nlohmann.me/api/basic_json/get_binary/ |
22061 | | binary_t& get_binary() |
22062 | | { |
22063 | | if (!is_binary()) |
22064 | | { |
22065 | | JSON_THROW(type_error::create(302, detail::concat("type must be binary, but is ", type_name()), this)); |
22066 | | } |
22067 | | |
22068 | | return *get_ptr<binary_t*>(); |
22069 | | } |
22070 | | |
22071 | | /// @brief get a binary value |
22072 | | /// @sa https://json.nlohmann.me/api/basic_json/get_binary/ |
22073 | | const binary_t& get_binary() const |
22074 | | { |
22075 | | if (!is_binary()) |
22076 | | { |
22077 | | JSON_THROW(type_error::create(302, detail::concat("type must be binary, but is ", type_name()), this)); |
22078 | | } |
22079 | | |
22080 | | return *get_ptr<const binary_t*>(); |
22081 | | } |
22082 | | |
22083 | | /// @} |
22084 | | |
22085 | | //////////////////// |
22086 | | // element access // |
22087 | | //////////////////// |
22088 | | |
22089 | | /// @name element access |
22090 | | /// Access to the JSON value. |
22091 | | /// @{ |
22092 | | |
22093 | | /// @brief access specified array element with bounds checking |
22094 | | /// @sa https://json.nlohmann.me/api/basic_json/at/ |
22095 | | reference at(size_type idx) |
22096 | | { |
22097 | | // at only works for arrays |
22098 | | if (JSON_HEDLEY_LIKELY(is_array())) |
22099 | | { |
22100 | | JSON_TRY |
22101 | | { |
22102 | | return set_parent(m_data.m_value.array->at(idx)); |
22103 | | } |
22104 | | JSON_CATCH (std::out_of_range&) |
22105 | | { |
22106 | | // create a better exception explanation |
22107 | | JSON_THROW(out_of_range::create(401, detail::concat("array index ", std::to_string(idx), " is out of range"), this)); |
22108 | | } // cppcheck-suppress[missingReturn] |
22109 | | } |
22110 | | else |
22111 | | { |
22112 | | JSON_THROW(type_error::create(304, detail::concat("cannot use at() with ", type_name()), this)); |
22113 | | } |
22114 | | } |
22115 | | |
22116 | | /// @brief access specified array element with bounds checking |
22117 | | /// @sa https://json.nlohmann.me/api/basic_json/at/ |
22118 | | const_reference at(size_type idx) const |
22119 | | { |
22120 | | // at only works for arrays |
22121 | | if (JSON_HEDLEY_LIKELY(is_array())) |
22122 | | { |
22123 | | JSON_TRY |
22124 | | { |
22125 | | return m_data.m_value.array->at(idx); |
22126 | | } |
22127 | | JSON_CATCH (std::out_of_range&) |
22128 | | { |
22129 | | // create a better exception explanation |
22130 | | JSON_THROW(out_of_range::create(401, detail::concat("array index ", std::to_string(idx), " is out of range"), this)); |
22131 | | } // cppcheck-suppress[missingReturn] |
22132 | | } |
22133 | | else |
22134 | | { |
22135 | | JSON_THROW(type_error::create(304, detail::concat("cannot use at() with ", type_name()), this)); |
22136 | | } |
22137 | | } |
22138 | | |
22139 | | /// @brief access specified object element with bounds checking |
22140 | | /// @sa https://json.nlohmann.me/api/basic_json/at/ |
22141 | | reference at(const typename object_t::key_type& key) |
22142 | | { |
22143 | | // at only works for objects |
22144 | | if (JSON_HEDLEY_UNLIKELY(!is_object())) |
22145 | | { |
22146 | | JSON_THROW(type_error::create(304, detail::concat("cannot use at() with ", type_name()), this)); |
22147 | | } |
22148 | | |
22149 | | auto it = m_data.m_value.object->find(key); |
22150 | | if (it == m_data.m_value.object->end()) |
22151 | | { |
22152 | | JSON_THROW(out_of_range::create(403, detail::concat("key '", key, "' not found"), this)); |
22153 | | } |
22154 | | return set_parent(it->second); |
22155 | | } |
22156 | | |
22157 | | /// @brief access specified object element with bounds checking |
22158 | | /// @sa https://json.nlohmann.me/api/basic_json/at/ |
22159 | | template<class KeyType, detail::enable_if_t< |
22160 | | detail::is_usable_as_basic_json_key_type<basic_json_t, KeyType>::value, int> = 0> |
22161 | | reference at(KeyType && key) |
22162 | | { |
22163 | | // at only works for objects |
22164 | | if (JSON_HEDLEY_UNLIKELY(!is_object())) |
22165 | | { |
22166 | | JSON_THROW(type_error::create(304, detail::concat("cannot use at() with ", type_name()), this)); |
22167 | | } |
22168 | | |
22169 | | auto it = m_data.m_value.object->find(std::forward<KeyType>(key)); |
22170 | | if (it == m_data.m_value.object->end()) |
22171 | | { |
22172 | | JSON_THROW(out_of_range::create(403, detail::concat("key '", string_t(std::forward<KeyType>(key)), "' not found"), this)); |
22173 | | } |
22174 | | return set_parent(it->second); |
22175 | | } |
22176 | | |
22177 | | /// @brief access specified object element with bounds checking |
22178 | | /// @sa https://json.nlohmann.me/api/basic_json/at/ |
22179 | | const_reference at(const typename object_t::key_type& key) const |
22180 | | { |
22181 | | // at only works for objects |
22182 | | if (JSON_HEDLEY_UNLIKELY(!is_object())) |
22183 | | { |
22184 | | JSON_THROW(type_error::create(304, detail::concat("cannot use at() with ", type_name()), this)); |
22185 | | } |
22186 | | |
22187 | | auto it = m_data.m_value.object->find(key); |
22188 | | if (it == m_data.m_value.object->end()) |
22189 | | { |
22190 | | JSON_THROW(out_of_range::create(403, detail::concat("key '", key, "' not found"), this)); |
22191 | | } |
22192 | | return it->second; |
22193 | | } |
22194 | | |
22195 | | /// @brief access specified object element with bounds checking |
22196 | | /// @sa https://json.nlohmann.me/api/basic_json/at/ |
22197 | | template<class KeyType, detail::enable_if_t< |
22198 | | detail::is_usable_as_basic_json_key_type<basic_json_t, KeyType>::value, int> = 0> |
22199 | | const_reference at(KeyType && key) const |
22200 | | { |
22201 | | // at only works for objects |
22202 | | if (JSON_HEDLEY_UNLIKELY(!is_object())) |
22203 | | { |
22204 | | JSON_THROW(type_error::create(304, detail::concat("cannot use at() with ", type_name()), this)); |
22205 | | } |
22206 | | |
22207 | | auto it = m_data.m_value.object->find(std::forward<KeyType>(key)); |
22208 | | if (it == m_data.m_value.object->end()) |
22209 | | { |
22210 | | JSON_THROW(out_of_range::create(403, detail::concat("key '", string_t(std::forward<KeyType>(key)), "' not found"), this)); |
22211 | | } |
22212 | | return it->second; |
22213 | | } |
22214 | | |
22215 | | /// @brief access specified array element |
22216 | | /// @sa https://json.nlohmann.me/api/basic_json/operator%5B%5D/ |
22217 | | reference operator[](size_type idx) |
22218 | 0 | { |
22219 | | // implicitly convert a null value to an empty array |
22220 | 0 | if (is_null()) |
22221 | 0 | { |
22222 | 0 | m_data.m_type = value_t::array; |
22223 | 0 | m_data.m_value.array = create<array_t>(); |
22224 | 0 | assert_invariant(); |
22225 | 0 | } |
22226 | | |
22227 | | // operator[] only works for arrays |
22228 | 0 | if (JSON_HEDLEY_LIKELY(is_array())) |
22229 | 0 | { |
22230 | | // fill up the array with null values if given idx is outside the range |
22231 | 0 | if (idx >= m_data.m_value.array->size()) |
22232 | 0 | { |
22233 | | #if JSON_DIAGNOSTICS |
22234 | | // remember array size & capacity before resizing |
22235 | | const auto old_size = m_data.m_value.array->size(); |
22236 | | const auto old_capacity = m_data.m_value.array->capacity(); |
22237 | | #endif |
22238 | 0 | m_data.m_value.array->resize(idx + 1); |
22239 | |
|
22240 | | #if JSON_DIAGNOSTICS |
22241 | | if (JSON_HEDLEY_UNLIKELY(m_data.m_value.array->capacity() != old_capacity)) |
22242 | | { |
22243 | | // capacity has changed: update all parents |
22244 | | set_parents(); |
22245 | | } |
22246 | | else |
22247 | | { |
22248 | | // set parent for values added above |
22249 | | set_parents(begin() + static_cast<typename iterator::difference_type>(old_size), static_cast<typename iterator::difference_type>(idx + 1 - old_size)); |
22250 | | } |
22251 | | #endif |
22252 | 0 | assert_invariant(); |
22253 | 0 | } |
22254 | |
|
22255 | 0 | return m_data.m_value.array->operator[](idx); |
22256 | 0 | } |
22257 | | |
22258 | 0 | JSON_THROW(type_error::create(305, detail::concat("cannot use operator[] with a numeric argument with ", type_name()), this)); |
22259 | 0 | } |
22260 | | |
22261 | | /// @brief access specified array element |
22262 | | /// @sa https://json.nlohmann.me/api/basic_json/operator%5B%5D/ |
22263 | | const_reference operator[](size_type idx) const |
22264 | 0 | { |
22265 | | // const operator[] only works for arrays |
22266 | 0 | if (JSON_HEDLEY_LIKELY(is_array())) |
22267 | 0 | { |
22268 | 0 | return m_data.m_value.array->operator[](idx); |
22269 | 0 | } |
22270 | | |
22271 | 0 | JSON_THROW(type_error::create(305, detail::concat("cannot use operator[] with a numeric argument with ", type_name()), this)); |
22272 | 0 | } |
22273 | | |
22274 | | /// @brief access specified object element |
22275 | | /// @sa https://json.nlohmann.me/api/basic_json/operator%5B%5D/ |
22276 | | reference operator[](typename object_t::key_type key) // NOLINT(performance-unnecessary-value-param) |
22277 | 0 | { |
22278 | | // implicitly convert a null value to an empty object |
22279 | 0 | if (is_null()) |
22280 | 0 | { |
22281 | 0 | m_data.m_type = value_t::object; |
22282 | 0 | m_data.m_value.object = create<object_t>(); |
22283 | 0 | assert_invariant(); |
22284 | 0 | } |
22285 | | |
22286 | | // operator[] only works for objects |
22287 | 0 | if (JSON_HEDLEY_LIKELY(is_object())) |
22288 | 0 | { |
22289 | 0 | auto result = m_data.m_value.object->emplace(std::move(key), nullptr); |
22290 | 0 | return set_parent(result.first->second); |
22291 | 0 | } |
22292 | | |
22293 | 0 | JSON_THROW(type_error::create(305, detail::concat("cannot use operator[] with a string argument with ", type_name()), this)); |
22294 | 0 | } |
22295 | | |
22296 | | /// @brief access specified object element |
22297 | | /// @sa https://json.nlohmann.me/api/basic_json/operator%5B%5D/ |
22298 | | const_reference operator[](const typename object_t::key_type& key) const |
22299 | | { |
22300 | | // const operator[] only works for objects |
22301 | | if (JSON_HEDLEY_LIKELY(is_object())) |
22302 | | { |
22303 | | auto it = m_data.m_value.object->find(key); |
22304 | | JSON_ASSERT(it != m_data.m_value.object->end()); |
22305 | | return it->second; |
22306 | | } |
22307 | | |
22308 | | JSON_THROW(type_error::create(305, detail::concat("cannot use operator[] with a string argument with ", type_name()), this)); |
22309 | | } |
22310 | | |
22311 | | // these two functions resolve a (const) char * ambiguity affecting Clang and MSVC |
22312 | | // (they seemingly cannot be constrained to resolve the ambiguity) |
22313 | | template<typename T> |
22314 | | reference operator[](T* key) |
22315 | 0 | { |
22316 | 0 | return operator[](typename object_t::key_type(key)); |
22317 | 0 | } |
22318 | | |
22319 | | template<typename T> |
22320 | | const_reference operator[](T* key) const |
22321 | 0 | { |
22322 | 0 | return operator[](typename object_t::key_type(key)); |
22323 | 0 | } |
22324 | | |
22325 | | /// @brief access specified object element |
22326 | | /// @sa https://json.nlohmann.me/api/basic_json/operator%5B%5D/ |
22327 | | template<class KeyType, detail::enable_if_t< |
22328 | | detail::is_usable_as_basic_json_key_type<basic_json_t, KeyType>::value, int > = 0 > |
22329 | | reference operator[](KeyType && key) |
22330 | | { |
22331 | | // implicitly convert a null value to an empty object |
22332 | | if (is_null()) |
22333 | | { |
22334 | | m_data.m_type = value_t::object; |
22335 | | m_data.m_value.object = create<object_t>(); |
22336 | | assert_invariant(); |
22337 | | } |
22338 | | |
22339 | | // operator[] only works for objects |
22340 | | if (JSON_HEDLEY_LIKELY(is_object())) |
22341 | | { |
22342 | | auto result = m_data.m_value.object->emplace(std::forward<KeyType>(key), nullptr); |
22343 | | return set_parent(result.first->second); |
22344 | | } |
22345 | | |
22346 | | JSON_THROW(type_error::create(305, detail::concat("cannot use operator[] with a string argument with ", type_name()), this)); |
22347 | | } |
22348 | | |
22349 | | /// @brief access specified object element |
22350 | | /// @sa https://json.nlohmann.me/api/basic_json/operator%5B%5D/ |
22351 | | template<class KeyType, detail::enable_if_t< |
22352 | | detail::is_usable_as_basic_json_key_type<basic_json_t, KeyType>::value, int > = 0 > |
22353 | | const_reference operator[](KeyType && key) const |
22354 | 0 | { |
22355 | | // const operator[] only works for objects |
22356 | 0 | if (JSON_HEDLEY_LIKELY(is_object())) |
22357 | 0 | { |
22358 | 0 | auto it = m_data.m_value.object->find(std::forward<KeyType>(key)); |
22359 | 0 | JSON_ASSERT(it != m_data.m_value.object->end()); |
22360 | 0 | return it->second; |
22361 | 0 | } |
22362 | | |
22363 | 0 | JSON_THROW(type_error::create(305, detail::concat("cannot use operator[] with a string argument with ", type_name()), this)); |
22364 | 0 | } |
22365 | | |
22366 | | private: |
22367 | | template<typename KeyType> |
22368 | | using is_comparable_with_object_key = detail::is_comparable < |
22369 | | object_comparator_t, const typename object_t::key_type&, KeyType >; |
22370 | | |
22371 | | template<typename ValueType> |
22372 | | using value_return_type = std::conditional < |
22373 | | detail::is_c_string_uncvref<ValueType>::value, |
22374 | | string_t, typename std::decay<ValueType>::type >; |
22375 | | |
22376 | | public: |
22377 | | /// @brief access specified object element with default value |
22378 | | /// @sa https://json.nlohmann.me/api/basic_json/value/ |
22379 | | template < class ValueType, detail::enable_if_t < |
22380 | | !detail::is_transparent<object_comparator_t>::value |
22381 | | && detail::is_getable<basic_json_t, ValueType>::value |
22382 | | && !std::is_same<value_t, detail::uncvref_t<ValueType>>::value, int > = 0 > |
22383 | | ValueType value(const typename object_t::key_type& key, const ValueType& default_value) const |
22384 | | { |
22385 | | // value only works for objects |
22386 | | if (JSON_HEDLEY_LIKELY(is_object())) |
22387 | | { |
22388 | | // If 'key' is found, return its value. Otherwise, return `default_value'. |
22389 | | const auto it = find(key); |
22390 | | if (it != end()) |
22391 | | { |
22392 | | return it->template get<ValueType>(); |
22393 | | } |
22394 | | |
22395 | | return default_value; |
22396 | | } |
22397 | | |
22398 | | JSON_THROW(type_error::create(306, detail::concat("cannot use value() with ", type_name()), this)); |
22399 | | } |
22400 | | |
22401 | | /// @brief access specified object element with default value |
22402 | | /// @sa https://json.nlohmann.me/api/basic_json/value/ |
22403 | | template < class ValueType, class ReturnType = typename value_return_type<ValueType>::type, |
22404 | | detail::enable_if_t < |
22405 | | !detail::is_transparent<object_comparator_t>::value |
22406 | | && detail::is_getable<basic_json_t, ReturnType>::value |
22407 | | && !std::is_same<value_t, detail::uncvref_t<ValueType>>::value, int > = 0 > |
22408 | | ReturnType value(const typename object_t::key_type& key, ValueType && default_value) const |
22409 | | { |
22410 | | // value only works for objects |
22411 | | if (JSON_HEDLEY_LIKELY(is_object())) |
22412 | | { |
22413 | | // If 'key' is found, return its value. Otherwise, return `default_value'. |
22414 | | const auto it = find(key); |
22415 | | if (it != end()) |
22416 | | { |
22417 | | return it->template get<ReturnType>(); |
22418 | | } |
22419 | | |
22420 | | return std::forward<ValueType>(default_value); |
22421 | | } |
22422 | | |
22423 | | JSON_THROW(type_error::create(306, detail::concat("cannot use value() with ", type_name()), this)); |
22424 | | } |
22425 | | |
22426 | | /// @brief access specified object element with default value |
22427 | | /// @sa https://json.nlohmann.me/api/basic_json/value/ |
22428 | | template < class ValueType, class KeyType, detail::enable_if_t < |
22429 | | detail::is_transparent<object_comparator_t>::value |
22430 | | && !detail::is_json_pointer<KeyType>::value |
22431 | | && is_comparable_with_object_key<KeyType>::value |
22432 | | && detail::is_getable<basic_json_t, ValueType>::value |
22433 | | && !std::is_same<value_t, detail::uncvref_t<ValueType>>::value, int > = 0 > |
22434 | | ValueType value(KeyType && key, const ValueType& default_value) const |
22435 | | { |
22436 | | // value only works for objects |
22437 | | if (JSON_HEDLEY_LIKELY(is_object())) |
22438 | | { |
22439 | | // If 'key' is found, return its value. Otherwise, return `default_value'. |
22440 | | const auto it = find(std::forward<KeyType>(key)); |
22441 | | if (it != end()) |
22442 | | { |
22443 | | return it->template get<ValueType>(); |
22444 | | } |
22445 | | |
22446 | | return default_value; |
22447 | | } |
22448 | | |
22449 | | JSON_THROW(type_error::create(306, detail::concat("cannot use value() with ", type_name()), this)); |
22450 | | } |
22451 | | |
22452 | | /// @brief access specified object element via JSON Pointer with default value |
22453 | | /// @sa https://json.nlohmann.me/api/basic_json/value/ |
22454 | | template < class ValueType, class KeyType, class ReturnType = typename value_return_type<ValueType>::type, |
22455 | | detail::enable_if_t < |
22456 | | detail::is_transparent<object_comparator_t>::value |
22457 | | && !detail::is_json_pointer<KeyType>::value |
22458 | | && is_comparable_with_object_key<KeyType>::value |
22459 | | && detail::is_getable<basic_json_t, ReturnType>::value |
22460 | | && !std::is_same<value_t, detail::uncvref_t<ValueType>>::value, int > = 0 > |
22461 | | ReturnType value(KeyType && key, ValueType && default_value) const |
22462 | | { |
22463 | | // value only works for objects |
22464 | | if (JSON_HEDLEY_LIKELY(is_object())) |
22465 | | { |
22466 | | // If 'key' is found, return its value. Otherwise, return `default_value'. |
22467 | | const auto it = find(std::forward<KeyType>(key)); |
22468 | | if (it != end()) |
22469 | | { |
22470 | | return it->template get<ReturnType>(); |
22471 | | } |
22472 | | |
22473 | | return std::forward<ValueType>(default_value); |
22474 | | } |
22475 | | |
22476 | | JSON_THROW(type_error::create(306, detail::concat("cannot use value() with ", type_name()), this)); |
22477 | | } |
22478 | | |
22479 | | /// @brief access specified object element via JSON Pointer with default value |
22480 | | /// @sa https://json.nlohmann.me/api/basic_json/value/ |
22481 | | template < class ValueType, detail::enable_if_t < |
22482 | | detail::is_getable<basic_json_t, ValueType>::value |
22483 | | && !std::is_same<value_t, detail::uncvref_t<ValueType>>::value, int > = 0 > |
22484 | | ValueType value(const json_pointer& ptr, const ValueType& default_value) const |
22485 | | { |
22486 | | // value only works for objects |
22487 | | if (JSON_HEDLEY_LIKELY(is_object())) |
22488 | | { |
22489 | | // If the pointer resolves to a value, return it. Otherwise, return |
22490 | | // 'default_value'. |
22491 | | JSON_TRY |
22492 | | { |
22493 | | return ptr.get_checked(this).template get<ValueType>(); |
22494 | | } |
22495 | | JSON_INTERNAL_CATCH (out_of_range&) |
22496 | | { |
22497 | | return default_value; |
22498 | | } |
22499 | | } |
22500 | | |
22501 | | JSON_THROW(type_error::create(306, detail::concat("cannot use value() with ", type_name()), this)); |
22502 | | } |
22503 | | |
22504 | | /// @brief access specified object element via JSON Pointer with default value |
22505 | | /// @sa https://json.nlohmann.me/api/basic_json/value/ |
22506 | | template < class ValueType, class ReturnType = typename value_return_type<ValueType>::type, |
22507 | | detail::enable_if_t < |
22508 | | detail::is_getable<basic_json_t, ReturnType>::value |
22509 | | && !std::is_same<value_t, detail::uncvref_t<ValueType>>::value, int > = 0 > |
22510 | | ReturnType value(const json_pointer& ptr, ValueType && default_value) const |
22511 | | { |
22512 | | // value only works for objects |
22513 | | if (JSON_HEDLEY_LIKELY(is_object())) |
22514 | | { |
22515 | | // If the pointer resolves to a value, return it. Otherwise, return |
22516 | | // 'default_value'. |
22517 | | JSON_TRY |
22518 | | { |
22519 | | return ptr.get_checked(this).template get<ReturnType>(); |
22520 | | } |
22521 | | JSON_INTERNAL_CATCH (out_of_range&) |
22522 | | { |
22523 | | return std::forward<ValueType>(default_value); |
22524 | | } |
22525 | | } |
22526 | | |
22527 | | JSON_THROW(type_error::create(306, detail::concat("cannot use value() with ", type_name()), this)); |
22528 | | } |
22529 | | |
22530 | | template < class ValueType, class BasicJsonType, detail::enable_if_t < |
22531 | | detail::is_basic_json<BasicJsonType>::value |
22532 | | && detail::is_getable<basic_json_t, ValueType>::value |
22533 | | && !std::is_same<value_t, detail::uncvref_t<ValueType>>::value, int > = 0 > |
22534 | | JSON_HEDLEY_DEPRECATED_FOR(3.11.0, basic_json::json_pointer or nlohmann::json_pointer<basic_json::string_t>) // NOLINT(readability/alt_tokens) |
22535 | | ValueType value(const ::nlohmann::json_pointer<BasicJsonType>& ptr, const ValueType& default_value) const |
22536 | | { |
22537 | | return value(ptr.convert(), default_value); |
22538 | | } |
22539 | | |
22540 | | template < class ValueType, class BasicJsonType, class ReturnType = typename value_return_type<ValueType>::type, |
22541 | | detail::enable_if_t < |
22542 | | detail::is_basic_json<BasicJsonType>::value |
22543 | | && detail::is_getable<basic_json_t, ReturnType>::value |
22544 | | && !std::is_same<value_t, detail::uncvref_t<ValueType>>::value, int > = 0 > |
22545 | | JSON_HEDLEY_DEPRECATED_FOR(3.11.0, basic_json::json_pointer or nlohmann::json_pointer<basic_json::string_t>) // NOLINT(readability/alt_tokens) |
22546 | | ReturnType value(const ::nlohmann::json_pointer<BasicJsonType>& ptr, ValueType && default_value) const |
22547 | | { |
22548 | | return value(ptr.convert(), std::forward<ValueType>(default_value)); |
22549 | | } |
22550 | | |
22551 | | /// @brief access the first element |
22552 | | /// @sa https://json.nlohmann.me/api/basic_json/front/ |
22553 | | reference front() |
22554 | | { |
22555 | | return *begin(); |
22556 | | } |
22557 | | |
22558 | | /// @brief access the first element |
22559 | | /// @sa https://json.nlohmann.me/api/basic_json/front/ |
22560 | | const_reference front() const |
22561 | | { |
22562 | | return *cbegin(); |
22563 | | } |
22564 | | |
22565 | | /// @brief access the last element |
22566 | | /// @sa https://json.nlohmann.me/api/basic_json/back/ |
22567 | | reference back() |
22568 | | { |
22569 | | auto tmp = end(); |
22570 | | --tmp; |
22571 | | return *tmp; |
22572 | | } |
22573 | | |
22574 | | /// @brief access the last element |
22575 | | /// @sa https://json.nlohmann.me/api/basic_json/back/ |
22576 | | const_reference back() const |
22577 | | { |
22578 | | auto tmp = cend(); |
22579 | | --tmp; |
22580 | | return *tmp; |
22581 | | } |
22582 | | |
22583 | | /// @brief remove element given an iterator |
22584 | | /// @sa https://json.nlohmann.me/api/basic_json/erase/ |
22585 | | template < class IteratorType, detail::enable_if_t < |
22586 | | std::is_same<IteratorType, typename basic_json_t::iterator>::value || |
22587 | | std::is_same<IteratorType, typename basic_json_t::const_iterator>::value, int > = 0 > |
22588 | | IteratorType erase(IteratorType pos) // NOLINT(performance-unnecessary-value-param) |
22589 | 0 | { |
22590 | | // make sure the iterator fits the current value |
22591 | 0 | if (JSON_HEDLEY_UNLIKELY(this != pos.m_object)) |
22592 | 0 | { |
22593 | 0 | JSON_THROW(invalid_iterator::create(202, "iterator does not fit current value", this)); |
22594 | 0 | } |
22595 | | |
22596 | 0 | IteratorType result = end(); |
22597 | |
|
22598 | 0 | switch (m_data.m_type) |
22599 | 0 | { |
22600 | 0 | case value_t::boolean: |
22601 | 0 | case value_t::number_float: |
22602 | 0 | case value_t::number_integer: |
22603 | 0 | case value_t::number_unsigned: |
22604 | 0 | case value_t::string: |
22605 | 0 | case value_t::binary: |
22606 | 0 | { |
22607 | 0 | if (JSON_HEDLEY_UNLIKELY(!pos.m_it.primitive_iterator.is_begin())) |
22608 | 0 | { |
22609 | 0 | JSON_THROW(invalid_iterator::create(205, "iterator out of range", this)); |
22610 | 0 | } |
22611 | | |
22612 | 0 | if (is_string()) |
22613 | 0 | { |
22614 | 0 | AllocatorType<string_t> alloc; |
22615 | 0 | std::allocator_traits<decltype(alloc)>::destroy(alloc, m_data.m_value.string); |
22616 | 0 | std::allocator_traits<decltype(alloc)>::deallocate(alloc, m_data.m_value.string, 1); |
22617 | 0 | m_data.m_value.string = nullptr; |
22618 | 0 | } |
22619 | 0 | else if (is_binary()) |
22620 | 0 | { |
22621 | 0 | AllocatorType<binary_t> alloc; |
22622 | 0 | std::allocator_traits<decltype(alloc)>::destroy(alloc, m_data.m_value.binary); |
22623 | 0 | std::allocator_traits<decltype(alloc)>::deallocate(alloc, m_data.m_value.binary, 1); |
22624 | 0 | m_data.m_value.binary = nullptr; |
22625 | 0 | } |
22626 | |
|
22627 | 0 | m_data.m_type = value_t::null; |
22628 | 0 | assert_invariant(); |
22629 | 0 | break; |
22630 | 0 | } |
22631 | | |
22632 | 0 | case value_t::object: |
22633 | 0 | { |
22634 | 0 | result.m_it.object_iterator = m_data.m_value.object->erase(pos.m_it.object_iterator); |
22635 | 0 | break; |
22636 | 0 | } |
22637 | | |
22638 | 0 | case value_t::array: |
22639 | 0 | { |
22640 | 0 | result.m_it.array_iterator = m_data.m_value.array->erase(pos.m_it.array_iterator); |
22641 | 0 | break; |
22642 | 0 | } |
22643 | | |
22644 | 0 | case value_t::null: |
22645 | 0 | case value_t::discarded: |
22646 | 0 | default: |
22647 | 0 | JSON_THROW(type_error::create(307, detail::concat("cannot use erase() with ", type_name()), this)); |
22648 | 0 | } |
22649 | | |
22650 | 0 | return result; |
22651 | 0 | } |
22652 | | |
22653 | | /// @brief remove elements given an iterator range |
22654 | | /// @sa https://json.nlohmann.me/api/basic_json/erase/ |
22655 | | template < class IteratorType, detail::enable_if_t < |
22656 | | std::is_same<IteratorType, typename basic_json_t::iterator>::value || |
22657 | | std::is_same<IteratorType, typename basic_json_t::const_iterator>::value, int > = 0 > |
22658 | | IteratorType erase(IteratorType first, IteratorType last) // NOLINT(performance-unnecessary-value-param) |
22659 | | { |
22660 | | // make sure the iterator fits the current value |
22661 | | if (JSON_HEDLEY_UNLIKELY(this != first.m_object || this != last.m_object)) |
22662 | | { |
22663 | | JSON_THROW(invalid_iterator::create(203, "iterators do not fit current value", this)); |
22664 | | } |
22665 | | |
22666 | | IteratorType result = end(); |
22667 | | |
22668 | | switch (m_data.m_type) |
22669 | | { |
22670 | | case value_t::boolean: |
22671 | | case value_t::number_float: |
22672 | | case value_t::number_integer: |
22673 | | case value_t::number_unsigned: |
22674 | | case value_t::string: |
22675 | | case value_t::binary: |
22676 | | { |
22677 | | if (JSON_HEDLEY_LIKELY(!first.m_it.primitive_iterator.is_begin() |
22678 | | || !last.m_it.primitive_iterator.is_end())) |
22679 | | { |
22680 | | JSON_THROW(invalid_iterator::create(204, "iterators out of range", this)); |
22681 | | } |
22682 | | |
22683 | | if (is_string()) |
22684 | | { |
22685 | | AllocatorType<string_t> alloc; |
22686 | | std::allocator_traits<decltype(alloc)>::destroy(alloc, m_data.m_value.string); |
22687 | | std::allocator_traits<decltype(alloc)>::deallocate(alloc, m_data.m_value.string, 1); |
22688 | | m_data.m_value.string = nullptr; |
22689 | | } |
22690 | | else if (is_binary()) |
22691 | | { |
22692 | | AllocatorType<binary_t> alloc; |
22693 | | std::allocator_traits<decltype(alloc)>::destroy(alloc, m_data.m_value.binary); |
22694 | | std::allocator_traits<decltype(alloc)>::deallocate(alloc, m_data.m_value.binary, 1); |
22695 | | m_data.m_value.binary = nullptr; |
22696 | | } |
22697 | | |
22698 | | m_data.m_type = value_t::null; |
22699 | | assert_invariant(); |
22700 | | break; |
22701 | | } |
22702 | | |
22703 | | case value_t::object: |
22704 | | { |
22705 | | result.m_it.object_iterator = m_data.m_value.object->erase(first.m_it.object_iterator, |
22706 | | last.m_it.object_iterator); |
22707 | | break; |
22708 | | } |
22709 | | |
22710 | | case value_t::array: |
22711 | | { |
22712 | | result.m_it.array_iterator = m_data.m_value.array->erase(first.m_it.array_iterator, |
22713 | | last.m_it.array_iterator); |
22714 | | break; |
22715 | | } |
22716 | | |
22717 | | case value_t::null: |
22718 | | case value_t::discarded: |
22719 | | default: |
22720 | | JSON_THROW(type_error::create(307, detail::concat("cannot use erase() with ", type_name()), this)); |
22721 | | } |
22722 | | |
22723 | | return result; |
22724 | | } |
22725 | | |
22726 | | private: |
22727 | | template < typename KeyType, detail::enable_if_t < |
22728 | | detail::has_erase_with_key_type<basic_json_t, KeyType>::value, int > = 0 > |
22729 | | size_type erase_internal(KeyType && key) |
22730 | | { |
22731 | | // this erase only works for objects |
22732 | | if (JSON_HEDLEY_UNLIKELY(!is_object())) |
22733 | | { |
22734 | | JSON_THROW(type_error::create(307, detail::concat("cannot use erase() with ", type_name()), this)); |
22735 | | } |
22736 | | |
22737 | | return m_data.m_value.object->erase(std::forward<KeyType>(key)); |
22738 | | } |
22739 | | |
22740 | | template < typename KeyType, detail::enable_if_t < |
22741 | | !detail::has_erase_with_key_type<basic_json_t, KeyType>::value, int > = 0 > |
22742 | | size_type erase_internal(KeyType && key) |
22743 | | { |
22744 | | // this erase only works for objects |
22745 | | if (JSON_HEDLEY_UNLIKELY(!is_object())) |
22746 | | { |
22747 | | JSON_THROW(type_error::create(307, detail::concat("cannot use erase() with ", type_name()), this)); |
22748 | | } |
22749 | | |
22750 | | const auto it = m_data.m_value.object->find(std::forward<KeyType>(key)); |
22751 | | if (it != m_data.m_value.object->end()) |
22752 | | { |
22753 | | m_data.m_value.object->erase(it); |
22754 | | return 1; |
22755 | | } |
22756 | | return 0; |
22757 | | } |
22758 | | |
22759 | | public: |
22760 | | |
22761 | | /// @brief remove element from a JSON object given a key |
22762 | | /// @sa https://json.nlohmann.me/api/basic_json/erase/ |
22763 | | size_type erase(const typename object_t::key_type& key) |
22764 | | { |
22765 | | // the indirection via erase_internal() is added to avoid making this |
22766 | | // function a template and thus de-rank it during overload resolution |
22767 | | return erase_internal(key); |
22768 | | } |
22769 | | |
22770 | | /// @brief remove element from a JSON object given a key |
22771 | | /// @sa https://json.nlohmann.me/api/basic_json/erase/ |
22772 | | template<class KeyType, detail::enable_if_t< |
22773 | | detail::is_usable_as_basic_json_key_type<basic_json_t, KeyType>::value, int> = 0> |
22774 | | size_type erase(KeyType && key) |
22775 | | { |
22776 | | return erase_internal(std::forward<KeyType>(key)); |
22777 | | } |
22778 | | |
22779 | | /// @brief remove element from a JSON array given an index |
22780 | | /// @sa https://json.nlohmann.me/api/basic_json/erase/ |
22781 | | void erase(const size_type idx) |
22782 | | { |
22783 | | // this erase only works for arrays |
22784 | | if (JSON_HEDLEY_LIKELY(is_array())) |
22785 | | { |
22786 | | if (JSON_HEDLEY_UNLIKELY(idx >= size())) |
22787 | | { |
22788 | | JSON_THROW(out_of_range::create(401, detail::concat("array index ", std::to_string(idx), " is out of range"), this)); |
22789 | | } |
22790 | | |
22791 | | m_data.m_value.array->erase(m_data.m_value.array->begin() + static_cast<difference_type>(idx)); |
22792 | | } |
22793 | | else |
22794 | | { |
22795 | | JSON_THROW(type_error::create(307, detail::concat("cannot use erase() with ", type_name()), this)); |
22796 | | } |
22797 | | } |
22798 | | |
22799 | | /// @} |
22800 | | |
22801 | | //////////// |
22802 | | // lookup // |
22803 | | //////////// |
22804 | | |
22805 | | /// @name lookup |
22806 | | /// @{ |
22807 | | |
22808 | | /// @brief find an element in a JSON object |
22809 | | /// @sa https://json.nlohmann.me/api/basic_json/find/ |
22810 | | iterator find(const typename object_t::key_type& key) |
22811 | | { |
22812 | | auto result = end(); |
22813 | | |
22814 | | if (is_object()) |
22815 | | { |
22816 | | result.m_it.object_iterator = m_data.m_value.object->find(key); |
22817 | | } |
22818 | | |
22819 | | return result; |
22820 | | } |
22821 | | |
22822 | | /// @brief find an element in a JSON object |
22823 | | /// @sa https://json.nlohmann.me/api/basic_json/find/ |
22824 | | const_iterator find(const typename object_t::key_type& key) const |
22825 | | { |
22826 | | auto result = cend(); |
22827 | | |
22828 | | if (is_object()) |
22829 | | { |
22830 | | result.m_it.object_iterator = m_data.m_value.object->find(key); |
22831 | | } |
22832 | | |
22833 | | return result; |
22834 | | } |
22835 | | |
22836 | | /// @brief find an element in a JSON object |
22837 | | /// @sa https://json.nlohmann.me/api/basic_json/find/ |
22838 | | template<class KeyType, detail::enable_if_t< |
22839 | | detail::is_usable_as_basic_json_key_type<basic_json_t, KeyType>::value, int> = 0> |
22840 | | iterator find(KeyType && key) |
22841 | | { |
22842 | | auto result = end(); |
22843 | | |
22844 | | if (is_object()) |
22845 | | { |
22846 | | result.m_it.object_iterator = m_data.m_value.object->find(std::forward<KeyType>(key)); |
22847 | | } |
22848 | | |
22849 | | return result; |
22850 | | } |
22851 | | |
22852 | | /// @brief find an element in a JSON object |
22853 | | /// @sa https://json.nlohmann.me/api/basic_json/find/ |
22854 | | template<class KeyType, detail::enable_if_t< |
22855 | | detail::is_usable_as_basic_json_key_type<basic_json_t, KeyType>::value, int> = 0> |
22856 | | const_iterator find(KeyType && key) const |
22857 | | { |
22858 | | auto result = cend(); |
22859 | | |
22860 | | if (is_object()) |
22861 | | { |
22862 | | result.m_it.object_iterator = m_data.m_value.object->find(std::forward<KeyType>(key)); |
22863 | | } |
22864 | | |
22865 | | return result; |
22866 | | } |
22867 | | |
22868 | | /// @brief returns the number of occurrences of a key in a JSON object |
22869 | | /// @sa https://json.nlohmann.me/api/basic_json/count/ |
22870 | | size_type count(const typename object_t::key_type& key) const |
22871 | | { |
22872 | | // return 0 for all nonobject types |
22873 | | return is_object() ? m_data.m_value.object->count(key) : 0; |
22874 | | } |
22875 | | |
22876 | | /// @brief returns the number of occurrences of a key in a JSON object |
22877 | | /// @sa https://json.nlohmann.me/api/basic_json/count/ |
22878 | | template<class KeyType, detail::enable_if_t< |
22879 | | detail::is_usable_as_basic_json_key_type<basic_json_t, KeyType>::value, int> = 0> |
22880 | | size_type count(KeyType && key) const |
22881 | | { |
22882 | | // return 0 for all nonobject types |
22883 | | return is_object() ? m_data.m_value.object->count(std::forward<KeyType>(key)) : 0; |
22884 | | } |
22885 | | |
22886 | | /// @brief check the existence of an element in a JSON object |
22887 | | /// @sa https://json.nlohmann.me/api/basic_json/contains/ |
22888 | | bool contains(const typename object_t::key_type& key) const |
22889 | | { |
22890 | | return is_object() && m_data.m_value.object->find(key) != m_data.m_value.object->end(); |
22891 | | } |
22892 | | |
22893 | | /// @brief check the existence of an element in a JSON object |
22894 | | /// @sa https://json.nlohmann.me/api/basic_json/contains/ |
22895 | | template<class KeyType, detail::enable_if_t< |
22896 | | detail::is_usable_as_basic_json_key_type<basic_json_t, KeyType>::value, int> = 0> |
22897 | | bool contains(KeyType && key) const |
22898 | | { |
22899 | | return is_object() && m_data.m_value.object->find(std::forward<KeyType>(key)) != m_data.m_value.object->end(); |
22900 | | } |
22901 | | |
22902 | | /// @brief check the existence of an element in a JSON object given a JSON pointer |
22903 | | /// @sa https://json.nlohmann.me/api/basic_json/contains/ |
22904 | | bool contains(const json_pointer& ptr) const |
22905 | | { |
22906 | | return ptr.contains(this); |
22907 | | } |
22908 | | |
22909 | | template<typename BasicJsonType, detail::enable_if_t<detail::is_basic_json<BasicJsonType>::value, int> = 0> |
22910 | | JSON_HEDLEY_DEPRECATED_FOR(3.11.0, basic_json::json_pointer or nlohmann::json_pointer<basic_json::string_t>) // NOLINT(readability/alt_tokens) |
22911 | | bool contains(const typename ::nlohmann::json_pointer<BasicJsonType>& ptr) const |
22912 | | { |
22913 | | return ptr.contains(this); |
22914 | | } |
22915 | | |
22916 | | /// @} |
22917 | | |
22918 | | /////////////// |
22919 | | // iterators // |
22920 | | /////////////// |
22921 | | |
22922 | | /// @name iterators |
22923 | | /// @{ |
22924 | | |
22925 | | /// @brief returns an iterator to the first element |
22926 | | /// @sa https://json.nlohmann.me/api/basic_json/begin/ |
22927 | | iterator begin() noexcept |
22928 | 0 | { |
22929 | 0 | iterator result(this); |
22930 | 0 | result.set_begin(); |
22931 | 0 | return result; |
22932 | 0 | } |
22933 | | |
22934 | | /// @brief returns an iterator to the first element |
22935 | | /// @sa https://json.nlohmann.me/api/basic_json/begin/ |
22936 | | const_iterator begin() const noexcept |
22937 | 0 | { |
22938 | 0 | return cbegin(); |
22939 | 0 | } |
22940 | | |
22941 | | /// @brief returns a const iterator to the first element |
22942 | | /// @sa https://json.nlohmann.me/api/basic_json/cbegin/ |
22943 | | const_iterator cbegin() const noexcept |
22944 | 0 | { |
22945 | 0 | const_iterator result(this); |
22946 | 0 | result.set_begin(); |
22947 | 0 | return result; |
22948 | 0 | } |
22949 | | |
22950 | | /// @brief returns an iterator to one past the last element |
22951 | | /// @sa https://json.nlohmann.me/api/basic_json/end/ |
22952 | | iterator end() noexcept |
22953 | 0 | { |
22954 | 0 | iterator result(this); |
22955 | 0 | result.set_end(); |
22956 | 0 | return result; |
22957 | 0 | } |
22958 | | |
22959 | | /// @brief returns an iterator to one past the last element |
22960 | | /// @sa https://json.nlohmann.me/api/basic_json/end/ |
22961 | | const_iterator end() const noexcept |
22962 | 0 | { |
22963 | 0 | return cend(); |
22964 | 0 | } |
22965 | | |
22966 | | /// @brief returns an iterator to one past the last element |
22967 | | /// @sa https://json.nlohmann.me/api/basic_json/cend/ |
22968 | | const_iterator cend() const noexcept |
22969 | 0 | { |
22970 | 0 | const_iterator result(this); |
22971 | 0 | result.set_end(); |
22972 | 0 | return result; |
22973 | 0 | } |
22974 | | |
22975 | | /// @brief returns an iterator to the reverse-beginning |
22976 | | /// @sa https://json.nlohmann.me/api/basic_json/rbegin/ |
22977 | | reverse_iterator rbegin() noexcept |
22978 | | { |
22979 | | return reverse_iterator(end()); |
22980 | | } |
22981 | | |
22982 | | /// @brief returns an iterator to the reverse-beginning |
22983 | | /// @sa https://json.nlohmann.me/api/basic_json/rbegin/ |
22984 | | const_reverse_iterator rbegin() const noexcept |
22985 | | { |
22986 | | return crbegin(); |
22987 | | } |
22988 | | |
22989 | | /// @brief returns an iterator to the reverse-end |
22990 | | /// @sa https://json.nlohmann.me/api/basic_json/rend/ |
22991 | | reverse_iterator rend() noexcept |
22992 | | { |
22993 | | return reverse_iterator(begin()); |
22994 | | } |
22995 | | |
22996 | | /// @brief returns an iterator to the reverse-end |
22997 | | /// @sa https://json.nlohmann.me/api/basic_json/rend/ |
22998 | | const_reverse_iterator rend() const noexcept |
22999 | | { |
23000 | | return crend(); |
23001 | | } |
23002 | | |
23003 | | /// @brief returns a const reverse iterator to the last element |
23004 | | /// @sa https://json.nlohmann.me/api/basic_json/crbegin/ |
23005 | | const_reverse_iterator crbegin() const noexcept |
23006 | | { |
23007 | | return const_reverse_iterator(cend()); |
23008 | | } |
23009 | | |
23010 | | /// @brief returns a const reverse iterator to one before the first |
23011 | | /// @sa https://json.nlohmann.me/api/basic_json/crend/ |
23012 | | const_reverse_iterator crend() const noexcept |
23013 | | { |
23014 | | return const_reverse_iterator(cbegin()); |
23015 | | } |
23016 | | |
23017 | | public: |
23018 | | /// @brief wrapper to access iterator member functions in range-based for |
23019 | | /// @sa https://json.nlohmann.me/api/basic_json/items/ |
23020 | | /// @deprecated This function is deprecated since 3.1.0 and will be removed in |
23021 | | /// version 4.0.0 of the library. Please use @ref items() instead; |
23022 | | /// that is, replace `json::iterator_wrapper(j)` with `j.items()`. |
23023 | | JSON_HEDLEY_DEPRECATED_FOR(3.1.0, items()) |
23024 | | static iteration_proxy<iterator> iterator_wrapper(reference ref) noexcept |
23025 | | { |
23026 | | return ref.items(); |
23027 | | } |
23028 | | |
23029 | | /// @brief wrapper to access iterator member functions in range-based for |
23030 | | /// @sa https://json.nlohmann.me/api/basic_json/items/ |
23031 | | /// @deprecated This function is deprecated since 3.1.0 and will be removed in |
23032 | | /// version 4.0.0 of the library. Please use @ref items() instead; |
23033 | | /// that is, replace `json::iterator_wrapper(j)` with `j.items()`. |
23034 | | JSON_HEDLEY_DEPRECATED_FOR(3.1.0, items()) |
23035 | | static iteration_proxy<const_iterator> iterator_wrapper(const_reference ref) noexcept |
23036 | | { |
23037 | | return ref.items(); |
23038 | | } |
23039 | | |
23040 | | /// @brief helper to access iterator member functions in range-based for |
23041 | | /// @sa https://json.nlohmann.me/api/basic_json/items/ |
23042 | | iteration_proxy<iterator> items() noexcept |
23043 | | { |
23044 | | return iteration_proxy<iterator>(*this); |
23045 | | } |
23046 | | |
23047 | | /// @brief helper to access iterator member functions in range-based for |
23048 | | /// @sa https://json.nlohmann.me/api/basic_json/items/ |
23049 | | iteration_proxy<const_iterator> items() const noexcept |
23050 | | { |
23051 | | return iteration_proxy<const_iterator>(*this); |
23052 | | } |
23053 | | |
23054 | | /// @} |
23055 | | |
23056 | | ////////////// |
23057 | | // capacity // |
23058 | | ////////////// |
23059 | | |
23060 | | /// @name capacity |
23061 | | /// @{ |
23062 | | |
23063 | | /// @brief checks whether the container is empty. |
23064 | | /// @sa https://json.nlohmann.me/api/basic_json/empty/ |
23065 | | bool empty() const noexcept |
23066 | | { |
23067 | | switch (m_data.m_type) |
23068 | | { |
23069 | | case value_t::null: |
23070 | | { |
23071 | | // null values are empty |
23072 | | return true; |
23073 | | } |
23074 | | |
23075 | | case value_t::array: |
23076 | | { |
23077 | | // delegate call to array_t::empty() |
23078 | | return m_data.m_value.array->empty(); |
23079 | | } |
23080 | | |
23081 | | case value_t::object: |
23082 | | { |
23083 | | // delegate call to object_t::empty() |
23084 | | return m_data.m_value.object->empty(); |
23085 | | } |
23086 | | |
23087 | | case value_t::string: |
23088 | | case value_t::boolean: |
23089 | | case value_t::number_integer: |
23090 | | case value_t::number_unsigned: |
23091 | | case value_t::number_float: |
23092 | | case value_t::binary: |
23093 | | case value_t::discarded: |
23094 | | default: |
23095 | | { |
23096 | | // all other types are nonempty |
23097 | | return false; |
23098 | | } |
23099 | | } |
23100 | | } |
23101 | | |
23102 | | /// @brief returns the number of elements |
23103 | | /// @sa https://json.nlohmann.me/api/basic_json/size/ |
23104 | | size_type size() const noexcept |
23105 | 0 | { |
23106 | 0 | switch (m_data.m_type) |
23107 | 0 | { |
23108 | 0 | case value_t::null: |
23109 | 0 | { |
23110 | | // null values are empty |
23111 | 0 | return 0; |
23112 | 0 | } |
23113 | | |
23114 | 0 | case value_t::array: |
23115 | 0 | { |
23116 | | // delegate call to array_t::size() |
23117 | 0 | return m_data.m_value.array->size(); |
23118 | 0 | } |
23119 | | |
23120 | 0 | case value_t::object: |
23121 | 0 | { |
23122 | | // delegate call to object_t::size() |
23123 | 0 | return m_data.m_value.object->size(); |
23124 | 0 | } |
23125 | | |
23126 | 0 | case value_t::string: |
23127 | 0 | case value_t::boolean: |
23128 | 0 | case value_t::number_integer: |
23129 | 0 | case value_t::number_unsigned: |
23130 | 0 | case value_t::number_float: |
23131 | 0 | case value_t::binary: |
23132 | 0 | case value_t::discarded: |
23133 | 0 | default: |
23134 | 0 | { |
23135 | | // all other types have size 1 |
23136 | 0 | return 1; |
23137 | 0 | } |
23138 | 0 | } |
23139 | 0 | } |
23140 | | |
23141 | | /// @brief returns the maximum possible number of elements |
23142 | | /// @sa https://json.nlohmann.me/api/basic_json/max_size/ |
23143 | | size_type max_size() const noexcept |
23144 | 0 | { |
23145 | 0 | switch (m_data.m_type) |
23146 | 0 | { |
23147 | 0 | case value_t::array: |
23148 | 0 | { |
23149 | | // delegate call to array_t::max_size() |
23150 | 0 | return m_data.m_value.array->max_size(); |
23151 | 0 | } |
23152 | | |
23153 | 0 | case value_t::object: |
23154 | 0 | { |
23155 | | // delegate call to object_t::max_size() |
23156 | 0 | return m_data.m_value.object->max_size(); |
23157 | 0 | } |
23158 | | |
23159 | 0 | case value_t::null: |
23160 | 0 | case value_t::string: |
23161 | 0 | case value_t::boolean: |
23162 | 0 | case value_t::number_integer: |
23163 | 0 | case value_t::number_unsigned: |
23164 | 0 | case value_t::number_float: |
23165 | 0 | case value_t::binary: |
23166 | 0 | case value_t::discarded: |
23167 | 0 | default: |
23168 | 0 | { |
23169 | | // all other types have max_size() == size() |
23170 | 0 | return size(); |
23171 | 0 | } |
23172 | 0 | } |
23173 | 0 | } |
23174 | | |
23175 | | /// @} |
23176 | | |
23177 | | /////////////// |
23178 | | // modifiers // |
23179 | | /////////////// |
23180 | | |
23181 | | /// @name modifiers |
23182 | | /// @{ |
23183 | | |
23184 | | /// @brief clears the contents |
23185 | | /// @sa https://json.nlohmann.me/api/basic_json/clear/ |
23186 | | void clear() noexcept |
23187 | | { |
23188 | | switch (m_data.m_type) |
23189 | | { |
23190 | | case value_t::number_integer: |
23191 | | { |
23192 | | m_data.m_value.number_integer = 0; |
23193 | | break; |
23194 | | } |
23195 | | |
23196 | | case value_t::number_unsigned: |
23197 | | { |
23198 | | m_data.m_value.number_unsigned = 0; |
23199 | | break; |
23200 | | } |
23201 | | |
23202 | | case value_t::number_float: |
23203 | | { |
23204 | | m_data.m_value.number_float = 0.0; |
23205 | | break; |
23206 | | } |
23207 | | |
23208 | | case value_t::boolean: |
23209 | | { |
23210 | | m_data.m_value.boolean = false; |
23211 | | break; |
23212 | | } |
23213 | | |
23214 | | case value_t::string: |
23215 | | { |
23216 | | m_data.m_value.string->clear(); |
23217 | | break; |
23218 | | } |
23219 | | |
23220 | | case value_t::binary: |
23221 | | { |
23222 | | m_data.m_value.binary->clear(); |
23223 | | break; |
23224 | | } |
23225 | | |
23226 | | case value_t::array: |
23227 | | { |
23228 | | m_data.m_value.array->clear(); |
23229 | | break; |
23230 | | } |
23231 | | |
23232 | | case value_t::object: |
23233 | | { |
23234 | | m_data.m_value.object->clear(); |
23235 | | break; |
23236 | | } |
23237 | | |
23238 | | case value_t::null: |
23239 | | case value_t::discarded: |
23240 | | default: |
23241 | | break; |
23242 | | } |
23243 | | } |
23244 | | |
23245 | | /// @brief add an object to an array |
23246 | | /// @sa https://json.nlohmann.me/api/basic_json/push_back/ |
23247 | | void push_back(basic_json&& val) |
23248 | | { |
23249 | | // push_back only works for null objects or arrays |
23250 | | if (JSON_HEDLEY_UNLIKELY(!(is_null() || is_array()))) |
23251 | | { |
23252 | | JSON_THROW(type_error::create(308, detail::concat("cannot use push_back() with ", type_name()), this)); |
23253 | | } |
23254 | | |
23255 | | // transform a null object into an array |
23256 | | if (is_null()) |
23257 | | { |
23258 | | m_data.m_type = value_t::array; |
23259 | | m_data.m_value = value_t::array; |
23260 | | assert_invariant(); |
23261 | | } |
23262 | | |
23263 | | // add the element to the array (move semantics) |
23264 | | const auto old_capacity = m_data.m_value.array->capacity(); |
23265 | | m_data.m_value.array->push_back(std::move(val)); |
23266 | | set_parent(m_data.m_value.array->back(), old_capacity); |
23267 | | // if val is moved from, basic_json move constructor marks it null, so we do not call the destructor |
23268 | | } |
23269 | | |
23270 | | /// @brief add an object to an array |
23271 | | /// @sa https://json.nlohmann.me/api/basic_json/operator+=/ |
23272 | | reference operator+=(basic_json&& val) |
23273 | | { |
23274 | | push_back(std::move(val)); |
23275 | | return *this; |
23276 | | } |
23277 | | |
23278 | | /// @brief add an object to an array |
23279 | | /// @sa https://json.nlohmann.me/api/basic_json/push_back/ |
23280 | | void push_back(const basic_json& val) |
23281 | 0 | { |
23282 | | // push_back only works for null objects or arrays |
23283 | 0 | if (JSON_HEDLEY_UNLIKELY(!(is_null() || is_array()))) |
23284 | 0 | { |
23285 | 0 | JSON_THROW(type_error::create(308, detail::concat("cannot use push_back() with ", type_name()), this)); |
23286 | 0 | } |
23287 | | |
23288 | | // transform a null object into an array |
23289 | 0 | if (is_null()) |
23290 | 0 | { |
23291 | 0 | m_data.m_type = value_t::array; |
23292 | 0 | m_data.m_value = value_t::array; |
23293 | 0 | assert_invariant(); |
23294 | 0 | } |
23295 | | |
23296 | | // add the element to the array |
23297 | 0 | const auto old_capacity = m_data.m_value.array->capacity(); |
23298 | 0 | m_data.m_value.array->push_back(val); |
23299 | 0 | set_parent(m_data.m_value.array->back(), old_capacity); |
23300 | 0 | } |
23301 | | |
23302 | | /// @brief add an object to an array |
23303 | | /// @sa https://json.nlohmann.me/api/basic_json/operator+=/ |
23304 | | reference operator+=(const basic_json& val) |
23305 | | { |
23306 | | push_back(val); |
23307 | | return *this; |
23308 | | } |
23309 | | |
23310 | | /// @brief add an object to an object |
23311 | | /// @sa https://json.nlohmann.me/api/basic_json/push_back/ |
23312 | | void push_back(const typename object_t::value_type& val) |
23313 | | { |
23314 | | // push_back only works for null objects or objects |
23315 | | if (JSON_HEDLEY_UNLIKELY(!(is_null() || is_object()))) |
23316 | | { |
23317 | | JSON_THROW(type_error::create(308, detail::concat("cannot use push_back() with ", type_name()), this)); |
23318 | | } |
23319 | | |
23320 | | // transform a null object into an object |
23321 | | if (is_null()) |
23322 | | { |
23323 | | m_data.m_type = value_t::object; |
23324 | | m_data.m_value = value_t::object; |
23325 | | assert_invariant(); |
23326 | | } |
23327 | | |
23328 | | // add the element to the object |
23329 | | auto res = m_data.m_value.object->insert(val); |
23330 | | set_parent(res.first->second); |
23331 | | } |
23332 | | |
23333 | | /// @brief add an object to an object |
23334 | | /// @sa https://json.nlohmann.me/api/basic_json/operator+=/ |
23335 | | reference operator+=(const typename object_t::value_type& val) |
23336 | | { |
23337 | | push_back(val); |
23338 | | return *this; |
23339 | | } |
23340 | | |
23341 | | /// @brief add an object to an object |
23342 | | /// @sa https://json.nlohmann.me/api/basic_json/push_back/ |
23343 | | void push_back(initializer_list_t init) |
23344 | | { |
23345 | | if (is_object() && init.size() == 2 && (*init.begin())->is_string()) |
23346 | | { |
23347 | | basic_json&& key = init.begin()->moved_or_copied(); |
23348 | | push_back(typename object_t::value_type( |
23349 | | std::move(key.get_ref<string_t&>()), (init.begin() + 1)->moved_or_copied())); |
23350 | | } |
23351 | | else |
23352 | | { |
23353 | | push_back(basic_json(init)); |
23354 | | } |
23355 | | } |
23356 | | |
23357 | | /// @brief add an object to an object |
23358 | | /// @sa https://json.nlohmann.me/api/basic_json/operator+=/ |
23359 | | reference operator+=(initializer_list_t init) |
23360 | | { |
23361 | | push_back(init); |
23362 | | return *this; |
23363 | | } |
23364 | | |
23365 | | /// @brief add an object to an array |
23366 | | /// @sa https://json.nlohmann.me/api/basic_json/emplace_back/ |
23367 | | template<class... Args> |
23368 | | reference emplace_back(Args&& ... args) |
23369 | | { |
23370 | | // emplace_back only works for null objects or arrays |
23371 | | if (JSON_HEDLEY_UNLIKELY(!(is_null() || is_array()))) |
23372 | | { |
23373 | | JSON_THROW(type_error::create(311, detail::concat("cannot use emplace_back() with ", type_name()), this)); |
23374 | | } |
23375 | | |
23376 | | // transform a null object into an array |
23377 | | if (is_null()) |
23378 | | { |
23379 | | m_data.m_type = value_t::array; |
23380 | | m_data.m_value = value_t::array; |
23381 | | assert_invariant(); |
23382 | | } |
23383 | | |
23384 | | // add the element to the array (perfect forwarding) |
23385 | | const auto old_capacity = m_data.m_value.array->capacity(); |
23386 | | m_data.m_value.array->emplace_back(std::forward<Args>(args)...); |
23387 | | return set_parent(m_data.m_value.array->back(), old_capacity); |
23388 | | } |
23389 | | |
23390 | | /// @brief add an object to an object if key does not exist |
23391 | | /// @sa https://json.nlohmann.me/api/basic_json/emplace/ |
23392 | | template<class... Args> |
23393 | | std::pair<iterator, bool> emplace(Args&& ... args) |
23394 | | { |
23395 | | // emplace only works for null objects or arrays |
23396 | | if (JSON_HEDLEY_UNLIKELY(!(is_null() || is_object()))) |
23397 | | { |
23398 | | JSON_THROW(type_error::create(311, detail::concat("cannot use emplace() with ", type_name()), this)); |
23399 | | } |
23400 | | |
23401 | | // transform a null object into an object |
23402 | | if (is_null()) |
23403 | | { |
23404 | | m_data.m_type = value_t::object; |
23405 | | m_data.m_value = value_t::object; |
23406 | | assert_invariant(); |
23407 | | } |
23408 | | |
23409 | | // add the element to the array (perfect forwarding) |
23410 | | auto res = m_data.m_value.object->emplace(std::forward<Args>(args)...); |
23411 | | set_parent(res.first->second); |
23412 | | |
23413 | | // create a result iterator and set iterator to the result of emplace |
23414 | | auto it = begin(); |
23415 | | it.m_it.object_iterator = res.first; |
23416 | | |
23417 | | // return pair of iterator and boolean |
23418 | | return {it, res.second}; |
23419 | | } |
23420 | | |
23421 | | /// Helper for insertion of an iterator |
23422 | | /// @note: This uses std::distance to support GCC 4.8, |
23423 | | /// see https://github.com/nlohmann/json/pull/1257 |
23424 | | template<typename... Args> |
23425 | | iterator insert_iterator(const_iterator pos, Args&& ... args) // NOLINT(performance-unnecessary-value-param) |
23426 | | { |
23427 | | iterator result(this); |
23428 | | JSON_ASSERT(m_data.m_value.array != nullptr); |
23429 | | |
23430 | | auto insert_pos = std::distance(m_data.m_value.array->begin(), pos.m_it.array_iterator); |
23431 | | m_data.m_value.array->insert(pos.m_it.array_iterator, std::forward<Args>(args)...); |
23432 | | result.m_it.array_iterator = m_data.m_value.array->begin() + insert_pos; |
23433 | | |
23434 | | // This could have been written as: |
23435 | | // result.m_it.array_iterator = m_data.m_value.array->insert(pos.m_it.array_iterator, cnt, val); |
23436 | | // but the return value of insert is missing in GCC 4.8, so it is written this way instead. |
23437 | | |
23438 | | set_parents(); |
23439 | | return result; |
23440 | | } |
23441 | | |
23442 | | /// @brief inserts element into array |
23443 | | /// @sa https://json.nlohmann.me/api/basic_json/insert/ |
23444 | | iterator insert(const_iterator pos, const basic_json& val) // NOLINT(performance-unnecessary-value-param) |
23445 | | { |
23446 | | // insert only works for arrays |
23447 | | if (JSON_HEDLEY_LIKELY(is_array())) |
23448 | | { |
23449 | | // check if iterator pos fits to this JSON value |
23450 | | if (JSON_HEDLEY_UNLIKELY(pos.m_object != this)) |
23451 | | { |
23452 | | JSON_THROW(invalid_iterator::create(202, "iterator does not fit current value", this)); |
23453 | | } |
23454 | | |
23455 | | // insert to array and return iterator |
23456 | | return insert_iterator(pos, val); |
23457 | | } |
23458 | | |
23459 | | JSON_THROW(type_error::create(309, detail::concat("cannot use insert() with ", type_name()), this)); |
23460 | | } |
23461 | | |
23462 | | /// @brief inserts element into array |
23463 | | /// @sa https://json.nlohmann.me/api/basic_json/insert/ |
23464 | | iterator insert(const_iterator pos, basic_json&& val) // NOLINT(performance-unnecessary-value-param) |
23465 | | { |
23466 | | return insert(pos, val); |
23467 | | } |
23468 | | |
23469 | | /// @brief inserts copies of element into array |
23470 | | /// @sa https://json.nlohmann.me/api/basic_json/insert/ |
23471 | | iterator insert(const_iterator pos, size_type cnt, const basic_json& val) // NOLINT(performance-unnecessary-value-param) |
23472 | | { |
23473 | | // insert only works for arrays |
23474 | | if (JSON_HEDLEY_LIKELY(is_array())) |
23475 | | { |
23476 | | // check if iterator pos fits to this JSON value |
23477 | | if (JSON_HEDLEY_UNLIKELY(pos.m_object != this)) |
23478 | | { |
23479 | | JSON_THROW(invalid_iterator::create(202, "iterator does not fit current value", this)); |
23480 | | } |
23481 | | |
23482 | | // insert to array and return iterator |
23483 | | return insert_iterator(pos, cnt, val); |
23484 | | } |
23485 | | |
23486 | | JSON_THROW(type_error::create(309, detail::concat("cannot use insert() with ", type_name()), this)); |
23487 | | } |
23488 | | |
23489 | | /// @brief inserts range of elements into array |
23490 | | /// @sa https://json.nlohmann.me/api/basic_json/insert/ |
23491 | | iterator insert(const_iterator pos, const_iterator first, const_iterator last) // NOLINT(performance-unnecessary-value-param) |
23492 | | { |
23493 | | // insert only works for arrays |
23494 | | if (JSON_HEDLEY_UNLIKELY(!is_array())) |
23495 | | { |
23496 | | JSON_THROW(type_error::create(309, detail::concat("cannot use insert() with ", type_name()), this)); |
23497 | | } |
23498 | | |
23499 | | // check if iterator pos fits to this JSON value |
23500 | | if (JSON_HEDLEY_UNLIKELY(pos.m_object != this)) |
23501 | | { |
23502 | | JSON_THROW(invalid_iterator::create(202, "iterator does not fit current value", this)); |
23503 | | } |
23504 | | |
23505 | | // check if range iterators belong to the same JSON object |
23506 | | if (JSON_HEDLEY_UNLIKELY(first.m_object != last.m_object)) |
23507 | | { |
23508 | | JSON_THROW(invalid_iterator::create(210, "iterators do not fit", this)); |
23509 | | } |
23510 | | |
23511 | | if (JSON_HEDLEY_UNLIKELY(first.m_object == this)) |
23512 | | { |
23513 | | JSON_THROW(invalid_iterator::create(211, "passed iterators may not belong to container", this)); |
23514 | | } |
23515 | | |
23516 | | // insert to array and return iterator |
23517 | | return insert_iterator(pos, first.m_it.array_iterator, last.m_it.array_iterator); |
23518 | | } |
23519 | | |
23520 | | /// @brief inserts elements from initializer list into array |
23521 | | /// @sa https://json.nlohmann.me/api/basic_json/insert/ |
23522 | | iterator insert(const_iterator pos, initializer_list_t ilist) // NOLINT(performance-unnecessary-value-param) |
23523 | | { |
23524 | | // insert only works for arrays |
23525 | | if (JSON_HEDLEY_UNLIKELY(!is_array())) |
23526 | | { |
23527 | | JSON_THROW(type_error::create(309, detail::concat("cannot use insert() with ", type_name()), this)); |
23528 | | } |
23529 | | |
23530 | | // check if iterator pos fits to this JSON value |
23531 | | if (JSON_HEDLEY_UNLIKELY(pos.m_object != this)) |
23532 | | { |
23533 | | JSON_THROW(invalid_iterator::create(202, "iterator does not fit current value", this)); |
23534 | | } |
23535 | | |
23536 | | // insert to array and return iterator |
23537 | | return insert_iterator(pos, ilist.begin(), ilist.end()); |
23538 | | } |
23539 | | |
23540 | | /// @brief inserts range of elements into object |
23541 | | /// @sa https://json.nlohmann.me/api/basic_json/insert/ |
23542 | | void insert(const_iterator first, const_iterator last) // NOLINT(performance-unnecessary-value-param) |
23543 | | { |
23544 | | // insert only works for objects |
23545 | | if (JSON_HEDLEY_UNLIKELY(!is_object())) |
23546 | | { |
23547 | | JSON_THROW(type_error::create(309, detail::concat("cannot use insert() with ", type_name()), this)); |
23548 | | } |
23549 | | |
23550 | | // check if range iterators belong to the same JSON object |
23551 | | if (JSON_HEDLEY_UNLIKELY(first.m_object != last.m_object)) |
23552 | | { |
23553 | | JSON_THROW(invalid_iterator::create(210, "iterators do not fit", this)); |
23554 | | } |
23555 | | |
23556 | | // passed iterators must belong to objects |
23557 | | if (JSON_HEDLEY_UNLIKELY(!first.m_object->is_object())) |
23558 | | { |
23559 | | JSON_THROW(invalid_iterator::create(202, "iterators first and last must point to objects", this)); |
23560 | | } |
23561 | | |
23562 | | m_data.m_value.object->insert(first.m_it.object_iterator, last.m_it.object_iterator); |
23563 | | set_parents(); |
23564 | | } |
23565 | | |
23566 | | /// @brief updates a JSON object from another object, overwriting existing keys |
23567 | | /// @sa https://json.nlohmann.me/api/basic_json/update/ |
23568 | | void update(const_reference j, bool merge_objects = false) |
23569 | | { |
23570 | | update(j.begin(), j.end(), merge_objects); |
23571 | | } |
23572 | | |
23573 | | /// @brief updates a JSON object from another object, overwriting existing keys |
23574 | | /// @sa https://json.nlohmann.me/api/basic_json/update/ |
23575 | | void update(const_iterator first, const_iterator last, bool merge_objects = false) // NOLINT(performance-unnecessary-value-param) |
23576 | | { |
23577 | | // implicitly convert a null value to an empty object |
23578 | | if (is_null()) |
23579 | | { |
23580 | | m_data.m_type = value_t::object; |
23581 | | m_data.m_value.object = create<object_t>(); |
23582 | | assert_invariant(); |
23583 | | } |
23584 | | |
23585 | | if (JSON_HEDLEY_UNLIKELY(!is_object())) |
23586 | | { |
23587 | | JSON_THROW(type_error::create(312, detail::concat("cannot use update() with ", type_name()), this)); |
23588 | | } |
23589 | | |
23590 | | // check if range iterators belong to the same JSON object |
23591 | | if (JSON_HEDLEY_UNLIKELY(first.m_object != last.m_object)) |
23592 | | { |
23593 | | JSON_THROW(invalid_iterator::create(210, "iterators do not fit", this)); |
23594 | | } |
23595 | | |
23596 | | // passed iterators must belong to objects |
23597 | | if (JSON_HEDLEY_UNLIKELY(!first.m_object->is_object())) |
23598 | | { |
23599 | | JSON_THROW(type_error::create(312, detail::concat("cannot use update() with ", first.m_object->type_name()), first.m_object)); |
23600 | | } |
23601 | | |
23602 | | for (auto it = first; it != last; ++it) |
23603 | | { |
23604 | | if (merge_objects && it.value().is_object()) |
23605 | | { |
23606 | | auto it2 = m_data.m_value.object->find(it.key()); |
23607 | | if (it2 != m_data.m_value.object->end()) |
23608 | | { |
23609 | | it2->second.update(it.value(), true); |
23610 | | continue; |
23611 | | } |
23612 | | } |
23613 | | m_data.m_value.object->operator[](it.key()) = it.value(); |
23614 | | #if JSON_DIAGNOSTICS |
23615 | | m_data.m_value.object->operator[](it.key()).m_parent = this; |
23616 | | #endif |
23617 | | } |
23618 | | } |
23619 | | |
23620 | | /// @brief exchanges the values |
23621 | | /// @sa https://json.nlohmann.me/api/basic_json/swap/ |
23622 | | void swap(reference other) noexcept ( |
23623 | | std::is_nothrow_move_constructible<value_t>::value&& |
23624 | | std::is_nothrow_move_assignable<value_t>::value&& |
23625 | | std::is_nothrow_move_constructible<json_value>::value&& // NOLINT(cppcoreguidelines-noexcept-swap,performance-noexcept-swap) |
23626 | | std::is_nothrow_move_assignable<json_value>::value |
23627 | | ) |
23628 | | { |
23629 | | std::swap(m_data.m_type, other.m_data.m_type); |
23630 | | std::swap(m_data.m_value, other.m_data.m_value); |
23631 | | |
23632 | | set_parents(); |
23633 | | other.set_parents(); |
23634 | | assert_invariant(); |
23635 | | } |
23636 | | |
23637 | | /// @brief exchanges the values |
23638 | | /// @sa https://json.nlohmann.me/api/basic_json/swap/ |
23639 | | friend void swap(reference left, reference right) noexcept ( |
23640 | | std::is_nothrow_move_constructible<value_t>::value&& |
23641 | | std::is_nothrow_move_assignable<value_t>::value&& |
23642 | | std::is_nothrow_move_constructible<json_value>::value&& // NOLINT(cppcoreguidelines-noexcept-swap,performance-noexcept-swap) |
23643 | | std::is_nothrow_move_assignable<json_value>::value |
23644 | | ) |
23645 | | { |
23646 | | left.swap(right); |
23647 | | } |
23648 | | |
23649 | | /// @brief exchanges the values |
23650 | | /// @sa https://json.nlohmann.me/api/basic_json/swap/ |
23651 | | void swap(array_t& other) // NOLINT(bugprone-exception-escape,cppcoreguidelines-noexcept-swap,performance-noexcept-swap) |
23652 | | { |
23653 | | // swap only works for arrays |
23654 | | if (JSON_HEDLEY_LIKELY(is_array())) |
23655 | | { |
23656 | | using std::swap; |
23657 | | swap(*(m_data.m_value.array), other); |
23658 | | } |
23659 | | else |
23660 | | { |
23661 | | JSON_THROW(type_error::create(310, detail::concat("cannot use swap(array_t&) with ", type_name()), this)); |
23662 | | } |
23663 | | } |
23664 | | |
23665 | | /// @brief exchanges the values |
23666 | | /// @sa https://json.nlohmann.me/api/basic_json/swap/ |
23667 | | void swap(object_t& other) // NOLINT(bugprone-exception-escape,cppcoreguidelines-noexcept-swap,performance-noexcept-swap) |
23668 | | { |
23669 | | // swap only works for objects |
23670 | | if (JSON_HEDLEY_LIKELY(is_object())) |
23671 | | { |
23672 | | using std::swap; |
23673 | | swap(*(m_data.m_value.object), other); |
23674 | | } |
23675 | | else |
23676 | | { |
23677 | | JSON_THROW(type_error::create(310, detail::concat("cannot use swap(object_t&) with ", type_name()), this)); |
23678 | | } |
23679 | | } |
23680 | | |
23681 | | /// @brief exchanges the values |
23682 | | /// @sa https://json.nlohmann.me/api/basic_json/swap/ |
23683 | | void swap(string_t& other) // NOLINT(bugprone-exception-escape,cppcoreguidelines-noexcept-swap,performance-noexcept-swap) |
23684 | | { |
23685 | | // swap only works for strings |
23686 | | if (JSON_HEDLEY_LIKELY(is_string())) |
23687 | | { |
23688 | | using std::swap; |
23689 | | swap(*(m_data.m_value.string), other); |
23690 | | } |
23691 | | else |
23692 | | { |
23693 | | JSON_THROW(type_error::create(310, detail::concat("cannot use swap(string_t&) with ", type_name()), this)); |
23694 | | } |
23695 | | } |
23696 | | |
23697 | | /// @brief exchanges the values |
23698 | | /// @sa https://json.nlohmann.me/api/basic_json/swap/ |
23699 | | void swap(binary_t& other) // NOLINT(bugprone-exception-escape,cppcoreguidelines-noexcept-swap,performance-noexcept-swap) |
23700 | | { |
23701 | | // swap only works for strings |
23702 | | if (JSON_HEDLEY_LIKELY(is_binary())) |
23703 | | { |
23704 | | using std::swap; |
23705 | | swap(*(m_data.m_value.binary), other); |
23706 | | } |
23707 | | else |
23708 | | { |
23709 | | JSON_THROW(type_error::create(310, detail::concat("cannot use swap(binary_t&) with ", type_name()), this)); |
23710 | | } |
23711 | | } |
23712 | | |
23713 | | /// @brief exchanges the values |
23714 | | /// @sa https://json.nlohmann.me/api/basic_json/swap/ |
23715 | | void swap(typename binary_t::container_type& other) // NOLINT(bugprone-exception-escape) |
23716 | | { |
23717 | | // swap only works for strings |
23718 | | if (JSON_HEDLEY_LIKELY(is_binary())) |
23719 | | { |
23720 | | using std::swap; |
23721 | | swap(*(m_data.m_value.binary), other); |
23722 | | } |
23723 | | else |
23724 | | { |
23725 | | JSON_THROW(type_error::create(310, detail::concat("cannot use swap(binary_t::container_type&) with ", type_name()), this)); |
23726 | | } |
23727 | | } |
23728 | | |
23729 | | /// @} |
23730 | | |
23731 | | ////////////////////////////////////////// |
23732 | | // lexicographical comparison operators // |
23733 | | ////////////////////////////////////////// |
23734 | | |
23735 | | /// @name lexicographical comparison operators |
23736 | | /// @{ |
23737 | | |
23738 | | // note parentheses around operands are necessary; see |
23739 | | // https://github.com/nlohmann/json/issues/1530 |
23740 | | #define JSON_IMPLEMENT_OPERATOR(op, null_result, unordered_result, default_result) \ |
23741 | 0 | const auto lhs_type = lhs.type(); \ |
23742 | 0 | const auto rhs_type = rhs.type(); \ |
23743 | 0 | \ |
23744 | 0 | if (lhs_type == rhs_type) /* NOLINT(readability/braces) */ \ |
23745 | 0 | { \ |
23746 | 0 | switch (lhs_type) \ |
23747 | 0 | { \ |
23748 | 0 | case value_t::array: \ |
23749 | 0 | return (*lhs.m_data.m_value.array) op (*rhs.m_data.m_value.array); \ |
23750 | 0 | \ |
23751 | 0 | case value_t::object: \ |
23752 | 0 | return (*lhs.m_data.m_value.object) op (*rhs.m_data.m_value.object); \ |
23753 | 0 | \ |
23754 | 0 | case value_t::null: \ |
23755 | 0 | return (null_result); \ |
23756 | 0 | \ |
23757 | 0 | case value_t::string: \ |
23758 | 0 | return (*lhs.m_data.m_value.string) op (*rhs.m_data.m_value.string); \ |
23759 | 0 | \ |
23760 | 0 | case value_t::boolean: \ |
23761 | 0 | return (lhs.m_data.m_value.boolean) op (rhs.m_data.m_value.boolean); \ |
23762 | 0 | \ |
23763 | 0 | case value_t::number_integer: \ |
23764 | 0 | return (lhs.m_data.m_value.number_integer) op (rhs.m_data.m_value.number_integer); \ |
23765 | 0 | \ |
23766 | 0 | case value_t::number_unsigned: \ |
23767 | 0 | return (lhs.m_data.m_value.number_unsigned) op (rhs.m_data.m_value.number_unsigned); \ |
23768 | 0 | \ |
23769 | 0 | case value_t::number_float: \ |
23770 | 0 | return (lhs.m_data.m_value.number_float) op (rhs.m_data.m_value.number_float); \ |
23771 | 0 | \ |
23772 | 0 | case value_t::binary: \ |
23773 | 0 | return (*lhs.m_data.m_value.binary) op (*rhs.m_data.m_value.binary); \ |
23774 | 0 | \ |
23775 | 0 | case value_t::discarded: \ |
23776 | 0 | default: \ |
23777 | 0 | return (unordered_result); \ |
23778 | 0 | } \ |
23779 | 0 | } \ |
23780 | 0 | else if (lhs_type == value_t::number_integer && rhs_type == value_t::number_float) \ |
23781 | 0 | { \ |
23782 | 0 | return static_cast<number_float_t>(lhs.m_data.m_value.number_integer) op rhs.m_data.m_value.number_float; \ |
23783 | 0 | } \ |
23784 | 0 | else if (lhs_type == value_t::number_float && rhs_type == value_t::number_integer) \ |
23785 | 0 | { \ |
23786 | 0 | return lhs.m_data.m_value.number_float op static_cast<number_float_t>(rhs.m_data.m_value.number_integer); \ |
23787 | 0 | } \ |
23788 | 0 | else if (lhs_type == value_t::number_unsigned && rhs_type == value_t::number_float) \ |
23789 | 0 | { \ |
23790 | 0 | return static_cast<number_float_t>(lhs.m_data.m_value.number_unsigned) op rhs.m_data.m_value.number_float; \ |
23791 | 0 | } \ |
23792 | 0 | else if (lhs_type == value_t::number_float && rhs_type == value_t::number_unsigned) \ |
23793 | 0 | { \ |
23794 | 0 | return lhs.m_data.m_value.number_float op static_cast<number_float_t>(rhs.m_data.m_value.number_unsigned); \ |
23795 | 0 | } \ |
23796 | 0 | else if (lhs_type == value_t::number_unsigned && rhs_type == value_t::number_integer) \ |
23797 | 0 | { \ |
23798 | 0 | return static_cast<number_integer_t>(lhs.m_data.m_value.number_unsigned) op rhs.m_data.m_value.number_integer; \ |
23799 | 0 | } \ |
23800 | 0 | else if (lhs_type == value_t::number_integer && rhs_type == value_t::number_unsigned) \ |
23801 | 0 | { \ |
23802 | 0 | return lhs.m_data.m_value.number_integer op static_cast<number_integer_t>(rhs.m_data.m_value.number_unsigned); \ |
23803 | 0 | } \ |
23804 | 0 | else if(compares_unordered(lhs, rhs))\ |
23805 | 0 | {\ |
23806 | 0 | return (unordered_result);\ |
23807 | 0 | }\ |
23808 | 0 | \ |
23809 | 0 | return (default_result); |
23810 | | |
23811 | | JSON_PRIVATE_UNLESS_TESTED: |
23812 | | // returns true if: |
23813 | | // - any operand is NaN and the other operand is of number type |
23814 | | // - any operand is discarded |
23815 | | // in legacy mode, discarded values are considered ordered if |
23816 | | // an operation is computed as an odd number of inverses of others |
23817 | | static bool compares_unordered(const_reference lhs, const_reference rhs, bool inverse = false) noexcept |
23818 | 0 | { |
23819 | 0 | if ((lhs.is_number_float() && std::isnan(lhs.m_data.m_value.number_float) && rhs.is_number()) |
23820 | 0 | || (rhs.is_number_float() && std::isnan(rhs.m_data.m_value.number_float) && lhs.is_number())) |
23821 | 0 | { |
23822 | 0 | return true; |
23823 | 0 | } |
23824 | | #if JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON |
23825 | | return (lhs.is_discarded() || rhs.is_discarded()) && !inverse; |
23826 | | #else |
23827 | 0 | static_cast<void>(inverse); |
23828 | 0 | return lhs.is_discarded() || rhs.is_discarded(); |
23829 | 0 | #endif |
23830 | 0 | } |
23831 | | |
23832 | | private: |
23833 | | bool compares_unordered(const_reference rhs, bool inverse = false) const noexcept |
23834 | | { |
23835 | | return compares_unordered(*this, rhs, inverse); |
23836 | | } |
23837 | | |
23838 | | public: |
23839 | | #if JSON_HAS_THREE_WAY_COMPARISON |
23840 | | /// @brief comparison: equal |
23841 | | /// @sa https://json.nlohmann.me/api/basic_json/operator_eq/ |
23842 | | bool operator==(const_reference rhs) const noexcept |
23843 | | { |
23844 | | #ifdef __GNUC__ |
23845 | | #pragma GCC diagnostic push |
23846 | | #pragma GCC diagnostic ignored "-Wfloat-equal" |
23847 | | #endif |
23848 | | const_reference lhs = *this; |
23849 | | JSON_IMPLEMENT_OPERATOR( ==, true, false, false) |
23850 | | #ifdef __GNUC__ |
23851 | | #pragma GCC diagnostic pop |
23852 | | #endif |
23853 | | } |
23854 | | |
23855 | | /// @brief comparison: equal |
23856 | | /// @sa https://json.nlohmann.me/api/basic_json/operator_eq/ |
23857 | | template<typename ScalarType> |
23858 | | requires std::is_scalar_v<ScalarType> |
23859 | | bool operator==(ScalarType rhs) const noexcept |
23860 | | { |
23861 | | return *this == basic_json(rhs); |
23862 | | } |
23863 | | |
23864 | | /// @brief comparison: not equal |
23865 | | /// @sa https://json.nlohmann.me/api/basic_json/operator_ne/ |
23866 | | bool operator!=(const_reference rhs) const noexcept |
23867 | | { |
23868 | | if (compares_unordered(rhs, true)) |
23869 | | { |
23870 | | return false; |
23871 | | } |
23872 | | return !operator==(rhs); |
23873 | | } |
23874 | | |
23875 | | /// @brief comparison: 3-way |
23876 | | /// @sa https://json.nlohmann.me/api/basic_json/operator_spaceship/ |
23877 | | std::partial_ordering operator<=>(const_reference rhs) const noexcept // *NOPAD* |
23878 | | { |
23879 | | const_reference lhs = *this; |
23880 | | // default_result is used if we cannot compare values. In that case, |
23881 | | // we compare types. |
23882 | | JSON_IMPLEMENT_OPERATOR(<=>, // *NOPAD* |
23883 | | std::partial_ordering::equivalent, |
23884 | | std::partial_ordering::unordered, |
23885 | | lhs_type <=> rhs_type) // *NOPAD* |
23886 | | } |
23887 | | |
23888 | | /// @brief comparison: 3-way |
23889 | | /// @sa https://json.nlohmann.me/api/basic_json/operator_spaceship/ |
23890 | | template<typename ScalarType> |
23891 | | requires std::is_scalar_v<ScalarType> |
23892 | | std::partial_ordering operator<=>(ScalarType rhs) const noexcept // *NOPAD* |
23893 | | { |
23894 | | return *this <=> basic_json(rhs); // *NOPAD* |
23895 | | } |
23896 | | |
23897 | | #if JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON |
23898 | | // all operators that are computed as an odd number of inverses of others |
23899 | | // need to be overloaded to emulate the legacy comparison behavior |
23900 | | |
23901 | | /// @brief comparison: less than or equal |
23902 | | /// @sa https://json.nlohmann.me/api/basic_json/operator_le/ |
23903 | | JSON_HEDLEY_DEPRECATED_FOR(3.11.0, undef JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON) |
23904 | | bool operator<=(const_reference rhs) const noexcept |
23905 | | { |
23906 | | if (compares_unordered(rhs, true)) |
23907 | | { |
23908 | | return false; |
23909 | | } |
23910 | | return !(rhs < *this); |
23911 | | } |
23912 | | |
23913 | | /// @brief comparison: less than or equal |
23914 | | /// @sa https://json.nlohmann.me/api/basic_json/operator_le/ |
23915 | | template<typename ScalarType> |
23916 | | requires std::is_scalar_v<ScalarType> |
23917 | | bool operator<=(ScalarType rhs) const noexcept |
23918 | | { |
23919 | | return *this <= basic_json(rhs); |
23920 | | } |
23921 | | |
23922 | | /// @brief comparison: greater than or equal |
23923 | | /// @sa https://json.nlohmann.me/api/basic_json/operator_ge/ |
23924 | | JSON_HEDLEY_DEPRECATED_FOR(3.11.0, undef JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON) |
23925 | | bool operator>=(const_reference rhs) const noexcept |
23926 | | { |
23927 | | if (compares_unordered(rhs, true)) |
23928 | | { |
23929 | | return false; |
23930 | | } |
23931 | | return !(*this < rhs); |
23932 | | } |
23933 | | |
23934 | | /// @brief comparison: greater than or equal |
23935 | | /// @sa https://json.nlohmann.me/api/basic_json/operator_ge/ |
23936 | | template<typename ScalarType> |
23937 | | requires std::is_scalar_v<ScalarType> |
23938 | | bool operator>=(ScalarType rhs) const noexcept |
23939 | | { |
23940 | | return *this >= basic_json(rhs); |
23941 | | } |
23942 | | #endif |
23943 | | #else |
23944 | | /// @brief comparison: equal |
23945 | | /// @sa https://json.nlohmann.me/api/basic_json/operator_eq/ |
23946 | | friend bool operator==(const_reference lhs, const_reference rhs) noexcept |
23947 | 0 | { |
23948 | 0 | #ifdef __GNUC__ |
23949 | 0 | #pragma GCC diagnostic push |
23950 | 0 | #pragma GCC diagnostic ignored "-Wfloat-equal" |
23951 | 0 | #endif |
23952 | 0 | JSON_IMPLEMENT_OPERATOR( ==, true, false, false) |
23953 | 0 | #ifdef __GNUC__ |
23954 | 0 | #pragma GCC diagnostic pop |
23955 | 0 | #endif |
23956 | 0 | } |
23957 | | |
23958 | | /// @brief comparison: equal |
23959 | | /// @sa https://json.nlohmann.me/api/basic_json/operator_eq/ |
23960 | | template<typename ScalarType, typename std::enable_if< |
23961 | | std::is_scalar<ScalarType>::value, int>::type = 0> |
23962 | | friend bool operator==(const_reference lhs, ScalarType rhs) noexcept |
23963 | | { |
23964 | | return lhs == basic_json(rhs); |
23965 | | } |
23966 | | |
23967 | | /// @brief comparison: equal |
23968 | | /// @sa https://json.nlohmann.me/api/basic_json/operator_eq/ |
23969 | | template<typename ScalarType, typename std::enable_if< |
23970 | | std::is_scalar<ScalarType>::value, int>::type = 0> |
23971 | | friend bool operator==(ScalarType lhs, const_reference rhs) noexcept |
23972 | | { |
23973 | | return basic_json(lhs) == rhs; |
23974 | | } |
23975 | | |
23976 | | /// @brief comparison: not equal |
23977 | | /// @sa https://json.nlohmann.me/api/basic_json/operator_ne/ |
23978 | | friend bool operator!=(const_reference lhs, const_reference rhs) noexcept |
23979 | 0 | { |
23980 | 0 | if (compares_unordered(lhs, rhs, true)) |
23981 | 0 | { |
23982 | 0 | return false; |
23983 | 0 | } |
23984 | 0 | return !(lhs == rhs); |
23985 | 0 | } |
23986 | | |
23987 | | /// @brief comparison: not equal |
23988 | | /// @sa https://json.nlohmann.me/api/basic_json/operator_ne/ |
23989 | | template<typename ScalarType, typename std::enable_if< |
23990 | | std::is_scalar<ScalarType>::value, int>::type = 0> |
23991 | | friend bool operator!=(const_reference lhs, ScalarType rhs) noexcept |
23992 | 0 | { |
23993 | 0 | return lhs != basic_json(rhs); |
23994 | 0 | } |
23995 | | |
23996 | | /// @brief comparison: not equal |
23997 | | /// @sa https://json.nlohmann.me/api/basic_json/operator_ne/ |
23998 | | template<typename ScalarType, typename std::enable_if< |
23999 | | std::is_scalar<ScalarType>::value, int>::type = 0> |
24000 | | friend bool operator!=(ScalarType lhs, const_reference rhs) noexcept |
24001 | | { |
24002 | | return basic_json(lhs) != rhs; |
24003 | | } |
24004 | | |
24005 | | /// @brief comparison: less than |
24006 | | /// @sa https://json.nlohmann.me/api/basic_json/operator_lt/ |
24007 | | friend bool operator<(const_reference lhs, const_reference rhs) noexcept |
24008 | | { |
24009 | | // default_result is used if we cannot compare values. In that case, |
24010 | | // we compare types. Note we have to call the operator explicitly, |
24011 | | // because MSVC has problems otherwise. |
24012 | | JSON_IMPLEMENT_OPERATOR( <, false, false, operator<(lhs_type, rhs_type)) |
24013 | | } |
24014 | | |
24015 | | /// @brief comparison: less than |
24016 | | /// @sa https://json.nlohmann.me/api/basic_json/operator_lt/ |
24017 | | template<typename ScalarType, typename std::enable_if< |
24018 | | std::is_scalar<ScalarType>::value, int>::type = 0> |
24019 | | friend bool operator<(const_reference lhs, ScalarType rhs) noexcept |
24020 | | { |
24021 | | return lhs < basic_json(rhs); |
24022 | | } |
24023 | | |
24024 | | /// @brief comparison: less than |
24025 | | /// @sa https://json.nlohmann.me/api/basic_json/operator_lt/ |
24026 | | template<typename ScalarType, typename std::enable_if< |
24027 | | std::is_scalar<ScalarType>::value, int>::type = 0> |
24028 | | friend bool operator<(ScalarType lhs, const_reference rhs) noexcept |
24029 | | { |
24030 | | return basic_json(lhs) < rhs; |
24031 | | } |
24032 | | |
24033 | | /// @brief comparison: less than or equal |
24034 | | /// @sa https://json.nlohmann.me/api/basic_json/operator_le/ |
24035 | | friend bool operator<=(const_reference lhs, const_reference rhs) noexcept |
24036 | | { |
24037 | | if (compares_unordered(lhs, rhs, true)) |
24038 | | { |
24039 | | return false; |
24040 | | } |
24041 | | return !(rhs < lhs); |
24042 | | } |
24043 | | |
24044 | | /// @brief comparison: less than or equal |
24045 | | /// @sa https://json.nlohmann.me/api/basic_json/operator_le/ |
24046 | | template<typename ScalarType, typename std::enable_if< |
24047 | | std::is_scalar<ScalarType>::value, int>::type = 0> |
24048 | | friend bool operator<=(const_reference lhs, ScalarType rhs) noexcept |
24049 | | { |
24050 | | return lhs <= basic_json(rhs); |
24051 | | } |
24052 | | |
24053 | | /// @brief comparison: less than or equal |
24054 | | /// @sa https://json.nlohmann.me/api/basic_json/operator_le/ |
24055 | | template<typename ScalarType, typename std::enable_if< |
24056 | | std::is_scalar<ScalarType>::value, int>::type = 0> |
24057 | | friend bool operator<=(ScalarType lhs, const_reference rhs) noexcept |
24058 | | { |
24059 | | return basic_json(lhs) <= rhs; |
24060 | | } |
24061 | | |
24062 | | /// @brief comparison: greater than |
24063 | | /// @sa https://json.nlohmann.me/api/basic_json/operator_gt/ |
24064 | | friend bool operator>(const_reference lhs, const_reference rhs) noexcept |
24065 | | { |
24066 | | // double inverse |
24067 | | if (compares_unordered(lhs, rhs)) |
24068 | | { |
24069 | | return false; |
24070 | | } |
24071 | | return !(lhs <= rhs); |
24072 | | } |
24073 | | |
24074 | | /// @brief comparison: greater than |
24075 | | /// @sa https://json.nlohmann.me/api/basic_json/operator_gt/ |
24076 | | template<typename ScalarType, typename std::enable_if< |
24077 | | std::is_scalar<ScalarType>::value, int>::type = 0> |
24078 | | friend bool operator>(const_reference lhs, ScalarType rhs) noexcept |
24079 | | { |
24080 | | return lhs > basic_json(rhs); |
24081 | | } |
24082 | | |
24083 | | /// @brief comparison: greater than |
24084 | | /// @sa https://json.nlohmann.me/api/basic_json/operator_gt/ |
24085 | | template<typename ScalarType, typename std::enable_if< |
24086 | | std::is_scalar<ScalarType>::value, int>::type = 0> |
24087 | | friend bool operator>(ScalarType lhs, const_reference rhs) noexcept |
24088 | | { |
24089 | | return basic_json(lhs) > rhs; |
24090 | | } |
24091 | | |
24092 | | /// @brief comparison: greater than or equal |
24093 | | /// @sa https://json.nlohmann.me/api/basic_json/operator_ge/ |
24094 | | friend bool operator>=(const_reference lhs, const_reference rhs) noexcept |
24095 | | { |
24096 | | if (compares_unordered(lhs, rhs, true)) |
24097 | | { |
24098 | | return false; |
24099 | | } |
24100 | | return !(lhs < rhs); |
24101 | | } |
24102 | | |
24103 | | /// @brief comparison: greater than or equal |
24104 | | /// @sa https://json.nlohmann.me/api/basic_json/operator_ge/ |
24105 | | template<typename ScalarType, typename std::enable_if< |
24106 | | std::is_scalar<ScalarType>::value, int>::type = 0> |
24107 | | friend bool operator>=(const_reference lhs, ScalarType rhs) noexcept |
24108 | | { |
24109 | | return lhs >= basic_json(rhs); |
24110 | | } |
24111 | | |
24112 | | /// @brief comparison: greater than or equal |
24113 | | /// @sa https://json.nlohmann.me/api/basic_json/operator_ge/ |
24114 | | template<typename ScalarType, typename std::enable_if< |
24115 | | std::is_scalar<ScalarType>::value, int>::type = 0> |
24116 | | friend bool operator>=(ScalarType lhs, const_reference rhs) noexcept |
24117 | | { |
24118 | | return basic_json(lhs) >= rhs; |
24119 | | } |
24120 | | #endif |
24121 | | |
24122 | | #undef JSON_IMPLEMENT_OPERATOR |
24123 | | |
24124 | | /// @} |
24125 | | |
24126 | | /////////////////// |
24127 | | // serialization // |
24128 | | /////////////////// |
24129 | | |
24130 | | /// @name serialization |
24131 | | /// @{ |
24132 | | #ifndef JSON_NO_IO |
24133 | | /// @brief serialize to stream |
24134 | | /// @sa https://json.nlohmann.me/api/basic_json/operator_ltlt/ |
24135 | | friend std::ostream& operator<<(std::ostream& o, const basic_json& j) |
24136 | | { |
24137 | | // read width member and use it as the indentation parameter if nonzero |
24138 | | const bool pretty_print = o.width() > 0; |
24139 | | const auto indentation = pretty_print ? o.width() : 0; |
24140 | | |
24141 | | // reset width to 0 for subsequent calls to this stream |
24142 | | o.width(0); |
24143 | | |
24144 | | // do the actual serialization |
24145 | | serializer s(detail::output_adapter<char>(o), o.fill()); |
24146 | | s.dump(j, pretty_print, false, static_cast<unsigned int>(indentation)); |
24147 | | return o; |
24148 | | } |
24149 | | |
24150 | | /// @brief serialize to stream |
24151 | | /// @sa https://json.nlohmann.me/api/basic_json/operator_ltlt/ |
24152 | | /// @deprecated This function is deprecated since 3.0.0 and will be removed in |
24153 | | /// version 4.0.0 of the library. Please use |
24154 | | /// operator<<(std::ostream&, const basic_json&) instead; that is, |
24155 | | /// replace calls like `j >> o;` with `o << j;`. |
24156 | | JSON_HEDLEY_DEPRECATED_FOR(3.0.0, operator<<(std::ostream&, const basic_json&)) |
24157 | | friend std::ostream& operator>>(const basic_json& j, std::ostream& o) |
24158 | | { |
24159 | | return o << j; |
24160 | | } |
24161 | | #endif // JSON_NO_IO |
24162 | | /// @} |
24163 | | |
24164 | | ///////////////////// |
24165 | | // deserialization // |
24166 | | ///////////////////// |
24167 | | |
24168 | | /// @name deserialization |
24169 | | /// @{ |
24170 | | |
24171 | | /// @brief deserialize from a compatible input |
24172 | | /// @sa https://json.nlohmann.me/api/basic_json/parse/ |
24173 | | template<typename InputType> |
24174 | | JSON_HEDLEY_WARN_UNUSED_RESULT |
24175 | | static basic_json parse(InputType&& i, |
24176 | | parser_callback_t cb = nullptr, |
24177 | | const bool allow_exceptions = true, |
24178 | | const bool ignore_comments = false, |
24179 | | const bool ignore_trailing_commas = false) |
24180 | 0 | { |
24181 | 0 | basic_json result; |
24182 | 0 | parser(detail::input_adapter(std::forward<InputType>(i)), std::move(cb), allow_exceptions, ignore_comments, ignore_trailing_commas).parse(true, result); // cppcheck-suppress[accessMoved,accessForwarded] |
24183 | 0 | return result; |
24184 | 0 | } |
24185 | | |
24186 | | /// @brief deserialize from a pair of character iterators |
24187 | | /// @sa https://json.nlohmann.me/api/basic_json/parse/ |
24188 | | template<typename IteratorType> |
24189 | | JSON_HEDLEY_WARN_UNUSED_RESULT |
24190 | | static basic_json parse(IteratorType first, |
24191 | | IteratorType last, |
24192 | | parser_callback_t cb = nullptr, |
24193 | | const bool allow_exceptions = true, |
24194 | | const bool ignore_comments = false, |
24195 | | const bool ignore_trailing_commas = false) |
24196 | 0 | { |
24197 | 0 | basic_json result; |
24198 | 0 | parser(detail::input_adapter(std::move(first), std::move(last)), std::move(cb), allow_exceptions, ignore_comments, ignore_trailing_commas).parse(true, result); // cppcheck-suppress[accessMoved] |
24199 | 0 | return result; |
24200 | 0 | } |
24201 | | |
24202 | | JSON_HEDLEY_WARN_UNUSED_RESULT |
24203 | | JSON_HEDLEY_DEPRECATED_FOR(3.8.0, parse(ptr, ptr + len)) |
24204 | | static basic_json parse(detail::span_input_adapter&& i, |
24205 | | parser_callback_t cb = nullptr, |
24206 | | const bool allow_exceptions = true, |
24207 | | const bool ignore_comments = false, |
24208 | | const bool ignore_trailing_commas = false) |
24209 | | { |
24210 | | basic_json result; |
24211 | | parser(i.get(), std::move(cb), allow_exceptions, ignore_comments, ignore_trailing_commas).parse(true, result); // cppcheck-suppress[accessMoved] |
24212 | | return result; |
24213 | | } |
24214 | | |
24215 | | /// @brief check if the input is valid JSON |
24216 | | /// @sa https://json.nlohmann.me/api/basic_json/accept/ |
24217 | | template<typename InputType> |
24218 | | static bool accept(InputType&& i, |
24219 | | const bool ignore_comments = false, |
24220 | | const bool ignore_trailing_commas = false) |
24221 | | { |
24222 | | return parser(detail::input_adapter(std::forward<InputType>(i)), nullptr, false, ignore_comments, ignore_trailing_commas).accept(true); |
24223 | | } |
24224 | | |
24225 | | /// @brief check if the input is valid JSON |
24226 | | /// @sa https://json.nlohmann.me/api/basic_json/accept/ |
24227 | | template<typename IteratorType> |
24228 | | static bool accept(IteratorType first, IteratorType last, |
24229 | | const bool ignore_comments = false, |
24230 | | const bool ignore_trailing_commas = false) |
24231 | | { |
24232 | | return parser(detail::input_adapter(std::move(first), std::move(last)), nullptr, false, ignore_comments, ignore_trailing_commas).accept(true); |
24233 | | } |
24234 | | |
24235 | | JSON_HEDLEY_WARN_UNUSED_RESULT |
24236 | | JSON_HEDLEY_DEPRECATED_FOR(3.8.0, accept(ptr, ptr + len)) |
24237 | | static bool accept(detail::span_input_adapter&& i, |
24238 | | const bool ignore_comments = false, |
24239 | | const bool ignore_trailing_commas = false) |
24240 | | { |
24241 | | return parser(i.get(), nullptr, false, ignore_comments, ignore_trailing_commas).accept(true); |
24242 | | } |
24243 | | |
24244 | | /// @brief generate SAX events |
24245 | | /// @sa https://json.nlohmann.me/api/basic_json/sax_parse/ |
24246 | | template <typename InputType, typename SAX> |
24247 | | JSON_HEDLEY_NON_NULL(2) |
24248 | | static bool sax_parse(InputType&& i, SAX* sax, |
24249 | | input_format_t format = input_format_t::json, |
24250 | | const bool strict = true, |
24251 | | const bool ignore_comments = false, |
24252 | | const bool ignore_trailing_commas = false) |
24253 | | { |
24254 | | #if defined(__clang__) |
24255 | | #pragma clang diagnostic push |
24256 | | #pragma clang diagnostic ignored "-Wtautological-pointer-compare" |
24257 | | #elif defined(__GNUC__) |
24258 | | #pragma GCC diagnostic push |
24259 | | #pragma GCC diagnostic ignored "-Wnonnull-compare" |
24260 | | #endif |
24261 | | if (sax == nullptr) |
24262 | | { |
24263 | | JSON_THROW(other_error::create(502, "SAX handler must not be null", nullptr)); |
24264 | | } |
24265 | | #if defined(__clang__) |
24266 | | #pragma clang diagnostic pop |
24267 | | #elif defined(__GNUC__) |
24268 | | #pragma GCC diagnostic pop |
24269 | | #endif |
24270 | | auto ia = detail::input_adapter(std::forward<InputType>(i)); |
24271 | | return format == input_format_t::json |
24272 | | ? parser(std::move(ia), nullptr, true, ignore_comments, ignore_trailing_commas).sax_parse(sax, strict) |
24273 | | : detail::binary_reader<basic_json, decltype(ia), SAX>(std::move(ia), format).sax_parse(format, sax, strict); |
24274 | | } |
24275 | | |
24276 | | /// @brief generate SAX events |
24277 | | /// @sa https://json.nlohmann.me/api/basic_json/sax_parse/ |
24278 | | template<class IteratorType, class SAX> |
24279 | | JSON_HEDLEY_NON_NULL(3) |
24280 | | static bool sax_parse(IteratorType first, IteratorType last, SAX* sax, |
24281 | | input_format_t format = input_format_t::json, |
24282 | | const bool strict = true, |
24283 | | const bool ignore_comments = false, |
24284 | | const bool ignore_trailing_commas = false) |
24285 | | { |
24286 | | #if defined(__clang__) |
24287 | | #pragma clang diagnostic push |
24288 | | #pragma clang diagnostic ignored "-Wtautological-pointer-compare" |
24289 | | #elif defined(__GNUC__) |
24290 | | #pragma GCC diagnostic push |
24291 | | #pragma GCC diagnostic ignored "-Wnonnull-compare" |
24292 | | #endif |
24293 | | if (sax == nullptr) |
24294 | | { |
24295 | | JSON_THROW(other_error::create(502, "SAX handler must not be null", nullptr)); |
24296 | | } |
24297 | | #if defined(__clang__) |
24298 | | #pragma clang diagnostic pop |
24299 | | #elif defined(__GNUC__) |
24300 | | #pragma GCC diagnostic pop |
24301 | | #endif |
24302 | | auto ia = detail::input_adapter(std::move(first), std::move(last)); |
24303 | | return format == input_format_t::json |
24304 | | ? parser(std::move(ia), nullptr, true, ignore_comments, ignore_trailing_commas).sax_parse(sax, strict) |
24305 | | : detail::binary_reader<basic_json, decltype(ia), SAX>(std::move(ia), format).sax_parse(format, sax, strict); |
24306 | | } |
24307 | | |
24308 | | /// @brief generate SAX events |
24309 | | /// @sa https://json.nlohmann.me/api/basic_json/sax_parse/ |
24310 | | /// @deprecated This function is deprecated since 3.8.0 and will be removed in |
24311 | | /// version 4.0.0 of the library. Please use |
24312 | | /// sax_parse(ptr, ptr + len) instead. |
24313 | | template <typename SAX> |
24314 | | JSON_HEDLEY_DEPRECATED_FOR(3.8.0, sax_parse(ptr, ptr + len, ...)) |
24315 | | JSON_HEDLEY_NON_NULL(2) |
24316 | | static bool sax_parse(detail::span_input_adapter&& i, SAX* sax, |
24317 | | input_format_t format = input_format_t::json, |
24318 | | const bool strict = true, |
24319 | | const bool ignore_comments = false, |
24320 | | const bool ignore_trailing_commas = false) |
24321 | | { |
24322 | | #if defined(__clang__) |
24323 | | #pragma clang diagnostic push |
24324 | | #pragma clang diagnostic ignored "-Wtautological-pointer-compare" |
24325 | | #elif defined(__GNUC__) |
24326 | | #pragma GCC diagnostic push |
24327 | | #pragma GCC diagnostic ignored "-Wnonnull-compare" |
24328 | | #endif |
24329 | | if (sax == nullptr) |
24330 | | { |
24331 | | JSON_THROW(other_error::create(502, "SAX handler must not be null", nullptr)); |
24332 | | } |
24333 | | #if defined(__clang__) |
24334 | | #pragma clang diagnostic pop |
24335 | | #elif defined(__GNUC__) |
24336 | | #pragma GCC diagnostic pop |
24337 | | #endif |
24338 | | auto ia = i.get(); |
24339 | | return format == input_format_t::json |
24340 | | // NOLINTNEXTLINE(hicpp-move-const-arg,performance-move-const-arg) |
24341 | | ? parser(std::move(ia), nullptr, true, ignore_comments, ignore_trailing_commas).sax_parse(sax, strict) |
24342 | | // NOLINTNEXTLINE(hicpp-move-const-arg,performance-move-const-arg) |
24343 | | : detail::binary_reader<basic_json, decltype(ia), SAX>(std::move(ia), format).sax_parse(format, sax, strict); |
24344 | | } |
24345 | | #ifndef JSON_NO_IO |
24346 | | /// @brief deserialize from stream |
24347 | | /// @sa https://json.nlohmann.me/api/basic_json/operator_gtgt/ |
24348 | | /// @deprecated This stream operator is deprecated since 3.0.0 and will be removed in |
24349 | | /// version 4.0.0 of the library. Please use |
24350 | | /// operator>>(std::istream&, basic_json&) instead; that is, |
24351 | | /// replace calls like `j << i;` with `i >> j;`. |
24352 | | JSON_HEDLEY_DEPRECATED_FOR(3.0.0, operator>>(std::istream&, basic_json&)) |
24353 | | friend std::istream& operator<<(basic_json& j, std::istream& i) |
24354 | | { |
24355 | | return operator>>(i, j); |
24356 | | } |
24357 | | |
24358 | | /// @brief deserialize from stream |
24359 | | /// @sa https://json.nlohmann.me/api/basic_json/operator_gtgt/ |
24360 | | friend std::istream& operator>>(std::istream& i, basic_json& j) |
24361 | | { |
24362 | | parser(detail::input_adapter(i)).parse(false, j); |
24363 | | return i; |
24364 | | } |
24365 | | #endif // JSON_NO_IO |
24366 | | /// @} |
24367 | | |
24368 | | /////////////////////////// |
24369 | | // convenience functions // |
24370 | | /////////////////////////// |
24371 | | |
24372 | | /// @brief return the type as string |
24373 | | /// @sa https://json.nlohmann.me/api/basic_json/type_name/ |
24374 | | JSON_HEDLEY_RETURNS_NON_NULL |
24375 | | const char* type_name() const noexcept |
24376 | 0 | { |
24377 | 0 | switch (m_data.m_type) |
24378 | 0 | { |
24379 | 0 | case value_t::null: |
24380 | 0 | return "null"; |
24381 | 0 | case value_t::object: |
24382 | 0 | return "object"; |
24383 | 0 | case value_t::array: |
24384 | 0 | return "array"; |
24385 | 0 | case value_t::string: |
24386 | 0 | return "string"; |
24387 | 0 | case value_t::boolean: |
24388 | 0 | return "boolean"; |
24389 | 0 | case value_t::binary: |
24390 | 0 | return "binary"; |
24391 | 0 | case value_t::discarded: |
24392 | 0 | return "discarded"; |
24393 | 0 | case value_t::number_integer: |
24394 | 0 | case value_t::number_unsigned: |
24395 | 0 | case value_t::number_float: |
24396 | 0 | return "number"; |
24397 | 0 | default: |
24398 | 0 | return "invalid"; |
24399 | 0 | } |
24400 | 0 | } |
24401 | | |
24402 | | JSON_PRIVATE_UNLESS_TESTED: |
24403 | | ////////////////////// |
24404 | | // member variables // |
24405 | | ////////////////////// |
24406 | | |
24407 | | struct data |
24408 | | { |
24409 | | /// the type of the current element |
24410 | | value_t m_type = value_t::null; |
24411 | | |
24412 | | /// the value of the current element |
24413 | | json_value m_value = {}; |
24414 | | |
24415 | | data(const value_t v) |
24416 | 0 | : m_type(v), m_value(v) |
24417 | 0 | { |
24418 | 0 | } |
24419 | | |
24420 | | data(size_type cnt, const basic_json& val) |
24421 | | : m_type(value_t::array) |
24422 | | { |
24423 | | m_value.array = create<array_t>(cnt, val); |
24424 | | } |
24425 | | |
24426 | 0 | data() noexcept = default; |
24427 | | data(data&&) noexcept = default; |
24428 | | data(const data&) noexcept = delete; |
24429 | | data& operator=(data&&) noexcept = delete; |
24430 | | data& operator=(const data&) noexcept = delete; |
24431 | | |
24432 | | ~data() noexcept |
24433 | 0 | { |
24434 | 0 | m_value.destroy(m_type); |
24435 | 0 | } |
24436 | | }; |
24437 | | |
24438 | | data m_data = {}; |
24439 | | |
24440 | | #if JSON_DIAGNOSTICS |
24441 | | /// a pointer to a parent value (for debugging purposes) |
24442 | | basic_json* m_parent = nullptr; |
24443 | | #endif |
24444 | | |
24445 | | #if JSON_DIAGNOSTIC_POSITIONS |
24446 | | /// the start position of the value |
24447 | | std::size_t start_position = std::string::npos; |
24448 | | /// the end position of the value |
24449 | | std::size_t end_position = std::string::npos; |
24450 | | public: |
24451 | | constexpr std::size_t start_pos() const noexcept |
24452 | | { |
24453 | | return start_position; |
24454 | | } |
24455 | | |
24456 | | constexpr std::size_t end_pos() const noexcept |
24457 | | { |
24458 | | return end_position; |
24459 | | } |
24460 | | #endif |
24461 | | |
24462 | | ////////////////////////////////////////// |
24463 | | // binary serialization/deserialization // |
24464 | | ////////////////////////////////////////// |
24465 | | |
24466 | | /// @name binary serialization/deserialization support |
24467 | | /// @{ |
24468 | | |
24469 | | public: |
24470 | | /// @brief create a CBOR serialization of a given JSON value |
24471 | | /// @sa https://json.nlohmann.me/api/basic_json/to_cbor/ |
24472 | | static std::vector<std::uint8_t> to_cbor(const basic_json& j) |
24473 | | { |
24474 | | std::vector<std::uint8_t> result; |
24475 | | to_cbor(j, result); |
24476 | | return result; |
24477 | | } |
24478 | | |
24479 | | /// @brief create a CBOR serialization of a given JSON value |
24480 | | /// @sa https://json.nlohmann.me/api/basic_json/to_cbor/ |
24481 | | static void to_cbor(const basic_json& j, detail::output_adapter<std::uint8_t> o) |
24482 | | { |
24483 | | binary_writer<std::uint8_t>(o).write_cbor(j); |
24484 | | } |
24485 | | |
24486 | | /// @brief create a CBOR serialization of a given JSON value |
24487 | | /// @sa https://json.nlohmann.me/api/basic_json/to_cbor/ |
24488 | | static void to_cbor(const basic_json& j, detail::output_adapter<char> o) |
24489 | | { |
24490 | | binary_writer<char>(o).write_cbor(j); |
24491 | | } |
24492 | | |
24493 | | /// @brief create a MessagePack serialization of a given JSON value |
24494 | | /// @sa https://json.nlohmann.me/api/basic_json/to_msgpack/ |
24495 | | static std::vector<std::uint8_t> to_msgpack(const basic_json& j) |
24496 | | { |
24497 | | std::vector<std::uint8_t> result; |
24498 | | to_msgpack(j, result); |
24499 | | return result; |
24500 | | } |
24501 | | |
24502 | | /// @brief create a MessagePack serialization of a given JSON value |
24503 | | /// @sa https://json.nlohmann.me/api/basic_json/to_msgpack/ |
24504 | | static void to_msgpack(const basic_json& j, detail::output_adapter<std::uint8_t> o) |
24505 | | { |
24506 | | binary_writer<std::uint8_t>(o).write_msgpack(j); |
24507 | | } |
24508 | | |
24509 | | /// @brief create a MessagePack serialization of a given JSON value |
24510 | | /// @sa https://json.nlohmann.me/api/basic_json/to_msgpack/ |
24511 | | static void to_msgpack(const basic_json& j, detail::output_adapter<char> o) |
24512 | | { |
24513 | | binary_writer<char>(o).write_msgpack(j); |
24514 | | } |
24515 | | |
24516 | | /// @brief create a UBJSON serialization of a given JSON value |
24517 | | /// @sa https://json.nlohmann.me/api/basic_json/to_ubjson/ |
24518 | | static std::vector<std::uint8_t> to_ubjson(const basic_json& j, |
24519 | | const bool use_size = false, |
24520 | | const bool use_type = false) |
24521 | | { |
24522 | | std::vector<std::uint8_t> result; |
24523 | | to_ubjson(j, result, use_size, use_type); |
24524 | | return result; |
24525 | | } |
24526 | | |
24527 | | /// @brief create a UBJSON serialization of a given JSON value |
24528 | | /// @sa https://json.nlohmann.me/api/basic_json/to_ubjson/ |
24529 | | static void to_ubjson(const basic_json& j, detail::output_adapter<std::uint8_t> o, |
24530 | | const bool use_size = false, const bool use_type = false) |
24531 | | { |
24532 | | binary_writer<std::uint8_t>(o).write_ubjson(j, use_size, use_type); |
24533 | | } |
24534 | | |
24535 | | /// @brief create a UBJSON serialization of a given JSON value |
24536 | | /// @sa https://json.nlohmann.me/api/basic_json/to_ubjson/ |
24537 | | static void to_ubjson(const basic_json& j, detail::output_adapter<char> o, |
24538 | | const bool use_size = false, const bool use_type = false) |
24539 | | { |
24540 | | binary_writer<char>(o).write_ubjson(j, use_size, use_type); |
24541 | | } |
24542 | | |
24543 | | /// @brief create a BJData serialization of a given JSON value |
24544 | | /// @sa https://json.nlohmann.me/api/basic_json/to_bjdata/ |
24545 | | static std::vector<std::uint8_t> to_bjdata(const basic_json& j, |
24546 | | const bool use_size = false, |
24547 | | const bool use_type = false, |
24548 | | const bjdata_version_t version = bjdata_version_t::draft2) |
24549 | | { |
24550 | | std::vector<std::uint8_t> result; |
24551 | | to_bjdata(j, result, use_size, use_type, version); |
24552 | | return result; |
24553 | | } |
24554 | | |
24555 | | /// @brief create a BJData serialization of a given JSON value |
24556 | | /// @sa https://json.nlohmann.me/api/basic_json/to_bjdata/ |
24557 | | static void to_bjdata(const basic_json& j, detail::output_adapter<std::uint8_t> o, |
24558 | | const bool use_size = false, const bool use_type = false, |
24559 | | const bjdata_version_t version = bjdata_version_t::draft2) |
24560 | | { |
24561 | | binary_writer<std::uint8_t>(o).write_ubjson(j, use_size, use_type, true, true, version); |
24562 | | } |
24563 | | |
24564 | | /// @brief create a BJData serialization of a given JSON value |
24565 | | /// @sa https://json.nlohmann.me/api/basic_json/to_bjdata/ |
24566 | | static void to_bjdata(const basic_json& j, detail::output_adapter<char> o, |
24567 | | const bool use_size = false, const bool use_type = false, |
24568 | | const bjdata_version_t version = bjdata_version_t::draft2) |
24569 | | { |
24570 | | binary_writer<char>(o).write_ubjson(j, use_size, use_type, true, true, version); |
24571 | | } |
24572 | | |
24573 | | /// @brief create a BSON serialization of a given JSON value |
24574 | | /// @sa https://json.nlohmann.me/api/basic_json/to_bson/ |
24575 | | static std::vector<std::uint8_t> to_bson(const basic_json& j) |
24576 | | { |
24577 | | std::vector<std::uint8_t> result; |
24578 | | to_bson(j, result); |
24579 | | return result; |
24580 | | } |
24581 | | |
24582 | | /// @brief create a BSON serialization of a given JSON value |
24583 | | /// @sa https://json.nlohmann.me/api/basic_json/to_bson/ |
24584 | | static void to_bson(const basic_json& j, detail::output_adapter<std::uint8_t> o) |
24585 | | { |
24586 | | binary_writer<std::uint8_t>(o).write_bson(j); |
24587 | | } |
24588 | | |
24589 | | /// @brief create a BSON serialization of a given JSON value |
24590 | | /// @sa https://json.nlohmann.me/api/basic_json/to_bson/ |
24591 | | static void to_bson(const basic_json& j, detail::output_adapter<char> o) |
24592 | | { |
24593 | | binary_writer<char>(o).write_bson(j); |
24594 | | } |
24595 | | |
24596 | | /// @brief create a JSON value from an input in CBOR format |
24597 | | /// @sa https://json.nlohmann.me/api/basic_json/from_cbor/ |
24598 | | template<typename InputType> |
24599 | | JSON_HEDLEY_WARN_UNUSED_RESULT |
24600 | | static basic_json from_cbor(InputType&& i, |
24601 | | const bool strict = true, |
24602 | | const bool allow_exceptions = true, |
24603 | | const cbor_tag_handler_t tag_handler = cbor_tag_handler_t::error) |
24604 | | { |
24605 | | basic_json result; |
24606 | | auto ia = detail::input_adapter(std::forward<InputType>(i)); |
24607 | | detail::json_sax_dom_parser<basic_json, decltype(ia)> sdp(result, allow_exceptions); |
24608 | | const bool res = binary_reader<decltype(ia)>(std::move(ia), input_format_t::cbor).sax_parse(input_format_t::cbor, &sdp, strict, tag_handler); // cppcheck-suppress[accessMoved] |
24609 | | return res ? result : basic_json(value_t::discarded); |
24610 | | } |
24611 | | |
24612 | | /// @brief create a JSON value from an input in CBOR format |
24613 | | /// @sa https://json.nlohmann.me/api/basic_json/from_cbor/ |
24614 | | template<typename IteratorType> |
24615 | | JSON_HEDLEY_WARN_UNUSED_RESULT |
24616 | | static basic_json from_cbor(IteratorType first, IteratorType last, |
24617 | | const bool strict = true, |
24618 | | const bool allow_exceptions = true, |
24619 | | const cbor_tag_handler_t tag_handler = cbor_tag_handler_t::error) |
24620 | | { |
24621 | | basic_json result; |
24622 | | auto ia = detail::input_adapter(std::move(first), std::move(last)); |
24623 | | detail::json_sax_dom_parser<basic_json, decltype(ia)> sdp(result, allow_exceptions); |
24624 | | const bool res = binary_reader<decltype(ia)>(std::move(ia), input_format_t::cbor).sax_parse(input_format_t::cbor, &sdp, strict, tag_handler); // cppcheck-suppress[accessMoved] |
24625 | | return res ? result : basic_json(value_t::discarded); |
24626 | | } |
24627 | | |
24628 | | template<typename T> |
24629 | | JSON_HEDLEY_WARN_UNUSED_RESULT |
24630 | | JSON_HEDLEY_DEPRECATED_FOR(3.8.0, from_cbor(ptr, ptr + len)) |
24631 | | static basic_json from_cbor(const T* ptr, std::size_t len, |
24632 | | const bool strict = true, |
24633 | | const bool allow_exceptions = true, |
24634 | | const cbor_tag_handler_t tag_handler = cbor_tag_handler_t::error) |
24635 | | { |
24636 | | return from_cbor(ptr, ptr + len, strict, allow_exceptions, tag_handler); |
24637 | | } |
24638 | | |
24639 | | JSON_HEDLEY_WARN_UNUSED_RESULT |
24640 | | JSON_HEDLEY_DEPRECATED_FOR(3.8.0, from_cbor(ptr, ptr + len)) |
24641 | | static basic_json from_cbor(detail::span_input_adapter&& i, |
24642 | | const bool strict = true, |
24643 | | const bool allow_exceptions = true, |
24644 | | const cbor_tag_handler_t tag_handler = cbor_tag_handler_t::error) |
24645 | | { |
24646 | | basic_json result; |
24647 | | auto ia = i.get(); |
24648 | | detail::json_sax_dom_parser<basic_json, decltype(ia)> sdp(result, allow_exceptions); |
24649 | | // NOLINTNEXTLINE(hicpp-move-const-arg,performance-move-const-arg) |
24650 | | const bool res = binary_reader<decltype(ia)>(std::move(ia), input_format_t::cbor).sax_parse(input_format_t::cbor, &sdp, strict, tag_handler); // cppcheck-suppress[accessMoved] |
24651 | | return res ? result : basic_json(value_t::discarded); |
24652 | | } |
24653 | | |
24654 | | /// @brief create a JSON value from an input in MessagePack format |
24655 | | /// @sa https://json.nlohmann.me/api/basic_json/from_msgpack/ |
24656 | | template<typename InputType> |
24657 | | JSON_HEDLEY_WARN_UNUSED_RESULT |
24658 | | static basic_json from_msgpack(InputType&& i, |
24659 | | const bool strict = true, |
24660 | | const bool allow_exceptions = true) |
24661 | | { |
24662 | | basic_json result; |
24663 | | auto ia = detail::input_adapter(std::forward<InputType>(i)); |
24664 | | detail::json_sax_dom_parser<basic_json, decltype(ia)> sdp(result, allow_exceptions); |
24665 | | const bool res = binary_reader<decltype(ia)>(std::move(ia), input_format_t::msgpack).sax_parse(input_format_t::msgpack, &sdp, strict); // cppcheck-suppress[accessMoved] |
24666 | | return res ? result : basic_json(value_t::discarded); |
24667 | | } |
24668 | | |
24669 | | /// @brief create a JSON value from an input in MessagePack format |
24670 | | /// @sa https://json.nlohmann.me/api/basic_json/from_msgpack/ |
24671 | | template<typename IteratorType> |
24672 | | JSON_HEDLEY_WARN_UNUSED_RESULT |
24673 | | static basic_json from_msgpack(IteratorType first, IteratorType last, |
24674 | | const bool strict = true, |
24675 | | const bool allow_exceptions = true) |
24676 | | { |
24677 | | basic_json result; |
24678 | | auto ia = detail::input_adapter(std::move(first), std::move(last)); |
24679 | | detail::json_sax_dom_parser<basic_json, decltype(ia)> sdp(result, allow_exceptions); |
24680 | | const bool res = binary_reader<decltype(ia)>(std::move(ia), input_format_t::msgpack).sax_parse(input_format_t::msgpack, &sdp, strict); // cppcheck-suppress[accessMoved] |
24681 | | return res ? result : basic_json(value_t::discarded); |
24682 | | } |
24683 | | |
24684 | | template<typename T> |
24685 | | JSON_HEDLEY_WARN_UNUSED_RESULT |
24686 | | JSON_HEDLEY_DEPRECATED_FOR(3.8.0, from_msgpack(ptr, ptr + len)) |
24687 | | static basic_json from_msgpack(const T* ptr, std::size_t len, |
24688 | | const bool strict = true, |
24689 | | const bool allow_exceptions = true) |
24690 | | { |
24691 | | return from_msgpack(ptr, ptr + len, strict, allow_exceptions); |
24692 | | } |
24693 | | |
24694 | | JSON_HEDLEY_WARN_UNUSED_RESULT |
24695 | | JSON_HEDLEY_DEPRECATED_FOR(3.8.0, from_msgpack(ptr, ptr + len)) |
24696 | | static basic_json from_msgpack(detail::span_input_adapter&& i, |
24697 | | const bool strict = true, |
24698 | | const bool allow_exceptions = true) |
24699 | | { |
24700 | | basic_json result; |
24701 | | auto ia = i.get(); |
24702 | | detail::json_sax_dom_parser<basic_json, decltype(ia)> sdp(result, allow_exceptions); |
24703 | | // NOLINTNEXTLINE(hicpp-move-const-arg,performance-move-const-arg) |
24704 | | const bool res = binary_reader<decltype(ia)>(std::move(ia), input_format_t::msgpack).sax_parse(input_format_t::msgpack, &sdp, strict); // cppcheck-suppress[accessMoved] |
24705 | | return res ? result : basic_json(value_t::discarded); |
24706 | | } |
24707 | | |
24708 | | /// @brief create a JSON value from an input in UBJSON format |
24709 | | /// @sa https://json.nlohmann.me/api/basic_json/from_ubjson/ |
24710 | | template<typename InputType> |
24711 | | JSON_HEDLEY_WARN_UNUSED_RESULT |
24712 | | static basic_json from_ubjson(InputType&& i, |
24713 | | const bool strict = true, |
24714 | | const bool allow_exceptions = true) |
24715 | | { |
24716 | | basic_json result; |
24717 | | auto ia = detail::input_adapter(std::forward<InputType>(i)); |
24718 | | detail::json_sax_dom_parser<basic_json, decltype(ia)> sdp(result, allow_exceptions); |
24719 | | const bool res = binary_reader<decltype(ia)>(std::move(ia), input_format_t::ubjson).sax_parse(input_format_t::ubjson, &sdp, strict); // cppcheck-suppress[accessMoved] |
24720 | | return res ? result : basic_json(value_t::discarded); |
24721 | | } |
24722 | | |
24723 | | /// @brief create a JSON value from an input in UBJSON format |
24724 | | /// @sa https://json.nlohmann.me/api/basic_json/from_ubjson/ |
24725 | | template<typename IteratorType> |
24726 | | JSON_HEDLEY_WARN_UNUSED_RESULT |
24727 | | static basic_json from_ubjson(IteratorType first, IteratorType last, |
24728 | | const bool strict = true, |
24729 | | const bool allow_exceptions = true) |
24730 | | { |
24731 | | basic_json result; |
24732 | | auto ia = detail::input_adapter(std::move(first), std::move(last)); |
24733 | | detail::json_sax_dom_parser<basic_json, decltype(ia)> sdp(result, allow_exceptions); |
24734 | | const bool res = binary_reader<decltype(ia)>(std::move(ia), input_format_t::ubjson).sax_parse(input_format_t::ubjson, &sdp, strict); // cppcheck-suppress[accessMoved] |
24735 | | return res ? result : basic_json(value_t::discarded); |
24736 | | } |
24737 | | |
24738 | | template<typename T> |
24739 | | JSON_HEDLEY_WARN_UNUSED_RESULT |
24740 | | JSON_HEDLEY_DEPRECATED_FOR(3.8.0, from_ubjson(ptr, ptr + len)) |
24741 | | static basic_json from_ubjson(const T* ptr, std::size_t len, |
24742 | | const bool strict = true, |
24743 | | const bool allow_exceptions = true) |
24744 | | { |
24745 | | return from_ubjson(ptr, ptr + len, strict, allow_exceptions); |
24746 | | } |
24747 | | |
24748 | | JSON_HEDLEY_WARN_UNUSED_RESULT |
24749 | | JSON_HEDLEY_DEPRECATED_FOR(3.8.0, from_ubjson(ptr, ptr + len)) |
24750 | | static basic_json from_ubjson(detail::span_input_adapter&& i, |
24751 | | const bool strict = true, |
24752 | | const bool allow_exceptions = true) |
24753 | | { |
24754 | | basic_json result; |
24755 | | auto ia = i.get(); |
24756 | | detail::json_sax_dom_parser<basic_json, decltype(ia)> sdp(result, allow_exceptions); |
24757 | | // NOLINTNEXTLINE(hicpp-move-const-arg,performance-move-const-arg) |
24758 | | const bool res = binary_reader<decltype(ia)>(std::move(ia), input_format_t::ubjson).sax_parse(input_format_t::ubjson, &sdp, strict); // cppcheck-suppress[accessMoved] |
24759 | | return res ? result : basic_json(value_t::discarded); |
24760 | | } |
24761 | | |
24762 | | /// @brief create a JSON value from an input in BJData format |
24763 | | /// @sa https://json.nlohmann.me/api/basic_json/from_bjdata/ |
24764 | | template<typename InputType> |
24765 | | JSON_HEDLEY_WARN_UNUSED_RESULT |
24766 | | static basic_json from_bjdata(InputType&& i, |
24767 | | const bool strict = true, |
24768 | | const bool allow_exceptions = true) |
24769 | | { |
24770 | | basic_json result; |
24771 | | auto ia = detail::input_adapter(std::forward<InputType>(i)); |
24772 | | detail::json_sax_dom_parser<basic_json, decltype(ia)> sdp(result, allow_exceptions); |
24773 | | const bool res = binary_reader<decltype(ia)>(std::move(ia), input_format_t::bjdata).sax_parse(input_format_t::bjdata, &sdp, strict); // cppcheck-suppress[accessMoved] |
24774 | | return res ? result : basic_json(value_t::discarded); |
24775 | | } |
24776 | | |
24777 | | /// @brief create a JSON value from an input in BJData format |
24778 | | /// @sa https://json.nlohmann.me/api/basic_json/from_bjdata/ |
24779 | | template<typename IteratorType> |
24780 | | JSON_HEDLEY_WARN_UNUSED_RESULT |
24781 | | static basic_json from_bjdata(IteratorType first, IteratorType last, |
24782 | | const bool strict = true, |
24783 | | const bool allow_exceptions = true) |
24784 | | { |
24785 | | basic_json result; |
24786 | | auto ia = detail::input_adapter(std::move(first), std::move(last)); |
24787 | | detail::json_sax_dom_parser<basic_json, decltype(ia)> sdp(result, allow_exceptions); |
24788 | | const bool res = binary_reader<decltype(ia)>(std::move(ia), input_format_t::bjdata).sax_parse(input_format_t::bjdata, &sdp, strict); // cppcheck-suppress[accessMoved] |
24789 | | return res ? result : basic_json(value_t::discarded); |
24790 | | } |
24791 | | |
24792 | | /// @brief create a JSON value from an input in BSON format |
24793 | | /// @sa https://json.nlohmann.me/api/basic_json/from_bson/ |
24794 | | template<typename InputType> |
24795 | | JSON_HEDLEY_WARN_UNUSED_RESULT |
24796 | | static basic_json from_bson(InputType&& i, |
24797 | | const bool strict = true, |
24798 | | const bool allow_exceptions = true) |
24799 | | { |
24800 | | basic_json result; |
24801 | | auto ia = detail::input_adapter(std::forward<InputType>(i)); |
24802 | | detail::json_sax_dom_parser<basic_json, decltype(ia)> sdp(result, allow_exceptions); |
24803 | | const bool res = binary_reader<decltype(ia)>(std::move(ia), input_format_t::bson).sax_parse(input_format_t::bson, &sdp, strict); // cppcheck-suppress[accessMoved] |
24804 | | return res ? result : basic_json(value_t::discarded); |
24805 | | } |
24806 | | |
24807 | | /// @brief create a JSON value from an input in BSON format |
24808 | | /// @sa https://json.nlohmann.me/api/basic_json/from_bson/ |
24809 | | template<typename IteratorType> |
24810 | | JSON_HEDLEY_WARN_UNUSED_RESULT |
24811 | | static basic_json from_bson(IteratorType first, IteratorType last, |
24812 | | const bool strict = true, |
24813 | | const bool allow_exceptions = true) |
24814 | | { |
24815 | | basic_json result; |
24816 | | auto ia = detail::input_adapter(std::move(first), std::move(last)); |
24817 | | detail::json_sax_dom_parser<basic_json, decltype(ia)> sdp(result, allow_exceptions); |
24818 | | const bool res = binary_reader<decltype(ia)>(std::move(ia), input_format_t::bson).sax_parse(input_format_t::bson, &sdp, strict); // cppcheck-suppress[accessMoved] |
24819 | | return res ? result : basic_json(value_t::discarded); |
24820 | | } |
24821 | | |
24822 | | template<typename T> |
24823 | | JSON_HEDLEY_WARN_UNUSED_RESULT |
24824 | | JSON_HEDLEY_DEPRECATED_FOR(3.8.0, from_bson(ptr, ptr + len)) |
24825 | | static basic_json from_bson(const T* ptr, std::size_t len, |
24826 | | const bool strict = true, |
24827 | | const bool allow_exceptions = true) |
24828 | | { |
24829 | | return from_bson(ptr, ptr + len, strict, allow_exceptions); |
24830 | | } |
24831 | | |
24832 | | JSON_HEDLEY_WARN_UNUSED_RESULT |
24833 | | JSON_HEDLEY_DEPRECATED_FOR(3.8.0, from_bson(ptr, ptr + len)) |
24834 | | static basic_json from_bson(detail::span_input_adapter&& i, |
24835 | | const bool strict = true, |
24836 | | const bool allow_exceptions = true) |
24837 | | { |
24838 | | basic_json result; |
24839 | | auto ia = i.get(); |
24840 | | detail::json_sax_dom_parser<basic_json, decltype(ia)> sdp(result, allow_exceptions); |
24841 | | // NOLINTNEXTLINE(hicpp-move-const-arg,performance-move-const-arg) |
24842 | | const bool res = binary_reader<decltype(ia)>(std::move(ia), input_format_t::bson).sax_parse(input_format_t::bson, &sdp, strict); // cppcheck-suppress[accessMoved] |
24843 | | return res ? result : basic_json(value_t::discarded); |
24844 | | } |
24845 | | /// @} |
24846 | | |
24847 | | ////////////////////////// |
24848 | | // JSON Pointer support // |
24849 | | ////////////////////////// |
24850 | | |
24851 | | /// @name JSON Pointer functions |
24852 | | /// @{ |
24853 | | |
24854 | | /// @brief access specified element via JSON Pointer |
24855 | | /// @sa https://json.nlohmann.me/api/basic_json/operator%5B%5D/ |
24856 | | reference operator[](const json_pointer& ptr) |
24857 | | { |
24858 | | return ptr.get_unchecked(this); |
24859 | | } |
24860 | | |
24861 | | template<typename BasicJsonType, detail::enable_if_t<detail::is_basic_json<BasicJsonType>::value, int> = 0> |
24862 | | JSON_HEDLEY_DEPRECATED_FOR(3.11.0, basic_json::json_pointer or nlohmann::json_pointer<basic_json::string_t>) // NOLINT(readability/alt_tokens) |
24863 | | reference operator[](const ::nlohmann::json_pointer<BasicJsonType>& ptr) |
24864 | | { |
24865 | | return ptr.get_unchecked(this); |
24866 | | } |
24867 | | |
24868 | | /// @brief access specified element via JSON Pointer |
24869 | | /// @sa https://json.nlohmann.me/api/basic_json/operator%5B%5D/ |
24870 | | const_reference operator[](const json_pointer& ptr) const |
24871 | | { |
24872 | | return ptr.get_unchecked(this); |
24873 | | } |
24874 | | |
24875 | | template<typename BasicJsonType, detail::enable_if_t<detail::is_basic_json<BasicJsonType>::value, int> = 0> |
24876 | | JSON_HEDLEY_DEPRECATED_FOR(3.11.0, basic_json::json_pointer or nlohmann::json_pointer<basic_json::string_t>) // NOLINT(readability/alt_tokens) |
24877 | | const_reference operator[](const ::nlohmann::json_pointer<BasicJsonType>& ptr) const |
24878 | | { |
24879 | | return ptr.get_unchecked(this); |
24880 | | } |
24881 | | |
24882 | | /// @brief access specified element via JSON Pointer |
24883 | | /// @sa https://json.nlohmann.me/api/basic_json/at/ |
24884 | | reference at(const json_pointer& ptr) |
24885 | | { |
24886 | | return ptr.get_checked(this); |
24887 | | } |
24888 | | |
24889 | | template<typename BasicJsonType, detail::enable_if_t<detail::is_basic_json<BasicJsonType>::value, int> = 0> |
24890 | | JSON_HEDLEY_DEPRECATED_FOR(3.11.0, basic_json::json_pointer or nlohmann::json_pointer<basic_json::string_t>) // NOLINT(readability/alt_tokens) |
24891 | | reference at(const ::nlohmann::json_pointer<BasicJsonType>& ptr) |
24892 | | { |
24893 | | return ptr.get_checked(this); |
24894 | | } |
24895 | | |
24896 | | /// @brief access specified element via JSON Pointer |
24897 | | /// @sa https://json.nlohmann.me/api/basic_json/at/ |
24898 | | const_reference at(const json_pointer& ptr) const |
24899 | | { |
24900 | | return ptr.get_checked(this); |
24901 | | } |
24902 | | |
24903 | | template<typename BasicJsonType, detail::enable_if_t<detail::is_basic_json<BasicJsonType>::value, int> = 0> |
24904 | | JSON_HEDLEY_DEPRECATED_FOR(3.11.0, basic_json::json_pointer or nlohmann::json_pointer<basic_json::string_t>) // NOLINT(readability/alt_tokens) |
24905 | | const_reference at(const ::nlohmann::json_pointer<BasicJsonType>& ptr) const |
24906 | | { |
24907 | | return ptr.get_checked(this); |
24908 | | } |
24909 | | |
24910 | | /// @brief return flattened JSON value |
24911 | | /// @sa https://json.nlohmann.me/api/basic_json/flatten/ |
24912 | | basic_json flatten() const |
24913 | | { |
24914 | | basic_json result(value_t::object); |
24915 | | json_pointer::flatten("", *this, result); |
24916 | | return result; |
24917 | | } |
24918 | | |
24919 | | /// @brief unflatten a previously flattened JSON value |
24920 | | /// @sa https://json.nlohmann.me/api/basic_json/unflatten/ |
24921 | | basic_json unflatten() const |
24922 | | { |
24923 | | return json_pointer::unflatten(*this); |
24924 | | } |
24925 | | |
24926 | | /// @} |
24927 | | |
24928 | | ////////////////////////// |
24929 | | // JSON Patch functions // |
24930 | | ////////////////////////// |
24931 | | |
24932 | | /// @name JSON Patch functions |
24933 | | /// @{ |
24934 | | |
24935 | | /// @brief applies a JSON patch in-place without copying the object |
24936 | | /// @sa https://json.nlohmann.me/api/basic_json/patch/ |
24937 | | void patch_inplace(const basic_json& json_patch) |
24938 | | { |
24939 | | basic_json& result = *this; |
24940 | | // the valid JSON Patch operations |
24941 | | enum class patch_operations {add, remove, replace, move, copy, test, invalid}; |
24942 | | |
24943 | | const auto get_op = [](const string_t& op) |
24944 | | { |
24945 | | if (op == "add") |
24946 | | { |
24947 | | return patch_operations::add; |
24948 | | } |
24949 | | if (op == "remove") |
24950 | | { |
24951 | | return patch_operations::remove; |
24952 | | } |
24953 | | if (op == "replace") |
24954 | | { |
24955 | | return patch_operations::replace; |
24956 | | } |
24957 | | if (op == "move") |
24958 | | { |
24959 | | return patch_operations::move; |
24960 | | } |
24961 | | if (op == "copy") |
24962 | | { |
24963 | | return patch_operations::copy; |
24964 | | } |
24965 | | if (op == "test") |
24966 | | { |
24967 | | return patch_operations::test; |
24968 | | } |
24969 | | |
24970 | | return patch_operations::invalid; |
24971 | | }; |
24972 | | |
24973 | | // wrapper for "add" operation; add value at ptr |
24974 | | const auto operation_add = [&result](json_pointer & ptr, const basic_json & val) |
24975 | | { |
24976 | | // adding to the root of the target document means replacing it |
24977 | | if (ptr.empty()) |
24978 | | { |
24979 | | result = val; |
24980 | | return; |
24981 | | } |
24982 | | |
24983 | | // make sure the top element of the pointer exists |
24984 | | json_pointer const top_pointer = ptr.top(); |
24985 | | if (top_pointer != ptr) |
24986 | | { |
24987 | | result.at(top_pointer); |
24988 | | } |
24989 | | |
24990 | | // get reference to the parent of the JSON pointer ptr |
24991 | | const auto last_path = ptr.back(); |
24992 | | ptr.pop_back(); |
24993 | | // parent must exist when performing patch add per RFC6902 specs |
24994 | | basic_json& parent = result.at(ptr); |
24995 | | |
24996 | | switch (parent.m_data.m_type) |
24997 | | { |
24998 | | case value_t::null: |
24999 | | case value_t::object: |
25000 | | { |
25001 | | // use operator[] to add value |
25002 | | parent[last_path] = val; |
25003 | | break; |
25004 | | } |
25005 | | |
25006 | | case value_t::array: |
25007 | | { |
25008 | | if (last_path == "-") |
25009 | | { |
25010 | | // special case: append to back |
25011 | | parent.push_back(val); |
25012 | | } |
25013 | | else |
25014 | | { |
25015 | | const auto idx = json_pointer::template array_index<basic_json_t>(last_path); |
25016 | | if (JSON_HEDLEY_UNLIKELY(idx > parent.size())) |
25017 | | { |
25018 | | // avoid undefined behavior |
25019 | | JSON_THROW(out_of_range::create(401, detail::concat("array index ", std::to_string(idx), " is out of range"), &parent)); |
25020 | | } |
25021 | | |
25022 | | // default case: insert add offset |
25023 | | parent.insert(parent.begin() + static_cast<difference_type>(idx), val); |
25024 | | } |
25025 | | break; |
25026 | | } |
25027 | | |
25028 | | // if there exists a parent, it cannot be primitive |
25029 | | case value_t::string: // LCOV_EXCL_LINE |
25030 | | case value_t::boolean: // LCOV_EXCL_LINE |
25031 | | case value_t::number_integer: // LCOV_EXCL_LINE |
25032 | | case value_t::number_unsigned: // LCOV_EXCL_LINE |
25033 | | case value_t::number_float: // LCOV_EXCL_LINE |
25034 | | case value_t::binary: // LCOV_EXCL_LINE |
25035 | | case value_t::discarded: // LCOV_EXCL_LINE |
25036 | | default: // LCOV_EXCL_LINE |
25037 | | JSON_ASSERT(false); // NOLINT(cert-dcl03-c,hicpp-static-assert,misc-static-assert) LCOV_EXCL_LINE |
25038 | | } |
25039 | | }; |
25040 | | |
25041 | | // wrapper for "remove" operation; remove value at ptr |
25042 | | const auto operation_remove = [this, & result](json_pointer & ptr) |
25043 | | { |
25044 | | // get reference to the parent of the JSON pointer ptr |
25045 | | const auto last_path = ptr.back(); |
25046 | | ptr.pop_back(); |
25047 | | basic_json& parent = result.at(ptr); |
25048 | | |
25049 | | // remove child |
25050 | | if (parent.is_object()) |
25051 | | { |
25052 | | // perform range check |
25053 | | auto it = parent.find(last_path); |
25054 | | if (JSON_HEDLEY_LIKELY(it != parent.end())) |
25055 | | { |
25056 | | parent.erase(it); |
25057 | | } |
25058 | | else |
25059 | | { |
25060 | | JSON_THROW(out_of_range::create(403, detail::concat("key '", last_path, "' not found"), this)); |
25061 | | } |
25062 | | } |
25063 | | else if (parent.is_array()) |
25064 | | { |
25065 | | // note erase performs range check |
25066 | | parent.erase(json_pointer::template array_index<basic_json_t>(last_path)); |
25067 | | } |
25068 | | }; |
25069 | | |
25070 | | // type check: top level value must be an array |
25071 | | if (JSON_HEDLEY_UNLIKELY(!json_patch.is_array())) |
25072 | | { |
25073 | | JSON_THROW(parse_error::create(104, 0, "JSON patch must be an array of objects", &json_patch)); |
25074 | | } |
25075 | | |
25076 | | // iterate and apply the operations |
25077 | | for (const auto& val : json_patch) |
25078 | | { |
25079 | | // wrapper to get a value for an operation |
25080 | | const auto get_value = [&val](const string_t& op, |
25081 | | const string_t& member, |
25082 | | bool string_type) -> basic_json & |
25083 | | { |
25084 | | // find value |
25085 | | auto it = val.m_data.m_value.object->find(member); |
25086 | | |
25087 | | // context-sensitive error message |
25088 | | const auto error_msg = (op == "op") ? "operation" : detail::concat("operation '", op, '\''); // NOLINT(bugprone-unused-local-non-trivial-variable) |
25089 | | |
25090 | | // check if the desired value is present |
25091 | | if (JSON_HEDLEY_UNLIKELY(it == val.m_data.m_value.object->end())) |
25092 | | { |
25093 | | // NOLINTNEXTLINE(performance-inefficient-string-concatenation) |
25094 | | JSON_THROW(parse_error::create(105, 0, detail::concat(error_msg, " must have member '", member, "'"), &val)); |
25095 | | } |
25096 | | |
25097 | | // check if the result is of type string |
25098 | | if (JSON_HEDLEY_UNLIKELY(string_type && !it->second.is_string())) |
25099 | | { |
25100 | | // NOLINTNEXTLINE(performance-inefficient-string-concatenation) |
25101 | | JSON_THROW(parse_error::create(105, 0, detail::concat(error_msg, " must have string member '", member, "'"), &val)); |
25102 | | } |
25103 | | |
25104 | | // no error: return value |
25105 | | return it->second; |
25106 | | }; |
25107 | | |
25108 | | // type check: every element of the array must be an object |
25109 | | if (JSON_HEDLEY_UNLIKELY(!val.is_object())) |
25110 | | { |
25111 | | JSON_THROW(parse_error::create(104, 0, "JSON patch must be an array of objects", &val)); |
25112 | | } |
25113 | | |
25114 | | // collect mandatory members |
25115 | | const auto op = get_value("op", "op", true).template get<string_t>(); |
25116 | | const auto path = get_value(op, "path", true).template get<string_t>(); |
25117 | | json_pointer ptr(path); |
25118 | | |
25119 | | switch (get_op(op)) |
25120 | | { |
25121 | | case patch_operations::add: |
25122 | | { |
25123 | | operation_add(ptr, get_value("add", "value", false)); |
25124 | | break; |
25125 | | } |
25126 | | |
25127 | | case patch_operations::remove: |
25128 | | { |
25129 | | operation_remove(ptr); |
25130 | | break; |
25131 | | } |
25132 | | |
25133 | | case patch_operations::replace: |
25134 | | { |
25135 | | // the "path" location must exist - use at() |
25136 | | result.at(ptr) = get_value("replace", "value", false); |
25137 | | break; |
25138 | | } |
25139 | | |
25140 | | case patch_operations::move: |
25141 | | { |
25142 | | const auto from_path = get_value("move", "from", true).template get<string_t>(); |
25143 | | json_pointer from_ptr(from_path); |
25144 | | |
25145 | | // the "from" location must exist - use at() |
25146 | | basic_json const v = result.at(from_ptr); |
25147 | | |
25148 | | // The move operation is functionally identical to a |
25149 | | // "remove" operation on the "from" location, followed |
25150 | | // immediately by an "add" operation at the target |
25151 | | // location with the value that was just removed. |
25152 | | operation_remove(from_ptr); |
25153 | | operation_add(ptr, v); |
25154 | | break; |
25155 | | } |
25156 | | |
25157 | | case patch_operations::copy: |
25158 | | { |
25159 | | const auto from_path = get_value("copy", "from", true).template get<string_t>(); |
25160 | | const json_pointer from_ptr(from_path); |
25161 | | |
25162 | | // the "from" location must exist - use at() |
25163 | | basic_json const v = result.at(from_ptr); |
25164 | | |
25165 | | // The copy is functionally identical to an "add" |
25166 | | // operation at the target location using the value |
25167 | | // specified in the "from" member. |
25168 | | operation_add(ptr, v); |
25169 | | break; |
25170 | | } |
25171 | | |
25172 | | case patch_operations::test: |
25173 | | { |
25174 | | bool success = false; |
25175 | | JSON_TRY |
25176 | | { |
25177 | | // check if "value" matches the one at "path" |
25178 | | // the "path" location must exist - use at() |
25179 | | success = (result.at(ptr) == get_value("test", "value", false)); |
25180 | | } |
25181 | | JSON_INTERNAL_CATCH (out_of_range&) |
25182 | | { |
25183 | | // ignore out of range errors: success remains false |
25184 | | } |
25185 | | |
25186 | | // throw an exception if the test fails |
25187 | | if (JSON_HEDLEY_UNLIKELY(!success)) |
25188 | | { |
25189 | | JSON_THROW(other_error::create(501, detail::concat("unsuccessful: ", val.dump()), &val)); |
25190 | | } |
25191 | | |
25192 | | break; |
25193 | | } |
25194 | | |
25195 | | case patch_operations::invalid: |
25196 | | default: |
25197 | | { |
25198 | | // op must be "add", "remove", "replace", "move", "copy", or |
25199 | | // "test" |
25200 | | JSON_THROW(parse_error::create(105, 0, detail::concat("operation value '", op, "' is invalid"), &val)); |
25201 | | } |
25202 | | } |
25203 | | } |
25204 | | } |
25205 | | |
25206 | | /// @brief applies a JSON patch to a copy of the current object |
25207 | | /// @sa https://json.nlohmann.me/api/basic_json/patch/ |
25208 | | basic_json patch(const basic_json& json_patch) const |
25209 | | { |
25210 | | basic_json result = *this; |
25211 | | result.patch_inplace(json_patch); |
25212 | | return result; |
25213 | | } |
25214 | | |
25215 | | /// @brief creates a diff as a JSON patch |
25216 | | /// @sa https://json.nlohmann.me/api/basic_json/diff/ |
25217 | | JSON_HEDLEY_WARN_UNUSED_RESULT |
25218 | | static basic_json diff(const basic_json& source, const basic_json& target, |
25219 | | const string_t& path = "") |
25220 | | { |
25221 | | // the patch |
25222 | | basic_json result(value_t::array); |
25223 | | |
25224 | | // if the values are the same, return an empty patch |
25225 | | if (source == target) |
25226 | | { |
25227 | | return result; |
25228 | | } |
25229 | | |
25230 | | if (source.type() != target.type()) |
25231 | | { |
25232 | | // different types: replace value |
25233 | | result.push_back( |
25234 | | { |
25235 | | {"op", "replace"}, {"path", path}, {"value", target} |
25236 | | }); |
25237 | | return result; |
25238 | | } |
25239 | | |
25240 | | switch (source.type()) |
25241 | | { |
25242 | | case value_t::array: |
25243 | | { |
25244 | | // first pass: traverse common elements |
25245 | | std::size_t i = 0; |
25246 | | while (i < source.size() && i < target.size()) |
25247 | | { |
25248 | | // recursive call to compare array values at index i |
25249 | | auto temp_diff = diff(source[i], target[i], detail::concat<string_t>(path, '/', detail::to_string<string_t>(i))); |
25250 | | result.insert(result.end(), temp_diff.begin(), temp_diff.end()); |
25251 | | ++i; |
25252 | | } |
25253 | | |
25254 | | // We now reached the end of at least one array |
25255 | | // in a second pass, traverse the remaining elements |
25256 | | |
25257 | | // remove my remaining elements |
25258 | | const auto end_index = static_cast<difference_type>(result.size()); |
25259 | | while (i < source.size()) |
25260 | | { |
25261 | | // add operations in reverse order to avoid invalid |
25262 | | // indices |
25263 | | result.insert(result.begin() + end_index, object( |
25264 | | { |
25265 | | {"op", "remove"}, |
25266 | | {"path", detail::concat<string_t>(path, '/', detail::to_string<string_t>(i))} |
25267 | | })); |
25268 | | ++i; |
25269 | | } |
25270 | | |
25271 | | // add other remaining elements |
25272 | | while (i < target.size()) |
25273 | | { |
25274 | | result.push_back( |
25275 | | { |
25276 | | {"op", "add"}, |
25277 | | {"path", detail::concat<string_t>(path, "/-")}, |
25278 | | {"value", target[i]} |
25279 | | }); |
25280 | | ++i; |
25281 | | } |
25282 | | |
25283 | | break; |
25284 | | } |
25285 | | |
25286 | | case value_t::object: |
25287 | | { |
25288 | | // first pass: traverse this object's elements |
25289 | | for (auto it = source.cbegin(); it != source.cend(); ++it) |
25290 | | { |
25291 | | // escape the key name to be used in a JSON patch |
25292 | | const auto path_key = detail::concat<string_t>(path, '/', detail::escape(it.key())); |
25293 | | |
25294 | | if (target.find(it.key()) != target.end()) |
25295 | | { |
25296 | | // recursive call to compare object values at key it |
25297 | | auto temp_diff = diff(it.value(), target[it.key()], path_key); |
25298 | | result.insert(result.end(), temp_diff.begin(), temp_diff.end()); |
25299 | | } |
25300 | | else |
25301 | | { |
25302 | | // found a key that is not in o -> remove it |
25303 | | result.push_back(object( |
25304 | | { |
25305 | | {"op", "remove"}, {"path", path_key} |
25306 | | })); |
25307 | | } |
25308 | | } |
25309 | | |
25310 | | // second pass: traverse other object's elements |
25311 | | for (auto it = target.cbegin(); it != target.cend(); ++it) |
25312 | | { |
25313 | | if (source.find(it.key()) == source.end()) |
25314 | | { |
25315 | | // found a key that is not in this -> add it |
25316 | | const auto path_key = detail::concat<string_t>(path, '/', detail::escape(it.key())); |
25317 | | result.push_back( |
25318 | | { |
25319 | | {"op", "add"}, {"path", path_key}, |
25320 | | {"value", it.value()} |
25321 | | }); |
25322 | | } |
25323 | | } |
25324 | | |
25325 | | break; |
25326 | | } |
25327 | | |
25328 | | case value_t::null: |
25329 | | case value_t::string: |
25330 | | case value_t::boolean: |
25331 | | case value_t::number_integer: |
25332 | | case value_t::number_unsigned: |
25333 | | case value_t::number_float: |
25334 | | case value_t::binary: |
25335 | | case value_t::discarded: |
25336 | | default: |
25337 | | { |
25338 | | // both primitive types: replace value |
25339 | | result.push_back( |
25340 | | { |
25341 | | {"op", "replace"}, {"path", path}, {"value", target} |
25342 | | }); |
25343 | | break; |
25344 | | } |
25345 | | } |
25346 | | |
25347 | | return result; |
25348 | | } |
25349 | | /// @} |
25350 | | |
25351 | | //////////////////////////////// |
25352 | | // JSON Merge Patch functions // |
25353 | | //////////////////////////////// |
25354 | | |
25355 | | /// @name JSON Merge Patch functions |
25356 | | /// @{ |
25357 | | |
25358 | | /// @brief applies a JSON Merge Patch |
25359 | | /// @sa https://json.nlohmann.me/api/basic_json/merge_patch/ |
25360 | | void merge_patch(const basic_json& apply_patch) |
25361 | | { |
25362 | | if (apply_patch.is_object()) |
25363 | | { |
25364 | | if (!is_object()) |
25365 | | { |
25366 | | *this = object(); |
25367 | | } |
25368 | | for (auto it = apply_patch.begin(); it != apply_patch.end(); ++it) |
25369 | | { |
25370 | | if (it.value().is_null()) |
25371 | | { |
25372 | | erase(it.key()); |
25373 | | } |
25374 | | else |
25375 | | { |
25376 | | operator[](it.key()).merge_patch(it.value()); |
25377 | | } |
25378 | | } |
25379 | | } |
25380 | | else |
25381 | | { |
25382 | | *this = apply_patch; |
25383 | | } |
25384 | | } |
25385 | | |
25386 | | /// @} |
25387 | | }; |
25388 | | |
25389 | | /// @brief user-defined to_string function for JSON values |
25390 | | /// @sa https://json.nlohmann.me/api/basic_json/to_string/ |
25391 | | NLOHMANN_BASIC_JSON_TPL_DECLARATION |
25392 | | std::string to_string(const NLOHMANN_BASIC_JSON_TPL& j) |
25393 | | { |
25394 | | return j.dump(); |
25395 | | } |
25396 | | |
25397 | | inline namespace literals |
25398 | | { |
25399 | | inline namespace json_literals |
25400 | | { |
25401 | | |
25402 | | /// @brief user-defined string literal for JSON values |
25403 | | /// @sa https://json.nlohmann.me/api/basic_json/operator_literal_json/ |
25404 | | JSON_HEDLEY_NON_NULL(1) |
25405 | | #if !defined(JSON_HEDLEY_GCC_VERSION) || JSON_HEDLEY_GCC_VERSION_CHECK(4,9,0) |
25406 | | inline nlohmann::json operator""_json(const char* s, std::size_t n) |
25407 | | #else |
25408 | | // GCC 4.8 requires a space between "" and suffix |
25409 | | inline nlohmann::json operator"" _json(const char* s, std::size_t n) |
25410 | | #endif |
25411 | 0 | { |
25412 | 0 | return nlohmann::json::parse(s, s + n); |
25413 | 0 | } |
25414 | | |
25415 | | #if defined(__cpp_char8_t) |
25416 | | JSON_HEDLEY_NON_NULL(1) |
25417 | | inline nlohmann::json operator""_json(const char8_t* s, std::size_t n) |
25418 | 0 | { |
25419 | 0 | return nlohmann::json::parse(reinterpret_cast<const char*>(s), |
25420 | 0 | reinterpret_cast<const char*>(s) + n); |
25421 | 0 | } |
25422 | | #endif |
25423 | | |
25424 | | /// @brief user-defined string literal for JSON pointer |
25425 | | /// @sa https://json.nlohmann.me/api/basic_json/operator_literal_json_pointer/ |
25426 | | JSON_HEDLEY_NON_NULL(1) |
25427 | | #if !defined(JSON_HEDLEY_GCC_VERSION) || JSON_HEDLEY_GCC_VERSION_CHECK(4,9,0) |
25428 | | inline nlohmann::json::json_pointer operator""_json_pointer(const char* s, std::size_t n) |
25429 | | #else |
25430 | | // GCC 4.8 requires a space between "" and suffix |
25431 | | inline nlohmann::json::json_pointer operator"" _json_pointer(const char* s, std::size_t n) |
25432 | | #endif |
25433 | 0 | { |
25434 | 0 | return nlohmann::json::json_pointer(std::string(s, n)); |
25435 | 0 | } |
25436 | | |
25437 | | #if defined(__cpp_char8_t) |
25438 | | inline nlohmann::json::json_pointer operator""_json_pointer(const char8_t* s, std::size_t n) |
25439 | 0 | { |
25440 | 0 | return nlohmann::json::json_pointer(std::string(reinterpret_cast<const char*>(s), n)); |
25441 | 0 | } |
25442 | | #endif |
25443 | | |
25444 | | } // namespace json_literals |
25445 | | } // namespace literals |
25446 | | NLOHMANN_JSON_NAMESPACE_END |
25447 | | |
25448 | | /////////////////////// |
25449 | | // nonmember support // |
25450 | | /////////////////////// |
25451 | | |
25452 | | namespace std // NOLINT(cert-dcl58-cpp) |
25453 | | { |
25454 | | |
25455 | | /// @brief hash value for JSON objects |
25456 | | /// @sa https://json.nlohmann.me/api/basic_json/std_hash/ |
25457 | | NLOHMANN_BASIC_JSON_TPL_DECLARATION |
25458 | | struct hash<nlohmann::NLOHMANN_BASIC_JSON_TPL> // NOLINT(cert-dcl58-cpp) |
25459 | | { |
25460 | | std::size_t operator()(const nlohmann::NLOHMANN_BASIC_JSON_TPL& j) const |
25461 | | { |
25462 | | return nlohmann::detail::hash(j); |
25463 | | } |
25464 | | }; |
25465 | | |
25466 | | // specialization for std::less<value_t> |
25467 | | template<> |
25468 | | struct less< ::nlohmann::detail::value_t> // do not remove the space after '<', see https://github.com/nlohmann/json/pull/679 |
25469 | | { |
25470 | | /*! |
25471 | | @brief compare two value_t enum values |
25472 | | @since version 3.0.0 |
25473 | | */ |
25474 | | bool operator()(::nlohmann::detail::value_t lhs, |
25475 | | ::nlohmann::detail::value_t rhs) const noexcept |
25476 | 0 | { |
25477 | 0 | #if JSON_HAS_THREE_WAY_COMPARISON |
25478 | 0 | return std::is_lt(lhs <=> rhs); // *NOPAD* |
25479 | 0 | #else |
25480 | 0 | return ::nlohmann::detail::operator<(lhs, rhs); |
25481 | 0 | #endif |
25482 | 0 | } |
25483 | | }; |
25484 | | |
25485 | | // C++20 prohibit function specialization in the std namespace. |
25486 | | #ifndef JSON_HAS_CPP_20 |
25487 | | |
25488 | | /// @brief exchanges the values of two JSON objects |
25489 | | /// @sa https://json.nlohmann.me/api/basic_json/std_swap/ |
25490 | | NLOHMANN_BASIC_JSON_TPL_DECLARATION |
25491 | | inline void swap(nlohmann::NLOHMANN_BASIC_JSON_TPL& j1, nlohmann::NLOHMANN_BASIC_JSON_TPL& j2) noexcept( // NOLINT(readability-inconsistent-declaration-parameter-name, cert-dcl58-cpp) |
25492 | | is_nothrow_move_constructible<nlohmann::NLOHMANN_BASIC_JSON_TPL>::value&& // NOLINT(misc-redundant-expression,cppcoreguidelines-noexcept-swap,performance-noexcept-swap) |
25493 | | is_nothrow_move_assignable<nlohmann::NLOHMANN_BASIC_JSON_TPL>::value) |
25494 | | { |
25495 | | j1.swap(j2); |
25496 | | } |
25497 | | |
25498 | | #endif |
25499 | | |
25500 | | } // namespace std |
25501 | | |
25502 | | #if JSON_USE_GLOBAL_UDLS |
25503 | | #if !defined(JSON_HEDLEY_GCC_VERSION) || JSON_HEDLEY_GCC_VERSION_CHECK(4,9,0) |
25504 | | using nlohmann::literals::json_literals::operator""_json; // NOLINT(misc-unused-using-decls,google-global-names-in-headers) |
25505 | | using nlohmann::literals::json_literals::operator""_json_pointer; //NOLINT(misc-unused-using-decls,google-global-names-in-headers) |
25506 | | #else |
25507 | | // GCC 4.8 requires a space between "" and suffix |
25508 | | using nlohmann::literals::json_literals::operator"" _json; // NOLINT(misc-unused-using-decls,google-global-names-in-headers) |
25509 | | using nlohmann::literals::json_literals::operator"" _json_pointer; //NOLINT(misc-unused-using-decls,google-global-names-in-headers) |
25510 | | #endif |
25511 | | #endif |
25512 | | |
25513 | | // #include <nlohmann/detail/macro_unscope.hpp> |
25514 | | // __ _____ _____ _____ |
25515 | | // __| | __| | | | JSON for Modern C++ |
25516 | | // | | |__ | | | | | | version 3.12.0 |
25517 | | // |_____|_____|_____|_|___| https://github.com/nlohmann/json |
25518 | | // |
25519 | | // SPDX-FileCopyrightText: 2013-2026 Niels Lohmann <https://nlohmann.me> |
25520 | | // SPDX-License-Identifier: MIT |
25521 | | |
25522 | | |
25523 | | |
25524 | | // restore clang diagnostic settings |
25525 | | #if defined(__clang__) |
25526 | | #pragma clang diagnostic pop |
25527 | | #endif |
25528 | | |
25529 | | // clean up |
25530 | | #undef JSON_ASSERT |
25531 | | #undef JSON_INTERNAL_CATCH |
25532 | | #undef JSON_THROW |
25533 | | #undef JSON_PRIVATE_UNLESS_TESTED |
25534 | | #undef NLOHMANN_BASIC_JSON_TPL_DECLARATION |
25535 | | #undef NLOHMANN_BASIC_JSON_TPL |
25536 | | #undef JSON_EXPLICIT |
25537 | | #undef NLOHMANN_CAN_CALL_STD_FUNC_IMPL |
25538 | | #undef JSON_INLINE_VARIABLE |
25539 | | #undef JSON_NO_UNIQUE_ADDRESS |
25540 | | #undef JSON_DISABLE_ENUM_SERIALIZATION |
25541 | | #undef JSON_USE_GLOBAL_UDLS |
25542 | | |
25543 | | #ifndef JSON_TEST_KEEP_MACROS |
25544 | | #undef JSON_CATCH |
25545 | | #undef JSON_TRY |
25546 | | #undef JSON_HAS_CPP_11 |
25547 | | #undef JSON_HAS_CPP_14 |
25548 | | #undef JSON_HAS_CPP_17 |
25549 | | #undef JSON_HAS_CPP_20 |
25550 | | #undef JSON_HAS_CPP_23 |
25551 | | #undef JSON_HAS_CPP_26 |
25552 | | #undef JSON_HAS_FILESYSTEM |
25553 | | #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM |
25554 | | #undef JSON_HAS_THREE_WAY_COMPARISON |
25555 | | #undef JSON_HAS_RANGES |
25556 | | #undef JSON_HAS_STATIC_RTTI |
25557 | | #undef JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON |
25558 | | #endif |
25559 | | |
25560 | | // #include <nlohmann/thirdparty/hedley/hedley_undef.hpp> |
25561 | | // __ _____ _____ _____ |
25562 | | // __| | __| | | | JSON for Modern C++ |
25563 | | // | | |__ | | | | | | version 3.12.0 |
25564 | | // |_____|_____|_____|_|___| https://github.com/nlohmann/json |
25565 | | // |
25566 | | // SPDX-FileCopyrightText: 2013-2026 Niels Lohmann <https://nlohmann.me> |
25567 | | // SPDX-License-Identifier: MIT |
25568 | | |
25569 | | |
25570 | | |
25571 | | #undef JSON_HEDLEY_ALWAYS_INLINE |
25572 | | #undef JSON_HEDLEY_ARM_VERSION |
25573 | | #undef JSON_HEDLEY_ARM_VERSION_CHECK |
25574 | | #undef JSON_HEDLEY_ARRAY_PARAM |
25575 | | #undef JSON_HEDLEY_ASSUME |
25576 | | #undef JSON_HEDLEY_BEGIN_C_DECLS |
25577 | | #undef JSON_HEDLEY_CLANG_HAS_ATTRIBUTE |
25578 | | #undef JSON_HEDLEY_CLANG_HAS_BUILTIN |
25579 | | #undef JSON_HEDLEY_CLANG_HAS_CPP_ATTRIBUTE |
25580 | | #undef JSON_HEDLEY_CLANG_HAS_DECLSPEC_DECLSPEC_ATTRIBUTE |
25581 | | #undef JSON_HEDLEY_CLANG_HAS_EXTENSION |
25582 | | #undef JSON_HEDLEY_CLANG_HAS_FEATURE |
25583 | | #undef JSON_HEDLEY_CLANG_HAS_WARNING |
25584 | | #undef JSON_HEDLEY_COMPCERT_VERSION |
25585 | | #undef JSON_HEDLEY_COMPCERT_VERSION_CHECK |
25586 | | #undef JSON_HEDLEY_CONCAT |
25587 | | #undef JSON_HEDLEY_CONCAT3 |
25588 | | #undef JSON_HEDLEY_CONCAT3_EX |
25589 | | #undef JSON_HEDLEY_CONCAT_EX |
25590 | | #undef JSON_HEDLEY_CONST |
25591 | | #undef JSON_HEDLEY_CONSTEXPR |
25592 | | #undef JSON_HEDLEY_CONST_CAST |
25593 | | #undef JSON_HEDLEY_CPP_CAST |
25594 | | #undef JSON_HEDLEY_CRAY_VERSION |
25595 | | #undef JSON_HEDLEY_CRAY_VERSION_CHECK |
25596 | | #undef JSON_HEDLEY_C_DECL |
25597 | | #undef JSON_HEDLEY_DEPRECATED |
25598 | | #undef JSON_HEDLEY_DEPRECATED_FOR |
25599 | | #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL |
25600 | | #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_ |
25601 | | #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED |
25602 | | #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES |
25603 | | #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS |
25604 | | #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION |
25605 | | #undef JSON_HEDLEY_DIAGNOSTIC_POP |
25606 | | #undef JSON_HEDLEY_DIAGNOSTIC_PUSH |
25607 | | #undef JSON_HEDLEY_DMC_VERSION |
25608 | | #undef JSON_HEDLEY_DMC_VERSION_CHECK |
25609 | | #undef JSON_HEDLEY_EMPTY_BASES |
25610 | | #undef JSON_HEDLEY_EMSCRIPTEN_VERSION |
25611 | | #undef JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK |
25612 | | #undef JSON_HEDLEY_END_C_DECLS |
25613 | | #undef JSON_HEDLEY_FLAGS |
25614 | | #undef JSON_HEDLEY_FLAGS_CAST |
25615 | | #undef JSON_HEDLEY_GCC_HAS_ATTRIBUTE |
25616 | | #undef JSON_HEDLEY_GCC_HAS_BUILTIN |
25617 | | #undef JSON_HEDLEY_GCC_HAS_CPP_ATTRIBUTE |
25618 | | #undef JSON_HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE |
25619 | | #undef JSON_HEDLEY_GCC_HAS_EXTENSION |
25620 | | #undef JSON_HEDLEY_GCC_HAS_FEATURE |
25621 | | #undef JSON_HEDLEY_GCC_HAS_WARNING |
25622 | | #undef JSON_HEDLEY_GCC_NOT_CLANG_VERSION_CHECK |
25623 | | #undef JSON_HEDLEY_GCC_VERSION |
25624 | | #undef JSON_HEDLEY_GCC_VERSION_CHECK |
25625 | | #undef JSON_HEDLEY_GNUC_HAS_ATTRIBUTE |
25626 | | #undef JSON_HEDLEY_GNUC_HAS_BUILTIN |
25627 | | #undef JSON_HEDLEY_GNUC_HAS_CPP_ATTRIBUTE |
25628 | | #undef JSON_HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE |
25629 | | #undef JSON_HEDLEY_GNUC_HAS_EXTENSION |
25630 | | #undef JSON_HEDLEY_GNUC_HAS_FEATURE |
25631 | | #undef JSON_HEDLEY_GNUC_HAS_WARNING |
25632 | | #undef JSON_HEDLEY_GNUC_VERSION |
25633 | | #undef JSON_HEDLEY_GNUC_VERSION_CHECK |
25634 | | #undef JSON_HEDLEY_HAS_ATTRIBUTE |
25635 | | #undef JSON_HEDLEY_HAS_BUILTIN |
25636 | | #undef JSON_HEDLEY_HAS_CPP_ATTRIBUTE |
25637 | | #undef JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS |
25638 | | #undef JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE |
25639 | | #undef JSON_HEDLEY_HAS_EXTENSION |
25640 | | #undef JSON_HEDLEY_HAS_FEATURE |
25641 | | #undef JSON_HEDLEY_HAS_WARNING |
25642 | | #undef JSON_HEDLEY_IAR_VERSION |
25643 | | #undef JSON_HEDLEY_IAR_VERSION_CHECK |
25644 | | #undef JSON_HEDLEY_IBM_VERSION |
25645 | | #undef JSON_HEDLEY_IBM_VERSION_CHECK |
25646 | | #undef JSON_HEDLEY_IMPORT |
25647 | | #undef JSON_HEDLEY_INLINE |
25648 | | #undef JSON_HEDLEY_INTEL_CL_VERSION |
25649 | | #undef JSON_HEDLEY_INTEL_CL_VERSION_CHECK |
25650 | | #undef JSON_HEDLEY_INTEL_VERSION |
25651 | | #undef JSON_HEDLEY_INTEL_VERSION_CHECK |
25652 | | #undef JSON_HEDLEY_IS_CONSTANT |
25653 | | #undef JSON_HEDLEY_IS_CONSTEXPR_ |
25654 | | #undef JSON_HEDLEY_LIKELY |
25655 | | #undef JSON_HEDLEY_MALLOC |
25656 | | #undef JSON_HEDLEY_MCST_LCC_VERSION |
25657 | | #undef JSON_HEDLEY_MCST_LCC_VERSION_CHECK |
25658 | | #undef JSON_HEDLEY_MESSAGE |
25659 | | #undef JSON_HEDLEY_MSVC_VERSION |
25660 | | #undef JSON_HEDLEY_MSVC_VERSION_CHECK |
25661 | | #undef JSON_HEDLEY_NEVER_INLINE |
25662 | | #undef JSON_HEDLEY_NON_NULL |
25663 | | #undef JSON_HEDLEY_NO_ESCAPE |
25664 | | #undef JSON_HEDLEY_NO_RETURN |
25665 | | #undef JSON_HEDLEY_NO_THROW |
25666 | | #undef JSON_HEDLEY_NULL |
25667 | | #undef JSON_HEDLEY_PELLES_VERSION |
25668 | | #undef JSON_HEDLEY_PELLES_VERSION_CHECK |
25669 | | #undef JSON_HEDLEY_PGI_VERSION |
25670 | | #undef JSON_HEDLEY_PGI_VERSION_CHECK |
25671 | | #undef JSON_HEDLEY_PREDICT |
25672 | | #undef JSON_HEDLEY_PRINTF_FORMAT |
25673 | | #undef JSON_HEDLEY_PRIVATE |
25674 | | #undef JSON_HEDLEY_PUBLIC |
25675 | | #undef JSON_HEDLEY_PURE |
25676 | | #undef JSON_HEDLEY_REINTERPRET_CAST |
25677 | | #undef JSON_HEDLEY_REQUIRE |
25678 | | #undef JSON_HEDLEY_REQUIRE_CONSTEXPR |
25679 | | #undef JSON_HEDLEY_REQUIRE_MSG |
25680 | | #undef JSON_HEDLEY_RESTRICT |
25681 | | #undef JSON_HEDLEY_RETURNS_NON_NULL |
25682 | | #undef JSON_HEDLEY_SENTINEL |
25683 | | #undef JSON_HEDLEY_STATIC_ASSERT |
25684 | | #undef JSON_HEDLEY_STATIC_CAST |
25685 | | #undef JSON_HEDLEY_STRINGIFY |
25686 | | #undef JSON_HEDLEY_STRINGIFY_EX |
25687 | | #undef JSON_HEDLEY_SUNPRO_VERSION |
25688 | | #undef JSON_HEDLEY_SUNPRO_VERSION_CHECK |
25689 | | #undef JSON_HEDLEY_TINYC_VERSION |
25690 | | #undef JSON_HEDLEY_TINYC_VERSION_CHECK |
25691 | | #undef JSON_HEDLEY_TI_ARMCL_VERSION |
25692 | | #undef JSON_HEDLEY_TI_ARMCL_VERSION_CHECK |
25693 | | #undef JSON_HEDLEY_TI_CL2000_VERSION |
25694 | | #undef JSON_HEDLEY_TI_CL2000_VERSION_CHECK |
25695 | | #undef JSON_HEDLEY_TI_CL430_VERSION |
25696 | | #undef JSON_HEDLEY_TI_CL430_VERSION_CHECK |
25697 | | #undef JSON_HEDLEY_TI_CL6X_VERSION |
25698 | | #undef JSON_HEDLEY_TI_CL6X_VERSION_CHECK |
25699 | | #undef JSON_HEDLEY_TI_CL7X_VERSION |
25700 | | #undef JSON_HEDLEY_TI_CL7X_VERSION_CHECK |
25701 | | #undef JSON_HEDLEY_TI_CLPRU_VERSION |
25702 | | #undef JSON_HEDLEY_TI_CLPRU_VERSION_CHECK |
25703 | | #undef JSON_HEDLEY_TI_VERSION |
25704 | | #undef JSON_HEDLEY_TI_VERSION_CHECK |
25705 | | #undef JSON_HEDLEY_UNAVAILABLE |
25706 | | #undef JSON_HEDLEY_UNLIKELY |
25707 | | #undef JSON_HEDLEY_UNPREDICTABLE |
25708 | | #undef JSON_HEDLEY_UNREACHABLE |
25709 | | #undef JSON_HEDLEY_UNREACHABLE_RETURN |
25710 | | #undef JSON_HEDLEY_VERSION |
25711 | | #undef JSON_HEDLEY_VERSION_DECODE_MAJOR |
25712 | | #undef JSON_HEDLEY_VERSION_DECODE_MINOR |
25713 | | #undef JSON_HEDLEY_VERSION_DECODE_REVISION |
25714 | | #undef JSON_HEDLEY_VERSION_ENCODE |
25715 | | #undef JSON_HEDLEY_WARNING |
25716 | | #undef JSON_HEDLEY_WARN_UNUSED_RESULT |
25717 | | #undef JSON_HEDLEY_WARN_UNUSED_RESULT_MSG |
25718 | | #undef JSON_HEDLEY_FALL_THROUGH |
25719 | | |
25720 | | |
25721 | | |
25722 | | #endif // INCLUDE_NLOHMANN_JSON_HPP_ |