JSON for Modern C++ 3.10.4
json.hpp
1/*
2 __ _____ _____ _____
3 __| | __| | | | JSON for Modern C++
4| | |__ | | | | | | version 3.10.4
5|_____|_____|_____|_|___| https://github.com/nlohmann/json
6
7Licensed under the MIT License <http://opensource.org/licenses/MIT>.
8SPDX-License-Identifier: MIT
9Copyright (c) 2013-2019 Niels Lohmann <http://nlohmann.me>.
10
11Permission is hereby granted, free of charge, to any person obtaining a copy
12of this software and associated documentation files (the "Software"), to deal
13in the Software without restriction, including without limitation the rights
14to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15copies of the Software, and to permit persons to whom the Software is
16furnished to do so, subject to the following conditions:
17
18The above copyright notice and this permission notice shall be included in all
19copies or substantial portions of the Software.
20
21THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
26OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
27SOFTWARE.
28*/
29
30#ifndef INCLUDE_NLOHMANN_JSON_HPP_
31#define INCLUDE_NLOHMANN_JSON_HPP_
32
33#define NLOHMANN_JSON_VERSION_MAJOR 3
34#define NLOHMANN_JSON_VERSION_MINOR 10
35#define NLOHMANN_JSON_VERSION_PATCH 4
36
37#include <algorithm> // all_of, find, for_each
38#include <cstddef> // nullptr_t, ptrdiff_t, size_t
39#include <functional> // hash, less
40#include <initializer_list> // initializer_list
41#ifndef JSON_NO_IO
42 #include <iosfwd> // istream, ostream
43#endif // JSON_NO_IO
44#include <iterator> // random_access_iterator_tag
45#include <memory> // unique_ptr
46#include <numeric> // accumulate
47#include <string> // string, stoi, to_string
48#include <utility> // declval, forward, move, pair, swap
49#include <vector> // vector
50
51// #include <nlohmann/adl_serializer.hpp>
52
53
54#include <type_traits>
55#include <utility>
56
57// #include <nlohmann/detail/conversions/from_json.hpp>
58
59
60#include <algorithm> // transform
61#include <array> // array
62#include <forward_list> // forward_list
63#include <iterator> // inserter, front_inserter, end
64#include <map> // map
65#include <string> // string
66#include <tuple> // tuple, make_tuple
67#include <type_traits> // is_arithmetic, is_same, is_enum, underlying_type, is_convertible
68#include <unordered_map> // unordered_map
69#include <utility> // pair, declval
70#include <valarray> // valarray
71
72// #include <nlohmann/detail/exceptions.hpp>
73
74
75#include <exception> // exception
76#include <stdexcept> // runtime_error
77#include <string> // to_string
78#include <vector> // vector
79
80// #include <nlohmann/detail/value_t.hpp>
81
82
83#include <array> // array
84#include <cstddef> // size_t
85#include <cstdint> // uint8_t
86#include <string> // string
87
88namespace nlohmann
89{
90namespace detail
91{
93// JSON type enumeration //
95
120enum class value_t : std::uint8_t
121{
122 null,
123 object,
124 array,
125 string,
126 boolean,
127 number_integer,
128 number_unsigned,
129 number_float,
130 binary,
131 discarded
132};
133
147inline bool operator<(const value_t lhs, const value_t rhs) noexcept
148{
149 static constexpr std::array<std::uint8_t, 9> order = {{
150 0 /* null */, 3 /* object */, 4 /* array */, 5 /* string */,
151 1 /* boolean */, 2 /* integer */, 2 /* unsigned */, 2 /* float */,
152 6 /* binary */
153 }
154 };
155
156 const auto l_index = static_cast<std::size_t>(lhs);
157 const auto r_index = static_cast<std::size_t>(rhs);
158 return l_index < order.size() && r_index < order.size() && order[l_index] < order[r_index];
159}
160} // namespace detail
161} // namespace nlohmann
162
163// #include <nlohmann/detail/string_escape.hpp>
164
165
166#include <string>
167// #include <nlohmann/detail/macro_scope.hpp>
168
169
170#include <utility> // declval, pair
171// #include <nlohmann/thirdparty/hedley/hedley.hpp>
172
173
174/* Hedley - https://nemequ.github.io/hedley
175 * Created by Evan Nemerson <evan@nemerson.com>
176 *
177 * To the extent possible under law, the author(s) have dedicated all
178 * copyright and related and neighboring rights to this software to
179 * the public domain worldwide. This software is distributed without
180 * any warranty.
181 *
182 * For details, see <http://creativecommons.org/publicdomain/zero/1.0/>.
183 * SPDX-License-Identifier: CC0-1.0
184 */
185
186#if !defined(JSON_HEDLEY_VERSION) || (JSON_HEDLEY_VERSION < 15)
187#if defined(JSON_HEDLEY_VERSION)
188 #undef JSON_HEDLEY_VERSION
189#endif
190#define JSON_HEDLEY_VERSION 15
191
192#if defined(JSON_HEDLEY_STRINGIFY_EX)
193 #undef JSON_HEDLEY_STRINGIFY_EX
194#endif
195#define JSON_HEDLEY_STRINGIFY_EX(x) #x
196
197#if defined(JSON_HEDLEY_STRINGIFY)
198 #undef JSON_HEDLEY_STRINGIFY
199#endif
200#define JSON_HEDLEY_STRINGIFY(x) JSON_HEDLEY_STRINGIFY_EX(x)
201
202#if defined(JSON_HEDLEY_CONCAT_EX)
203 #undef JSON_HEDLEY_CONCAT_EX
204#endif
205#define JSON_HEDLEY_CONCAT_EX(a,b) a##b
206
207#if defined(JSON_HEDLEY_CONCAT)
208 #undef JSON_HEDLEY_CONCAT
209#endif
210#define JSON_HEDLEY_CONCAT(a,b) JSON_HEDLEY_CONCAT_EX(a,b)
211
212#if defined(JSON_HEDLEY_CONCAT3_EX)
213 #undef JSON_HEDLEY_CONCAT3_EX
214#endif
215#define JSON_HEDLEY_CONCAT3_EX(a,b,c) a##b##c
216
217#if defined(JSON_HEDLEY_CONCAT3)
218 #undef JSON_HEDLEY_CONCAT3
219#endif
220#define JSON_HEDLEY_CONCAT3(a,b,c) JSON_HEDLEY_CONCAT3_EX(a,b,c)
221
222#if defined(JSON_HEDLEY_VERSION_ENCODE)
223 #undef JSON_HEDLEY_VERSION_ENCODE
224#endif
225#define JSON_HEDLEY_VERSION_ENCODE(major,minor,revision) (((major) * 1000000) + ((minor) * 1000) + (revision))
226
227#if defined(JSON_HEDLEY_VERSION_DECODE_MAJOR)
228 #undef JSON_HEDLEY_VERSION_DECODE_MAJOR
229#endif
230#define JSON_HEDLEY_VERSION_DECODE_MAJOR(version) ((version) / 1000000)
231
232#if defined(JSON_HEDLEY_VERSION_DECODE_MINOR)
233 #undef JSON_HEDLEY_VERSION_DECODE_MINOR
234#endif
235#define JSON_HEDLEY_VERSION_DECODE_MINOR(version) (((version) % 1000000) / 1000)
236
237#if defined(JSON_HEDLEY_VERSION_DECODE_REVISION)
238 #undef JSON_HEDLEY_VERSION_DECODE_REVISION
239#endif
240#define JSON_HEDLEY_VERSION_DECODE_REVISION(version) ((version) % 1000)
241
242#if defined(JSON_HEDLEY_GNUC_VERSION)
243 #undef JSON_HEDLEY_GNUC_VERSION
244#endif
245#if defined(__GNUC__) && defined(__GNUC_PATCHLEVEL__)
246 #define JSON_HEDLEY_GNUC_VERSION JSON_HEDLEY_VERSION_ENCODE(__GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__)
247#elif defined(__GNUC__)
248 #define JSON_HEDLEY_GNUC_VERSION JSON_HEDLEY_VERSION_ENCODE(__GNUC__, __GNUC_MINOR__, 0)
249#endif
250
251#if defined(JSON_HEDLEY_GNUC_VERSION_CHECK)
252 #undef JSON_HEDLEY_GNUC_VERSION_CHECK
253#endif
254#if defined(JSON_HEDLEY_GNUC_VERSION)
255 #define JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_GNUC_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
256#else
257 #define JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) (0)
258#endif
259
260#if defined(JSON_HEDLEY_MSVC_VERSION)
261 #undef JSON_HEDLEY_MSVC_VERSION
262#endif
263#if defined(_MSC_FULL_VER) && (_MSC_FULL_VER >= 140000000) && !defined(__ICL)
264 #define JSON_HEDLEY_MSVC_VERSION JSON_HEDLEY_VERSION_ENCODE(_MSC_FULL_VER / 10000000, (_MSC_FULL_VER % 10000000) / 100000, (_MSC_FULL_VER % 100000) / 100)
265#elif defined(_MSC_FULL_VER) && !defined(__ICL)
266 #define JSON_HEDLEY_MSVC_VERSION JSON_HEDLEY_VERSION_ENCODE(_MSC_FULL_VER / 1000000, (_MSC_FULL_VER % 1000000) / 10000, (_MSC_FULL_VER % 10000) / 10)
267#elif defined(_MSC_VER) && !defined(__ICL)
268 #define JSON_HEDLEY_MSVC_VERSION JSON_HEDLEY_VERSION_ENCODE(_MSC_VER / 100, _MSC_VER % 100, 0)
269#endif
270
271#if defined(JSON_HEDLEY_MSVC_VERSION_CHECK)
272 #undef JSON_HEDLEY_MSVC_VERSION_CHECK
273#endif
274#if !defined(JSON_HEDLEY_MSVC_VERSION)
275 #define JSON_HEDLEY_MSVC_VERSION_CHECK(major,minor,patch) (0)
276#elif defined(_MSC_VER) && (_MSC_VER >= 1400)
277 #define JSON_HEDLEY_MSVC_VERSION_CHECK(major,minor,patch) (_MSC_FULL_VER >= ((major * 10000000) + (minor * 100000) + (patch)))
278#elif defined(_MSC_VER) && (_MSC_VER >= 1200)
279 #define JSON_HEDLEY_MSVC_VERSION_CHECK(major,minor,patch) (_MSC_FULL_VER >= ((major * 1000000) + (minor * 10000) + (patch)))
280#else
281 #define JSON_HEDLEY_MSVC_VERSION_CHECK(major,minor,patch) (_MSC_VER >= ((major * 100) + (minor)))
282#endif
283
284#if defined(JSON_HEDLEY_INTEL_VERSION)
285 #undef JSON_HEDLEY_INTEL_VERSION
286#endif
287#if defined(__INTEL_COMPILER) && defined(__INTEL_COMPILER_UPDATE) && !defined(__ICL)
288 #define JSON_HEDLEY_INTEL_VERSION JSON_HEDLEY_VERSION_ENCODE(__INTEL_COMPILER / 100, __INTEL_COMPILER % 100, __INTEL_COMPILER_UPDATE)
289#elif defined(__INTEL_COMPILER) && !defined(__ICL)
290 #define JSON_HEDLEY_INTEL_VERSION JSON_HEDLEY_VERSION_ENCODE(__INTEL_COMPILER / 100, __INTEL_COMPILER % 100, 0)
291#endif
292
293#if defined(JSON_HEDLEY_INTEL_VERSION_CHECK)
294 #undef JSON_HEDLEY_INTEL_VERSION_CHECK
295#endif
296#if defined(JSON_HEDLEY_INTEL_VERSION)
297 #define JSON_HEDLEY_INTEL_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_INTEL_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
298#else
299 #define JSON_HEDLEY_INTEL_VERSION_CHECK(major,minor,patch) (0)
300#endif
301
302#if defined(JSON_HEDLEY_INTEL_CL_VERSION)
303 #undef JSON_HEDLEY_INTEL_CL_VERSION
304#endif
305#if defined(__INTEL_COMPILER) && defined(__INTEL_COMPILER_UPDATE) && defined(__ICL)
306 #define JSON_HEDLEY_INTEL_CL_VERSION JSON_HEDLEY_VERSION_ENCODE(__INTEL_COMPILER, __INTEL_COMPILER_UPDATE, 0)
307#endif
308
309#if defined(JSON_HEDLEY_INTEL_CL_VERSION_CHECK)
310 #undef JSON_HEDLEY_INTEL_CL_VERSION_CHECK
311#endif
312#if defined(JSON_HEDLEY_INTEL_CL_VERSION)
313 #define JSON_HEDLEY_INTEL_CL_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_INTEL_CL_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
314#else
315 #define JSON_HEDLEY_INTEL_CL_VERSION_CHECK(major,minor,patch) (0)
316#endif
317
318#if defined(JSON_HEDLEY_PGI_VERSION)
319 #undef JSON_HEDLEY_PGI_VERSION
320#endif
321#if defined(__PGI) && defined(__PGIC__) && defined(__PGIC_MINOR__) && defined(__PGIC_PATCHLEVEL__)
322 #define JSON_HEDLEY_PGI_VERSION JSON_HEDLEY_VERSION_ENCODE(__PGIC__, __PGIC_MINOR__, __PGIC_PATCHLEVEL__)
323#endif
324
325#if defined(JSON_HEDLEY_PGI_VERSION_CHECK)
326 #undef JSON_HEDLEY_PGI_VERSION_CHECK
327#endif
328#if defined(JSON_HEDLEY_PGI_VERSION)
329 #define JSON_HEDLEY_PGI_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_PGI_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
330#else
331 #define JSON_HEDLEY_PGI_VERSION_CHECK(major,minor,patch) (0)
332#endif
333
334#if defined(JSON_HEDLEY_SUNPRO_VERSION)
335 #undef JSON_HEDLEY_SUNPRO_VERSION
336#endif
337#if defined(__SUNPRO_C) && (__SUNPRO_C > 0x1000)
338 #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)
339#elif defined(__SUNPRO_C)
340 #define JSON_HEDLEY_SUNPRO_VERSION JSON_HEDLEY_VERSION_ENCODE((__SUNPRO_C >> 8) & 0xf, (__SUNPRO_C >> 4) & 0xf, (__SUNPRO_C) & 0xf)
341#elif defined(__SUNPRO_CC) && (__SUNPRO_CC > 0x1000)
342 #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)
343#elif defined(__SUNPRO_CC)
344 #define JSON_HEDLEY_SUNPRO_VERSION JSON_HEDLEY_VERSION_ENCODE((__SUNPRO_CC >> 8) & 0xf, (__SUNPRO_CC >> 4) & 0xf, (__SUNPRO_CC) & 0xf)
345#endif
346
347#if defined(JSON_HEDLEY_SUNPRO_VERSION_CHECK)
348 #undef JSON_HEDLEY_SUNPRO_VERSION_CHECK
349#endif
350#if defined(JSON_HEDLEY_SUNPRO_VERSION)
351 #define JSON_HEDLEY_SUNPRO_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_SUNPRO_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
352#else
353 #define JSON_HEDLEY_SUNPRO_VERSION_CHECK(major,minor,patch) (0)
354#endif
355
356#if defined(JSON_HEDLEY_EMSCRIPTEN_VERSION)
357 #undef JSON_HEDLEY_EMSCRIPTEN_VERSION
358#endif
359#if defined(__EMSCRIPTEN__)
360 #define JSON_HEDLEY_EMSCRIPTEN_VERSION JSON_HEDLEY_VERSION_ENCODE(__EMSCRIPTEN_major__, __EMSCRIPTEN_minor__, __EMSCRIPTEN_tiny__)
361#endif
362
363#if defined(JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK)
364 #undef JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK
365#endif
366#if defined(JSON_HEDLEY_EMSCRIPTEN_VERSION)
367 #define JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_EMSCRIPTEN_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
368#else
369 #define JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK(major,minor,patch) (0)
370#endif
371
372#if defined(JSON_HEDLEY_ARM_VERSION)
373 #undef JSON_HEDLEY_ARM_VERSION
374#endif
375#if defined(__CC_ARM) && defined(__ARMCOMPILER_VERSION)
376 #define JSON_HEDLEY_ARM_VERSION JSON_HEDLEY_VERSION_ENCODE(__ARMCOMPILER_VERSION / 1000000, (__ARMCOMPILER_VERSION % 1000000) / 10000, (__ARMCOMPILER_VERSION % 10000) / 100)
377#elif defined(__CC_ARM) && defined(__ARMCC_VERSION)
378 #define JSON_HEDLEY_ARM_VERSION JSON_HEDLEY_VERSION_ENCODE(__ARMCC_VERSION / 1000000, (__ARMCC_VERSION % 1000000) / 10000, (__ARMCC_VERSION % 10000) / 100)
379#endif
380
381#if defined(JSON_HEDLEY_ARM_VERSION_CHECK)
382 #undef JSON_HEDLEY_ARM_VERSION_CHECK
383#endif
384#if defined(JSON_HEDLEY_ARM_VERSION)
385 #define JSON_HEDLEY_ARM_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_ARM_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
386#else
387 #define JSON_HEDLEY_ARM_VERSION_CHECK(major,minor,patch) (0)
388#endif
389
390#if defined(JSON_HEDLEY_IBM_VERSION)
391 #undef JSON_HEDLEY_IBM_VERSION
392#endif
393#if defined(__ibmxl__)
394 #define JSON_HEDLEY_IBM_VERSION JSON_HEDLEY_VERSION_ENCODE(__ibmxl_version__, __ibmxl_release__, __ibmxl_modification__)
395#elif defined(__xlC__) && defined(__xlC_ver__)
396 #define JSON_HEDLEY_IBM_VERSION JSON_HEDLEY_VERSION_ENCODE(__xlC__ >> 8, __xlC__ & 0xff, (__xlC_ver__ >> 8) & 0xff)
397#elif defined(__xlC__)
398 #define JSON_HEDLEY_IBM_VERSION JSON_HEDLEY_VERSION_ENCODE(__xlC__ >> 8, __xlC__ & 0xff, 0)
399#endif
400
401#if defined(JSON_HEDLEY_IBM_VERSION_CHECK)
402 #undef JSON_HEDLEY_IBM_VERSION_CHECK
403#endif
404#if defined(JSON_HEDLEY_IBM_VERSION)
405 #define JSON_HEDLEY_IBM_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_IBM_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
406#else
407 #define JSON_HEDLEY_IBM_VERSION_CHECK(major,minor,patch) (0)
408#endif
409
410#if defined(JSON_HEDLEY_TI_VERSION)
411 #undef JSON_HEDLEY_TI_VERSION
412#endif
413#if \
414 defined(__TI_COMPILER_VERSION__) && \
415 ( \
416 defined(__TMS470__) || defined(__TI_ARM__) || \
417 defined(__MSP430__) || \
418 defined(__TMS320C2000__) \
419 )
420#if (__TI_COMPILER_VERSION__ >= 16000000)
421 #define JSON_HEDLEY_TI_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000))
422#endif
423#endif
424
425#if defined(JSON_HEDLEY_TI_VERSION_CHECK)
426 #undef JSON_HEDLEY_TI_VERSION_CHECK
427#endif
428#if defined(JSON_HEDLEY_TI_VERSION)
429 #define JSON_HEDLEY_TI_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
430#else
431 #define JSON_HEDLEY_TI_VERSION_CHECK(major,minor,patch) (0)
432#endif
433
434#if defined(JSON_HEDLEY_TI_CL2000_VERSION)
435 #undef JSON_HEDLEY_TI_CL2000_VERSION
436#endif
437#if defined(__TI_COMPILER_VERSION__) && defined(__TMS320C2000__)
438 #define JSON_HEDLEY_TI_CL2000_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000))
439#endif
440
441#if defined(JSON_HEDLEY_TI_CL2000_VERSION_CHECK)
442 #undef JSON_HEDLEY_TI_CL2000_VERSION_CHECK
443#endif
444#if defined(JSON_HEDLEY_TI_CL2000_VERSION)
445 #define JSON_HEDLEY_TI_CL2000_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_CL2000_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
446#else
447 #define JSON_HEDLEY_TI_CL2000_VERSION_CHECK(major,minor,patch) (0)
448#endif
449
450#if defined(JSON_HEDLEY_TI_CL430_VERSION)
451 #undef JSON_HEDLEY_TI_CL430_VERSION
452#endif
453#if defined(__TI_COMPILER_VERSION__) && defined(__MSP430__)
454 #define JSON_HEDLEY_TI_CL430_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000))
455#endif
456
457#if defined(JSON_HEDLEY_TI_CL430_VERSION_CHECK)
458 #undef JSON_HEDLEY_TI_CL430_VERSION_CHECK
459#endif
460#if defined(JSON_HEDLEY_TI_CL430_VERSION)
461 #define JSON_HEDLEY_TI_CL430_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_CL430_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
462#else
463 #define JSON_HEDLEY_TI_CL430_VERSION_CHECK(major,minor,patch) (0)
464#endif
465
466#if defined(JSON_HEDLEY_TI_ARMCL_VERSION)
467 #undef JSON_HEDLEY_TI_ARMCL_VERSION
468#endif
469#if defined(__TI_COMPILER_VERSION__) && (defined(__TMS470__) || defined(__TI_ARM__))
470 #define JSON_HEDLEY_TI_ARMCL_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000))
471#endif
472
473#if defined(JSON_HEDLEY_TI_ARMCL_VERSION_CHECK)
474 #undef JSON_HEDLEY_TI_ARMCL_VERSION_CHECK
475#endif
476#if defined(JSON_HEDLEY_TI_ARMCL_VERSION)
477 #define JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_ARMCL_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
478#else
479 #define JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(major,minor,patch) (0)
480#endif
481
482#if defined(JSON_HEDLEY_TI_CL6X_VERSION)
483 #undef JSON_HEDLEY_TI_CL6X_VERSION
484#endif
485#if defined(__TI_COMPILER_VERSION__) && defined(__TMS320C6X__)
486 #define JSON_HEDLEY_TI_CL6X_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000))
487#endif
488
489#if defined(JSON_HEDLEY_TI_CL6X_VERSION_CHECK)
490 #undef JSON_HEDLEY_TI_CL6X_VERSION_CHECK
491#endif
492#if defined(JSON_HEDLEY_TI_CL6X_VERSION)
493 #define JSON_HEDLEY_TI_CL6X_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_CL6X_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
494#else
495 #define JSON_HEDLEY_TI_CL6X_VERSION_CHECK(major,minor,patch) (0)
496#endif
497
498#if defined(JSON_HEDLEY_TI_CL7X_VERSION)
499 #undef JSON_HEDLEY_TI_CL7X_VERSION
500#endif
501#if defined(__TI_COMPILER_VERSION__) && defined(__C7000__)
502 #define JSON_HEDLEY_TI_CL7X_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000))
503#endif
504
505#if defined(JSON_HEDLEY_TI_CL7X_VERSION_CHECK)
506 #undef JSON_HEDLEY_TI_CL7X_VERSION_CHECK
507#endif
508#if defined(JSON_HEDLEY_TI_CL7X_VERSION)
509 #define JSON_HEDLEY_TI_CL7X_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_CL7X_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
510#else
511 #define JSON_HEDLEY_TI_CL7X_VERSION_CHECK(major,minor,patch) (0)
512#endif
513
514#if defined(JSON_HEDLEY_TI_CLPRU_VERSION)
515 #undef JSON_HEDLEY_TI_CLPRU_VERSION
516#endif
517#if defined(__TI_COMPILER_VERSION__) && defined(__PRU__)
518 #define JSON_HEDLEY_TI_CLPRU_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000))
519#endif
520
521#if defined(JSON_HEDLEY_TI_CLPRU_VERSION_CHECK)
522 #undef JSON_HEDLEY_TI_CLPRU_VERSION_CHECK
523#endif
524#if defined(JSON_HEDLEY_TI_CLPRU_VERSION)
525 #define JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_CLPRU_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
526#else
527 #define JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(major,minor,patch) (0)
528#endif
529
530#if defined(JSON_HEDLEY_CRAY_VERSION)
531 #undef JSON_HEDLEY_CRAY_VERSION
532#endif
533#if defined(_CRAYC)
534 #if defined(_RELEASE_PATCHLEVEL)
535 #define JSON_HEDLEY_CRAY_VERSION JSON_HEDLEY_VERSION_ENCODE(_RELEASE_MAJOR, _RELEASE_MINOR, _RELEASE_PATCHLEVEL)
536 #else
537 #define JSON_HEDLEY_CRAY_VERSION JSON_HEDLEY_VERSION_ENCODE(_RELEASE_MAJOR, _RELEASE_MINOR, 0)
538 #endif
539#endif
540
541#if defined(JSON_HEDLEY_CRAY_VERSION_CHECK)
542 #undef JSON_HEDLEY_CRAY_VERSION_CHECK
543#endif
544#if defined(JSON_HEDLEY_CRAY_VERSION)
545 #define JSON_HEDLEY_CRAY_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_CRAY_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
546#else
547 #define JSON_HEDLEY_CRAY_VERSION_CHECK(major,minor,patch) (0)
548#endif
549
550#if defined(JSON_HEDLEY_IAR_VERSION)
551 #undef JSON_HEDLEY_IAR_VERSION
552#endif
553#if defined(__IAR_SYSTEMS_ICC__)
554 #if __VER__ > 1000
555 #define JSON_HEDLEY_IAR_VERSION JSON_HEDLEY_VERSION_ENCODE((__VER__ / 1000000), ((__VER__ / 1000) % 1000), (__VER__ % 1000))
556 #else
557 #define JSON_HEDLEY_IAR_VERSION JSON_HEDLEY_VERSION_ENCODE(__VER__ / 100, __VER__ % 100, 0)
558 #endif
559#endif
560
561#if defined(JSON_HEDLEY_IAR_VERSION_CHECK)
562 #undef JSON_HEDLEY_IAR_VERSION_CHECK
563#endif
564#if defined(JSON_HEDLEY_IAR_VERSION)
565 #define JSON_HEDLEY_IAR_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_IAR_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
566#else
567 #define JSON_HEDLEY_IAR_VERSION_CHECK(major,minor,patch) (0)
568#endif
569
570#if defined(JSON_HEDLEY_TINYC_VERSION)
571 #undef JSON_HEDLEY_TINYC_VERSION
572#endif
573#if defined(__TINYC__)
574 #define JSON_HEDLEY_TINYC_VERSION JSON_HEDLEY_VERSION_ENCODE(__TINYC__ / 1000, (__TINYC__ / 100) % 10, __TINYC__ % 100)
575#endif
576
577#if defined(JSON_HEDLEY_TINYC_VERSION_CHECK)
578 #undef JSON_HEDLEY_TINYC_VERSION_CHECK
579#endif
580#if defined(JSON_HEDLEY_TINYC_VERSION)
581 #define JSON_HEDLEY_TINYC_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TINYC_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
582#else
583 #define JSON_HEDLEY_TINYC_VERSION_CHECK(major,minor,patch) (0)
584#endif
585
586#if defined(JSON_HEDLEY_DMC_VERSION)
587 #undef JSON_HEDLEY_DMC_VERSION
588#endif
589#if defined(__DMC__)
590 #define JSON_HEDLEY_DMC_VERSION JSON_HEDLEY_VERSION_ENCODE(__DMC__ >> 8, (__DMC__ >> 4) & 0xf, __DMC__ & 0xf)
591#endif
592
593#if defined(JSON_HEDLEY_DMC_VERSION_CHECK)
594 #undef JSON_HEDLEY_DMC_VERSION_CHECK
595#endif
596#if defined(JSON_HEDLEY_DMC_VERSION)
597 #define JSON_HEDLEY_DMC_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_DMC_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
598#else
599 #define JSON_HEDLEY_DMC_VERSION_CHECK(major,minor,patch) (0)
600#endif
601
602#if defined(JSON_HEDLEY_COMPCERT_VERSION)
603 #undef JSON_HEDLEY_COMPCERT_VERSION
604#endif
605#if defined(__COMPCERT_VERSION__)
606 #define JSON_HEDLEY_COMPCERT_VERSION JSON_HEDLEY_VERSION_ENCODE(__COMPCERT_VERSION__ / 10000, (__COMPCERT_VERSION__ / 100) % 100, __COMPCERT_VERSION__ % 100)
607#endif
608
609#if defined(JSON_HEDLEY_COMPCERT_VERSION_CHECK)
610 #undef JSON_HEDLEY_COMPCERT_VERSION_CHECK
611#endif
612#if defined(JSON_HEDLEY_COMPCERT_VERSION)
613 #define JSON_HEDLEY_COMPCERT_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_COMPCERT_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
614#else
615 #define JSON_HEDLEY_COMPCERT_VERSION_CHECK(major,minor,patch) (0)
616#endif
617
618#if defined(JSON_HEDLEY_PELLES_VERSION)
619 #undef JSON_HEDLEY_PELLES_VERSION
620#endif
621#if defined(__POCC__)
622 #define JSON_HEDLEY_PELLES_VERSION JSON_HEDLEY_VERSION_ENCODE(__POCC__ / 100, __POCC__ % 100, 0)
623#endif
624
625#if defined(JSON_HEDLEY_PELLES_VERSION_CHECK)
626 #undef JSON_HEDLEY_PELLES_VERSION_CHECK
627#endif
628#if defined(JSON_HEDLEY_PELLES_VERSION)
629 #define JSON_HEDLEY_PELLES_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_PELLES_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
630#else
631 #define JSON_HEDLEY_PELLES_VERSION_CHECK(major,minor,patch) (0)
632#endif
633
634#if defined(JSON_HEDLEY_MCST_LCC_VERSION)
635 #undef JSON_HEDLEY_MCST_LCC_VERSION
636#endif
637#if defined(__LCC__) && defined(__LCC_MINOR__)
638 #define JSON_HEDLEY_MCST_LCC_VERSION JSON_HEDLEY_VERSION_ENCODE(__LCC__ / 100, __LCC__ % 100, __LCC_MINOR__)
639#endif
640
641#if defined(JSON_HEDLEY_MCST_LCC_VERSION_CHECK)
642 #undef JSON_HEDLEY_MCST_LCC_VERSION_CHECK
643#endif
644#if defined(JSON_HEDLEY_MCST_LCC_VERSION)
645 #define JSON_HEDLEY_MCST_LCC_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_MCST_LCC_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
646#else
647 #define JSON_HEDLEY_MCST_LCC_VERSION_CHECK(major,minor,patch) (0)
648#endif
649
650#if defined(JSON_HEDLEY_GCC_VERSION)
651 #undef JSON_HEDLEY_GCC_VERSION
652#endif
653#if \
654 defined(JSON_HEDLEY_GNUC_VERSION) && \
655 !defined(__clang__) && \
656 !defined(JSON_HEDLEY_INTEL_VERSION) && \
657 !defined(JSON_HEDLEY_PGI_VERSION) && \
658 !defined(JSON_HEDLEY_ARM_VERSION) && \
659 !defined(JSON_HEDLEY_CRAY_VERSION) && \
660 !defined(JSON_HEDLEY_TI_VERSION) && \
661 !defined(JSON_HEDLEY_TI_ARMCL_VERSION) && \
662 !defined(JSON_HEDLEY_TI_CL430_VERSION) && \
663 !defined(JSON_HEDLEY_TI_CL2000_VERSION) && \
664 !defined(JSON_HEDLEY_TI_CL6X_VERSION) && \
665 !defined(JSON_HEDLEY_TI_CL7X_VERSION) && \
666 !defined(JSON_HEDLEY_TI_CLPRU_VERSION) && \
667 !defined(__COMPCERT__) && \
668 !defined(JSON_HEDLEY_MCST_LCC_VERSION)
669 #define JSON_HEDLEY_GCC_VERSION JSON_HEDLEY_GNUC_VERSION
670#endif
671
672#if defined(JSON_HEDLEY_GCC_VERSION_CHECK)
673 #undef JSON_HEDLEY_GCC_VERSION_CHECK
674#endif
675#if defined(JSON_HEDLEY_GCC_VERSION)
676 #define JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_GCC_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
677#else
678 #define JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) (0)
679#endif
680
681#if defined(JSON_HEDLEY_HAS_ATTRIBUTE)
682 #undef JSON_HEDLEY_HAS_ATTRIBUTE
683#endif
684#if \
685 defined(__has_attribute) && \
686 ( \
687 (!defined(JSON_HEDLEY_IAR_VERSION) || JSON_HEDLEY_IAR_VERSION_CHECK(8,5,9)) \
688 )
689# define JSON_HEDLEY_HAS_ATTRIBUTE(attribute) __has_attribute(attribute)
690#else
691# define JSON_HEDLEY_HAS_ATTRIBUTE(attribute) (0)
692#endif
693
694#if defined(JSON_HEDLEY_GNUC_HAS_ATTRIBUTE)
695 #undef JSON_HEDLEY_GNUC_HAS_ATTRIBUTE
696#endif
697#if defined(__has_attribute)
698 #define JSON_HEDLEY_GNUC_HAS_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_HAS_ATTRIBUTE(attribute)
699#else
700 #define JSON_HEDLEY_GNUC_HAS_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch)
701#endif
702
703#if defined(JSON_HEDLEY_GCC_HAS_ATTRIBUTE)
704 #undef JSON_HEDLEY_GCC_HAS_ATTRIBUTE
705#endif
706#if defined(__has_attribute)
707 #define JSON_HEDLEY_GCC_HAS_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_HAS_ATTRIBUTE(attribute)
708#else
709 #define JSON_HEDLEY_GCC_HAS_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch)
710#endif
711
712#if defined(JSON_HEDLEY_HAS_CPP_ATTRIBUTE)
713 #undef JSON_HEDLEY_HAS_CPP_ATTRIBUTE
714#endif
715#if \
716 defined(__has_cpp_attribute) && \
717 defined(__cplusplus) && \
718 (!defined(JSON_HEDLEY_SUNPRO_VERSION) || JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,15,0))
719 #define JSON_HEDLEY_HAS_CPP_ATTRIBUTE(attribute) __has_cpp_attribute(attribute)
720#else
721 #define JSON_HEDLEY_HAS_CPP_ATTRIBUTE(attribute) (0)
722#endif
723
724#if defined(JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS)
725 #undef JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS
726#endif
727#if !defined(__cplusplus) || !defined(__has_cpp_attribute)
728 #define JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS(ns,attribute) (0)
729#elif \
730 !defined(JSON_HEDLEY_PGI_VERSION) && \
731 !defined(JSON_HEDLEY_IAR_VERSION) && \
732 (!defined(JSON_HEDLEY_SUNPRO_VERSION) || JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,15,0)) && \
733 (!defined(JSON_HEDLEY_MSVC_VERSION) || JSON_HEDLEY_MSVC_VERSION_CHECK(19,20,0))
734 #define JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS(ns,attribute) JSON_HEDLEY_HAS_CPP_ATTRIBUTE(ns::attribute)
735#else
736 #define JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS(ns,attribute) (0)
737#endif
738
739#if defined(JSON_HEDLEY_GNUC_HAS_CPP_ATTRIBUTE)
740 #undef JSON_HEDLEY_GNUC_HAS_CPP_ATTRIBUTE
741#endif
742#if defined(__has_cpp_attribute) && defined(__cplusplus)
743 #define JSON_HEDLEY_GNUC_HAS_CPP_ATTRIBUTE(attribute,major,minor,patch) __has_cpp_attribute(attribute)
744#else
745 #define JSON_HEDLEY_GNUC_HAS_CPP_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch)
746#endif
747
748#if defined(JSON_HEDLEY_GCC_HAS_CPP_ATTRIBUTE)
749 #undef JSON_HEDLEY_GCC_HAS_CPP_ATTRIBUTE
750#endif
751#if defined(__has_cpp_attribute) && defined(__cplusplus)
752 #define JSON_HEDLEY_GCC_HAS_CPP_ATTRIBUTE(attribute,major,minor,patch) __has_cpp_attribute(attribute)
753#else
754 #define JSON_HEDLEY_GCC_HAS_CPP_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch)
755#endif
756
757#if defined(JSON_HEDLEY_HAS_BUILTIN)
758 #undef JSON_HEDLEY_HAS_BUILTIN
759#endif
760#if defined(__has_builtin)
761 #define JSON_HEDLEY_HAS_BUILTIN(builtin) __has_builtin(builtin)
762#else
763 #define JSON_HEDLEY_HAS_BUILTIN(builtin) (0)
764#endif
765
766#if defined(JSON_HEDLEY_GNUC_HAS_BUILTIN)
767 #undef JSON_HEDLEY_GNUC_HAS_BUILTIN
768#endif
769#if defined(__has_builtin)
770 #define JSON_HEDLEY_GNUC_HAS_BUILTIN(builtin,major,minor,patch) __has_builtin(builtin)
771#else
772 #define JSON_HEDLEY_GNUC_HAS_BUILTIN(builtin,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch)
773#endif
774
775#if defined(JSON_HEDLEY_GCC_HAS_BUILTIN)
776 #undef JSON_HEDLEY_GCC_HAS_BUILTIN
777#endif
778#if defined(__has_builtin)
779 #define JSON_HEDLEY_GCC_HAS_BUILTIN(builtin,major,minor,patch) __has_builtin(builtin)
780#else
781 #define JSON_HEDLEY_GCC_HAS_BUILTIN(builtin,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch)
782#endif
783
784#if defined(JSON_HEDLEY_HAS_FEATURE)
785 #undef JSON_HEDLEY_HAS_FEATURE
786#endif
787#if defined(__has_feature)
788 #define JSON_HEDLEY_HAS_FEATURE(feature) __has_feature(feature)
789#else
790 #define JSON_HEDLEY_HAS_FEATURE(feature) (0)
791#endif
792
793#if defined(JSON_HEDLEY_GNUC_HAS_FEATURE)
794 #undef JSON_HEDLEY_GNUC_HAS_FEATURE
795#endif
796#if defined(__has_feature)
797 #define JSON_HEDLEY_GNUC_HAS_FEATURE(feature,major,minor,patch) __has_feature(feature)
798#else
799 #define JSON_HEDLEY_GNUC_HAS_FEATURE(feature,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch)
800#endif
801
802#if defined(JSON_HEDLEY_GCC_HAS_FEATURE)
803 #undef JSON_HEDLEY_GCC_HAS_FEATURE
804#endif
805#if defined(__has_feature)
806 #define JSON_HEDLEY_GCC_HAS_FEATURE(feature,major,minor,patch) __has_feature(feature)
807#else
808 #define JSON_HEDLEY_GCC_HAS_FEATURE(feature,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch)
809#endif
810
811#if defined(JSON_HEDLEY_HAS_EXTENSION)
812 #undef JSON_HEDLEY_HAS_EXTENSION
813#endif
814#if defined(__has_extension)
815 #define JSON_HEDLEY_HAS_EXTENSION(extension) __has_extension(extension)
816#else
817 #define JSON_HEDLEY_HAS_EXTENSION(extension) (0)
818#endif
819
820#if defined(JSON_HEDLEY_GNUC_HAS_EXTENSION)
821 #undef JSON_HEDLEY_GNUC_HAS_EXTENSION
822#endif
823#if defined(__has_extension)
824 #define JSON_HEDLEY_GNUC_HAS_EXTENSION(extension,major,minor,patch) __has_extension(extension)
825#else
826 #define JSON_HEDLEY_GNUC_HAS_EXTENSION(extension,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch)
827#endif
828
829#if defined(JSON_HEDLEY_GCC_HAS_EXTENSION)
830 #undef JSON_HEDLEY_GCC_HAS_EXTENSION
831#endif
832#if defined(__has_extension)
833 #define JSON_HEDLEY_GCC_HAS_EXTENSION(extension,major,minor,patch) __has_extension(extension)
834#else
835 #define JSON_HEDLEY_GCC_HAS_EXTENSION(extension,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch)
836#endif
837
838#if defined(JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE)
839 #undef JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE
840#endif
841#if defined(__has_declspec_attribute)
842 #define JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE(attribute) __has_declspec_attribute(attribute)
843#else
844 #define JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE(attribute) (0)
845#endif
846
847#if defined(JSON_HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE)
848 #undef JSON_HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE
849#endif
850#if defined(__has_declspec_attribute)
851 #define JSON_HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE(attribute,major,minor,patch) __has_declspec_attribute(attribute)
852#else
853 #define JSON_HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch)
854#endif
855
856#if defined(JSON_HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE)
857 #undef JSON_HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE
858#endif
859#if defined(__has_declspec_attribute)
860 #define JSON_HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE(attribute,major,minor,patch) __has_declspec_attribute(attribute)
861#else
862 #define JSON_HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch)
863#endif
864
865#if defined(JSON_HEDLEY_HAS_WARNING)
866 #undef JSON_HEDLEY_HAS_WARNING
867#endif
868#if defined(__has_warning)
869 #define JSON_HEDLEY_HAS_WARNING(warning) __has_warning(warning)
870#else
871 #define JSON_HEDLEY_HAS_WARNING(warning) (0)
872#endif
873
874#if defined(JSON_HEDLEY_GNUC_HAS_WARNING)
875 #undef JSON_HEDLEY_GNUC_HAS_WARNING
876#endif
877#if defined(__has_warning)
878 #define JSON_HEDLEY_GNUC_HAS_WARNING(warning,major,minor,patch) __has_warning(warning)
879#else
880 #define JSON_HEDLEY_GNUC_HAS_WARNING(warning,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch)
881#endif
882
883#if defined(JSON_HEDLEY_GCC_HAS_WARNING)
884 #undef JSON_HEDLEY_GCC_HAS_WARNING
885#endif
886#if defined(__has_warning)
887 #define JSON_HEDLEY_GCC_HAS_WARNING(warning,major,minor,patch) __has_warning(warning)
888#else
889 #define JSON_HEDLEY_GCC_HAS_WARNING(warning,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch)
890#endif
891
892#if \
893 (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)) || \
894 defined(__clang__) || \
895 JSON_HEDLEY_GCC_VERSION_CHECK(3,0,0) || \
896 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
897 JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) || \
898 JSON_HEDLEY_PGI_VERSION_CHECK(18,4,0) || \
899 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
900 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
901 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,7,0) || \
902 JSON_HEDLEY_TI_CL430_VERSION_CHECK(2,0,1) || \
903 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,1,0) || \
904 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,0,0) || \
905 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
906 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
907 JSON_HEDLEY_CRAY_VERSION_CHECK(5,0,0) || \
908 JSON_HEDLEY_TINYC_VERSION_CHECK(0,9,17) || \
909 JSON_HEDLEY_SUNPRO_VERSION_CHECK(8,0,0) || \
910 (JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) && defined(__C99_PRAGMA_OPERATOR))
911 #define JSON_HEDLEY_PRAGMA(value) _Pragma(#value)
912#elif JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0)
913 #define JSON_HEDLEY_PRAGMA(value) __pragma(value)
914#else
915 #define JSON_HEDLEY_PRAGMA(value)
916#endif
917
918#if defined(JSON_HEDLEY_DIAGNOSTIC_PUSH)
919 #undef JSON_HEDLEY_DIAGNOSTIC_PUSH
920#endif
921#if defined(JSON_HEDLEY_DIAGNOSTIC_POP)
922 #undef JSON_HEDLEY_DIAGNOSTIC_POP
923#endif
924#if defined(__clang__)
925 #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("clang diagnostic push")
926 #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("clang diagnostic pop")
927#elif JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0)
928 #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("warning(push)")
929 #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("warning(pop)")
930#elif JSON_HEDLEY_GCC_VERSION_CHECK(4,6,0)
931 #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("GCC diagnostic push")
932 #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("GCC diagnostic pop")
933#elif \
934 JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0) || \
935 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
936 #define JSON_HEDLEY_DIAGNOSTIC_PUSH __pragma(warning(push))
937 #define JSON_HEDLEY_DIAGNOSTIC_POP __pragma(warning(pop))
938#elif JSON_HEDLEY_ARM_VERSION_CHECK(5,6,0)
939 #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("push")
940 #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("pop")
941#elif \
942 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
943 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
944 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,4,0) || \
945 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,1,0) || \
946 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
947 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0)
948 #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("diag_push")
949 #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("diag_pop")
950#elif JSON_HEDLEY_PELLES_VERSION_CHECK(2,90,0)
951 #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("warning(push)")
952 #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("warning(pop)")
953#else
954 #define JSON_HEDLEY_DIAGNOSTIC_PUSH
955 #define JSON_HEDLEY_DIAGNOSTIC_POP
956#endif
957
958/* JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_ is for
959 HEDLEY INTERNAL USE ONLY. API subject to change without notice. */
960#if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_)
961 #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_
962#endif
963#if defined(__cplusplus)
964# if JSON_HEDLEY_HAS_WARNING("-Wc++98-compat")
965# if JSON_HEDLEY_HAS_WARNING("-Wc++17-extensions")
966# if JSON_HEDLEY_HAS_WARNING("-Wc++1z-extensions")
967# define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(xpr) \
968 JSON_HEDLEY_DIAGNOSTIC_PUSH \
969 _Pragma("clang diagnostic ignored \"-Wc++98-compat\"") \
970 _Pragma("clang diagnostic ignored \"-Wc++17-extensions\"") \
971 _Pragma("clang diagnostic ignored \"-Wc++1z-extensions\"") \
972 xpr \
973 JSON_HEDLEY_DIAGNOSTIC_POP
974# else
975# define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(xpr) \
976 JSON_HEDLEY_DIAGNOSTIC_PUSH \
977 _Pragma("clang diagnostic ignored \"-Wc++98-compat\"") \
978 _Pragma("clang diagnostic ignored \"-Wc++17-extensions\"") \
979 xpr \
980 JSON_HEDLEY_DIAGNOSTIC_POP
981# endif
982# else
983# define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(xpr) \
984 JSON_HEDLEY_DIAGNOSTIC_PUSH \
985 _Pragma("clang diagnostic ignored \"-Wc++98-compat\"") \
986 xpr \
987 JSON_HEDLEY_DIAGNOSTIC_POP
988# endif
989# endif
990#endif
991#if !defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_)
992 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(x) x
993#endif
994
995#if defined(JSON_HEDLEY_CONST_CAST)
996 #undef JSON_HEDLEY_CONST_CAST
997#endif
998#if defined(__cplusplus)
999# define JSON_HEDLEY_CONST_CAST(T, expr) (const_cast<T>(expr))
1000#elif \
1001 JSON_HEDLEY_HAS_WARNING("-Wcast-qual") || \
1002 JSON_HEDLEY_GCC_VERSION_CHECK(4,6,0) || \
1003 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0)
1004# define JSON_HEDLEY_CONST_CAST(T, expr) (__extension__ ({ \
1005 JSON_HEDLEY_DIAGNOSTIC_PUSH \
1006 JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL \
1007 ((T) (expr)); \
1008 JSON_HEDLEY_DIAGNOSTIC_POP \
1009 }))
1010#else
1011# define JSON_HEDLEY_CONST_CAST(T, expr) ((T) (expr))
1012#endif
1013
1014#if defined(JSON_HEDLEY_REINTERPRET_CAST)
1015 #undef JSON_HEDLEY_REINTERPRET_CAST
1016#endif
1017#if defined(__cplusplus)
1018 #define JSON_HEDLEY_REINTERPRET_CAST(T, expr) (reinterpret_cast<T>(expr))
1019#else
1020 #define JSON_HEDLEY_REINTERPRET_CAST(T, expr) ((T) (expr))
1021#endif
1022
1023#if defined(JSON_HEDLEY_STATIC_CAST)
1024 #undef JSON_HEDLEY_STATIC_CAST
1025#endif
1026#if defined(__cplusplus)
1027 #define JSON_HEDLEY_STATIC_CAST(T, expr) (static_cast<T>(expr))
1028#else
1029 #define JSON_HEDLEY_STATIC_CAST(T, expr) ((T) (expr))
1030#endif
1031
1032#if defined(JSON_HEDLEY_CPP_CAST)
1033 #undef JSON_HEDLEY_CPP_CAST
1034#endif
1035#if defined(__cplusplus)
1036# if JSON_HEDLEY_HAS_WARNING("-Wold-style-cast")
1037# define JSON_HEDLEY_CPP_CAST(T, expr) \
1038 JSON_HEDLEY_DIAGNOSTIC_PUSH \
1039 _Pragma("clang diagnostic ignored \"-Wold-style-cast\"") \
1040 ((T) (expr)) \
1041 JSON_HEDLEY_DIAGNOSTIC_POP
1042# elif JSON_HEDLEY_IAR_VERSION_CHECK(8,3,0)
1043# define JSON_HEDLEY_CPP_CAST(T, expr) \
1044 JSON_HEDLEY_DIAGNOSTIC_PUSH \
1045 _Pragma("diag_suppress=Pe137") \
1046 JSON_HEDLEY_DIAGNOSTIC_POP
1047# else
1048# define JSON_HEDLEY_CPP_CAST(T, expr) ((T) (expr))
1049# endif
1050#else
1051# define JSON_HEDLEY_CPP_CAST(T, expr) (expr)
1052#endif
1053
1054#if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED)
1055 #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED
1056#endif
1057#if JSON_HEDLEY_HAS_WARNING("-Wdeprecated-declarations")
1058 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("clang diagnostic ignored \"-Wdeprecated-declarations\"")
1059#elif JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0)
1060 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("warning(disable:1478 1786)")
1061#elif JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1062 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED __pragma(warning(disable:1478 1786))
1063#elif JSON_HEDLEY_PGI_VERSION_CHECK(20,7,0)
1064 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress 1215,1216,1444,1445")
1065#elif JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0)
1066 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress 1215,1444")
1067#elif JSON_HEDLEY_GCC_VERSION_CHECK(4,3,0)
1068 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"")
1069#elif JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0)
1070 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED __pragma(warning(disable:4996))
1071#elif JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1072 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress 1215,1444")
1073#elif \
1074 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1075 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1076 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1077 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1078 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1079 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1080 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1081 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1082 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1083 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1084 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0)
1085 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress 1291,1718")
1086#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,13,0) && !defined(__cplusplus)
1087 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("error_messages(off,E_DEPRECATED_ATT,E_DEPRECATED_ATT_MESS)")
1088#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,13,0) && defined(__cplusplus)
1089 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("error_messages(off,symdeprecated,symdeprecated2)")
1090#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
1091 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress=Pe1444,Pe1215")
1092#elif JSON_HEDLEY_PELLES_VERSION_CHECK(2,90,0)
1093 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("warn(disable:2241)")
1094#else
1095 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED
1096#endif
1097
1098#if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS)
1099 #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS
1100#endif
1101#if JSON_HEDLEY_HAS_WARNING("-Wunknown-pragmas")
1102 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("clang diagnostic ignored \"-Wunknown-pragmas\"")
1103#elif JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0)
1104 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("warning(disable:161)")
1105#elif JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1106 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS __pragma(warning(disable:161))
1107#elif JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0)
1108 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress 1675")
1109#elif JSON_HEDLEY_GCC_VERSION_CHECK(4,3,0)
1110 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("GCC diagnostic ignored \"-Wunknown-pragmas\"")
1111#elif JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0)
1112 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS __pragma(warning(disable:4068))
1113#elif \
1114 JSON_HEDLEY_TI_VERSION_CHECK(16,9,0) || \
1115 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,0,0) || \
1116 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1117 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,3,0)
1118 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress 163")
1119#elif JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,0,0)
1120 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress 163")
1121#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
1122 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress=Pe161")
1123#elif JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1124 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress 161")
1125#else
1126 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS
1127#endif
1128
1129#if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES)
1130 #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES
1131#endif
1132#if JSON_HEDLEY_HAS_WARNING("-Wunknown-attributes")
1133 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("clang diagnostic ignored \"-Wunknown-attributes\"")
1134#elif JSON_HEDLEY_GCC_VERSION_CHECK(4,6,0)
1135 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"")
1136#elif JSON_HEDLEY_INTEL_VERSION_CHECK(17,0,0)
1137 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("warning(disable:1292)")
1138#elif JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1139 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES __pragma(warning(disable:1292))
1140#elif JSON_HEDLEY_MSVC_VERSION_CHECK(19,0,0)
1141 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES __pragma(warning(disable:5030))
1142#elif JSON_HEDLEY_PGI_VERSION_CHECK(20,7,0)
1143 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress 1097,1098")
1144#elif JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0)
1145 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress 1097")
1146#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,14,0) && defined(__cplusplus)
1147 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("error_messages(off,attrskipunsup)")
1148#elif \
1149 JSON_HEDLEY_TI_VERSION_CHECK(18,1,0) || \
1150 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,3,0) || \
1151 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0)
1152 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress 1173")
1153#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
1154 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress=Pe1097")
1155#elif JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1156 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress 1097")
1157#else
1158 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES
1159#endif
1160
1161#if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL)
1162 #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL
1163#endif
1164#if JSON_HEDLEY_HAS_WARNING("-Wcast-qual")
1165 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL _Pragma("clang diagnostic ignored \"-Wcast-qual\"")
1166#elif JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0)
1167 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL _Pragma("warning(disable:2203 2331)")
1168#elif JSON_HEDLEY_GCC_VERSION_CHECK(3,0,0)
1169 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL _Pragma("GCC diagnostic ignored \"-Wcast-qual\"")
1170#else
1171 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL
1172#endif
1173
1174#if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION)
1175 #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION
1176#endif
1177#if JSON_HEDLEY_HAS_WARNING("-Wunused-function")
1178 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION _Pragma("clang diagnostic ignored \"-Wunused-function\"")
1179#elif JSON_HEDLEY_GCC_VERSION_CHECK(3,4,0)
1180 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION _Pragma("GCC diagnostic ignored \"-Wunused-function\"")
1181#elif JSON_HEDLEY_MSVC_VERSION_CHECK(1,0,0)
1182 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION __pragma(warning(disable:4505))
1183#elif JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1184 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION _Pragma("diag_suppress 3142")
1185#else
1186 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION
1187#endif
1188
1189#if defined(JSON_HEDLEY_DEPRECATED)
1190 #undef JSON_HEDLEY_DEPRECATED
1191#endif
1192#if defined(JSON_HEDLEY_DEPRECATED_FOR)
1193 #undef JSON_HEDLEY_DEPRECATED_FOR
1194#endif
1195#if \
1196 JSON_HEDLEY_MSVC_VERSION_CHECK(14,0,0) || \
1197 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1198 #define JSON_HEDLEY_DEPRECATED(since) __declspec(deprecated("Since " # since))
1199 #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) __declspec(deprecated("Since " #since "; use " #replacement))
1200#elif \
1201 (JSON_HEDLEY_HAS_EXTENSION(attribute_deprecated_with_message) && !defined(JSON_HEDLEY_IAR_VERSION)) || \
1202 JSON_HEDLEY_GCC_VERSION_CHECK(4,5,0) || \
1203 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1204 JSON_HEDLEY_ARM_VERSION_CHECK(5,6,0) || \
1205 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,13,0) || \
1206 JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) || \
1207 JSON_HEDLEY_TI_VERSION_CHECK(18,1,0) || \
1208 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(18,1,0) || \
1209 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,3,0) || \
1210 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1211 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,3,0) || \
1212 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1213 #define JSON_HEDLEY_DEPRECATED(since) __attribute__((__deprecated__("Since " #since)))
1214 #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) __attribute__((__deprecated__("Since " #since "; use " #replacement)))
1215#elif defined(__cplusplus) && (__cplusplus >= 201402L)
1216 #define JSON_HEDLEY_DEPRECATED(since) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[deprecated("Since " #since)]])
1217 #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[deprecated("Since " #since "; use " #replacement)]])
1218#elif \
1219 JSON_HEDLEY_HAS_ATTRIBUTE(deprecated) || \
1220 JSON_HEDLEY_GCC_VERSION_CHECK(3,1,0) || \
1221 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1222 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1223 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1224 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1225 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1226 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1227 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1228 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1229 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1230 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1231 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1232 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1233 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) || \
1234 JSON_HEDLEY_IAR_VERSION_CHECK(8,10,0)
1235 #define JSON_HEDLEY_DEPRECATED(since) __attribute__((__deprecated__))
1236 #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) __attribute__((__deprecated__))
1237#elif \
1238 JSON_HEDLEY_MSVC_VERSION_CHECK(13,10,0) || \
1239 JSON_HEDLEY_PELLES_VERSION_CHECK(6,50,0) || \
1240 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1241 #define JSON_HEDLEY_DEPRECATED(since) __declspec(deprecated)
1242 #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) __declspec(deprecated)
1243#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
1244 #define JSON_HEDLEY_DEPRECATED(since) _Pragma("deprecated")
1245 #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) _Pragma("deprecated")
1246#else
1247 #define JSON_HEDLEY_DEPRECATED(since)
1248 #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement)
1249#endif
1250
1251#if defined(JSON_HEDLEY_UNAVAILABLE)
1252 #undef JSON_HEDLEY_UNAVAILABLE
1253#endif
1254#if \
1255 JSON_HEDLEY_HAS_ATTRIBUTE(warning) || \
1256 JSON_HEDLEY_GCC_VERSION_CHECK(4,3,0) || \
1257 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1258 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1259 #define JSON_HEDLEY_UNAVAILABLE(available_since) __attribute__((__warning__("Not available until " #available_since)))
1260#else
1261 #define JSON_HEDLEY_UNAVAILABLE(available_since)
1262#endif
1263
1264#if defined()
1265 #undef
1266#endif
1267#if defined(_MSG)
1268 #undef _MSG
1269#endif
1270#if \
1271 JSON_HEDLEY_HAS_ATTRIBUTE(warn_unused_result) || \
1272 JSON_HEDLEY_GCC_VERSION_CHECK(3,4,0) || \
1273 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1274 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1275 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1276 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1277 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1278 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1279 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1280 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1281 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1282 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1283 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1284 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1285 (JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,15,0) && defined(__cplusplus)) || \
1286 JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) || \
1287 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1288 #define __attribute__((__warn_unused_result__))
1289 #define _MSG(msg) __attribute__((__warn_unused_result__))
1290#elif (JSON_HEDLEY_HAS_CPP_ATTRIBUTE(nodiscard) >= 201907L)
1291 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[nodiscard]])
1292 #define _MSG(msg) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[nodiscard(msg)]])
1293#elif JSON_HEDLEY_HAS_CPP_ATTRIBUTE(nodiscard)
1294 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[nodiscard]])
1295 #define _MSG(msg) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[nodiscard]])
1296#elif defined(_Check_return_) /* SAL */
1297 #define _Check_return_
1298 #define _MSG(msg) _Check_return_
1299#else
1300 #define
1301 #define _MSG(msg)
1302#endif
1303
1304#if defined(JSON_HEDLEY_SENTINEL)
1305 #undef JSON_HEDLEY_SENTINEL
1306#endif
1307#if \
1308 JSON_HEDLEY_HAS_ATTRIBUTE(sentinel) || \
1309 JSON_HEDLEY_GCC_VERSION_CHECK(4,0,0) || \
1310 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1311 JSON_HEDLEY_ARM_VERSION_CHECK(5,4,0) || \
1312 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1313 #define JSON_HEDLEY_SENTINEL(position) __attribute__((__sentinel__(position)))
1314#else
1315 #define JSON_HEDLEY_SENTINEL(position)
1316#endif
1317
1318#if defined(JSON_HEDLEY_NO_RETURN)
1319 #undef JSON_HEDLEY_NO_RETURN
1320#endif
1321#if JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
1322 #define JSON_HEDLEY_NO_RETURN __noreturn
1323#elif \
1324 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1325 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1326 #define JSON_HEDLEY_NO_RETURN __attribute__((__noreturn__))
1327#elif defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L
1328 #define JSON_HEDLEY_NO_RETURN _Noreturn
1329#elif defined(__cplusplus) && (__cplusplus >= 201103L)
1330 #define JSON_HEDLEY_NO_RETURN JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[noreturn]])
1331#elif \
1332 JSON_HEDLEY_HAS_ATTRIBUTE(noreturn) || \
1333 JSON_HEDLEY_GCC_VERSION_CHECK(3,2,0) || \
1334 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \
1335 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1336 JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
1337 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1338 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1339 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1340 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1341 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1342 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1343 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1344 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1345 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1346 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1347 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1348 JSON_HEDLEY_IAR_VERSION_CHECK(8,10,0)
1349 #define JSON_HEDLEY_NO_RETURN __attribute__((__noreturn__))
1350#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0)
1351 #define JSON_HEDLEY_NO_RETURN _Pragma("does_not_return")
1352#elif \
1353 JSON_HEDLEY_MSVC_VERSION_CHECK(13,10,0) || \
1354 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1355 #define JSON_HEDLEY_NO_RETURN __declspec(noreturn)
1356#elif JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6,0,0) && defined(__cplusplus)
1357 #define JSON_HEDLEY_NO_RETURN _Pragma("FUNC_NEVER_RETURNS;")
1358#elif JSON_HEDLEY_COMPCERT_VERSION_CHECK(3,2,0)
1359 #define JSON_HEDLEY_NO_RETURN __attribute((noreturn))
1360#elif JSON_HEDLEY_PELLES_VERSION_CHECK(9,0,0)
1361 #define JSON_HEDLEY_NO_RETURN __declspec(noreturn)
1362#else
1363 #define JSON_HEDLEY_NO_RETURN
1364#endif
1365
1366#if defined(JSON_HEDLEY_NO_ESCAPE)
1367 #undef JSON_HEDLEY_NO_ESCAPE
1368#endif
1369#if JSON_HEDLEY_HAS_ATTRIBUTE(noescape)
1370 #define JSON_HEDLEY_NO_ESCAPE __attribute__((__noescape__))
1371#else
1372 #define JSON_HEDLEY_NO_ESCAPE
1373#endif
1374
1375#if defined(JSON_HEDLEY_UNREACHABLE)
1376 #undef JSON_HEDLEY_UNREACHABLE
1377#endif
1378#if defined(JSON_HEDLEY_UNREACHABLE_RETURN)
1379 #undef JSON_HEDLEY_UNREACHABLE_RETURN
1380#endif
1381#if defined(JSON_HEDLEY_ASSUME)
1382 #undef JSON_HEDLEY_ASSUME
1383#endif
1384#if \
1385 JSON_HEDLEY_MSVC_VERSION_CHECK(13,10,0) || \
1386 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1387 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1388 #define JSON_HEDLEY_ASSUME(expr) __assume(expr)
1389#elif JSON_HEDLEY_HAS_BUILTIN(__builtin_assume)
1390 #define JSON_HEDLEY_ASSUME(expr) __builtin_assume(expr)
1391#elif \
1392 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,2,0) || \
1393 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(4,0,0)
1394 #if defined(__cplusplus)
1395 #define JSON_HEDLEY_ASSUME(expr) std::_nassert(expr)
1396 #else
1397 #define JSON_HEDLEY_ASSUME(expr) _nassert(expr)
1398 #endif
1399#endif
1400#if \
1401 (JSON_HEDLEY_HAS_BUILTIN(__builtin_unreachable) && (!defined(JSON_HEDLEY_ARM_VERSION))) || \
1402 JSON_HEDLEY_GCC_VERSION_CHECK(4,5,0) || \
1403 JSON_HEDLEY_PGI_VERSION_CHECK(18,10,0) || \
1404 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1405 JSON_HEDLEY_IBM_VERSION_CHECK(13,1,5) || \
1406 JSON_HEDLEY_CRAY_VERSION_CHECK(10,0,0) || \
1407 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1408 #define JSON_HEDLEY_UNREACHABLE() __builtin_unreachable()
1409#elif defined(JSON_HEDLEY_ASSUME)
1410 #define JSON_HEDLEY_UNREACHABLE() JSON_HEDLEY_ASSUME(0)
1411#endif
1412#if !defined(JSON_HEDLEY_ASSUME)
1413 #if defined(JSON_HEDLEY_UNREACHABLE)
1414 #define JSON_HEDLEY_ASSUME(expr) JSON_HEDLEY_STATIC_CAST(void, ((expr) ? 1 : (JSON_HEDLEY_UNREACHABLE(), 1)))
1415 #else
1416 #define JSON_HEDLEY_ASSUME(expr) JSON_HEDLEY_STATIC_CAST(void, expr)
1417 #endif
1418#endif
1419#if defined(JSON_HEDLEY_UNREACHABLE)
1420 #if \
1421 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,2,0) || \
1422 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(4,0,0)
1423 #define JSON_HEDLEY_UNREACHABLE_RETURN(value) return (JSON_HEDLEY_STATIC_CAST(void, JSON_HEDLEY_ASSUME(0)), (value))
1424 #else
1425 #define JSON_HEDLEY_UNREACHABLE_RETURN(value) JSON_HEDLEY_UNREACHABLE()
1426 #endif
1427#else
1428 #define JSON_HEDLEY_UNREACHABLE_RETURN(value) return (value)
1429#endif
1430#if !defined(JSON_HEDLEY_UNREACHABLE)
1431 #define JSON_HEDLEY_UNREACHABLE() JSON_HEDLEY_ASSUME(0)
1432#endif
1433
1434JSON_HEDLEY_DIAGNOSTIC_PUSH
1435#if JSON_HEDLEY_HAS_WARNING("-Wpedantic")
1436 #pragma clang diagnostic ignored "-Wpedantic"
1437#endif
1438#if JSON_HEDLEY_HAS_WARNING("-Wc++98-compat-pedantic") && defined(__cplusplus)
1439 #pragma clang diagnostic ignored "-Wc++98-compat-pedantic"
1440#endif
1441#if JSON_HEDLEY_GCC_HAS_WARNING("-Wvariadic-macros",4,0,0)
1442 #if defined(__clang__)
1443 #pragma clang diagnostic ignored "-Wvariadic-macros"
1444 #elif defined(JSON_HEDLEY_GCC_VERSION)
1445 #pragma GCC diagnostic ignored "-Wvariadic-macros"
1446 #endif
1447#endif
1448#if defined(JSON_HEDLEY_NON_NULL)
1449 #undef JSON_HEDLEY_NON_NULL
1450#endif
1451#if \
1452 JSON_HEDLEY_HAS_ATTRIBUTE(nonnull) || \
1453 JSON_HEDLEY_GCC_VERSION_CHECK(3,3,0) || \
1454 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1455 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0)
1456 #define JSON_HEDLEY_NON_NULL(...) __attribute__((__nonnull__(__VA_ARGS__)))
1457#else
1458 #define JSON_HEDLEY_NON_NULL(...)
1459#endif
1460JSON_HEDLEY_DIAGNOSTIC_POP
1461
1462#if defined(JSON_HEDLEY_PRINTF_FORMAT)
1463 #undef JSON_HEDLEY_PRINTF_FORMAT
1464#endif
1465#if defined(__MINGW32__) && JSON_HEDLEY_GCC_HAS_ATTRIBUTE(format,4,4,0) && !defined(__USE_MINGW_ANSI_STDIO)
1466 #define JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) __attribute__((__format__(ms_printf, string_idx, first_to_check)))
1467#elif defined(__MINGW32__) && JSON_HEDLEY_GCC_HAS_ATTRIBUTE(format,4,4,0) && defined(__USE_MINGW_ANSI_STDIO)
1468 #define JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) __attribute__((__format__(gnu_printf, string_idx, first_to_check)))
1469#elif \
1470 JSON_HEDLEY_HAS_ATTRIBUTE(format) || \
1471 JSON_HEDLEY_GCC_VERSION_CHECK(3,1,0) || \
1472 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1473 JSON_HEDLEY_ARM_VERSION_CHECK(5,6,0) || \
1474 JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
1475 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1476 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1477 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1478 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1479 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1480 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1481 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1482 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1483 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1484 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1485 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1486 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1487 #define JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) __attribute__((__format__(__printf__, string_idx, first_to_check)))
1488#elif JSON_HEDLEY_PELLES_VERSION_CHECK(6,0,0)
1489 #define JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) __declspec(vaformat(printf,string_idx,first_to_check))
1490#else
1491 #define JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check)
1492#endif
1493
1494#if defined(JSON_HEDLEY_CONSTEXPR)
1495 #undef JSON_HEDLEY_CONSTEXPR
1496#endif
1497#if defined(__cplusplus)
1498 #if __cplusplus >= 201103L
1499 #define JSON_HEDLEY_CONSTEXPR JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(constexpr)
1500 #endif
1501#endif
1502#if !defined(JSON_HEDLEY_CONSTEXPR)
1503 #define JSON_HEDLEY_CONSTEXPR
1504#endif
1505
1506#if defined(JSON_HEDLEY_PREDICT)
1507 #undef JSON_HEDLEY_PREDICT
1508#endif
1509#if defined(JSON_HEDLEY_LIKELY)
1510 #undef JSON_HEDLEY_LIKELY
1511#endif
1512#if defined(JSON_HEDLEY_UNLIKELY)
1513 #undef JSON_HEDLEY_UNLIKELY
1514#endif
1515#if defined(JSON_HEDLEY_UNPREDICTABLE)
1516 #undef JSON_HEDLEY_UNPREDICTABLE
1517#endif
1518#if JSON_HEDLEY_HAS_BUILTIN(__builtin_unpredictable)
1519 #define JSON_HEDLEY_UNPREDICTABLE(expr) __builtin_unpredictable((expr))
1520#endif
1521#if \
1522 (JSON_HEDLEY_HAS_BUILTIN(__builtin_expect_with_probability) && !defined(JSON_HEDLEY_PGI_VERSION)) || \
1523 JSON_HEDLEY_GCC_VERSION_CHECK(9,0,0) || \
1524 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1525# define JSON_HEDLEY_PREDICT(expr, value, probability) __builtin_expect_with_probability( (expr), (value), (probability))
1526# define JSON_HEDLEY_PREDICT_TRUE(expr, probability) __builtin_expect_with_probability(!!(expr), 1 , (probability))
1527# define JSON_HEDLEY_PREDICT_FALSE(expr, probability) __builtin_expect_with_probability(!!(expr), 0 , (probability))
1528# define JSON_HEDLEY_LIKELY(expr) __builtin_expect (!!(expr), 1 )
1529# define JSON_HEDLEY_UNLIKELY(expr) __builtin_expect (!!(expr), 0 )
1530#elif \
1531 (JSON_HEDLEY_HAS_BUILTIN(__builtin_expect) && !defined(JSON_HEDLEY_INTEL_CL_VERSION)) || \
1532 JSON_HEDLEY_GCC_VERSION_CHECK(3,0,0) || \
1533 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1534 (JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,15,0) && defined(__cplusplus)) || \
1535 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1536 JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
1537 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1538 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,7,0) || \
1539 JSON_HEDLEY_TI_CL430_VERSION_CHECK(3,1,0) || \
1540 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,1,0) || \
1541 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6,1,0) || \
1542 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1543 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1544 JSON_HEDLEY_TINYC_VERSION_CHECK(0,9,27) || \
1545 JSON_HEDLEY_CRAY_VERSION_CHECK(8,1,0) || \
1546 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1547# define JSON_HEDLEY_PREDICT(expr, expected, probability) \
1548 (((probability) >= 0.9) ? __builtin_expect((expr), (expected)) : (JSON_HEDLEY_STATIC_CAST(void, expected), (expr)))
1549# define JSON_HEDLEY_PREDICT_TRUE(expr, probability) \
1550 (__extension__ ({ \
1551 double hedley_probability_ = (probability); \
1552 ((hedley_probability_ >= 0.9) ? __builtin_expect(!!(expr), 1) : ((hedley_probability_ <= 0.1) ? __builtin_expect(!!(expr), 0) : !!(expr))); \
1553 }))
1554# define JSON_HEDLEY_PREDICT_FALSE(expr, probability) \
1555 (__extension__ ({ \
1556 double hedley_probability_ = (probability); \
1557 ((hedley_probability_ >= 0.9) ? __builtin_expect(!!(expr), 0) : ((hedley_probability_ <= 0.1) ? __builtin_expect(!!(expr), 1) : !!(expr))); \
1558 }))
1559# define JSON_HEDLEY_LIKELY(expr) __builtin_expect(!!(expr), 1)
1560# define JSON_HEDLEY_UNLIKELY(expr) __builtin_expect(!!(expr), 0)
1561#else
1562# define JSON_HEDLEY_PREDICT(expr, expected, probability) (JSON_HEDLEY_STATIC_CAST(void, expected), (expr))
1563# define JSON_HEDLEY_PREDICT_TRUE(expr, probability) (!!(expr))
1564# define JSON_HEDLEY_PREDICT_FALSE(expr, probability) (!!(expr))
1565# define JSON_HEDLEY_LIKELY(expr) (!!(expr))
1566# define JSON_HEDLEY_UNLIKELY(expr) (!!(expr))
1567#endif
1568#if !defined(JSON_HEDLEY_UNPREDICTABLE)
1569 #define JSON_HEDLEY_UNPREDICTABLE(expr) JSON_HEDLEY_PREDICT(expr, 1, 0.5)
1570#endif
1571
1572#if defined(JSON_HEDLEY_MALLOC)
1573 #undef JSON_HEDLEY_MALLOC
1574#endif
1575#if \
1576 JSON_HEDLEY_HAS_ATTRIBUTE(malloc) || \
1577 JSON_HEDLEY_GCC_VERSION_CHECK(3,1,0) || \
1578 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1579 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \
1580 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1581 JSON_HEDLEY_IBM_VERSION_CHECK(12,1,0) || \
1582 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1583 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1584 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1585 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1586 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1587 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1588 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1589 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1590 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1591 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1592 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1593 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1594 #define JSON_HEDLEY_MALLOC __attribute__((__malloc__))
1595#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0)
1596 #define JSON_HEDLEY_MALLOC _Pragma("returns_new_memory")
1597#elif \
1598 JSON_HEDLEY_MSVC_VERSION_CHECK(14,0,0) || \
1599 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1600 #define JSON_HEDLEY_MALLOC __declspec(restrict)
1601#else
1602 #define JSON_HEDLEY_MALLOC
1603#endif
1604
1605#if defined(JSON_HEDLEY_PURE)
1606 #undef JSON_HEDLEY_PURE
1607#endif
1608#if \
1609 JSON_HEDLEY_HAS_ATTRIBUTE(pure) || \
1610 JSON_HEDLEY_GCC_VERSION_CHECK(2,96,0) || \
1611 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1612 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \
1613 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1614 JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
1615 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1616 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1617 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1618 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1619 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1620 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1621 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1622 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1623 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1624 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1625 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1626 JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) || \
1627 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1628# define JSON_HEDLEY_PURE __attribute__((__pure__))
1629#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0)
1630# define JSON_HEDLEY_PURE _Pragma("does_not_write_global_data")
1631#elif defined(__cplusplus) && \
1632 ( \
1633 JSON_HEDLEY_TI_CL430_VERSION_CHECK(2,0,1) || \
1634 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(4,0,0) || \
1635 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) \
1636 )
1637# define JSON_HEDLEY_PURE _Pragma("FUNC_IS_PURE;")
1638#else
1639# define JSON_HEDLEY_PURE
1640#endif
1641
1642#if defined(JSON_HEDLEY_CONST)
1643 #undef JSON_HEDLEY_CONST
1644#endif
1645#if \
1646 JSON_HEDLEY_HAS_ATTRIBUTE(const) || \
1647 JSON_HEDLEY_GCC_VERSION_CHECK(2,5,0) || \
1648 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1649 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \
1650 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1651 JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
1652 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1653 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1654 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1655 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1656 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1657 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1658 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1659 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1660 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1661 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1662 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1663 JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) || \
1664 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1665 #define JSON_HEDLEY_CONST __attribute__((__const__))
1666#elif \
1667 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0)
1668 #define JSON_HEDLEY_CONST _Pragma("no_side_effect")
1669#else
1670 #define JSON_HEDLEY_CONST JSON_HEDLEY_PURE
1671#endif
1672
1673#if defined(JSON_HEDLEY_RESTRICT)
1674 #undef JSON_HEDLEY_RESTRICT
1675#endif
1676#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) && !defined(__cplusplus)
1677 #define JSON_HEDLEY_RESTRICT restrict
1678#elif \
1679 JSON_HEDLEY_GCC_VERSION_CHECK(3,1,0) || \
1680 JSON_HEDLEY_MSVC_VERSION_CHECK(14,0,0) || \
1681 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1682 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) || \
1683 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1684 JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
1685 JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) || \
1686 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1687 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,2,4) || \
1688 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,1,0) || \
1689 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1690 (JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,14,0) && defined(__cplusplus)) || \
1691 JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) || \
1692 defined(__clang__) || \
1693 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1694 #define JSON_HEDLEY_RESTRICT __restrict
1695#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,3,0) && !defined(__cplusplus)
1696 #define JSON_HEDLEY_RESTRICT _Restrict
1697#else
1698 #define JSON_HEDLEY_RESTRICT
1699#endif
1700
1701#if defined(JSON_HEDLEY_INLINE)
1702 #undef JSON_HEDLEY_INLINE
1703#endif
1704#if \
1705 (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)) || \
1706 (defined(__cplusplus) && (__cplusplus >= 199711L))
1707 #define JSON_HEDLEY_INLINE inline
1708#elif \
1709 defined(JSON_HEDLEY_GCC_VERSION) || \
1710 JSON_HEDLEY_ARM_VERSION_CHECK(6,2,0)
1711 #define JSON_HEDLEY_INLINE __inline__
1712#elif \
1713 JSON_HEDLEY_MSVC_VERSION_CHECK(12,0,0) || \
1714 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) || \
1715 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1716 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,1,0) || \
1717 JSON_HEDLEY_TI_CL430_VERSION_CHECK(3,1,0) || \
1718 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,2,0) || \
1719 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,0,0) || \
1720 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1721 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1722 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1723 #define JSON_HEDLEY_INLINE __inline
1724#else
1725 #define JSON_HEDLEY_INLINE
1726#endif
1727
1728#if defined(JSON_HEDLEY_ALWAYS_INLINE)
1729 #undef JSON_HEDLEY_ALWAYS_INLINE
1730#endif
1731#if \
1732 JSON_HEDLEY_HAS_ATTRIBUTE(always_inline) || \
1733 JSON_HEDLEY_GCC_VERSION_CHECK(4,0,0) || \
1734 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1735 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \
1736 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1737 JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
1738 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1739 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1740 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1741 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1742 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1743 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1744 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1745 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1746 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1747 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1748 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1749 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) || \
1750 JSON_HEDLEY_IAR_VERSION_CHECK(8,10,0)
1751# define JSON_HEDLEY_ALWAYS_INLINE __attribute__((__always_inline__)) JSON_HEDLEY_INLINE
1752#elif \
1753 JSON_HEDLEY_MSVC_VERSION_CHECK(12,0,0) || \
1754 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1755# define JSON_HEDLEY_ALWAYS_INLINE __forceinline
1756#elif defined(__cplusplus) && \
1757 ( \
1758 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1759 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1760 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1761 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6,1,0) || \
1762 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1763 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) \
1764 )
1765# define JSON_HEDLEY_ALWAYS_INLINE _Pragma("FUNC_ALWAYS_INLINE;")
1766#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
1767# define JSON_HEDLEY_ALWAYS_INLINE _Pragma("inline=forced")
1768#else
1769# define JSON_HEDLEY_ALWAYS_INLINE JSON_HEDLEY_INLINE
1770#endif
1771
1772#if defined(JSON_HEDLEY_NEVER_INLINE)
1773 #undef JSON_HEDLEY_NEVER_INLINE
1774#endif
1775#if \
1776 JSON_HEDLEY_HAS_ATTRIBUTE(noinline) || \
1777 JSON_HEDLEY_GCC_VERSION_CHECK(4,0,0) || \
1778 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1779 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \
1780 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1781 JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
1782 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1783 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1784 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1785 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1786 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1787 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1788 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1789 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1790 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1791 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1792 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1793 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) || \
1794 JSON_HEDLEY_IAR_VERSION_CHECK(8,10,0)
1795 #define JSON_HEDLEY_NEVER_INLINE __attribute__((__noinline__))
1796#elif \
1797 JSON_HEDLEY_MSVC_VERSION_CHECK(13,10,0) || \
1798 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1799 #define JSON_HEDLEY_NEVER_INLINE __declspec(noinline)
1800#elif JSON_HEDLEY_PGI_VERSION_CHECK(10,2,0)
1801 #define JSON_HEDLEY_NEVER_INLINE _Pragma("noinline")
1802#elif JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6,0,0) && defined(__cplusplus)
1803 #define JSON_HEDLEY_NEVER_INLINE _Pragma("FUNC_CANNOT_INLINE;")
1804#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
1805 #define JSON_HEDLEY_NEVER_INLINE _Pragma("inline=never")
1806#elif JSON_HEDLEY_COMPCERT_VERSION_CHECK(3,2,0)
1807 #define JSON_HEDLEY_NEVER_INLINE __attribute((noinline))
1808#elif JSON_HEDLEY_PELLES_VERSION_CHECK(9,0,0)
1809 #define JSON_HEDLEY_NEVER_INLINE __declspec(noinline)
1810#else
1811 #define JSON_HEDLEY_NEVER_INLINE
1812#endif
1813
1814#if defined(JSON_HEDLEY_PRIVATE)
1815 #undef JSON_HEDLEY_PRIVATE
1816#endif
1817#if defined(JSON_HEDLEY_PUBLIC)
1818 #undef JSON_HEDLEY_PUBLIC
1819#endif
1820#if defined(JSON_HEDLEY_IMPORT)
1821 #undef JSON_HEDLEY_IMPORT
1822#endif
1823#if defined(_WIN32) || defined(__CYGWIN__)
1824# define JSON_HEDLEY_PRIVATE
1825# define JSON_HEDLEY_PUBLIC __declspec(dllexport)
1826# define JSON_HEDLEY_IMPORT __declspec(dllimport)
1827#else
1828# if \
1829 JSON_HEDLEY_HAS_ATTRIBUTE(visibility) || \
1830 JSON_HEDLEY_GCC_VERSION_CHECK(3,3,0) || \
1831 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \
1832 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1833 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1834 JSON_HEDLEY_IBM_VERSION_CHECK(13,1,0) || \
1835 ( \
1836 defined(__TI_EABI__) && \
1837 ( \
1838 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1839 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) \
1840 ) \
1841 ) || \
1842 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1843# define JSON_HEDLEY_PRIVATE __attribute__((__visibility__("hidden")))
1844# define JSON_HEDLEY_PUBLIC __attribute__((__visibility__("default")))
1845# else
1846# define JSON_HEDLEY_PRIVATE
1847# define JSON_HEDLEY_PUBLIC
1848# endif
1849# define JSON_HEDLEY_IMPORT extern
1850#endif
1851
1852#if defined(JSON_HEDLEY_NO_THROW)
1853 #undef JSON_HEDLEY_NO_THROW
1854#endif
1855#if \
1856 JSON_HEDLEY_HAS_ATTRIBUTE(nothrow) || \
1857 JSON_HEDLEY_GCC_VERSION_CHECK(3,3,0) || \
1858 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1859 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1860 #define JSON_HEDLEY_NO_THROW __attribute__((__nothrow__))
1861#elif \
1862 JSON_HEDLEY_MSVC_VERSION_CHECK(13,1,0) || \
1863 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) || \
1864 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0)
1865 #define JSON_HEDLEY_NO_THROW __declspec(nothrow)
1866#else
1867 #define JSON_HEDLEY_NO_THROW
1868#endif
1869
1870#if defined(JSON_HEDLEY_FALL_THROUGH)
1871 #undef JSON_HEDLEY_FALL_THROUGH
1872#endif
1873#if \
1874 JSON_HEDLEY_HAS_ATTRIBUTE(fallthrough) || \
1875 JSON_HEDLEY_GCC_VERSION_CHECK(7,0,0) || \
1876 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1877 #define JSON_HEDLEY_FALL_THROUGH __attribute__((__fallthrough__))
1878#elif JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS(clang,fallthrough)
1879 #define JSON_HEDLEY_FALL_THROUGH JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[clang::fallthrough]])
1880#elif JSON_HEDLEY_HAS_CPP_ATTRIBUTE(fallthrough)
1881 #define JSON_HEDLEY_FALL_THROUGH JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[fallthrough]])
1882#elif defined(__fallthrough) /* SAL */
1883 #define JSON_HEDLEY_FALL_THROUGH __fallthrough
1884#else
1885 #define JSON_HEDLEY_FALL_THROUGH
1886#endif
1887
1888#if defined()
1889 #undef
1890#endif
1891#if \
1892 JSON_HEDLEY_HAS_ATTRIBUTE(returns_nonnull) || \
1893 JSON_HEDLEY_GCC_VERSION_CHECK(4,9,0) || \
1894 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1895 #define __attribute__((__returns_nonnull__))
1896#elif defined(_Ret_notnull_) /* SAL */
1897 #define _Ret_notnull_
1898#else
1899 #define
1900#endif
1901
1902#if defined(JSON_HEDLEY_ARRAY_PARAM)
1903 #undef JSON_HEDLEY_ARRAY_PARAM
1904#endif
1905#if \
1906 defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) && \
1907 !defined(__STDC_NO_VLA__) && \
1908 !defined(__cplusplus) && \
1909 !defined(JSON_HEDLEY_PGI_VERSION) && \
1910 !defined(JSON_HEDLEY_TINYC_VERSION)
1911 #define JSON_HEDLEY_ARRAY_PARAM(name) (name)
1912#else
1913 #define JSON_HEDLEY_ARRAY_PARAM(name)
1914#endif
1915
1916#if defined(JSON_HEDLEY_IS_CONSTANT)
1917 #undef JSON_HEDLEY_IS_CONSTANT
1918#endif
1919#if defined(JSON_HEDLEY_REQUIRE_CONSTEXPR)
1920 #undef JSON_HEDLEY_REQUIRE_CONSTEXPR
1921#endif
1922/* JSON_HEDLEY_IS_CONSTEXPR_ is for
1923 HEDLEY INTERNAL USE ONLY. API subject to change without notice. */
1924#if defined(JSON_HEDLEY_IS_CONSTEXPR_)
1925 #undef JSON_HEDLEY_IS_CONSTEXPR_
1926#endif
1927#if \
1928 JSON_HEDLEY_HAS_BUILTIN(__builtin_constant_p) || \
1929 JSON_HEDLEY_GCC_VERSION_CHECK(3,4,0) || \
1930 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1931 JSON_HEDLEY_TINYC_VERSION_CHECK(0,9,19) || \
1932 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1933 JSON_HEDLEY_IBM_VERSION_CHECK(13,1,0) || \
1934 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6,1,0) || \
1935 (JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0) && !defined(__cplusplus)) || \
1936 JSON_HEDLEY_CRAY_VERSION_CHECK(8,1,0) || \
1937 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1938 #define JSON_HEDLEY_IS_CONSTANT(expr) __builtin_constant_p(expr)
1939#endif
1940#if !defined(__cplusplus)
1941# if \
1942 JSON_HEDLEY_HAS_BUILTIN(__builtin_types_compatible_p) || \
1943 JSON_HEDLEY_GCC_VERSION_CHECK(3,4,0) || \
1944 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1945 JSON_HEDLEY_IBM_VERSION_CHECK(13,1,0) || \
1946 JSON_HEDLEY_CRAY_VERSION_CHECK(8,1,0) || \
1947 JSON_HEDLEY_ARM_VERSION_CHECK(5,4,0) || \
1948 JSON_HEDLEY_TINYC_VERSION_CHECK(0,9,24)
1949#if defined(__INTPTR_TYPE__)
1950 #define JSON_HEDLEY_IS_CONSTEXPR_(expr) __builtin_types_compatible_p(__typeof__((1 ? (void*) ((__INTPTR_TYPE__) ((expr) * 0)) : (int*) 0)), int*)
1951#else
1952 #include <stdint.h>
1953 #define JSON_HEDLEY_IS_CONSTEXPR_(expr) __builtin_types_compatible_p(__typeof__((1 ? (void*) ((intptr_t) ((expr) * 0)) : (int*) 0)), int*)
1954#endif
1955# elif \
1956 ( \
1957 defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L) && \
1958 !defined(JSON_HEDLEY_SUNPRO_VERSION) && \
1959 !defined(JSON_HEDLEY_PGI_VERSION) && \
1960 !defined(JSON_HEDLEY_IAR_VERSION)) || \
1961 (JSON_HEDLEY_HAS_EXTENSION(c_generic_selections) && !defined(JSON_HEDLEY_IAR_VERSION)) || \
1962 JSON_HEDLEY_GCC_VERSION_CHECK(4,9,0) || \
1963 JSON_HEDLEY_INTEL_VERSION_CHECK(17,0,0) || \
1964 JSON_HEDLEY_IBM_VERSION_CHECK(12,1,0) || \
1965 JSON_HEDLEY_ARM_VERSION_CHECK(5,3,0)
1966#if defined(__INTPTR_TYPE__)
1967 #define JSON_HEDLEY_IS_CONSTEXPR_(expr) _Generic((1 ? (void*) ((__INTPTR_TYPE__) ((expr) * 0)) : (int*) 0), int*: 1, void*: 0)
1968#else
1969 #include <stdint.h>
1970 #define JSON_HEDLEY_IS_CONSTEXPR_(expr) _Generic((1 ? (void*) ((intptr_t) * 0) : (int*) 0), int*: 1, void*: 0)
1971#endif
1972# elif \
1973 defined(JSON_HEDLEY_GCC_VERSION) || \
1974 defined(JSON_HEDLEY_INTEL_VERSION) || \
1975 defined(JSON_HEDLEY_TINYC_VERSION) || \
1976 defined(JSON_HEDLEY_TI_ARMCL_VERSION) || \
1977 JSON_HEDLEY_TI_CL430_VERSION_CHECK(18,12,0) || \
1978 defined(JSON_HEDLEY_TI_CL2000_VERSION) || \
1979 defined(JSON_HEDLEY_TI_CL6X_VERSION) || \
1980 defined(JSON_HEDLEY_TI_CL7X_VERSION) || \
1981 defined(JSON_HEDLEY_TI_CLPRU_VERSION) || \
1982 defined(__clang__)
1983# define JSON_HEDLEY_IS_CONSTEXPR_(expr) ( \
1984 sizeof(void) != \
1985 sizeof(*( \
1986 1 ? \
1987 ((void*) ((expr) * 0L) ) : \
1988((struct { char v[sizeof(void) * 2]; } *) 1) \
1989 ) \
1990 ) \
1991 )
1992# endif
1993#endif
1994#if defined(JSON_HEDLEY_IS_CONSTEXPR_)
1995 #if !defined(JSON_HEDLEY_IS_CONSTANT)
1996 #define JSON_HEDLEY_IS_CONSTANT(expr) JSON_HEDLEY_IS_CONSTEXPR_(expr)
1997 #endif
1998 #define JSON_HEDLEY_REQUIRE_CONSTEXPR(expr) (JSON_HEDLEY_IS_CONSTEXPR_(expr) ? (expr) : (-1))
1999#else
2000 #if !defined(JSON_HEDLEY_IS_CONSTANT)
2001 #define JSON_HEDLEY_IS_CONSTANT(expr) (0)
2002 #endif
2003 #define JSON_HEDLEY_REQUIRE_CONSTEXPR(expr) (expr)
2004#endif
2005
2006#if defined(JSON_HEDLEY_BEGIN_C_DECLS)
2007 #undef JSON_HEDLEY_BEGIN_C_DECLS
2008#endif
2009#if defined(JSON_HEDLEY_END_C_DECLS)
2010 #undef JSON_HEDLEY_END_C_DECLS
2011#endif
2012#if defined(JSON_HEDLEY_C_DECL)
2013 #undef JSON_HEDLEY_C_DECL
2014#endif
2015#if defined(__cplusplus)
2016 #define JSON_HEDLEY_BEGIN_C_DECLS extern "C" {
2017 #define JSON_HEDLEY_END_C_DECLS }
2018 #define JSON_HEDLEY_C_DECL extern "C"
2019#else
2020 #define JSON_HEDLEY_BEGIN_C_DECLS
2021 #define JSON_HEDLEY_END_C_DECLS
2022 #define JSON_HEDLEY_C_DECL
2023#endif
2024
2025#if defined(JSON_HEDLEY_STATIC_ASSERT)
2026 #undef JSON_HEDLEY_STATIC_ASSERT
2027#endif
2028#if \
2029 !defined(__cplusplus) && ( \
2030 (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L)) || \
2031 (JSON_HEDLEY_HAS_FEATURE(c_static_assert) && !defined(JSON_HEDLEY_INTEL_CL_VERSION)) || \
2032 JSON_HEDLEY_GCC_VERSION_CHECK(6,0,0) || \
2033 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
2034 defined(_Static_assert) \
2035 )
2036# define JSON_HEDLEY_STATIC_ASSERT(expr, message) _Static_assert(expr, message)
2037#elif \
2038 (defined(__cplusplus) && (__cplusplus >= 201103L)) || \
2039 JSON_HEDLEY_MSVC_VERSION_CHECK(16,0,0) || \
2040 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
2041# define JSON_HEDLEY_STATIC_ASSERT(expr, message) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(static_assert(expr, message))
2042#else
2043# define JSON_HEDLEY_STATIC_ASSERT(expr, message)
2044#endif
2045
2046#if defined(JSON_HEDLEY_NULL)
2047 #undef JSON_HEDLEY_NULL
2048#endif
2049#if defined(__cplusplus)
2050 #if __cplusplus >= 201103L
2051 #define JSON_HEDLEY_NULL JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(nullptr)
2052 #elif defined(NULL)
2053 #define JSON_HEDLEY_NULL NULL
2054 #else
2055 #define JSON_HEDLEY_NULL JSON_HEDLEY_STATIC_CAST(void*, 0)
2056 #endif
2057#elif defined(NULL)
2058 #define JSON_HEDLEY_NULL NULL
2059#else
2060 #define JSON_HEDLEY_NULL ((void*) 0)
2061#endif
2062
2063#if defined(JSON_HEDLEY_MESSAGE)
2064 #undef JSON_HEDLEY_MESSAGE
2065#endif
2066#if JSON_HEDLEY_HAS_WARNING("-Wunknown-pragmas")
2067# define JSON_HEDLEY_MESSAGE(msg) \
2068 JSON_HEDLEY_DIAGNOSTIC_PUSH \
2069 JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS \
2070 JSON_HEDLEY_PRAGMA(message msg) \
2071 JSON_HEDLEY_DIAGNOSTIC_POP
2072#elif \
2073 JSON_HEDLEY_GCC_VERSION_CHECK(4,4,0) || \
2074 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0)
2075# define JSON_HEDLEY_MESSAGE(msg) JSON_HEDLEY_PRAGMA(message msg)
2076#elif JSON_HEDLEY_CRAY_VERSION_CHECK(5,0,0)
2077# define JSON_HEDLEY_MESSAGE(msg) JSON_HEDLEY_PRAGMA(_CRI message msg)
2078#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
2079# define JSON_HEDLEY_MESSAGE(msg) JSON_HEDLEY_PRAGMA(message(msg))
2080#elif JSON_HEDLEY_PELLES_VERSION_CHECK(2,0,0)
2081# define JSON_HEDLEY_MESSAGE(msg) JSON_HEDLEY_PRAGMA(message(msg))
2082#else
2083# define JSON_HEDLEY_MESSAGE(msg)
2084#endif
2085
2086#if defined(JSON_HEDLEY_WARNING)
2087 #undef JSON_HEDLEY_WARNING
2088#endif
2089#if JSON_HEDLEY_HAS_WARNING("-Wunknown-pragmas")
2090# define JSON_HEDLEY_WARNING(msg) \
2091 JSON_HEDLEY_DIAGNOSTIC_PUSH \
2092 JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS \
2093 JSON_HEDLEY_PRAGMA(clang warning msg) \
2094 JSON_HEDLEY_DIAGNOSTIC_POP
2095#elif \
2096 JSON_HEDLEY_GCC_VERSION_CHECK(4,8,0) || \
2097 JSON_HEDLEY_PGI_VERSION_CHECK(18,4,0) || \
2098 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0)
2099# define JSON_HEDLEY_WARNING(msg) JSON_HEDLEY_PRAGMA(GCC warning msg)
2100#elif \
2101 JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0) || \
2102 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
2103# define JSON_HEDLEY_WARNING(msg) JSON_HEDLEY_PRAGMA(message(msg))
2104#else
2105# define JSON_HEDLEY_WARNING(msg) JSON_HEDLEY_MESSAGE(msg)
2106#endif
2107
2108#if defined(JSON_HEDLEY_REQUIRE)
2109 #undef JSON_HEDLEY_REQUIRE
2110#endif
2111#if defined(JSON_HEDLEY_REQUIRE_MSG)
2112 #undef JSON_HEDLEY_REQUIRE_MSG
2113#endif
2114#if JSON_HEDLEY_HAS_ATTRIBUTE(diagnose_if)
2115# if JSON_HEDLEY_HAS_WARNING("-Wgcc-compat")
2116# define JSON_HEDLEY_REQUIRE(expr) \
2117 JSON_HEDLEY_DIAGNOSTIC_PUSH \
2118 _Pragma("clang diagnostic ignored \"-Wgcc-compat\"") \
2119 __attribute__((diagnose_if(!(expr), #expr, "error"))) \
2120 JSON_HEDLEY_DIAGNOSTIC_POP
2121# define JSON_HEDLEY_REQUIRE_MSG(expr,msg) \
2122 JSON_HEDLEY_DIAGNOSTIC_PUSH \
2123 _Pragma("clang diagnostic ignored \"-Wgcc-compat\"") \
2124 __attribute__((diagnose_if(!(expr), msg, "error"))) \
2125 JSON_HEDLEY_DIAGNOSTIC_POP
2126# else
2127# define JSON_HEDLEY_REQUIRE(expr) __attribute__((diagnose_if(!(expr), #expr, "error")))
2128# define JSON_HEDLEY_REQUIRE_MSG(expr,msg) __attribute__((diagnose_if(!(expr), msg, "error")))
2129# endif
2130#else
2131# define JSON_HEDLEY_REQUIRE(expr)
2132# define JSON_HEDLEY_REQUIRE_MSG(expr,msg)
2133#endif
2134
2135#if defined(JSON_HEDLEY_FLAGS)
2136 #undef JSON_HEDLEY_FLAGS
2137#endif
2138#if JSON_HEDLEY_HAS_ATTRIBUTE(flag_enum) && (!defined(__cplusplus) || JSON_HEDLEY_HAS_WARNING("-Wbitfield-enum-conversion"))
2139 #define JSON_HEDLEY_FLAGS __attribute__((__flag_enum__))
2140#else
2141 #define JSON_HEDLEY_FLAGS
2142#endif
2143
2144#if defined(JSON_HEDLEY_FLAGS_CAST)
2145 #undef JSON_HEDLEY_FLAGS_CAST
2146#endif
2147#if JSON_HEDLEY_INTEL_VERSION_CHECK(19,0,0)
2148# define JSON_HEDLEY_FLAGS_CAST(T, expr) (__extension__ ({ \
2149 JSON_HEDLEY_DIAGNOSTIC_PUSH \
2150 _Pragma("warning(disable:188)") \
2151 ((T) (expr)); \
2152 JSON_HEDLEY_DIAGNOSTIC_POP \
2153 }))
2154#else
2155# define JSON_HEDLEY_FLAGS_CAST(T, expr) JSON_HEDLEY_STATIC_CAST(T, expr)
2156#endif
2157
2158#if defined(JSON_HEDLEY_EMPTY_BASES)
2159 #undef JSON_HEDLEY_EMPTY_BASES
2160#endif
2161#if \
2162 (JSON_HEDLEY_MSVC_VERSION_CHECK(19,0,23918) && !JSON_HEDLEY_MSVC_VERSION_CHECK(20,0,0)) || \
2163 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
2164 #define JSON_HEDLEY_EMPTY_BASES __declspec(empty_bases)
2165#else
2166 #define JSON_HEDLEY_EMPTY_BASES
2167#endif
2168
2169/* Remaining macros are deprecated. */
2170
2171#if defined(JSON_HEDLEY_GCC_NOT_CLANG_VERSION_CHECK)
2172 #undef JSON_HEDLEY_GCC_NOT_CLANG_VERSION_CHECK
2173#endif
2174#if defined(__clang__)
2175 #define JSON_HEDLEY_GCC_NOT_CLANG_VERSION_CHECK(major,minor,patch) (0)
2176#else
2177 #define JSON_HEDLEY_GCC_NOT_CLANG_VERSION_CHECK(major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch)
2178#endif
2179
2180#if defined(JSON_HEDLEY_CLANG_HAS_ATTRIBUTE)
2181 #undef JSON_HEDLEY_CLANG_HAS_ATTRIBUTE
2182#endif
2183#define JSON_HEDLEY_CLANG_HAS_ATTRIBUTE(attribute) JSON_HEDLEY_HAS_ATTRIBUTE(attribute)
2184
2185#if defined(JSON_HEDLEY_CLANG_HAS_CPP_ATTRIBUTE)
2186 #undef JSON_HEDLEY_CLANG_HAS_CPP_ATTRIBUTE
2187#endif
2188#define JSON_HEDLEY_CLANG_HAS_CPP_ATTRIBUTE(attribute) JSON_HEDLEY_HAS_CPP_ATTRIBUTE(attribute)
2189
2190#if defined(JSON_HEDLEY_CLANG_HAS_BUILTIN)
2191 #undef JSON_HEDLEY_CLANG_HAS_BUILTIN
2192#endif
2193#define JSON_HEDLEY_CLANG_HAS_BUILTIN(builtin) JSON_HEDLEY_HAS_BUILTIN(builtin)
2194
2195#if defined(JSON_HEDLEY_CLANG_HAS_FEATURE)
2196 #undef JSON_HEDLEY_CLANG_HAS_FEATURE
2197#endif
2198#define JSON_HEDLEY_CLANG_HAS_FEATURE(feature) JSON_HEDLEY_HAS_FEATURE(feature)
2199
2200#if defined(JSON_HEDLEY_CLANG_HAS_EXTENSION)
2201 #undef JSON_HEDLEY_CLANG_HAS_EXTENSION
2202#endif
2203#define JSON_HEDLEY_CLANG_HAS_EXTENSION(extension) JSON_HEDLEY_HAS_EXTENSION(extension)
2204
2205#if defined(JSON_HEDLEY_CLANG_HAS_DECLSPEC_DECLSPEC_ATTRIBUTE)
2206 #undef JSON_HEDLEY_CLANG_HAS_DECLSPEC_DECLSPEC_ATTRIBUTE
2207#endif
2208#define JSON_HEDLEY_CLANG_HAS_DECLSPEC_ATTRIBUTE(attribute) JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE(attribute)
2209
2210#if defined(JSON_HEDLEY_CLANG_HAS_WARNING)
2211 #undef JSON_HEDLEY_CLANG_HAS_WARNING
2212#endif
2213#define JSON_HEDLEY_CLANG_HAS_WARNING(warning) JSON_HEDLEY_HAS_WARNING(warning)
2214
2215#endif /* !defined(JSON_HEDLEY_VERSION) || (JSON_HEDLEY_VERSION < X) */
2216
2217// #include <nlohmann/detail/meta/detected.hpp>
2218
2219
2220#include <type_traits>
2221
2222// #include <nlohmann/detail/meta/void_t.hpp>
2223
2224
2225namespace nlohmann
2226{
2227namespace detail
2228{
2229template<typename ...Ts> struct make_void
2230{
2231 using type = void;
2232};
2233template<typename ...Ts> using void_t = typename make_void<Ts...>::type;
2234} // namespace detail
2235} // namespace nlohmann
2236
2237
2238// https://en.cppreference.com/w/cpp/experimental/is_detected
2239namespace nlohmann
2240{
2241namespace detail
2242{
2243struct nonesuch
2244{
2245 nonesuch() = delete;
2246 ~nonesuch() = delete;
2247 nonesuch(nonesuch const&) = delete;
2248 nonesuch(nonesuch const&&) = delete;
2249 void operator=(nonesuch const&) = delete;
2250 void operator=(nonesuch&&) = delete;
2251};
2252
2253template<class Default,
2254 class AlwaysVoid,
2255 template<class...> class Op,
2256 class... Args>
2257struct detector
2258{
2259 using value_t = std::false_type;
2260 using type = Default;
2261};
2262
2263template<class Default, template<class...> class Op, class... Args>
2264struct detector<Default, void_t<Op<Args...>>, Op, Args...>
2265{
2266 using value_t = std::true_type;
2267 using type = Op<Args...>;
2268};
2269
2270template<template<class...> class Op, class... Args>
2271using is_detected = typename detector<nonesuch, void, Op, Args...>::value_t;
2272
2273template<template<class...> class Op, class... Args>
2274struct is_detected_lazy : is_detected<Op, Args...> { };
2275
2276template<template<class...> class Op, class... Args>
2277using detected_t = typename detector<nonesuch, void, Op, Args...>::type;
2278
2279template<class Default, template<class...> class Op, class... Args>
2280using detected_or = detector<Default, void, Op, Args...>;
2281
2282template<class Default, template<class...> class Op, class... Args>
2283using detected_or_t = typename detected_or<Default, Op, Args...>::type;
2284
2285template<class Expected, template<class...> class Op, class... Args>
2286using is_detected_exact = std::is_same<Expected, detected_t<Op, Args...>>;
2287
2288template<class To, template<class...> class Op, class... Args>
2289using is_detected_convertible =
2290 std::is_convertible<detected_t<Op, Args...>, To>;
2291} // namespace detail
2292} // namespace nlohmann
2293
2294
2295// This file contains all internal macro definitions
2296// You MUST include macro_unscope.hpp at the end of json.hpp to undef all of them
2297
2298// exclude unsupported compilers
2299#if !defined(JSON_SKIP_UNSUPPORTED_COMPILER_CHECK)
2300 #if defined(__clang__)
2301 #if (__clang_major__ * 10000 + __clang_minor__ * 100 + __clang_patchlevel__) < 30400
2302 #error "unsupported Clang version - see https://github.com/nlohmann/json#supported-compilers"
2303 #endif
2304 #elif defined(__GNUC__) && !(defined(__ICC) || defined(__INTEL_COMPILER))
2305 #if (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) < 40800
2306 #error "unsupported GCC version - see https://github.com/nlohmann/json#supported-compilers"
2307 #endif
2308 #endif
2309#endif
2310
2311// C++ language standard detection
2312// if the user manually specified the used c++ version this is skipped
2313#if !defined(JSON_HAS_CPP_20) && !defined(JSON_HAS_CPP_17) && !defined(JSON_HAS_CPP_14) && !defined(JSON_HAS_CPP_11)
2314 #if (defined(__cplusplus) && __cplusplus >= 202002L) || (defined(_MSVC_LANG) && _MSVC_LANG >= 202002L)
2315 #define JSON_HAS_CPP_20
2316 #define JSON_HAS_CPP_17
2317 #define JSON_HAS_CPP_14
2318 #elif (defined(__cplusplus) && __cplusplus >= 201703L) || (defined(_HAS_CXX17) && _HAS_CXX17 == 1) // fix for issue #464
2319 #define JSON_HAS_CPP_17
2320 #define JSON_HAS_CPP_14
2321 #elif (defined(__cplusplus) && __cplusplus >= 201402L) || (defined(_HAS_CXX14) && _HAS_CXX14 == 1)
2322 #define JSON_HAS_CPP_14
2323 #endif
2324 // the cpp 11 flag is always specified because it is the minimal required version
2325 #define JSON_HAS_CPP_11
2326#endif
2327
2328// disable documentation warnings on clang
2329#if defined(__clang__)
2330 #pragma clang diagnostic push
2331 #pragma clang diagnostic ignored "-Wdocumentation"
2332 #pragma clang diagnostic ignored "-Wdocumentation-unknown-command"
2333#endif
2334
2335// allow to disable exceptions
2336#if (defined(__cpp_exceptions) || defined(__EXCEPTIONS) || defined(_CPPUNWIND)) && !defined(JSON_NOEXCEPTION)
2337 #define JSON_THROW(exception) throw exception
2338 #define JSON_TRY try
2339 #define JSON_CATCH(exception) catch(exception)
2340 #define JSON_INTERNAL_CATCH(exception) catch(exception)
2341#else
2342 #include <cstdlib>
2343 #define JSON_THROW(exception) std::abort()
2344 #define JSON_TRY if(true)
2345 #define JSON_CATCH(exception) if(false)
2346 #define JSON_INTERNAL_CATCH(exception) if(false)
2347#endif
2348
2349// override exception macros
2350#if defined(JSON_THROW_USER)
2351 #undef JSON_THROW
2352 #define JSON_THROW JSON_THROW_USER
2353#endif
2354#if defined(JSON_TRY_USER)
2355 #undef JSON_TRY
2356 #define JSON_TRY JSON_TRY_USER
2357#endif
2358#if defined(JSON_CATCH_USER)
2359 #undef JSON_CATCH
2360 #define JSON_CATCH JSON_CATCH_USER
2361 #undef JSON_INTERNAL_CATCH
2362 #define JSON_INTERNAL_CATCH JSON_CATCH_USER
2363#endif
2364#if defined(JSON_INTERNAL_CATCH_USER)
2365 #undef JSON_INTERNAL_CATCH
2366 #define JSON_INTERNAL_CATCH JSON_INTERNAL_CATCH_USER
2367#endif
2368
2369// allow to override assert
2370#if !defined(JSON_ASSERT)
2371 #include <cassert> // assert
2372 #define JSON_ASSERT(x) assert(x)
2373#endif
2374
2375// allow to access some private functions (needed by the test suite)
2376#if defined(JSON_TESTS_PRIVATE)
2377 #define JSON_PRIVATE_UNLESS_TESTED public
2378#else
2379 #define JSON_PRIVATE_UNLESS_TESTED private
2380#endif
2381
2387#define NLOHMANN_JSON_SERIALIZE_ENUM(ENUM_TYPE, ...) \
2388 template<typename BasicJsonType> \
2389 inline void to_json(BasicJsonType& j, const ENUM_TYPE& e) \
2390 { \
2391 static_assert(std::is_enum<ENUM_TYPE>::value, #ENUM_TYPE " must be an enum!"); \
2392 static const std::pair<ENUM_TYPE, BasicJsonType> m[] = __VA_ARGS__; \
2393 auto it = std::find_if(std::begin(m), std::end(m), \
2394 [e](const std::pair<ENUM_TYPE, BasicJsonType>& ej_pair) -> bool \
2395 { \
2396 return ej_pair.first == e; \
2397 }); \
2398 j = ((it != std::end(m)) ? it : std::begin(m))->second; \
2399 } \
2400 template<typename BasicJsonType> \
2401 inline void from_json(const BasicJsonType& j, ENUM_TYPE& e) \
2402 { \
2403 static_assert(std::is_enum<ENUM_TYPE>::value, #ENUM_TYPE " must be an enum!"); \
2404 static const std::pair<ENUM_TYPE, BasicJsonType> m[] = __VA_ARGS__; \
2405 auto it = std::find_if(std::begin(m), std::end(m), \
2406 [&j](const std::pair<ENUM_TYPE, BasicJsonType>& ej_pair) -> bool \
2407 { \
2408 return ej_pair.second == j; \
2409 }); \
2410 e = ((it != std::end(m)) ? it : std::begin(m))->first; \
2411 }
2412
2413// Ugly macros to avoid uglier copy-paste when specializing basic_json. They
2414// may be removed in the future once the class is split.
2415
2416#define NLOHMANN_BASIC_JSON_TPL_DECLARATION \
2417 template<template<typename, typename, typename...> class ObjectType, \
2418 template<typename, typename...> class ArrayType, \
2419 class StringType, class BooleanType, class NumberIntegerType, \
2420 class NumberUnsignedType, class NumberFloatType, \
2421 template<typename> class AllocatorType, \
2422 template<typename, typename = void> class JSONSerializer, \
2423 class BinaryType>
2424
2425#define NLOHMANN_BASIC_JSON_TPL \
2426 basic_json<ObjectType, ArrayType, StringType, BooleanType, \
2427 NumberIntegerType, NumberUnsignedType, NumberFloatType, \
2428 AllocatorType, JSONSerializer, BinaryType>
2429
2430// Macros to simplify conversion from/to types
2431
2432#define NLOHMANN_JSON_EXPAND( x ) x
2433#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
2434#define NLOHMANN_JSON_PASTE(...) NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_GET_MACRO(__VA_ARGS__, \
2435 NLOHMANN_JSON_PASTE64, \
2436 NLOHMANN_JSON_PASTE63, \
2437 NLOHMANN_JSON_PASTE62, \
2438 NLOHMANN_JSON_PASTE61, \
2439 NLOHMANN_JSON_PASTE60, \
2440 NLOHMANN_JSON_PASTE59, \
2441 NLOHMANN_JSON_PASTE58, \
2442 NLOHMANN_JSON_PASTE57, \
2443 NLOHMANN_JSON_PASTE56, \
2444 NLOHMANN_JSON_PASTE55, \
2445 NLOHMANN_JSON_PASTE54, \
2446 NLOHMANN_JSON_PASTE53, \
2447 NLOHMANN_JSON_PASTE52, \
2448 NLOHMANN_JSON_PASTE51, \
2449 NLOHMANN_JSON_PASTE50, \
2450 NLOHMANN_JSON_PASTE49, \
2451 NLOHMANN_JSON_PASTE48, \
2452 NLOHMANN_JSON_PASTE47, \
2453 NLOHMANN_JSON_PASTE46, \
2454 NLOHMANN_JSON_PASTE45, \
2455 NLOHMANN_JSON_PASTE44, \
2456 NLOHMANN_JSON_PASTE43, \
2457 NLOHMANN_JSON_PASTE42, \
2458 NLOHMANN_JSON_PASTE41, \
2459 NLOHMANN_JSON_PASTE40, \
2460 NLOHMANN_JSON_PASTE39, \
2461 NLOHMANN_JSON_PASTE38, \
2462 NLOHMANN_JSON_PASTE37, \
2463 NLOHMANN_JSON_PASTE36, \
2464 NLOHMANN_JSON_PASTE35, \
2465 NLOHMANN_JSON_PASTE34, \
2466 NLOHMANN_JSON_PASTE33, \
2467 NLOHMANN_JSON_PASTE32, \
2468 NLOHMANN_JSON_PASTE31, \
2469 NLOHMANN_JSON_PASTE30, \
2470 NLOHMANN_JSON_PASTE29, \
2471 NLOHMANN_JSON_PASTE28, \
2472 NLOHMANN_JSON_PASTE27, \
2473 NLOHMANN_JSON_PASTE26, \
2474 NLOHMANN_JSON_PASTE25, \
2475 NLOHMANN_JSON_PASTE24, \
2476 NLOHMANN_JSON_PASTE23, \
2477 NLOHMANN_JSON_PASTE22, \
2478 NLOHMANN_JSON_PASTE21, \
2479 NLOHMANN_JSON_PASTE20, \
2480 NLOHMANN_JSON_PASTE19, \
2481 NLOHMANN_JSON_PASTE18, \
2482 NLOHMANN_JSON_PASTE17, \
2483 NLOHMANN_JSON_PASTE16, \
2484 NLOHMANN_JSON_PASTE15, \
2485 NLOHMANN_JSON_PASTE14, \
2486 NLOHMANN_JSON_PASTE13, \
2487 NLOHMANN_JSON_PASTE12, \
2488 NLOHMANN_JSON_PASTE11, \
2489 NLOHMANN_JSON_PASTE10, \
2490 NLOHMANN_JSON_PASTE9, \
2491 NLOHMANN_JSON_PASTE8, \
2492 NLOHMANN_JSON_PASTE7, \
2493 NLOHMANN_JSON_PASTE6, \
2494 NLOHMANN_JSON_PASTE5, \
2495 NLOHMANN_JSON_PASTE4, \
2496 NLOHMANN_JSON_PASTE3, \
2497 NLOHMANN_JSON_PASTE2, \
2498 NLOHMANN_JSON_PASTE1)(__VA_ARGS__))
2499#define NLOHMANN_JSON_PASTE2(func, v1) func(v1)
2500#define NLOHMANN_JSON_PASTE3(func, v1, v2) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE2(func, v2)
2501#define NLOHMANN_JSON_PASTE4(func, v1, v2, v3) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE3(func, v2, v3)
2502#define NLOHMANN_JSON_PASTE5(func, v1, v2, v3, v4) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE4(func, v2, v3, v4)
2503#define NLOHMANN_JSON_PASTE6(func, v1, v2, v3, v4, v5) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE5(func, v2, v3, v4, v5)
2504#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)
2505#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)
2506#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)
2507#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)
2508#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)
2509#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)
2510#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)
2511#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)
2512#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)
2513#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)
2514#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)
2515#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)
2516#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)
2517#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)
2518#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)
2519#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)
2520#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)
2521#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)
2522#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)
2523#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)
2524#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)
2525#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)
2526#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)
2527#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)
2528#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)
2529#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)
2530#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)
2531#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)
2532#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)
2533#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)
2534#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)
2535#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)
2536#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)
2537#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)
2538#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)
2539#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)
2540#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)
2541#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)
2542#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)
2543#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)
2544#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)
2545#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)
2546#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)
2547#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)
2548#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)
2549#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)
2550#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)
2551#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)
2552#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)
2553#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)
2554#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)
2555#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)
2556#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)
2557#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)
2558#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)
2559#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)
2560#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)
2561#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)
2562
2563#define NLOHMANN_JSON_TO(v1) nlohmann_json_j[#v1] = nlohmann_json_t.v1;
2564#define NLOHMANN_JSON_FROM(v1) nlohmann_json_j.at(#v1).get_to(nlohmann_json_t.v1);
2565
2571#define NLOHMANN_DEFINE_TYPE_INTRUSIVE(Type, ...) \
2572 friend void to_json(nlohmann::json& nlohmann_json_j, const Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) } \
2573 friend void from_json(const nlohmann::json& nlohmann_json_j, Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM, __VA_ARGS__)) }
2574
2580#define NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(Type, ...) \
2581 inline void to_json(nlohmann::json& nlohmann_json_j, const Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) } \
2582 inline void from_json(const nlohmann::json& nlohmann_json_j, Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM, __VA_ARGS__)) }
2583
2584
2585// inspired from https://stackoverflow.com/a/26745591
2586// allows to call any std function as if (e.g. with begin):
2587// using std::begin; begin(x);
2588//
2589// it allows using the detected idiom to retrieve the return type
2590// of such an expression
2591#define NLOHMANN_CAN_CALL_STD_FUNC_IMPL(std_name) \
2592 namespace detail { \
2593 using std::std_name; \
2594 \
2595 template<typename... T> \
2596 using result_of_##std_name = decltype(std_name(std::declval<T>()...)); \
2597 } \
2598 \
2599 namespace detail2 { \
2600 struct std_name##_tag \
2601 { \
2602 }; \
2603 \
2604 template<typename... T> \
2605 std_name##_tag std_name(T&&...); \
2606 \
2607 template<typename... T> \
2608 using result_of_##std_name = decltype(std_name(std::declval<T>()...)); \
2609 \
2610 template<typename... T> \
2611 struct would_call_std_##std_name \
2612 { \
2613 static constexpr auto const value = ::nlohmann::detail:: \
2614 is_detected_exact<std_name##_tag, result_of_##std_name, T...>::value; \
2615 }; \
2616 } /* namespace detail2 */ \
2617 \
2618 template<typename... T> \
2619 struct would_call_std_##std_name : detail2::would_call_std_##std_name<T...> \
2620 { \
2621 }
2622
2623#ifndef JSON_USE_IMPLICIT_CONVERSIONS
2624 #define JSON_USE_IMPLICIT_CONVERSIONS 1
2625#endif
2626
2627#if JSON_USE_IMPLICIT_CONVERSIONS
2628 #define JSON_EXPLICIT
2629#else
2630 #define JSON_EXPLICIT explicit
2631#endif
2632
2633#ifndef JSON_DIAGNOSTICS
2634 #define JSON_DIAGNOSTICS 0
2635#endif
2636
2637
2638namespace nlohmann
2639{
2640namespace detail
2641{
2642
2656inline void replace_substring(std::string& s, const std::string& f,
2657 const std::string& t)
2658{
2659 JSON_ASSERT(!f.empty());
2660 for (auto pos = s.find(f); // find first occurrence of f
2661 pos != std::string::npos; // make sure f was found
2662 s.replace(pos, f.size(), t), // replace with t, and
2663 pos = s.find(f, pos + t.size())) // find next occurrence of f
2664 {}
2665}
2666
2674inline std::string escape(std::string s)
2675{
2676 replace_substring(s, "~", "~0");
2677 replace_substring(s, "/", "~1");
2678 return s;
2679}
2680
2688static void unescape(std::string& s)
2689{
2690 replace_substring(s, "~1", "/");
2691 replace_substring(s, "~0", "~");
2692}
2693
2694} // namespace detail
2695} // namespace nlohmann
2696
2697// #include <nlohmann/detail/input/position_t.hpp>
2698
2699
2700#include <cstddef> // size_t
2701
2702namespace nlohmann
2703{
2704namespace detail
2705{
2707struct position_t
2708{
2710 std::size_t chars_read_total = 0;
2712 std::size_t chars_read_current_line = 0;
2714 std::size_t lines_read = 0;
2715
2717 constexpr operator size_t() const
2718 {
2719 return chars_read_total;
2720 }
2721};
2722
2723} // namespace detail
2724} // namespace nlohmann
2725
2726// #include <nlohmann/detail/macro_scope.hpp>
2727
2728
2729namespace nlohmann
2730{
2731namespace detail
2732{
2734// exceptions //
2736
2765class exception : public std::exception
2766{
2767 public:
2769 const char* what() const noexcept override
2770 {
2771 return m.what();
2772 }
2773
2775 const int id; // NOLINT(cppcoreguidelines-non-private-member-variables-in-classes)
2776
2777 protected:
2778 JSON_HEDLEY_NON_NULL(3)
2779 exception(int id_, const char* what_arg) : id(id_), m(what_arg) {}
2780
2781 static std::string name(const std::string& ename, int id_)
2782 {
2783 return "[json.exception." + ename + "." + std::to_string(id_) + "] ";
2784 }
2785
2786 template<typename BasicJsonType>
2787 static std::string diagnostics(const BasicJsonType& leaf_element)
2788 {
2789#if JSON_DIAGNOSTICS
2790 std::vector<std::string> tokens;
2791 for (const auto* current = &leaf_element; current->m_parent != nullptr; current = current->m_parent)
2792 {
2793 switch (current->m_parent->type())
2794 {
2795 case value_t::array:
2796 {
2797 for (std::size_t i = 0; i < current->m_parent->m_value.array->size(); ++i)
2798 {
2799 if (&current->m_parent->m_value.array->operator[](i) == current)
2800 {
2801 tokens.emplace_back(std::to_string(i));
2802 break;
2803 }
2804 }
2805 break;
2806 }
2807
2808 case value_t::object:
2809 {
2810 for (const auto& element : *current->m_parent->m_value.object)
2811 {
2812 if (&element.second == current)
2813 {
2814 tokens.emplace_back(element.first.c_str());
2815 break;
2816 }
2817 }
2818 break;
2819 }
2820
2821 case value_t::null: // LCOV_EXCL_LINE
2822 case value_t::string: // LCOV_EXCL_LINE
2823 case value_t::boolean: // LCOV_EXCL_LINE
2824 case value_t::number_integer: // LCOV_EXCL_LINE
2825 case value_t::number_unsigned: // LCOV_EXCL_LINE
2826 case value_t::number_float: // LCOV_EXCL_LINE
2827 case value_t::binary: // LCOV_EXCL_LINE
2828 case value_t::discarded: // LCOV_EXCL_LINE
2829 default: // LCOV_EXCL_LINE
2830 break; // LCOV_EXCL_LINE
2831 }
2832 }
2833
2834 if (tokens.empty())
2835 {
2836 return "";
2837 }
2838
2839 return "(" + std::accumulate(tokens.rbegin(), tokens.rend(), std::string{},
2840 [](const std::string & a, const std::string & b)
2841 {
2842 return a + "/" + detail::escape(b);
2843 }) + ") ";
2844#else
2845 static_cast<void>(leaf_element);
2846 return "";
2847#endif
2848 }
2849
2850 private:
2852 std::runtime_error m;
2853};
2854
2900class parse_error : public exception
2901{
2902 public:
2912 template<typename BasicJsonType>
2913 static parse_error create(int id_, const position_t& pos, const std::string& what_arg, const BasicJsonType& context)
2914 {
2915 std::string w = exception::name("parse_error", id_) + "parse error" +
2916 position_string(pos) + ": " + exception::diagnostics(context) + what_arg;
2917 return parse_error(id_, pos.chars_read_total, w.c_str());
2918 }
2919
2920 template<typename BasicJsonType>
2921 static parse_error create(int id_, std::size_t byte_, const std::string& what_arg, const BasicJsonType& context)
2922 {
2923 std::string w = exception::name("parse_error", id_) + "parse error" +
2924 (byte_ != 0 ? (" at byte " + std::to_string(byte_)) : "") +
2925 ": " + exception::diagnostics(context) + what_arg;
2926 return parse_error(id_, byte_, w.c_str());
2927 }
2928
2938 const std::size_t byte;
2939
2940 private:
2941 parse_error(int id_, std::size_t byte_, const char* what_arg)
2942 : exception(id_, what_arg), byte(byte_) {}
2943
2944 static std::string position_string(const position_t& pos)
2945 {
2946 return " at line " + std::to_string(pos.lines_read + 1) +
2947 ", column " + std::to_string(pos.chars_read_current_line);
2948 }
2949};
2950
2988class invalid_iterator : public exception
2989{
2990 public:
2991 template<typename BasicJsonType>
2992 static invalid_iterator create(int id_, const std::string& what_arg, const BasicJsonType& context)
2993 {
2994 std::string w = exception::name("invalid_iterator", id_) + exception::diagnostics(context) + what_arg;
2995 return invalid_iterator(id_, w.c_str());
2996 }
2997
2998 private:
2999 JSON_HEDLEY_NON_NULL(3)
3000 invalid_iterator(int id_, const char* what_arg)
3001 : exception(id_, what_arg) {}
3002};
3003
3043class type_error : public exception
3044{
3045 public:
3046 template<typename BasicJsonType>
3047 static type_error create(int id_, const std::string& what_arg, const BasicJsonType& context)
3048 {
3049 std::string w = exception::name("type_error", id_) + exception::diagnostics(context) + what_arg;
3050 return type_error(id_, w.c_str());
3051 }
3052
3053 private:
3054 JSON_HEDLEY_NON_NULL(3)
3055 type_error(int id_, const char* what_arg) : exception(id_, what_arg) {}
3056};
3057
3091class out_of_range : public exception
3092{
3093 public:
3094 template<typename BasicJsonType>
3095 static out_of_range create(int id_, const std::string& what_arg, const BasicJsonType& context)
3096 {
3097 std::string w = exception::name("out_of_range", id_) + exception::diagnostics(context) + what_arg;
3098 return out_of_range(id_, w.c_str());
3099 }
3100
3101 private:
3102 JSON_HEDLEY_NON_NULL(3)
3103 out_of_range(int id_, const char* what_arg) : exception(id_, what_arg) {}
3104};
3105
3130class other_error : public exception
3131{
3132 public:
3133 template<typename BasicJsonType>
3134 static other_error create(int id_, const std::string& what_arg, const BasicJsonType& context)
3135 {
3136 std::string w = exception::name("other_error", id_) + exception::diagnostics(context) + what_arg;
3137 return other_error(id_, w.c_str());
3138 }
3139
3140 private:
3141 JSON_HEDLEY_NON_NULL(3)
3142 other_error(int id_, const char* what_arg) : exception(id_, what_arg) {}
3143};
3144} // namespace detail
3145} // namespace nlohmann
3146
3147// #include <nlohmann/detail/macro_scope.hpp>
3148
3149// #include <nlohmann/detail/meta/cpp_future.hpp>
3150
3151
3152#include <cstddef> // size_t
3153#include <type_traits> // conditional, enable_if, false_type, integral_constant, is_constructible, is_integral, is_same, remove_cv, remove_reference, true_type
3154#include <utility> // index_sequence, make_index_sequence, index_sequence_for
3155
3156// #include <nlohmann/detail/macro_scope.hpp>
3157
3158
3159namespace nlohmann
3160{
3161namespace detail
3162{
3163
3164template<typename T>
3165using uncvref_t = typename std::remove_cv<typename std::remove_reference<T>::type>::type;
3166
3167#ifdef JSON_HAS_CPP_14
3168
3169// the following utilities are natively available in C++14
3170using std::enable_if_t;
3171using std::index_sequence;
3172using std::make_index_sequence;
3173using std::index_sequence_for;
3174
3175#else
3176
3177// alias templates to reduce boilerplate
3178template<bool B, typename T = void>
3179using enable_if_t = typename std::enable_if<B, T>::type;
3180
3181// The following code is taken from https://github.com/abseil/abseil-cpp/blob/10cb35e459f5ecca5b2ff107635da0bfa41011b4/absl/utility/utility.h
3182// which is part of Google Abseil (https://github.com/abseil/abseil-cpp), licensed under the Apache License 2.0.
3183
3185
3186// integer_sequence
3187//
3188// Class template representing a compile-time integer sequence. An instantiation
3189// of `integer_sequence<T, Ints...>` has a sequence of integers encoded in its
3190// type through its template arguments (which is a common need when
3191// working with C++11 variadic templates). `absl::integer_sequence` is designed
3192// to be a drop-in replacement for C++14's `std::integer_sequence`.
3193//
3194// Example:
3195//
3196// template< class T, T... Ints >
3197// void user_function(integer_sequence<T, Ints...>);
3198//
3199// int main()
3200// {
3201// // user_function's `T` will be deduced to `int` and `Ints...`
3202// // will be deduced to `0, 1, 2, 3, 4`.
3203// user_function(make_integer_sequence<int, 5>());
3204// }
3205template <typename T, T... Ints>
3206struct integer_sequence
3207{
3208 using value_type = T;
3209 static constexpr std::size_t size() noexcept
3210 {
3211 return sizeof...(Ints);
3212 }
3213};
3214
3215// index_sequence
3216//
3217// A helper template for an `integer_sequence` of `size_t`,
3218// `absl::index_sequence` is designed to be a drop-in replacement for C++14's
3219// `std::index_sequence`.
3220template <size_t... Ints>
3221using index_sequence = integer_sequence<size_t, Ints...>;
3222
3223namespace utility_internal
3224{
3225
3226template <typename Seq, size_t SeqSize, size_t Rem>
3227struct Extend;
3228
3229// Note that SeqSize == sizeof...(Ints). It's passed explicitly for efficiency.
3230template <typename T, T... Ints, size_t SeqSize>
3231struct Extend<integer_sequence<T, Ints...>, SeqSize, 0>
3232{
3233 using type = integer_sequence < T, Ints..., (Ints + SeqSize)... >;
3234};
3235
3236template <typename T, T... Ints, size_t SeqSize>
3237struct Extend<integer_sequence<T, Ints...>, SeqSize, 1>
3238{
3239 using type = integer_sequence < T, Ints..., (Ints + SeqSize)..., 2 * SeqSize >;
3240};
3241
3242// Recursion helper for 'make_integer_sequence<T, N>'.
3243// 'Gen<T, N>::type' is an alias for 'integer_sequence<T, 0, 1, ... N-1>'.
3244template <typename T, size_t N>
3245struct Gen
3246{
3247 using type =
3248 typename Extend < typename Gen < T, N / 2 >::type, N / 2, N % 2 >::type;
3249};
3250
3251template <typename T>
3252struct Gen<T, 0>
3253{
3254 using type = integer_sequence<T>;
3255};
3256
3257} // namespace utility_internal
3258
3259// Compile-time sequences of integers
3260
3261// make_integer_sequence
3262//
3263// This template alias is equivalent to
3264// `integer_sequence<int, 0, 1, ..., N-1>`, and is designed to be a drop-in
3265// replacement for C++14's `std::make_integer_sequence`.
3266template <typename T, T N>
3267using make_integer_sequence = typename utility_internal::Gen<T, N>::type;
3268
3269// make_index_sequence
3270//
3271// This template alias is equivalent to `index_sequence<0, 1, ..., N-1>`,
3272// and is designed to be a drop-in replacement for C++14's
3273// `std::make_index_sequence`.
3274template <size_t N>
3275using make_index_sequence = make_integer_sequence<size_t, N>;
3276
3277// index_sequence_for
3278//
3279// Converts a typename pack into an index sequence of the same length, and
3280// is designed to be a drop-in replacement for C++14's
3281// `std::index_sequence_for()`
3282template <typename... Ts>
3283using index_sequence_for = make_index_sequence<sizeof...(Ts)>;
3284
3286
3287#endif
3288
3289// dispatch utility (taken from ranges-v3)
3290template<unsigned N> struct priority_tag : priority_tag < N - 1 > {};
3291template<> struct priority_tag<0> {};
3292
3293// taken from ranges-v3
3294template<typename T>
3295struct static_const
3296{
3297 static constexpr T value{};
3298};
3299
3300template<typename T>
3301constexpr T static_const<T>::value;
3302
3303} // namespace detail
3304} // namespace nlohmann
3305
3306// #include <nlohmann/detail/meta/identity_tag.hpp>
3307
3308
3309namespace nlohmann
3310{
3311namespace detail
3312{
3313// dispatching helper struct
3314template <class T> struct identity_tag {};
3315} // namespace detail
3316} // namespace nlohmann
3317
3318// #include <nlohmann/detail/meta/type_traits.hpp>
3319
3320
3321#include <limits> // numeric_limits
3322#include <type_traits> // false_type, is_constructible, is_integral, is_same, true_type
3323#include <utility> // declval
3324#include <tuple> // tuple
3325
3326// #include <nlohmann/detail/macro_scope.hpp>
3327
3328
3329// #include <nlohmann/detail/iterators/iterator_traits.hpp>
3330
3331
3332#include <iterator> // random_access_iterator_tag
3333
3334// #include <nlohmann/detail/meta/void_t.hpp>
3335
3336// #include <nlohmann/detail/meta/cpp_future.hpp>
3337
3338
3339namespace nlohmann
3340{
3341namespace detail
3342{
3343template<typename It, typename = void>
3344struct iterator_types {};
3345
3346template<typename It>
3347struct iterator_types <
3348 It,
3349 void_t<typename It::difference_type, typename It::value_type, typename It::pointer,
3350 typename It::reference, typename It::iterator_category >>
3351{
3352 using difference_type = typename It::difference_type;
3353 using value_type = typename It::value_type;
3354 using pointer = typename It::pointer;
3355 using reference = typename It::reference;
3356 using iterator_category = typename It::iterator_category;
3357};
3358
3359// This is required as some compilers implement std::iterator_traits in a way that
3360// doesn't work with SFINAE. See https://github.com/nlohmann/json/issues/1341.
3361template<typename T, typename = void>
3362struct iterator_traits
3363{
3364};
3365
3366template<typename T>
3367struct iterator_traits < T, enable_if_t < !std::is_pointer<T>::value >>
3368 : iterator_types<T>
3369{
3370};
3371
3372template<typename T>
3373struct iterator_traits<T*, enable_if_t<std::is_object<T>::value>>
3374{
3375 using iterator_category = std::random_access_iterator_tag;
3376 using value_type = T;
3377 using difference_type = ptrdiff_t;
3378 using pointer = T*;
3379 using reference = T&;
3380};
3381} // namespace detail
3382} // namespace nlohmann
3383
3384// #include <nlohmann/detail/meta/call_std/begin.hpp>
3385
3386
3387// #include <nlohmann/detail/macro_scope.hpp>
3388
3389
3390namespace nlohmann
3391{
3393} // namespace nlohmann
3394
3395// #include <nlohmann/detail/meta/call_std/end.hpp>
3396
3397
3398// #include <nlohmann/detail/macro_scope.hpp>
3399
3400
3401namespace nlohmann
3402{
3404} // namespace nlohmann
3405
3406// #include <nlohmann/detail/meta/cpp_future.hpp>
3407
3408// #include <nlohmann/detail/meta/detected.hpp>
3409
3410// #include <nlohmann/json_fwd.hpp>
3411#ifndef INCLUDE_NLOHMANN_JSON_FWD_HPP_
3412#define INCLUDE_NLOHMANN_JSON_FWD_HPP_
3413
3414#include <cstdint> // int64_t, uint64_t
3415#include <map> // map
3416#include <memory> // allocator
3417#include <string> // string
3418#include <vector> // vector
3419
3425namespace nlohmann
3426{
3434template<typename T = void, typename SFINAE = void>
3435struct adl_serializer;
3436
3437template<template<typename U, typename V, typename... Args> class ObjectType =
3438 std::map,
3439 template<typename U, typename... Args> class ArrayType = std::vector,
3440 class StringType = std::string, class BooleanType = bool,
3441 class NumberIntegerType = std::int64_t,
3442 class NumberUnsignedType = std::uint64_t,
3443 class NumberFloatType = double,
3444 template<typename U> class AllocatorType = std::allocator,
3445 template<typename T, typename SFINAE = void> class JSONSerializer =
3446 adl_serializer,
3447 class BinaryType = std::vector<std::uint8_t>>
3448class basic_json;
3449
3461template<typename BasicJsonType>
3462class json_pointer;
3463
3473
3474template<class Key, class T, class IgnoredLess, class Allocator>
3475struct ordered_map;
3476
3485
3486} // namespace nlohmann
3487
3488#endif // INCLUDE_NLOHMANN_JSON_FWD_HPP_
3489
3490
3491namespace nlohmann
3492{
3501namespace detail
3502{
3504// helpers //
3506
3507// Note to maintainers:
3508//
3509// Every trait in this file expects a non CV-qualified type.
3510// The only exceptions are in the 'aliases for detected' section
3511// (i.e. those of the form: decltype(T::member_function(std::declval<T>())))
3512//
3513// In this case, T has to be properly CV-qualified to constraint the function arguments
3514// (e.g. to_json(BasicJsonType&, const T&))
3515
3516template<typename> struct is_basic_json : std::false_type {};
3517
3518NLOHMANN_BASIC_JSON_TPL_DECLARATION
3519struct is_basic_json<NLOHMANN_BASIC_JSON_TPL> : std::true_type {};
3520
3522// json_ref helpers //
3524
3525template<typename>
3526class json_ref;
3527
3528template<typename>
3529struct is_json_ref : std::false_type {};
3530
3531template<typename T>
3532struct is_json_ref<json_ref<T>> : std::true_type {};
3533
3535// aliases for detected //
3537
3538template<typename T>
3539using mapped_type_t = typename T::mapped_type;
3540
3541template<typename T>
3542using key_type_t = typename T::key_type;
3543
3544template<typename T>
3545using value_type_t = typename T::value_type;
3546
3547template<typename T>
3548using difference_type_t = typename T::difference_type;
3549
3550template<typename T>
3551using pointer_t = typename T::pointer;
3552
3553template<typename T>
3554using reference_t = typename T::reference;
3555
3556template<typename T>
3557using iterator_category_t = typename T::iterator_category;
3558
3559template<typename T, typename... Args>
3560using to_json_function = decltype(T::to_json(std::declval<Args>()...));
3561
3562template<typename T, typename... Args>
3563using from_json_function = decltype(T::from_json(std::declval<Args>()...));
3564
3565template<typename T, typename U>
3566using get_template_function = decltype(std::declval<T>().template get<U>());
3567
3568// trait checking if JSONSerializer<T>::from_json(json const&, udt&) exists
3569template<typename BasicJsonType, typename T, typename = void>
3570struct has_from_json : std::false_type {};
3571
3572// trait checking if j.get<T> is valid
3573// use this trait instead of std::is_constructible or std::is_convertible,
3574// both rely on, or make use of implicit conversions, and thus fail when T
3575// has several constructors/operator= (see https://github.com/nlohmann/json/issues/958)
3576template <typename BasicJsonType, typename T>
3577struct is_getable
3578{
3579 static constexpr bool value = is_detected<get_template_function, const BasicJsonType&, T>::value;
3580};
3581
3582template<typename BasicJsonType, typename T>
3583struct has_from_json < BasicJsonType, T, enable_if_t < !is_basic_json<T>::value >>
3584{
3585 using serializer = typename BasicJsonType::template json_serializer<T, void>;
3586
3587 static constexpr bool value =
3588 is_detected_exact<void, from_json_function, serializer,
3589 const BasicJsonType&, T&>::value;
3590};
3591
3592// This trait checks if JSONSerializer<T>::from_json(json const&) exists
3593// this overload is used for non-default-constructible user-defined-types
3594template<typename BasicJsonType, typename T, typename = void>
3595struct has_non_default_from_json : std::false_type {};
3596
3597template<typename BasicJsonType, typename T>
3598struct has_non_default_from_json < BasicJsonType, T, enable_if_t < !is_basic_json<T>::value >>
3599{
3600 using serializer = typename BasicJsonType::template json_serializer<T, void>;
3601
3602 static constexpr bool value =
3603 is_detected_exact<T, from_json_function, serializer,
3604 const BasicJsonType&>::value;
3605};
3606
3607// This trait checks if BasicJsonType::json_serializer<T>::to_json exists
3608// Do not evaluate the trait when T is a basic_json type, to avoid template instantiation infinite recursion.
3609template<typename BasicJsonType, typename T, typename = void>
3610struct has_to_json : std::false_type {};
3611
3612template<typename BasicJsonType, typename T>
3613struct has_to_json < BasicJsonType, T, enable_if_t < !is_basic_json<T>::value >>
3614{
3615 using serializer = typename BasicJsonType::template json_serializer<T, void>;
3616
3617 static constexpr bool value =
3618 is_detected_exact<void, to_json_function, serializer, BasicJsonType&,
3619 T>::value;
3620};
3621
3622
3624// is_ functions //
3626
3627// https://en.cppreference.com/w/cpp/types/conjunction
3628template<class...> struct conjunction : std::true_type { };
3629template<class B1> struct conjunction<B1> : B1 { };
3630template<class B1, class... Bn>
3631struct conjunction<B1, Bn...>
3632: std::conditional<bool(B1::value), conjunction<Bn...>, B1>::type {};
3633
3634// https://en.cppreference.com/w/cpp/types/negation
3635template<class B> struct negation : std::integral_constant < bool, !B::value > { };
3636
3637// Reimplementation of is_constructible and is_default_constructible, due to them being broken for
3638// std::pair and std::tuple until LWG 2367 fix (see https://cplusplus.github.io/LWG/lwg-defects.html#2367).
3639// This causes compile errors in e.g. clang 3.5 or gcc 4.9.
3640template <typename T>
3641struct is_default_constructible : std::is_default_constructible<T> {};
3642
3643template <typename T1, typename T2>
3644struct is_default_constructible<std::pair<T1, T2>>
3645 : conjunction<is_default_constructible<T1>, is_default_constructible<T2>> {};
3646
3647template <typename T1, typename T2>
3648struct is_default_constructible<const std::pair<T1, T2>>
3649 : conjunction<is_default_constructible<T1>, is_default_constructible<T2>> {};
3650
3651template <typename... Ts>
3652struct is_default_constructible<std::tuple<Ts...>>
3653 : conjunction<is_default_constructible<Ts>...> {};
3654
3655template <typename... Ts>
3656struct is_default_constructible<const std::tuple<Ts...>>
3657 : conjunction<is_default_constructible<Ts>...> {};
3658
3659
3660template <typename T, typename... Args>
3661struct is_constructible : std::is_constructible<T, Args...> {};
3662
3663template <typename T1, typename T2>
3664struct is_constructible<std::pair<T1, T2>> : is_default_constructible<std::pair<T1, T2>> {};
3665
3666template <typename T1, typename T2>
3667struct is_constructible<const std::pair<T1, T2>> : is_default_constructible<const std::pair<T1, T2>> {};
3668
3669template <typename... Ts>
3670struct is_constructible<std::tuple<Ts...>> : is_default_constructible<std::tuple<Ts...>> {};
3671
3672template <typename... Ts>
3673struct is_constructible<const std::tuple<Ts...>> : is_default_constructible<const std::tuple<Ts...>> {};
3674
3675
3676template<typename T, typename = void>
3677struct is_iterator_traits : std::false_type {};
3678
3679template<typename T>
3680struct is_iterator_traits<iterator_traits<T>>
3681{
3682 private:
3683 using traits = iterator_traits<T>;
3684
3685 public:
3686 static constexpr auto value =
3687 is_detected<value_type_t, traits>::value &&
3688 is_detected<difference_type_t, traits>::value &&
3689 is_detected<pointer_t, traits>::value &&
3690 is_detected<iterator_category_t, traits>::value &&
3691 is_detected<reference_t, traits>::value;
3692};
3693
3694template<typename T>
3695struct is_range
3696{
3697 private:
3698 using t_ref = typename std::add_lvalue_reference<T>::type;
3699
3700 using iterator = detected_t<result_of_begin, t_ref>;
3701 using sentinel = detected_t<result_of_end, t_ref>;
3702
3703 // to be 100% correct, it should use https://en.cppreference.com/w/cpp/iterator/input_or_output_iterator
3704 // and https://en.cppreference.com/w/cpp/iterator/sentinel_for
3705 // but reimplementing these would be too much work, as a lot of other concepts are used underneath
3706 static constexpr auto is_iterator_begin =
3707 is_iterator_traits<iterator_traits<iterator>>::value;
3708
3709 public:
3710 static constexpr bool value = !std::is_same<iterator, nonesuch>::value && !std::is_same<sentinel, nonesuch>::value && is_iterator_begin;
3711};
3712
3713template<typename R>
3714using iterator_t = enable_if_t<is_range<R>::value, result_of_begin<decltype(std::declval<R&>())>>;
3715
3716template<typename T>
3717using range_value_t = value_type_t<iterator_traits<iterator_t<T>>>;
3718
3719// The following implementation of is_complete_type is taken from
3720// https://blogs.msdn.microsoft.com/vcblog/2015/12/02/partial-support-for-expression-sfinae-in-vs-2015-update-1/
3721// and is written by Xiang Fan who agreed to using it in this library.
3722
3723template<typename T, typename = void>
3724struct is_complete_type : std::false_type {};
3725
3726template<typename T>
3727struct is_complete_type<T, decltype(void(sizeof(T)))> : std::true_type {};
3728
3729template<typename BasicJsonType, typename CompatibleObjectType,
3730 typename = void>
3731struct is_compatible_object_type_impl : std::false_type {};
3732
3733template<typename BasicJsonType, typename CompatibleObjectType>
3734struct is_compatible_object_type_impl <
3735 BasicJsonType, CompatibleObjectType,
3736 enable_if_t < is_detected<mapped_type_t, CompatibleObjectType>::value&&
3737 is_detected<key_type_t, CompatibleObjectType>::value >>
3738{
3739 using object_t = typename BasicJsonType::object_t;
3740
3741 // macOS's is_constructible does not play well with nonesuch...
3742 static constexpr bool value =
3743 is_constructible<typename object_t::key_type,
3744 typename CompatibleObjectType::key_type>::value &&
3745 is_constructible<typename object_t::mapped_type,
3746 typename CompatibleObjectType::mapped_type>::value;
3747};
3748
3749template<typename BasicJsonType, typename CompatibleObjectType>
3750struct is_compatible_object_type
3751 : is_compatible_object_type_impl<BasicJsonType, CompatibleObjectType> {};
3752
3753template<typename BasicJsonType, typename ConstructibleObjectType,
3754 typename = void>
3755struct is_constructible_object_type_impl : std::false_type {};
3756
3757template<typename BasicJsonType, typename ConstructibleObjectType>
3758struct is_constructible_object_type_impl <
3759 BasicJsonType, ConstructibleObjectType,
3760 enable_if_t < is_detected<mapped_type_t, ConstructibleObjectType>::value&&
3761 is_detected<key_type_t, ConstructibleObjectType>::value >>
3762{
3763 using object_t = typename BasicJsonType::object_t;
3764
3765 static constexpr bool value =
3766 (is_default_constructible<ConstructibleObjectType>::value &&
3767 (std::is_move_assignable<ConstructibleObjectType>::value ||
3768 std::is_copy_assignable<ConstructibleObjectType>::value) &&
3769 (is_constructible<typename ConstructibleObjectType::key_type,
3770 typename object_t::key_type>::value &&
3771 std::is_same <
3772 typename object_t::mapped_type,
3773 typename ConstructibleObjectType::mapped_type >::value)) ||
3774 (has_from_json<BasicJsonType,
3775 typename ConstructibleObjectType::mapped_type>::value ||
3776 has_non_default_from_json <
3777 BasicJsonType,
3778 typename ConstructibleObjectType::mapped_type >::value);
3779};
3780
3781template<typename BasicJsonType, typename ConstructibleObjectType>
3782struct is_constructible_object_type
3783 : is_constructible_object_type_impl<BasicJsonType,
3784 ConstructibleObjectType> {};
3785
3786template<typename BasicJsonType, typename CompatibleStringType>
3787struct is_compatible_string_type
3788{
3789 static constexpr auto value =
3790 is_constructible<typename BasicJsonType::string_t, CompatibleStringType>::value;
3791};
3792
3793template<typename BasicJsonType, typename ConstructibleStringType>
3794struct is_constructible_string_type
3795{
3796 static constexpr auto value =
3797 is_constructible<ConstructibleStringType,
3798 typename BasicJsonType::string_t>::value;
3799};
3800
3801template<typename BasicJsonType, typename CompatibleArrayType, typename = void>
3802struct is_compatible_array_type_impl : std::false_type {};
3803
3804template<typename BasicJsonType, typename CompatibleArrayType>
3805struct is_compatible_array_type_impl <
3806 BasicJsonType, CompatibleArrayType,
3807 enable_if_t <
3808 is_detected<iterator_t, CompatibleArrayType>::value&&
3809 is_iterator_traits<iterator_traits<detected_t<iterator_t, CompatibleArrayType>>>::value&&
3810// special case for types like std::filesystem::path whose iterator's value_type are themselves
3811// c.f. https://github.com/nlohmann/json/pull/3073
3812 !std::is_same<CompatibleArrayType, detected_t<range_value_t, CompatibleArrayType>>::value >>
3813{
3814 static constexpr bool value =
3815 is_constructible<BasicJsonType,
3816 range_value_t<CompatibleArrayType>>::value;
3817};
3818
3819template<typename BasicJsonType, typename CompatibleArrayType>
3820struct is_compatible_array_type
3821 : is_compatible_array_type_impl<BasicJsonType, CompatibleArrayType> {};
3822
3823template<typename BasicJsonType, typename ConstructibleArrayType, typename = void>
3824struct is_constructible_array_type_impl : std::false_type {};
3825
3826template<typename BasicJsonType, typename ConstructibleArrayType>
3827struct is_constructible_array_type_impl <
3828 BasicJsonType, ConstructibleArrayType,
3829 enable_if_t<std::is_same<ConstructibleArrayType,
3830 typename BasicJsonType::value_type>::value >>
3831 : std::true_type {};
3832
3833template<typename BasicJsonType, typename ConstructibleArrayType>
3834struct is_constructible_array_type_impl <
3835 BasicJsonType, ConstructibleArrayType,
3836 enable_if_t < !std::is_same<ConstructibleArrayType,
3837 typename BasicJsonType::value_type>::value&&
3838 !is_compatible_string_type<BasicJsonType, ConstructibleArrayType>::value&&
3839 is_default_constructible<ConstructibleArrayType>::value&&
3840(std::is_move_assignable<ConstructibleArrayType>::value ||
3841 std::is_copy_assignable<ConstructibleArrayType>::value)&&
3842is_detected<iterator_t, ConstructibleArrayType>::value&&
3843is_iterator_traits<iterator_traits<detected_t<iterator_t, ConstructibleArrayType>>>::value&&
3844is_detected<range_value_t, ConstructibleArrayType>::value&&
3845// special case for types like std::filesystem::path whose iterator's value_type are themselves
3846// c.f. https://github.com/nlohmann/json/pull/3073
3847!std::is_same<ConstructibleArrayType, detected_t<range_value_t, ConstructibleArrayType>>::value&&
3848 is_complete_type <
3849 detected_t<range_value_t, ConstructibleArrayType >>::value >>
3850{
3851 using value_type = range_value_t<ConstructibleArrayType>;
3852
3853 static constexpr bool value =
3854 std::is_same<value_type,
3855 typename BasicJsonType::array_t::value_type>::value ||
3856 has_from_json<BasicJsonType,
3857 value_type>::value ||
3858 has_non_default_from_json <
3859 BasicJsonType,
3860 value_type >::value;
3861};
3862
3863template<typename BasicJsonType, typename ConstructibleArrayType>
3864struct is_constructible_array_type
3865 : is_constructible_array_type_impl<BasicJsonType, ConstructibleArrayType> {};
3866
3867template<typename RealIntegerType, typename CompatibleNumberIntegerType,
3868 typename = void>
3869struct is_compatible_integer_type_impl : std::false_type {};
3870
3871template<typename RealIntegerType, typename CompatibleNumberIntegerType>
3872struct is_compatible_integer_type_impl <
3873 RealIntegerType, CompatibleNumberIntegerType,
3874 enable_if_t < std::is_integral<RealIntegerType>::value&&
3875 std::is_integral<CompatibleNumberIntegerType>::value&&
3876 !std::is_same<bool, CompatibleNumberIntegerType>::value >>
3877{
3878 // is there an assert somewhere on overflows?
3879 using RealLimits = std::numeric_limits<RealIntegerType>;
3880 using CompatibleLimits = std::numeric_limits<CompatibleNumberIntegerType>;
3881
3882 static constexpr auto value =
3883 is_constructible<RealIntegerType,
3884 CompatibleNumberIntegerType>::value &&
3885 CompatibleLimits::is_integer &&
3886 RealLimits::is_signed == CompatibleLimits::is_signed;
3887};
3888
3889template<typename RealIntegerType, typename CompatibleNumberIntegerType>
3890struct is_compatible_integer_type
3891 : is_compatible_integer_type_impl<RealIntegerType,
3892 CompatibleNumberIntegerType> {};
3893
3894template<typename BasicJsonType, typename CompatibleType, typename = void>
3895struct is_compatible_type_impl: std::false_type {};
3896
3897template<typename BasicJsonType, typename CompatibleType>
3898struct is_compatible_type_impl <
3899 BasicJsonType, CompatibleType,
3900 enable_if_t<is_complete_type<CompatibleType>::value >>
3901{
3902 static constexpr bool value =
3903 has_to_json<BasicJsonType, CompatibleType>::value;
3904};
3905
3906template<typename BasicJsonType, typename CompatibleType>
3907struct is_compatible_type
3908 : is_compatible_type_impl<BasicJsonType, CompatibleType> {};
3909
3910template<typename T1, typename T2>
3911struct is_constructible_tuple : std::false_type {};
3912
3913template<typename T1, typename... Args>
3914struct is_constructible_tuple<T1, std::tuple<Args...>> : conjunction<is_constructible<T1, Args>...> {};
3915
3916// a naive helper to check if a type is an ordered_map (exploits the fact that
3917// ordered_map inherits capacity() from std::vector)
3918template <typename T>
3919struct is_ordered_map
3920{
3921 using one = char;
3922
3923 struct two
3924 {
3925 char x[2]; // NOLINT(cppcoreguidelines-avoid-c-arrays,hicpp-avoid-c-arrays,modernize-avoid-c-arrays)
3926 };
3927
3928 template <typename C> static one test( decltype(&C::capacity) ) ;
3929 template <typename C> static two test(...);
3930
3931 enum { value = sizeof(test<T>(nullptr)) == sizeof(char) }; // NOLINT(cppcoreguidelines-pro-type-vararg,hicpp-vararg)
3932};
3933
3934// to avoid useless casts (see https://github.com/nlohmann/json/issues/2893#issuecomment-889152324)
3935template < typename T, typename U, enable_if_t < !std::is_same<T, U>::value, int > = 0 >
3936T conditional_static_cast(U value)
3937{
3938 return static_cast<T>(value);
3939}
3940
3941template<typename T, typename U, enable_if_t<std::is_same<T, U>::value, int> = 0>
3942T conditional_static_cast(U value)
3943{
3944 return value;
3945}
3946
3947} // namespace detail
3948} // namespace nlohmann
3949
3950// #include <nlohmann/detail/value_t.hpp>
3951
3952
3953#ifdef JSON_HAS_CPP_17
3954 #include <filesystem>
3955#endif
3956
3957namespace nlohmann
3958{
3959namespace detail
3960{
3961template<typename BasicJsonType>
3962void from_json(const BasicJsonType& j, typename std::nullptr_t& n)
3963{
3964 if (JSON_HEDLEY_UNLIKELY(!j.is_null()))
3965 {
3966 JSON_THROW(type_error::create(302, "type must be null, but is " + std::string(j.type_name()), j));
3967 }
3968 n = nullptr;
3969}
3970
3971// overloads for basic_json template parameters
3972template < typename BasicJsonType, typename ArithmeticType,
3973 enable_if_t < std::is_arithmetic<ArithmeticType>::value&&
3974 !std::is_same<ArithmeticType, typename BasicJsonType::boolean_t>::value,
3975 int > = 0 >
3976void get_arithmetic_value(const BasicJsonType& j, ArithmeticType& val)
3977{
3978 switch (static_cast<value_t>(j))
3979 {
3980 case value_t::number_unsigned:
3981 {
3982 val = static_cast<ArithmeticType>(*j.template get_ptr<const typename BasicJsonType::number_unsigned_t*>());
3983 break;
3984 }
3985 case value_t::number_integer:
3986 {
3987 val = static_cast<ArithmeticType>(*j.template get_ptr<const typename BasicJsonType::number_integer_t*>());
3988 break;
3989 }
3990 case value_t::number_float:
3991 {
3992 val = static_cast<ArithmeticType>(*j.template get_ptr<const typename BasicJsonType::number_float_t*>());
3993 break;
3994 }
3995
3996 case value_t::null:
3997 case value_t::object:
3998 case value_t::array:
3999 case value_t::string:
4000 case value_t::boolean:
4001 case value_t::binary:
4002 case value_t::discarded:
4003 default:
4004 JSON_THROW(type_error::create(302, "type must be number, but is " + std::string(j.type_name()), j));
4005 }
4006}
4007
4008template<typename BasicJsonType>
4009void from_json(const BasicJsonType& j, typename BasicJsonType::boolean_t& b)
4010{
4011 if (JSON_HEDLEY_UNLIKELY(!j.is_boolean()))
4012 {
4013 JSON_THROW(type_error::create(302, "type must be boolean, but is " + std::string(j.type_name()), j));
4014 }
4015 b = *j.template get_ptr<const typename BasicJsonType::boolean_t*>();
4016}
4017
4018template<typename BasicJsonType>
4019void from_json(const BasicJsonType& j, typename BasicJsonType::string_t& s)
4020{
4021 if (JSON_HEDLEY_UNLIKELY(!j.is_string()))
4022 {
4023 JSON_THROW(type_error::create(302, "type must be string, but is " + std::string(j.type_name()), j));
4024 }
4025 s = *j.template get_ptr<const typename BasicJsonType::string_t*>();
4026}
4027
4028template <
4029 typename BasicJsonType, typename ConstructibleStringType,
4030 enable_if_t <
4031 is_constructible_string_type<BasicJsonType, ConstructibleStringType>::value&&
4032 !std::is_same<typename BasicJsonType::string_t,
4033 ConstructibleStringType>::value,
4034 int > = 0 >
4035void from_json(const BasicJsonType& j, ConstructibleStringType& s)
4036{
4037 if (JSON_HEDLEY_UNLIKELY(!j.is_string()))
4038 {
4039 JSON_THROW(type_error::create(302, "type must be string, but is " + std::string(j.type_name()), j));
4040 }
4041
4042 s = *j.template get_ptr<const typename BasicJsonType::string_t*>();
4043}
4044
4045template<typename BasicJsonType>
4046void from_json(const BasicJsonType& j, typename BasicJsonType::number_float_t& val)
4047{
4048 get_arithmetic_value(j, val);
4049}
4050
4051template<typename BasicJsonType>
4052void from_json(const BasicJsonType& j, typename BasicJsonType::number_unsigned_t& val)
4053{
4054 get_arithmetic_value(j, val);
4055}
4056
4057template<typename BasicJsonType>
4058void from_json(const BasicJsonType& j, typename BasicJsonType::number_integer_t& val)
4059{
4060 get_arithmetic_value(j, val);
4061}
4062
4063template<typename BasicJsonType, typename EnumType,
4064 enable_if_t<std::is_enum<EnumType>::value, int> = 0>
4065void from_json(const BasicJsonType& j, EnumType& e)
4066{
4067 typename std::underlying_type<EnumType>::type val;
4068 get_arithmetic_value(j, val);
4069 e = static_cast<EnumType>(val);
4070}
4071
4072// forward_list doesn't have an insert method
4073template<typename BasicJsonType, typename T, typename Allocator,
4074 enable_if_t<is_getable<BasicJsonType, T>::value, int> = 0>
4075void from_json(const BasicJsonType& j, std::forward_list<T, Allocator>& l)
4076{
4077 if (JSON_HEDLEY_UNLIKELY(!j.is_array()))
4078 {
4079 JSON_THROW(type_error::create(302, "type must be array, but is " + std::string(j.type_name()), j));
4080 }
4081 l.clear();
4082 std::transform(j.rbegin(), j.rend(),
4083 std::front_inserter(l), [](const BasicJsonType & i)
4084 {
4085 return i.template get<T>();
4086 });
4087}
4088
4089// valarray doesn't have an insert method
4090template<typename BasicJsonType, typename T,
4091 enable_if_t<is_getable<BasicJsonType, T>::value, int> = 0>
4092void from_json(const BasicJsonType& j, std::valarray<T>& l)
4093{
4094 if (JSON_HEDLEY_UNLIKELY(!j.is_array()))
4095 {
4096 JSON_THROW(type_error::create(302, "type must be array, but is " + std::string(j.type_name()), j));
4097 }
4098 l.resize(j.size());
4099 std::transform(j.begin(), j.end(), std::begin(l),
4100 [](const BasicJsonType & elem)
4101 {
4102 return elem.template get<T>();
4103 });
4104}
4105
4106template<typename BasicJsonType, typename T, std::size_t N>
4107auto from_json(const BasicJsonType& j, T (&arr)[N]) // NOLINT(cppcoreguidelines-avoid-c-arrays,hicpp-avoid-c-arrays,modernize-avoid-c-arrays)
4108-> decltype(j.template get<T>(), void())
4109{
4110 for (std::size_t i = 0; i < N; ++i)
4111 {
4112 arr[i] = j.at(i).template get<T>();
4113 }
4114}
4115
4116template<typename BasicJsonType>
4117void from_json_array_impl(const BasicJsonType& j, typename BasicJsonType::array_t& arr, priority_tag<3> /*unused*/)
4118{
4119 arr = *j.template get_ptr<const typename BasicJsonType::array_t*>();
4120}
4121
4122template<typename BasicJsonType, typename T, std::size_t N>
4123auto from_json_array_impl(const BasicJsonType& j, std::array<T, N>& arr,
4124 priority_tag<2> /*unused*/)
4125-> decltype(j.template get<T>(), void())
4126{
4127 for (std::size_t i = 0; i < N; ++i)
4128 {
4129 arr[i] = j.at(i).template get<T>();
4130 }
4131}
4132
4133template<typename BasicJsonType, typename ConstructibleArrayType,
4134 enable_if_t<
4135 std::is_assignable<ConstructibleArrayType&, ConstructibleArrayType>::value,
4136 int> = 0>
4137auto from_json_array_impl(const BasicJsonType& j, ConstructibleArrayType& arr, priority_tag<1> /*unused*/)
4138-> decltype(
4139 arr.reserve(std::declval<typename ConstructibleArrayType::size_type>()),
4140 j.template get<typename ConstructibleArrayType::value_type>(),
4141 void())
4142{
4143 using std::end;
4144
4145 ConstructibleArrayType ret;
4146 ret.reserve(j.size());
4147 std::transform(j.begin(), j.end(),
4148 std::inserter(ret, end(ret)), [](const BasicJsonType & i)
4149 {
4150 // get<BasicJsonType>() returns *this, this won't call a from_json
4151 // method when value_type is BasicJsonType
4152 return i.template get<typename ConstructibleArrayType::value_type>();
4153 });
4154 arr = std::move(ret);
4155}
4156
4157template<typename BasicJsonType, typename ConstructibleArrayType,
4158 enable_if_t<
4159 std::is_assignable<ConstructibleArrayType&, ConstructibleArrayType>::value,
4160 int> = 0>
4161void from_json_array_impl(const BasicJsonType& j, ConstructibleArrayType& arr,
4162 priority_tag<0> /*unused*/)
4163{
4164 using std::end;
4165
4166 ConstructibleArrayType ret;
4167 std::transform(
4168 j.begin(), j.end(), std::inserter(ret, end(ret)),
4169 [](const BasicJsonType & i)
4170 {
4171 // get<BasicJsonType>() returns *this, this won't call a from_json
4172 // method when value_type is BasicJsonType
4173 return i.template get<typename ConstructibleArrayType::value_type>();
4174 });
4175 arr = std::move(ret);
4176}
4177
4178template < typename BasicJsonType, typename ConstructibleArrayType,
4179 enable_if_t <
4180 is_constructible_array_type<BasicJsonType, ConstructibleArrayType>::value&&
4181 !is_constructible_object_type<BasicJsonType, ConstructibleArrayType>::value&&
4182 !is_constructible_string_type<BasicJsonType, ConstructibleArrayType>::value&&
4183 !std::is_same<ConstructibleArrayType, typename BasicJsonType::binary_t>::value&&
4184 !is_basic_json<ConstructibleArrayType>::value,
4185 int > = 0 >
4186auto from_json(const BasicJsonType& j, ConstructibleArrayType& arr)
4187-> decltype(from_json_array_impl(j, arr, priority_tag<3> {}),
4188j.template get<typename ConstructibleArrayType::value_type>(),
4189void())
4190{
4191 if (JSON_HEDLEY_UNLIKELY(!j.is_array()))
4192 {
4193 JSON_THROW(type_error::create(302, "type must be array, but is " + std::string(j.type_name()), j));
4194 }
4195
4196 from_json_array_impl(j, arr, priority_tag<3> {});
4197}
4198
4199template < typename BasicJsonType, typename T, std::size_t... Idx >
4200std::array<T, sizeof...(Idx)> from_json_inplace_array_impl(BasicJsonType&& j,
4201 identity_tag<std::array<T, sizeof...(Idx)>> /*unused*/, index_sequence<Idx...> /*unused*/)
4202{
4203 return { { std::forward<BasicJsonType>(j).at(Idx).template get<T>()... } };
4204}
4205
4206template < typename BasicJsonType, typename T, std::size_t N >
4207auto from_json(BasicJsonType&& j, identity_tag<std::array<T, N>> tag)
4208-> decltype(from_json_inplace_array_impl(std::forward<BasicJsonType>(j), tag, make_index_sequence<N> {}))
4209{
4210 if (JSON_HEDLEY_UNLIKELY(!j.is_array()))
4211 {
4212 JSON_THROW(type_error::create(302, "type must be array, but is " + std::string(j.type_name()), j));
4213 }
4214
4215 return from_json_inplace_array_impl(std::forward<BasicJsonType>(j), tag, make_index_sequence<N> {});
4216}
4217
4218template<typename BasicJsonType>
4219void from_json(const BasicJsonType& j, typename BasicJsonType::binary_t& bin)
4220{
4221 if (JSON_HEDLEY_UNLIKELY(!j.is_binary()))
4222 {
4223 JSON_THROW(type_error::create(302, "type must be binary, but is " + std::string(j.type_name()), j));
4224 }
4225
4226 bin = *j.template get_ptr<const typename BasicJsonType::binary_t*>();
4227}
4228
4229template<typename BasicJsonType, typename ConstructibleObjectType,
4230 enable_if_t<is_constructible_object_type<BasicJsonType, ConstructibleObjectType>::value, int> = 0>
4231void from_json(const BasicJsonType& j, ConstructibleObjectType& obj)
4232{
4233 if (JSON_HEDLEY_UNLIKELY(!j.is_object()))
4234 {
4235 JSON_THROW(type_error::create(302, "type must be object, but is " + std::string(j.type_name()), j));
4236 }
4237
4238 ConstructibleObjectType ret;
4239 const auto* inner_object = j.template get_ptr<const typename BasicJsonType::object_t*>();
4240 using value_type = typename ConstructibleObjectType::value_type;
4241 std::transform(
4242 inner_object->begin(), inner_object->end(),
4243 std::inserter(ret, ret.begin()),
4244 [](typename BasicJsonType::object_t::value_type const & p)
4245 {
4246 return value_type(p.first, p.second.template get<typename ConstructibleObjectType::mapped_type>());
4247 });
4248 obj = std::move(ret);
4249}
4250
4251// overload for arithmetic types, not chosen for basic_json template arguments
4252// (BooleanType, etc..); note: Is it really necessary to provide explicit
4253// overloads for boolean_t etc. in case of a custom BooleanType which is not
4254// an arithmetic type?
4255template < typename BasicJsonType, typename ArithmeticType,
4256 enable_if_t <
4257 std::is_arithmetic<ArithmeticType>::value&&
4258 !std::is_same<ArithmeticType, typename BasicJsonType::number_unsigned_t>::value&&
4259 !std::is_same<ArithmeticType, typename BasicJsonType::number_integer_t>::value&&
4260 !std::is_same<ArithmeticType, typename BasicJsonType::number_float_t>::value&&
4261 !std::is_same<ArithmeticType, typename BasicJsonType::boolean_t>::value,
4262 int > = 0 >
4263void from_json(const BasicJsonType& j, ArithmeticType& val)
4264{
4265 switch (static_cast<value_t>(j))
4266 {
4267 case value_t::number_unsigned:
4268 {
4269 val = static_cast<ArithmeticType>(*j.template get_ptr<const typename BasicJsonType::number_unsigned_t*>());
4270 break;
4271 }
4272 case value_t::number_integer:
4273 {
4274 val = static_cast<ArithmeticType>(*j.template get_ptr<const typename BasicJsonType::number_integer_t*>());
4275 break;
4276 }
4277 case value_t::number_float:
4278 {
4279 val = static_cast<ArithmeticType>(*j.template get_ptr<const typename BasicJsonType::number_float_t*>());
4280 break;
4281 }
4282 case value_t::boolean:
4283 {
4284 val = static_cast<ArithmeticType>(*j.template get_ptr<const typename BasicJsonType::boolean_t*>());
4285 break;
4286 }
4287
4288 case value_t::null:
4289 case value_t::object:
4290 case value_t::array:
4291 case value_t::string:
4292 case value_t::binary:
4293 case value_t::discarded:
4294 default:
4295 JSON_THROW(type_error::create(302, "type must be number, but is " + std::string(j.type_name()), j));
4296 }
4297}
4298
4299template<typename BasicJsonType, typename... Args, std::size_t... Idx>
4300std::tuple<Args...> from_json_tuple_impl_base(BasicJsonType&& j, index_sequence<Idx...> /*unused*/)
4301{
4302 return std::make_tuple(std::forward<BasicJsonType>(j).at(Idx).template get<Args>()...);
4303}
4304
4305template < typename BasicJsonType, class A1, class A2 >
4306std::pair<A1, A2> from_json_tuple_impl(BasicJsonType&& j, identity_tag<std::pair<A1, A2>> /*unused*/, priority_tag<0> /*unused*/)
4307{
4308 return {std::forward<BasicJsonType>(j).at(0).template get<A1>(),
4309 std::forward<BasicJsonType>(j).at(1).template get<A2>()};
4310}
4311
4312template<typename BasicJsonType, typename A1, typename A2>
4313void from_json_tuple_impl(BasicJsonType&& j, std::pair<A1, A2>& p, priority_tag<1> /*unused*/)
4314{
4315 p = from_json_tuple_impl(std::forward<BasicJsonType>(j), identity_tag<std::pair<A1, A2>> {}, priority_tag<0> {});
4316}
4317
4318template<typename BasicJsonType, typename... Args>
4319std::tuple<Args...> from_json_tuple_impl(BasicJsonType&& j, identity_tag<std::tuple<Args...>> /*unused*/, priority_tag<2> /*unused*/)
4320{
4321 return from_json_tuple_impl_base<BasicJsonType, Args...>(std::forward<BasicJsonType>(j), index_sequence_for<Args...> {});
4322}
4323
4324template<typename BasicJsonType, typename... Args>
4325void from_json_tuple_impl(BasicJsonType&& j, std::tuple<Args...>& t, priority_tag<3> /*unused*/)
4326{
4327 t = from_json_tuple_impl_base<BasicJsonType, Args...>(std::forward<BasicJsonType>(j), index_sequence_for<Args...> {});
4328}
4329
4330template<typename BasicJsonType, typename TupleRelated>
4331auto from_json(BasicJsonType&& j, TupleRelated&& t)
4332-> decltype(from_json_tuple_impl(std::forward<BasicJsonType>(j), std::forward<TupleRelated>(t), priority_tag<3> {}))
4333{
4334 if (JSON_HEDLEY_UNLIKELY(!j.is_array()))
4335 {
4336 JSON_THROW(type_error::create(302, "type must be array, but is " + std::string(j.type_name()), j));
4337 }
4338
4339 return from_json_tuple_impl(std::forward<BasicJsonType>(j), std::forward<TupleRelated>(t), priority_tag<3> {});
4340}
4341
4342template < typename BasicJsonType, typename Key, typename Value, typename Compare, typename Allocator,
4343 typename = enable_if_t < !std::is_constructible <
4344 typename BasicJsonType::string_t, Key >::value >>
4345void from_json(const BasicJsonType& j, std::map<Key, Value, Compare, Allocator>& m)
4346{
4347 if (JSON_HEDLEY_UNLIKELY(!j.is_array()))
4348 {
4349 JSON_THROW(type_error::create(302, "type must be array, but is " + std::string(j.type_name()), j));
4350 }
4351 m.clear();
4352 for (const auto& p : j)
4353 {
4354 if (JSON_HEDLEY_UNLIKELY(!p.is_array()))
4355 {
4356 JSON_THROW(type_error::create(302, "type must be array, but is " + std::string(p.type_name()), j));
4357 }
4358 m.emplace(p.at(0).template get<Key>(), p.at(1).template get<Value>());
4359 }
4360}
4361
4362template < typename BasicJsonType, typename Key, typename Value, typename Hash, typename KeyEqual, typename Allocator,
4363 typename = enable_if_t < !std::is_constructible <
4364 typename BasicJsonType::string_t, Key >::value >>
4365void from_json(const BasicJsonType& j, std::unordered_map<Key, Value, Hash, KeyEqual, Allocator>& m)
4366{
4367 if (JSON_HEDLEY_UNLIKELY(!j.is_array()))
4368 {
4369 JSON_THROW(type_error::create(302, "type must be array, but is " + std::string(j.type_name()), j));
4370 }
4371 m.clear();
4372 for (const auto& p : j)
4373 {
4374 if (JSON_HEDLEY_UNLIKELY(!p.is_array()))
4375 {
4376 JSON_THROW(type_error::create(302, "type must be array, but is " + std::string(p.type_name()), j));
4377 }
4378 m.emplace(p.at(0).template get<Key>(), p.at(1).template get<Value>());
4379 }
4380}
4381
4382#ifdef JSON_HAS_CPP_17
4383template<typename BasicJsonType>
4384void from_json(const BasicJsonType& j, std::filesystem::path& p)
4385{
4386 if (JSON_HEDLEY_UNLIKELY(!j.is_string()))
4387 {
4388 JSON_THROW(type_error::create(302, "type must be string, but is " + std::string(j.type_name()), j));
4389 }
4390 p = *j.template get_ptr<const typename BasicJsonType::string_t*>();
4391}
4392#endif
4393
4394struct from_json_fn
4395{
4396 template<typename BasicJsonType, typename T>
4397 auto operator()(const BasicJsonType& j, T&& val) const
4398 noexcept(noexcept(from_json(j, std::forward<T>(val))))
4399 -> decltype(from_json(j, std::forward<T>(val)))
4400 {
4401 return from_json(j, std::forward<T>(val));
4402 }
4403};
4404} // namespace detail
4405
4409namespace // NOLINT(cert-dcl59-cpp,fuchsia-header-anon-namespaces,google-build-namespaces)
4410{
4411constexpr const auto& from_json = detail::static_const<detail::from_json_fn>::value; // NOLINT(misc-definitions-in-headers)
4412} // namespace
4413} // namespace nlohmann
4414
4415// #include <nlohmann/detail/conversions/to_json.hpp>
4416
4417
4418#include <algorithm> // copy
4419#include <iterator> // begin, end
4420#include <string> // string
4421#include <tuple> // tuple, get
4422#include <type_traits> // is_same, is_constructible, is_floating_point, is_enum, underlying_type
4423#include <utility> // move, forward, declval, pair
4424#include <valarray> // valarray
4425#include <vector> // vector
4426
4427// #include <nlohmann/detail/macro_scope.hpp>
4428
4429// #include <nlohmann/detail/iterators/iteration_proxy.hpp>
4430
4431
4432#include <cstddef> // size_t
4433#include <iterator> // input_iterator_tag
4434#include <string> // string, to_string
4435#include <tuple> // tuple_size, get, tuple_element
4436#include <utility> // move
4437
4438// #include <nlohmann/detail/meta/type_traits.hpp>
4439
4440// #include <nlohmann/detail/value_t.hpp>
4441
4442
4443namespace nlohmann
4444{
4445namespace detail
4446{
4447template<typename string_type>
4448void int_to_string( string_type& target, std::size_t value )
4449{
4450 // For ADL
4451 using std::to_string;
4452 target = to_string(value);
4453}
4454template<typename IteratorType> class iteration_proxy_value
4455{
4456 public:
4457 using difference_type = std::ptrdiff_t;
4458 using value_type = iteration_proxy_value;
4459 using pointer = value_type * ;
4460 using reference = value_type & ;
4461 using iterator_category = std::input_iterator_tag;
4462 using string_type = typename std::remove_cv< typename std::remove_reference<decltype( std::declval<IteratorType>().key() ) >::type >::type;
4463
4464 private:
4466 IteratorType anchor;
4468 std::size_t array_index = 0;
4470 mutable std::size_t array_index_last = 0;
4472 mutable string_type array_index_str = "0";
4474 const string_type empty_str{};
4475
4476 public:
4477 explicit iteration_proxy_value(IteratorType it) noexcept
4478 : anchor(std::move(it))
4479 {}
4480
4482 iteration_proxy_value& operator*()
4483 {
4484 return *this;
4485 }
4486
4488 iteration_proxy_value& operator++()
4489 {
4490 ++anchor;
4491 ++array_index;
4492
4493 return *this;
4494 }
4495
4497 bool operator==(const iteration_proxy_value& o) const
4498 {
4499 return anchor == o.anchor;
4500 }
4501
4503 bool operator!=(const iteration_proxy_value& o) const
4504 {
4505 return anchor != o.anchor;
4506 }
4507
4509 const string_type& key() const
4510 {
4511 JSON_ASSERT(anchor.m_object != nullptr);
4512
4513 switch (anchor.m_object->type())
4514 {
4515 // use integer array index as key
4516 case value_t::array:
4517 {
4518 if (array_index != array_index_last)
4519 {
4520 int_to_string( array_index_str, array_index );
4521 array_index_last = array_index;
4522 }
4523 return array_index_str;
4524 }
4525
4526 // use key from the object
4527 case value_t::object:
4528 return anchor.key();
4529
4530 // use an empty key for all primitive types
4531 case value_t::null:
4532 case value_t::string:
4533 case value_t::boolean:
4534 case value_t::number_integer:
4535 case value_t::number_unsigned:
4536 case value_t::number_float:
4537 case value_t::binary:
4538 case value_t::discarded:
4539 default:
4540 return empty_str;
4541 }
4542 }
4543
4545 typename IteratorType::reference value() const
4546 {
4547 return anchor.value();
4548 }
4549};
4550
4552template<typename IteratorType> class iteration_proxy
4553{
4554 private:
4556 typename IteratorType::reference container;
4557
4558 public:
4560 explicit iteration_proxy(typename IteratorType::reference cont) noexcept
4561 : container(cont) {}
4562
4564 iteration_proxy_value<IteratorType> begin() noexcept
4565 {
4566 return iteration_proxy_value<IteratorType>(container.begin());
4567 }
4568
4570 iteration_proxy_value<IteratorType> end() noexcept
4571 {
4572 return iteration_proxy_value<IteratorType>(container.end());
4573 }
4574};
4575// Structured Bindings Support
4576// For further reference see https://blog.tartanllama.xyz/structured-bindings/
4577// And see https://github.com/nlohmann/json/pull/1391
4578template<std::size_t N, typename IteratorType, enable_if_t<N == 0, int> = 0>
4579auto get(const nlohmann::detail::iteration_proxy_value<IteratorType>& i) -> decltype(i.key())
4580{
4581 return i.key();
4582}
4583// Structured Bindings Support
4584// For further reference see https://blog.tartanllama.xyz/structured-bindings/
4585// And see https://github.com/nlohmann/json/pull/1391
4586template<std::size_t N, typename IteratorType, enable_if_t<N == 1, int> = 0>
4587auto get(const nlohmann::detail::iteration_proxy_value<IteratorType>& i) -> decltype(i.value())
4588{
4589 return i.value();
4590}
4591} // namespace detail
4592} // namespace nlohmann
4593
4594// The Addition to the STD Namespace is required to add
4595// Structured Bindings Support to the iteration_proxy_value class
4596// For further reference see https://blog.tartanllama.xyz/structured-bindings/
4597// And see https://github.com/nlohmann/json/pull/1391
4598namespace std
4599{
4600#if defined(__clang__)
4601 // Fix: https://github.com/nlohmann/json/issues/1401
4602 #pragma clang diagnostic push
4603 #pragma clang diagnostic ignored "-Wmismatched-tags"
4604#endif
4605template<typename IteratorType>
4606class tuple_size<::nlohmann::detail::iteration_proxy_value<IteratorType>>
4607 : public std::integral_constant<std::size_t, 2> {};
4608
4609template<std::size_t N, typename IteratorType>
4610class tuple_element<N, ::nlohmann::detail::iteration_proxy_value<IteratorType >>
4611{
4612 public:
4613 using type = decltype(
4614 get<N>(std::declval <
4615 ::nlohmann::detail::iteration_proxy_value<IteratorType >> ()));
4616};
4617#if defined(__clang__)
4618 #pragma clang diagnostic pop
4619#endif
4620} // namespace std
4621
4622// #include <nlohmann/detail/meta/cpp_future.hpp>
4623
4624// #include <nlohmann/detail/meta/type_traits.hpp>
4625
4626// #include <nlohmann/detail/value_t.hpp>
4627
4628
4629#ifdef JSON_HAS_CPP_17
4630 #include <filesystem>
4631#endif
4632
4633namespace nlohmann
4634{
4635namespace detail
4636{
4638// constructors //
4640
4641/*
4642 * Note all external_constructor<>::construct functions need to call
4643 * j.m_value.destroy(j.m_type) to avoid a memory leak in case j contains an
4644 * allocated value (e.g., a string). See bug issue
4645 * https://github.com/nlohmann/json/issues/2865 for more information.
4646 */
4647
4648template<value_t> struct external_constructor;
4649
4650template<>
4651struct external_constructor<value_t::boolean>
4652{
4653 template<typename BasicJsonType>
4654 static void construct(BasicJsonType& j, typename BasicJsonType::boolean_t b) noexcept
4655 {
4656 j.m_value.destroy(j.m_type);
4657 j.m_type = value_t::boolean;
4658 j.m_value = b;
4659 j.assert_invariant();
4660 }
4661};
4662
4663template<>
4664struct external_constructor<value_t::string>
4665{
4666 template<typename BasicJsonType>
4667 static void construct(BasicJsonType& j, const typename BasicJsonType::string_t& s)
4668 {
4669 j.m_value.destroy(j.m_type);
4670 j.m_type = value_t::string;
4671 j.m_value = s;
4672 j.assert_invariant();
4673 }
4674
4675 template<typename BasicJsonType>
4676 static void construct(BasicJsonType& j, typename BasicJsonType::string_t&& s)
4677 {
4678 j.m_value.destroy(j.m_type);
4679 j.m_type = value_t::string;
4680 j.m_value = std::move(s);
4681 j.assert_invariant();
4682 }
4683
4684 template < typename BasicJsonType, typename CompatibleStringType,
4685 enable_if_t < !std::is_same<CompatibleStringType, typename BasicJsonType::string_t>::value,
4686 int > = 0 >
4687 static void construct(BasicJsonType& j, const CompatibleStringType& str)
4688 {
4689 j.m_value.destroy(j.m_type);
4690 j.m_type = value_t::string;
4691 j.m_value.string = j.template create<typename BasicJsonType::string_t>(str);
4692 j.assert_invariant();
4693 }
4694};
4695
4696template<>
4697struct external_constructor<value_t::binary>
4698{
4699 template<typename BasicJsonType>
4700 static void construct(BasicJsonType& j, const typename BasicJsonType::binary_t& b)
4701 {
4702 j.m_value.destroy(j.m_type);
4703 j.m_type = value_t::binary;
4704 j.m_value = typename BasicJsonType::binary_t(b);
4705 j.assert_invariant();
4706 }
4707
4708 template<typename BasicJsonType>
4709 static void construct(BasicJsonType& j, typename BasicJsonType::binary_t&& b)
4710 {
4711 j.m_value.destroy(j.m_type);
4712 j.m_type = value_t::binary;
4713 j.m_value = typename BasicJsonType::binary_t(std::move(b));
4714 j.assert_invariant();
4715 }
4716};
4717
4718template<>
4719struct external_constructor<value_t::number_float>
4720{
4721 template<typename BasicJsonType>
4722 static void construct(BasicJsonType& j, typename BasicJsonType::number_float_t val) noexcept
4723 {
4724 j.m_value.destroy(j.m_type);
4725 j.m_type = value_t::number_float;
4726 j.m_value = val;
4727 j.assert_invariant();
4728 }
4729};
4730
4731template<>
4732struct external_constructor<value_t::number_unsigned>
4733{
4734 template<typename BasicJsonType>
4735 static void construct(BasicJsonType& j, typename BasicJsonType::number_unsigned_t val) noexcept
4736 {
4737 j.m_value.destroy(j.m_type);
4738 j.m_type = value_t::number_unsigned;
4739 j.m_value = val;
4740 j.assert_invariant();
4741 }
4742};
4743
4744template<>
4745struct external_constructor<value_t::number_integer>
4746{
4747 template<typename BasicJsonType>
4748 static void construct(BasicJsonType& j, typename BasicJsonType::number_integer_t val) noexcept
4749 {
4750 j.m_value.destroy(j.m_type);
4751 j.m_type = value_t::number_integer;
4752 j.m_value = val;
4753 j.assert_invariant();
4754 }
4755};
4756
4757template<>
4758struct external_constructor<value_t::array>
4759{
4760 template<typename BasicJsonType>
4761 static void construct(BasicJsonType& j, const typename BasicJsonType::array_t& arr)
4762 {
4763 j.m_value.destroy(j.m_type);
4764 j.m_type = value_t::array;
4765 j.m_value = arr;
4766 j.set_parents();
4767 j.assert_invariant();
4768 }
4769
4770 template<typename BasicJsonType>
4771 static void construct(BasicJsonType& j, typename BasicJsonType::array_t&& arr)
4772 {
4773 j.m_value.destroy(j.m_type);
4774 j.m_type = value_t::array;
4775 j.m_value = std::move(arr);
4776 j.set_parents();
4777 j.assert_invariant();
4778 }
4779
4780 template < typename BasicJsonType, typename CompatibleArrayType,
4781 enable_if_t < !std::is_same<CompatibleArrayType, typename BasicJsonType::array_t>::value,
4782 int > = 0 >
4783 static void construct(BasicJsonType& j, const CompatibleArrayType& arr)
4784 {
4785 using std::begin;
4786 using std::end;
4787
4788 j.m_value.destroy(j.m_type);
4789 j.m_type = value_t::array;
4790 j.m_value.array = j.template create<typename BasicJsonType::array_t>(begin(arr), end(arr));
4791 j.set_parents();
4792 j.assert_invariant();
4793 }
4794
4795 template<typename BasicJsonType>
4796 static void construct(BasicJsonType& j, const std::vector<bool>& arr)
4797 {
4798 j.m_value.destroy(j.m_type);
4799 j.m_type = value_t::array;
4800 j.m_value = value_t::array;
4801 j.m_value.array->reserve(arr.size());
4802 for (const bool x : arr)
4803 {
4804 j.m_value.array->push_back(x);
4805 j.set_parent(j.m_value.array->back());
4806 }
4807 j.assert_invariant();
4808 }
4809
4810 template<typename BasicJsonType, typename T,
4811 enable_if_t<std::is_convertible<T, BasicJsonType>::value, int> = 0>
4812 static void construct(BasicJsonType& j, const std::valarray<T>& arr)
4813 {
4814 j.m_value.destroy(j.m_type);
4815 j.m_type = value_t::array;
4816 j.m_value = value_t::array;
4817 j.m_value.array->resize(arr.size());
4818 if (arr.size() > 0)
4819 {
4820 std::copy(std::begin(arr), std::end(arr), j.m_value.array->begin());
4821 }
4822 j.set_parents();
4823 j.assert_invariant();
4824 }
4825};
4826
4827template<>
4828struct external_constructor<value_t::object>
4829{
4830 template<typename BasicJsonType>
4831 static void construct(BasicJsonType& j, const typename BasicJsonType::object_t& obj)
4832 {
4833 j.m_value.destroy(j.m_type);
4834 j.m_type = value_t::object;
4835 j.m_value = obj;
4836 j.set_parents();
4837 j.assert_invariant();
4838 }
4839
4840 template<typename BasicJsonType>
4841 static void construct(BasicJsonType& j, typename BasicJsonType::object_t&& obj)
4842 {
4843 j.m_value.destroy(j.m_type);
4844 j.m_type = value_t::object;
4845 j.m_value = std::move(obj);
4846 j.set_parents();
4847 j.assert_invariant();
4848 }
4849
4850 template < typename BasicJsonType, typename CompatibleObjectType,
4851 enable_if_t < !std::is_same<CompatibleObjectType, typename BasicJsonType::object_t>::value, int > = 0 >
4852 static void construct(BasicJsonType& j, const CompatibleObjectType& obj)
4853 {
4854 using std::begin;
4855 using std::end;
4856
4857 j.m_value.destroy(j.m_type);
4858 j.m_type = value_t::object;
4859 j.m_value.object = j.template create<typename BasicJsonType::object_t>(begin(obj), end(obj));
4860 j.set_parents();
4861 j.assert_invariant();
4862 }
4863};
4864
4866// to_json //
4868
4869template<typename BasicJsonType, typename T,
4870 enable_if_t<std::is_same<T, typename BasicJsonType::boolean_t>::value, int> = 0>
4871void to_json(BasicJsonType& j, T b) noexcept
4872{
4873 external_constructor<value_t::boolean>::construct(j, b);
4874}
4875
4876template<typename BasicJsonType, typename CompatibleString,
4877 enable_if_t<std::is_constructible<typename BasicJsonType::string_t, CompatibleString>::value, int> = 0>
4878void to_json(BasicJsonType& j, const CompatibleString& s)
4879{
4880 external_constructor<value_t::string>::construct(j, s);
4881}
4882
4883template<typename BasicJsonType>
4884void to_json(BasicJsonType& j, typename BasicJsonType::string_t&& s)
4885{
4886 external_constructor<value_t::string>::construct(j, std::move(s));
4887}
4888
4889template<typename BasicJsonType, typename FloatType,
4890 enable_if_t<std::is_floating_point<FloatType>::value, int> = 0>
4891void to_json(BasicJsonType& j, FloatType val) noexcept
4892{
4893 external_constructor<value_t::number_float>::construct(j, static_cast<typename BasicJsonType::number_float_t>(val));
4894}
4895
4896template<typename BasicJsonType, typename CompatibleNumberUnsignedType,
4897 enable_if_t<is_compatible_integer_type<typename BasicJsonType::number_unsigned_t, CompatibleNumberUnsignedType>::value, int> = 0>
4898void to_json(BasicJsonType& j, CompatibleNumberUnsignedType val) noexcept
4899{
4900 external_constructor<value_t::number_unsigned>::construct(j, static_cast<typename BasicJsonType::number_unsigned_t>(val));
4901}
4902
4903template<typename BasicJsonType, typename CompatibleNumberIntegerType,
4904 enable_if_t<is_compatible_integer_type<typename BasicJsonType::number_integer_t, CompatibleNumberIntegerType>::value, int> = 0>
4905void to_json(BasicJsonType& j, CompatibleNumberIntegerType val) noexcept
4906{
4907 external_constructor<value_t::number_integer>::construct(j, static_cast<typename BasicJsonType::number_integer_t>(val));
4908}
4909
4910template<typename BasicJsonType, typename EnumType,
4911 enable_if_t<std::is_enum<EnumType>::value, int> = 0>
4912void to_json(BasicJsonType& j, EnumType e) noexcept
4913{
4914 using underlying_type = typename std::underlying_type<EnumType>::type;
4915 external_constructor<value_t::number_integer>::construct(j, static_cast<underlying_type>(e));
4916}
4917
4918template<typename BasicJsonType>
4919void to_json(BasicJsonType& j, const std::vector<bool>& e)
4920{
4921 external_constructor<value_t::array>::construct(j, e);
4922}
4923
4924template < typename BasicJsonType, typename CompatibleArrayType,
4925 enable_if_t < is_compatible_array_type<BasicJsonType,
4926 CompatibleArrayType>::value&&
4927 !is_compatible_object_type<BasicJsonType, CompatibleArrayType>::value&&
4928 !is_compatible_string_type<BasicJsonType, CompatibleArrayType>::value&&
4929 !std::is_same<typename BasicJsonType::binary_t, CompatibleArrayType>::value&&
4930 !is_basic_json<CompatibleArrayType>::value,
4931 int > = 0 >
4932void to_json(BasicJsonType& j, const CompatibleArrayType& arr)
4933{
4934 external_constructor<value_t::array>::construct(j, arr);
4935}
4936
4937template<typename BasicJsonType>
4938void to_json(BasicJsonType& j, const typename BasicJsonType::binary_t& bin)
4939{
4940 external_constructor<value_t::binary>::construct(j, bin);
4941}
4942
4943template<typename BasicJsonType, typename T,
4944 enable_if_t<std::is_convertible<T, BasicJsonType>::value, int> = 0>
4945void to_json(BasicJsonType& j, const std::valarray<T>& arr)
4946{
4947 external_constructor<value_t::array>::construct(j, std::move(arr));
4948}
4949
4950template<typename BasicJsonType>
4951void to_json(BasicJsonType& j, typename BasicJsonType::array_t&& arr)
4952{
4953 external_constructor<value_t::array>::construct(j, std::move(arr));
4954}
4955
4956template < typename BasicJsonType, typename CompatibleObjectType,
4957 enable_if_t < is_compatible_object_type<BasicJsonType, CompatibleObjectType>::value&& !is_basic_json<CompatibleObjectType>::value, int > = 0 >
4958void to_json(BasicJsonType& j, const CompatibleObjectType& obj)
4959{
4960 external_constructor<value_t::object>::construct(j, obj);
4961}
4962
4963template<typename BasicJsonType>
4964void to_json(BasicJsonType& j, typename BasicJsonType::object_t&& obj)
4965{
4966 external_constructor<value_t::object>::construct(j, std::move(obj));
4967}
4968
4969template <
4970 typename BasicJsonType, typename T, std::size_t N,
4971 enable_if_t < !std::is_constructible<typename BasicJsonType::string_t,
4972 const T(&)[N]>::value, // NOLINT(cppcoreguidelines-avoid-c-arrays,hicpp-avoid-c-arrays,modernize-avoid-c-arrays)
4973 int > = 0 >
4974void to_json(BasicJsonType& j, const T(&arr)[N]) // NOLINT(cppcoreguidelines-avoid-c-arrays,hicpp-avoid-c-arrays,modernize-avoid-c-arrays)
4975{
4976 external_constructor<value_t::array>::construct(j, arr);
4977}
4978
4979template < typename BasicJsonType, typename T1, typename T2, enable_if_t < std::is_constructible<BasicJsonType, T1>::value&& std::is_constructible<BasicJsonType, T2>::value, int > = 0 >
4980void to_json(BasicJsonType& j, const std::pair<T1, T2>& p)
4981{
4982 j = { p.first, p.second };
4983}
4984
4985// for https://github.com/nlohmann/json/pull/1134
4986template<typename BasicJsonType, typename T,
4987 enable_if_t<std::is_same<T, iteration_proxy_value<typename BasicJsonType::iterator>>::value, int> = 0>
4988void to_json(BasicJsonType& j, const T& b)
4989{
4990 j = { {b.key(), b.value()} };
4991}
4992
4993template<typename BasicJsonType, typename Tuple, std::size_t... Idx>
4994void to_json_tuple_impl(BasicJsonType& j, const Tuple& t, index_sequence<Idx...> /*unused*/)
4995{
4996 j = { std::get<Idx>(t)... };
4997}
4998
4999template<typename BasicJsonType, typename T, enable_if_t<is_constructible_tuple<BasicJsonType, T>::value, int > = 0>
5000void to_json(BasicJsonType& j, const T& t)
5001{
5002 to_json_tuple_impl(j, t, make_index_sequence<std::tuple_size<T>::value> {});
5003}
5004
5005#ifdef JSON_HAS_CPP_17
5006template<typename BasicJsonType>
5007void to_json(BasicJsonType& j, const std::filesystem::path& p)
5008{
5009 j = p.string();
5010}
5011#endif
5012
5013struct to_json_fn
5014{
5015 template<typename BasicJsonType, typename T>
5016 auto operator()(BasicJsonType& j, T&& val) const noexcept(noexcept(to_json(j, std::forward<T>(val))))
5017 -> decltype(to_json(j, std::forward<T>(val)), void())
5018 {
5019 return to_json(j, std::forward<T>(val));
5020 }
5021};
5022} // namespace detail
5023
5027namespace // NOLINT(cert-dcl59-cpp,fuchsia-header-anon-namespaces,google-build-namespaces)
5028{
5029constexpr const auto& to_json = detail::static_const<detail::to_json_fn>::value; // NOLINT(misc-definitions-in-headers)
5030} // namespace
5031} // namespace nlohmann
5032
5033// #include <nlohmann/detail/meta/identity_tag.hpp>
5034
5035// #include <nlohmann/detail/meta/type_traits.hpp>
5036
5037
5038namespace nlohmann
5039{
5040
5041template<typename ValueType, typename>
5043{
5055 template<typename BasicJsonType, typename TargetType = ValueType>
5056 static auto from_json(BasicJsonType && j, TargetType& val) noexcept(
5057 noexcept(::nlohmann::from_json(std::forward<BasicJsonType>(j), val)))
5058 -> decltype(::nlohmann::from_json(std::forward<BasicJsonType>(j), val), void())
5059 {
5060 ::nlohmann::from_json(std::forward<BasicJsonType>(j), val);
5061 }
5062
5075 template<typename BasicJsonType, typename TargetType = ValueType>
5076 static auto from_json(BasicJsonType && j) noexcept(
5077 noexcept(::nlohmann::from_json(std::forward<BasicJsonType>(j), detail::identity_tag<TargetType> {})))
5078 -> decltype(::nlohmann::from_json(std::forward<BasicJsonType>(j), detail::identity_tag<TargetType> {}))
5079 {
5080 return ::nlohmann::from_json(std::forward<BasicJsonType>(j), detail::identity_tag<TargetType> {});
5081 }
5082
5092 template<typename BasicJsonType, typename TargetType = ValueType>
5093 static auto to_json(BasicJsonType& j, TargetType && val) noexcept(
5094 noexcept(::nlohmann::to_json(j, std::forward<TargetType>(val))))
5095 -> decltype(::nlohmann::to_json(j, std::forward<TargetType>(val)), void())
5096 {
5097 ::nlohmann::to_json(j, std::forward<TargetType>(val));
5098 }
5099};
5100} // namespace nlohmann
5101
5102// #include <nlohmann/byte_container_with_subtype.hpp>
5103
5104
5105#include <cstdint> // uint8_t, uint64_t
5106#include <tuple> // tie
5107#include <utility> // move
5108
5109namespace nlohmann
5110{
5111
5125template<typename BinaryType>
5126class byte_container_with_subtype : public BinaryType
5127{
5128 public:
5130 using container_type = BinaryType;
5132 using subtype_type = std::uint64_t;
5133
5135 : container_type()
5136 {}
5137
5139 : container_type(b)
5140 {}
5141
5142 byte_container_with_subtype(container_type&& b) noexcept(noexcept(container_type(std::move(b))))
5143 : container_type(std::move(b))
5144 {}
5145
5147 : container_type(b)
5148 , m_subtype(subtype_)
5149 , m_has_subtype(true)
5150 {}
5151
5152 byte_container_with_subtype(container_type&& b, subtype_type subtype_) noexcept(noexcept(container_type(std::move(b))))
5153 : container_type(std::move(b))
5154 , m_subtype(subtype_)
5155 , m_has_subtype(true)
5156 {}
5157
5159 {
5160 return std::tie(static_cast<const BinaryType&>(*this), m_subtype, m_has_subtype) ==
5161 std::tie(static_cast<const BinaryType&>(rhs), rhs.m_subtype, rhs.m_has_subtype);
5162 }
5163
5165 {
5166 return !(rhs == *this);
5167 }
5168
5187 void set_subtype(subtype_type subtype_) noexcept
5188 {
5189 m_subtype = subtype_;
5190 m_has_subtype = true;
5191 }
5192
5215 constexpr subtype_type subtype() const noexcept
5216 {
5217 return m_has_subtype ? m_subtype : subtype_type(-1);
5218 }
5219
5236 constexpr bool has_subtype() const noexcept
5237 {
5238 return m_has_subtype;
5239 }
5240
5260 void clear_subtype() noexcept
5261 {
5262 m_subtype = 0;
5263 m_has_subtype = false;
5264 }
5265
5266 private:
5267 subtype_type m_subtype = 0;
5268 bool m_has_subtype = false;
5269};
5270
5271} // namespace nlohmann
5272
5273// #include <nlohmann/detail/conversions/from_json.hpp>
5274
5275// #include <nlohmann/detail/conversions/to_json.hpp>
5276
5277// #include <nlohmann/detail/exceptions.hpp>
5278
5279// #include <nlohmann/detail/hash.hpp>
5280
5281
5282#include <cstdint> // uint8_t
5283#include <cstddef> // size_t
5284#include <functional> // hash
5285
5286// #include <nlohmann/detail/macro_scope.hpp>
5287
5288// #include <nlohmann/detail/value_t.hpp>
5289
5290
5291namespace nlohmann
5292{
5293namespace detail
5294{
5295
5296// boost::hash_combine
5297inline std::size_t combine(std::size_t seed, std::size_t h) noexcept
5298{
5299 seed ^= h + 0x9e3779b9 + (seed << 6U) + (seed >> 2U);
5300 return seed;
5301}
5302
5314template<typename BasicJsonType>
5315std::size_t hash(const BasicJsonType& j)
5316{
5317 using string_t = typename BasicJsonType::string_t;
5318 using number_integer_t = typename BasicJsonType::number_integer_t;
5319 using number_unsigned_t = typename BasicJsonType::number_unsigned_t;
5320 using number_float_t = typename BasicJsonType::number_float_t;
5321
5322 const auto type = static_cast<std::size_t>(j.type());
5323 switch (j.type())
5324 {
5325 case BasicJsonType::value_t::null:
5326 case BasicJsonType::value_t::discarded:
5327 {
5328 return combine(type, 0);
5329 }
5330
5331 case BasicJsonType::value_t::object:
5332 {
5333 auto seed = combine(type, j.size());
5334 for (const auto& element : j.items())
5335 {
5336 const auto h = std::hash<string_t> {}(element.key());
5337 seed = combine(seed, h);
5338 seed = combine(seed, hash(element.value()));
5339 }
5340 return seed;
5341 }
5342
5343 case BasicJsonType::value_t::array:
5344 {
5345 auto seed = combine(type, j.size());
5346 for (const auto& element : j)
5347 {
5348 seed = combine(seed, hash(element));
5349 }
5350 return seed;
5351 }
5352
5353 case BasicJsonType::value_t::string:
5354 {
5355 const auto h = std::hash<string_t> {}(j.template get_ref<const string_t&>());
5356 return combine(type, h);
5357 }
5358
5359 case BasicJsonType::value_t::boolean:
5360 {
5361 const auto h = std::hash<bool> {}(j.template get<bool>());
5362 return combine(type, h);
5363 }
5364
5365 case BasicJsonType::value_t::number_integer:
5366 {
5367 const auto h = std::hash<number_integer_t> {}(j.template get<number_integer_t>());
5368 return combine(type, h);
5369 }
5370
5371 case BasicJsonType::value_t::number_unsigned:
5372 {
5373 const auto h = std::hash<number_unsigned_t> {}(j.template get<number_unsigned_t>());
5374 return combine(type, h);
5375 }
5376
5377 case BasicJsonType::value_t::number_float:
5378 {
5379 const auto h = std::hash<number_float_t> {}(j.template get<number_float_t>());
5380 return combine(type, h);
5381 }
5382
5383 case BasicJsonType::value_t::binary:
5384 {
5385 auto seed = combine(type, j.get_binary().size());
5386 const auto h = std::hash<bool> {}(j.get_binary().has_subtype());
5387 seed = combine(seed, h);
5388 seed = combine(seed, static_cast<std::size_t>(j.get_binary().subtype()));
5389 for (const auto byte : j.get_binary())
5390 {
5391 seed = combine(seed, std::hash<std::uint8_t> {}(byte));
5392 }
5393 return seed;
5394 }
5395
5396 default: // LCOV_EXCL_LINE
5397 JSON_ASSERT(false); // NOLINT(cert-dcl03-c,hicpp-static-assert,misc-static-assert) LCOV_EXCL_LINE
5398 return 0; // LCOV_EXCL_LINE
5399 }
5400}
5401
5402} // namespace detail
5403} // namespace nlohmann
5404
5405// #include <nlohmann/detail/input/binary_reader.hpp>
5406
5407
5408#include <algorithm> // generate_n
5409#include <array> // array
5410#include <cmath> // ldexp
5411#include <cstddef> // size_t
5412#include <cstdint> // uint8_t, uint16_t, uint32_t, uint64_t
5413#include <cstdio> // snprintf
5414#include <cstring> // memcpy
5415#include <iterator> // back_inserter
5416#include <limits> // numeric_limits
5417#include <string> // char_traits, string
5418#include <utility> // make_pair, move
5419#include <vector> // vector
5420
5421// #include <nlohmann/detail/exceptions.hpp>
5422
5423// #include <nlohmann/detail/input/input_adapters.hpp>
5424
5425
5426#include <array> // array
5427#include <cstddef> // size_t
5428#include <cstring> // strlen
5429#include <iterator> // begin, end, iterator_traits, random_access_iterator_tag, distance, next
5430#include <memory> // shared_ptr, make_shared, addressof
5431#include <numeric> // accumulate
5432#include <string> // string, char_traits
5433#include <type_traits> // enable_if, is_base_of, is_pointer, is_integral, remove_pointer
5434#include <utility> // pair, declval
5435
5436#ifndef JSON_NO_IO
5437 #include <cstdio> // FILE *
5438 #include <istream> // istream
5439#endif // JSON_NO_IO
5440
5441// #include <nlohmann/detail/iterators/iterator_traits.hpp>
5442
5443// #include <nlohmann/detail/macro_scope.hpp>
5444
5445
5446namespace nlohmann
5447{
5448namespace detail
5449{
5451enum class input_format_t { json, cbor, msgpack, ubjson, bson };
5452
5454// input adapters //
5456
5457#ifndef JSON_NO_IO
5462class file_input_adapter
5463{
5464 public:
5465 using char_type = char;
5466
5467 JSON_HEDLEY_NON_NULL(2)
5468 explicit file_input_adapter(std::FILE* f) noexcept
5469 : m_file(f)
5470 {}
5471
5472 // make class move-only
5473 file_input_adapter(const file_input_adapter&) = delete;
5474 file_input_adapter(file_input_adapter&&) noexcept = default;
5475 file_input_adapter& operator=(const file_input_adapter&) = delete;
5476 file_input_adapter& operator=(file_input_adapter&&) = delete;
5477 ~file_input_adapter() = default;
5478
5479 std::char_traits<char>::int_type get_character() noexcept
5480 {
5481 return std::fgetc(m_file);
5482 }
5483
5484 private:
5486 std::FILE* m_file;
5487};
5488
5489
5499class input_stream_adapter
5500{
5501 public:
5502 using char_type = char;
5503
5504 ~input_stream_adapter()
5505 {
5506 // clear stream flags; we use underlying streambuf I/O, do not
5507 // maintain ifstream flags, except eof
5508 if (is != nullptr)
5509 {
5510 is->clear(is->rdstate() & std::ios::eofbit);
5511 }
5512 }
5513
5514 explicit input_stream_adapter(std::istream& i)
5515 : is(&i), sb(i.rdbuf())
5516 {}
5517
5518 // delete because of pointer members
5519 input_stream_adapter(const input_stream_adapter&) = delete;
5520 input_stream_adapter& operator=(input_stream_adapter&) = delete;
5521 input_stream_adapter& operator=(input_stream_adapter&&) = delete;
5522
5523 input_stream_adapter(input_stream_adapter&& rhs) noexcept
5524 : is(rhs.is), sb(rhs.sb)
5525 {
5526 rhs.is = nullptr;
5527 rhs.sb = nullptr;
5528 }
5529
5530 // std::istream/std::streambuf use std::char_traits<char>::to_int_type, to
5531 // ensure that std::char_traits<char>::eof() and the character 0xFF do not
5532 // end up as the same value, eg. 0xFFFFFFFF.
5533 std::char_traits<char>::int_type get_character()
5534 {
5535 auto res = sb->sbumpc();
5536 // set eof manually, as we don't use the istream interface.
5537 if (JSON_HEDLEY_UNLIKELY(res == std::char_traits<char>::eof()))
5538 {
5539 is->clear(is->rdstate() | std::ios::eofbit);
5540 }
5541 return res;
5542 }
5543
5544 private:
5546 std::istream* is = nullptr;
5547 std::streambuf* sb = nullptr;
5548};
5549#endif // JSON_NO_IO
5550
5551// General-purpose iterator-based adapter. It might not be as fast as
5552// theoretically possible for some containers, but it is extremely versatile.
5553template<typename IteratorType>
5554class iterator_input_adapter
5555{
5556 public:
5557 using char_type = typename std::iterator_traits<IteratorType>::value_type;
5558
5559 iterator_input_adapter(IteratorType first, IteratorType last)
5560 : current(std::move(first)), end(std::move(last))
5561 {}
5562
5563 typename std::char_traits<char_type>::int_type get_character()
5564 {
5565 if (JSON_HEDLEY_LIKELY(current != end))
5566 {
5567 auto result = std::char_traits<char_type>::to_int_type(*current);
5568 std::advance(current, 1);
5569 return result;
5570 }
5571
5572 return std::char_traits<char_type>::eof();
5573 }
5574
5575 private:
5576 IteratorType current;
5577 IteratorType end;
5578
5579 template<typename BaseInputAdapter, size_t T>
5580 friend struct wide_string_input_helper;
5581
5582 bool empty() const
5583 {
5584 return current == end;
5585 }
5586};
5587
5588
5589template<typename BaseInputAdapter, size_t T>
5590struct wide_string_input_helper;
5591
5592template<typename BaseInputAdapter>
5593struct wide_string_input_helper<BaseInputAdapter, 4>
5594{
5595 // UTF-32
5596 static void fill_buffer(BaseInputAdapter& input,
5597 std::array<std::char_traits<char>::int_type, 4>& utf8_bytes,
5598 size_t& utf8_bytes_index,
5599 size_t& utf8_bytes_filled)
5600 {
5601 utf8_bytes_index = 0;
5602
5603 if (JSON_HEDLEY_UNLIKELY(input.empty()))
5604 {
5605 utf8_bytes[0] = std::char_traits<char>::eof();
5606 utf8_bytes_filled = 1;
5607 }
5608 else
5609 {
5610 // get the current character
5611 const auto wc = input.get_character();
5612
5613 // UTF-32 to UTF-8 encoding
5614 if (wc < 0x80)
5615 {
5616 utf8_bytes[0] = static_cast<std::char_traits<char>::int_type>(wc);
5617 utf8_bytes_filled = 1;
5618 }
5619 else if (wc <= 0x7FF)
5620 {
5621 utf8_bytes[0] = static_cast<std::char_traits<char>::int_type>(0xC0u | ((static_cast<unsigned int>(wc) >> 6u) & 0x1Fu));
5622 utf8_bytes[1] = static_cast<std::char_traits<char>::int_type>(0x80u | (static_cast<unsigned int>(wc) & 0x3Fu));
5623 utf8_bytes_filled = 2;
5624 }
5625 else if (wc <= 0xFFFF)
5626 {
5627 utf8_bytes[0] = static_cast<std::char_traits<char>::int_type>(0xE0u | ((static_cast<unsigned int>(wc) >> 12u) & 0x0Fu));
5628 utf8_bytes[1] = static_cast<std::char_traits<char>::int_type>(0x80u | ((static_cast<unsigned int>(wc) >> 6u) & 0x3Fu));
5629 utf8_bytes[2] = static_cast<std::char_traits<char>::int_type>(0x80u | (static_cast<unsigned int>(wc) & 0x3Fu));
5630 utf8_bytes_filled = 3;
5631 }
5632 else if (wc <= 0x10FFFF)
5633 {
5634 utf8_bytes[0] = static_cast<std::char_traits<char>::int_type>(0xF0u | ((static_cast<unsigned int>(wc) >> 18u) & 0x07u));
5635 utf8_bytes[1] = static_cast<std::char_traits<char>::int_type>(0x80u | ((static_cast<unsigned int>(wc) >> 12u) & 0x3Fu));
5636 utf8_bytes[2] = static_cast<std::char_traits<char>::int_type>(0x80u | ((static_cast<unsigned int>(wc) >> 6u) & 0x3Fu));
5637 utf8_bytes[3] = static_cast<std::char_traits<char>::int_type>(0x80u | (static_cast<unsigned int>(wc) & 0x3Fu));
5638 utf8_bytes_filled = 4;
5639 }
5640 else
5641 {
5642 // unknown character
5643 utf8_bytes[0] = static_cast<std::char_traits<char>::int_type>(wc);
5644 utf8_bytes_filled = 1;
5645 }
5646 }
5647 }
5648};
5649
5650template<typename BaseInputAdapter>
5651struct wide_string_input_helper<BaseInputAdapter, 2>
5652{
5653 // UTF-16
5654 static void fill_buffer(BaseInputAdapter& input,
5655 std::array<std::char_traits<char>::int_type, 4>& utf8_bytes,
5656 size_t& utf8_bytes_index,
5657 size_t& utf8_bytes_filled)
5658 {
5659 utf8_bytes_index = 0;
5660
5661 if (JSON_HEDLEY_UNLIKELY(input.empty()))
5662 {
5663 utf8_bytes[0] = std::char_traits<char>::eof();
5664 utf8_bytes_filled = 1;
5665 }
5666 else
5667 {
5668 // get the current character
5669 const auto wc = input.get_character();
5670
5671 // UTF-16 to UTF-8 encoding
5672 if (wc < 0x80)
5673 {
5674 utf8_bytes[0] = static_cast<std::char_traits<char>::int_type>(wc);
5675 utf8_bytes_filled = 1;
5676 }
5677 else if (wc <= 0x7FF)
5678 {
5679 utf8_bytes[0] = static_cast<std::char_traits<char>::int_type>(0xC0u | ((static_cast<unsigned int>(wc) >> 6u)));
5680 utf8_bytes[1] = static_cast<std::char_traits<char>::int_type>(0x80u | (static_cast<unsigned int>(wc) & 0x3Fu));
5681 utf8_bytes_filled = 2;
5682 }
5683 else if (0xD800 > wc || wc >= 0xE000)
5684 {
5685 utf8_bytes[0] = static_cast<std::char_traits<char>::int_type>(0xE0u | ((static_cast<unsigned int>(wc) >> 12u)));
5686 utf8_bytes[1] = static_cast<std::char_traits<char>::int_type>(0x80u | ((static_cast<unsigned int>(wc) >> 6u) & 0x3Fu));
5687 utf8_bytes[2] = static_cast<std::char_traits<char>::int_type>(0x80u | (static_cast<unsigned int>(wc) & 0x3Fu));
5688 utf8_bytes_filled = 3;
5689 }
5690 else
5691 {
5692 if (JSON_HEDLEY_UNLIKELY(!input.empty()))
5693 {
5694 const auto wc2 = static_cast<unsigned int>(input.get_character());
5695 const auto charcode = 0x10000u + (((static_cast<unsigned int>(wc) & 0x3FFu) << 10u) | (wc2 & 0x3FFu));
5696 utf8_bytes[0] = static_cast<std::char_traits<char>::int_type>(0xF0u | (charcode >> 18u));
5697 utf8_bytes[1] = static_cast<std::char_traits<char>::int_type>(0x80u | ((charcode >> 12u) & 0x3Fu));
5698 utf8_bytes[2] = static_cast<std::char_traits<char>::int_type>(0x80u | ((charcode >> 6u) & 0x3Fu));
5699 utf8_bytes[3] = static_cast<std::char_traits<char>::int_type>(0x80u | (charcode & 0x3Fu));
5700 utf8_bytes_filled = 4;
5701 }
5702 else
5703 {
5704 utf8_bytes[0] = static_cast<std::char_traits<char>::int_type>(wc);
5705 utf8_bytes_filled = 1;
5706 }
5707 }
5708 }
5709 }
5710};
5711
5712// Wraps another input apdater to convert wide character types into individual bytes.
5713template<typename BaseInputAdapter, typename WideCharType>
5714class wide_string_input_adapter
5715{
5716 public:
5717 using char_type = char;
5718
5719 wide_string_input_adapter(BaseInputAdapter base)
5720 : base_adapter(base) {}
5721
5722 typename std::char_traits<char>::int_type get_character() noexcept
5723 {
5724 // check if buffer needs to be filled
5725 if (utf8_bytes_index == utf8_bytes_filled)
5726 {
5727 fill_buffer<sizeof(WideCharType)>();
5728
5729 JSON_ASSERT(utf8_bytes_filled > 0);
5730 JSON_ASSERT(utf8_bytes_index == 0);
5731 }
5732
5733 // use buffer
5734 JSON_ASSERT(utf8_bytes_filled > 0);
5735 JSON_ASSERT(utf8_bytes_index < utf8_bytes_filled);
5736 return utf8_bytes[utf8_bytes_index++];
5737 }
5738
5739 private:
5740 BaseInputAdapter base_adapter;
5741
5742 template<size_t T>
5743 void fill_buffer()
5744 {
5745 wide_string_input_helper<BaseInputAdapter, T>::fill_buffer(base_adapter, utf8_bytes, utf8_bytes_index, utf8_bytes_filled);
5746 }
5747
5749 std::array<std::char_traits<char>::int_type, 4> utf8_bytes = {{0, 0, 0, 0}};
5750
5752 std::size_t utf8_bytes_index = 0;
5754 std::size_t utf8_bytes_filled = 0;
5755};
5756
5757
5758template<typename IteratorType, typename Enable = void>
5759struct iterator_input_adapter_factory
5760{
5761 using iterator_type = IteratorType;
5762 using char_type = typename std::iterator_traits<iterator_type>::value_type;
5763 using adapter_type = iterator_input_adapter<iterator_type>;
5764
5765 static adapter_type create(IteratorType first, IteratorType last)
5766 {
5767 return adapter_type(std::move(first), std::move(last));
5768 }
5769};
5770
5771template<typename T>
5772struct is_iterator_of_multibyte
5773{
5774 using value_type = typename std::iterator_traits<T>::value_type;
5775 enum
5776 {
5777 value = sizeof(value_type) > 1
5778 };
5779};
5780
5781template<typename IteratorType>
5782struct iterator_input_adapter_factory<IteratorType, enable_if_t<is_iterator_of_multibyte<IteratorType>::value>>
5783{
5784 using iterator_type = IteratorType;
5785 using char_type = typename std::iterator_traits<iterator_type>::value_type;
5786 using base_adapter_type = iterator_input_adapter<iterator_type>;
5787 using adapter_type = wide_string_input_adapter<base_adapter_type, char_type>;
5788
5789 static adapter_type create(IteratorType first, IteratorType last)
5790 {
5791 return adapter_type(base_adapter_type(std::move(first), std::move(last)));
5792 }
5793};
5794
5795// General purpose iterator-based input
5796template<typename IteratorType>
5797typename iterator_input_adapter_factory<IteratorType>::adapter_type input_adapter(IteratorType first, IteratorType last)
5798{
5799 using factory_type = iterator_input_adapter_factory<IteratorType>;
5800 return factory_type::create(first, last);
5801}
5802
5803// Convenience shorthand from container to iterator
5804// Enables ADL on begin(container) and end(container)
5805// Encloses the using declarations in namespace for not to leak them to outside scope
5806
5807namespace container_input_adapter_factory_impl
5808{
5809
5810using std::begin;
5811using std::end;
5812
5813template<typename ContainerType, typename Enable = void>
5814struct container_input_adapter_factory {};
5815
5816template<typename ContainerType>
5817struct container_input_adapter_factory< ContainerType,
5818 void_t<decltype(begin(std::declval<ContainerType>()), end(std::declval<ContainerType>()))>>
5819 {
5820 using adapter_type = decltype(input_adapter(begin(std::declval<ContainerType>()), end(std::declval<ContainerType>())));
5821
5822 static adapter_type create(const ContainerType& container)
5823{
5824 return input_adapter(begin(container), end(container));
5825}
5826 };
5827
5828} // namespace container_input_adapter_factory_impl
5829
5830template<typename ContainerType>
5831typename container_input_adapter_factory_impl::container_input_adapter_factory<ContainerType>::adapter_type input_adapter(const ContainerType& container)
5832{
5833 return container_input_adapter_factory_impl::container_input_adapter_factory<ContainerType>::create(container);
5834}
5835
5836#ifndef JSON_NO_IO
5837// Special cases with fast paths
5838inline file_input_adapter input_adapter(std::FILE* file)
5839{
5840 return file_input_adapter(file);
5841}
5842
5843inline input_stream_adapter input_adapter(std::istream& stream)
5844{
5845 return input_stream_adapter(stream);
5846}
5847
5848inline input_stream_adapter input_adapter(std::istream&& stream)
5849{
5850 return input_stream_adapter(stream);
5851}
5852#endif // JSON_NO_IO
5853
5854using contiguous_bytes_input_adapter = decltype(input_adapter(std::declval<const char*>(), std::declval<const char*>()));
5855
5856// Null-delimited strings, and the like.
5857template < typename CharT,
5858 typename std::enable_if <
5859 std::is_pointer<CharT>::value&&
5860 !std::is_array<CharT>::value&&
5861 std::is_integral<typename std::remove_pointer<CharT>::type>::value&&
5862 sizeof(typename std::remove_pointer<CharT>::type) == 1,
5863 int >::type = 0 >
5864contiguous_bytes_input_adapter input_adapter(CharT b)
5865{
5866 auto length = std::strlen(reinterpret_cast<const char*>(b));
5867 const auto* ptr = reinterpret_cast<const char*>(b);
5868 return input_adapter(ptr, ptr + length);
5869}
5870
5871template<typename T, std::size_t N>
5872auto input_adapter(T (&array)[N]) -> decltype(input_adapter(array, array + N)) // NOLINT(cppcoreguidelines-avoid-c-arrays,hicpp-avoid-c-arrays,modernize-avoid-c-arrays)
5873{
5874 return input_adapter(array, array + N);
5875}
5876
5877// This class only handles inputs of input_buffer_adapter type.
5878// It's required so that expressions like {ptr, len} can be implicitely casted
5879// to the correct adapter.
5880class span_input_adapter
5881{
5882 public:
5883 template < typename CharT,
5884 typename std::enable_if <
5885 std::is_pointer<CharT>::value&&
5886 std::is_integral<typename std::remove_pointer<CharT>::type>::value&&
5887 sizeof(typename std::remove_pointer<CharT>::type) == 1,
5888 int >::type = 0 >
5889 span_input_adapter(CharT b, std::size_t l)
5890 : ia(reinterpret_cast<const char*>(b), reinterpret_cast<const char*>(b) + l) {}
5891
5892 template<class IteratorType,
5893 typename std::enable_if<
5894 std::is_same<typename iterator_traits<IteratorType>::iterator_category, std::random_access_iterator_tag>::value,
5895 int>::type = 0>
5896 span_input_adapter(IteratorType first, IteratorType last)
5897 : ia(input_adapter(first, last)) {}
5898
5899 contiguous_bytes_input_adapter&& get()
5900 {
5901 return std::move(ia); // NOLINT(hicpp-move-const-arg,performance-move-const-arg)
5902 }
5903
5904 private:
5905 contiguous_bytes_input_adapter ia;
5906};
5907} // namespace detail
5908} // namespace nlohmann
5909
5910// #include <nlohmann/detail/input/json_sax.hpp>
5911
5912
5913#include <cstddef>
5914#include <string> // string
5915#include <utility> // move
5916#include <vector> // vector
5917
5918// #include <nlohmann/detail/exceptions.hpp>
5919
5920// #include <nlohmann/detail/macro_scope.hpp>
5921
5922
5923namespace nlohmann
5924{
5925
5934template<typename BasicJsonType>
5936{
5937 using number_integer_t = typename BasicJsonType::number_integer_t;
5938 using number_unsigned_t = typename BasicJsonType::number_unsigned_t;
5939 using number_float_t = typename BasicJsonType::number_float_t;
5940 using string_t = typename BasicJsonType::string_t;
5941 using binary_t = typename BasicJsonType::binary_t;
5942
5947 virtual bool null() = 0;
5948
5954 virtual bool boolean(bool val) = 0;
5955
5961 virtual bool number_integer(number_integer_t val) = 0;
5962
5968 virtual bool number_unsigned(number_unsigned_t val) = 0;
5969
5976 virtual bool number_float(number_float_t val, const string_t& s) = 0;
5977
5984 virtual bool string(string_t& val) = 0;
5985
5992 virtual bool binary(binary_t& val) = 0;
5993
6000 virtual bool start_object(std::size_t elements) = 0;
6001
6008 virtual bool key(string_t& val) = 0;
6009
6014 virtual bool end_object() = 0;
6015
6022 virtual bool start_array(std::size_t elements) = 0;
6023
6028 virtual bool end_array() = 0;
6029
6037 virtual bool parse_error(std::size_t position,
6038 const std::string& last_token,
6039 const detail::exception& ex) = 0;
6040
6041 json_sax() = default;
6042 json_sax(const json_sax&) = default;
6043 json_sax(json_sax&&) noexcept = default;
6044 json_sax& operator=(const json_sax&) = default;
6045 json_sax& operator=(json_sax&&) noexcept = default;
6046 virtual ~json_sax() = default;
6047};
6048
6049
6050namespace detail
6051{
6065template<typename BasicJsonType>
6066class json_sax_dom_parser
6067{
6068 public:
6069 using number_integer_t = typename BasicJsonType::number_integer_t;
6070 using number_unsigned_t = typename BasicJsonType::number_unsigned_t;
6071 using number_float_t = typename BasicJsonType::number_float_t;
6072 using string_t = typename BasicJsonType::string_t;
6073 using binary_t = typename BasicJsonType::binary_t;
6074
6080 explicit json_sax_dom_parser(BasicJsonType& r, const bool allow_exceptions_ = true)
6081 : root(r), allow_exceptions(allow_exceptions_)
6082 {}
6083
6084 // make class move-only
6085 json_sax_dom_parser(const json_sax_dom_parser&) = delete;
6086 json_sax_dom_parser(json_sax_dom_parser&&) = default; // NOLINT(hicpp-noexcept-move,performance-noexcept-move-constructor)
6087 json_sax_dom_parser& operator=(const json_sax_dom_parser&) = delete;
6088 json_sax_dom_parser& operator=(json_sax_dom_parser&&) = default; // NOLINT(hicpp-noexcept-move,performance-noexcept-move-constructor)
6089 ~json_sax_dom_parser() = default;
6090
6091 bool null()
6092 {
6093 handle_value(nullptr);
6094 return true;
6095 }
6096
6097 bool boolean(bool val)
6098 {
6099 handle_value(val);
6100 return true;
6101 }
6102
6104 {
6105 handle_value(val);
6106 return true;
6107 }
6108
6110 {
6111 handle_value(val);
6112 return true;
6113 }
6114
6115 bool number_float(number_float_t val, const string_t& /*unused*/)
6116 {
6117 handle_value(val);
6118 return true;
6119 }
6120
6121 bool string(string_t& val)
6122 {
6123 handle_value(val);
6124 return true;
6125 }
6126
6127 bool binary(binary_t& val)
6128 {
6129 handle_value(std::move(val));
6130 return true;
6131 }
6132
6133 bool start_object(std::size_t len)
6134 {
6135 ref_stack.push_back(handle_value(BasicJsonType::value_t::object));
6136
6137 if (JSON_HEDLEY_UNLIKELY(len != std::size_t(-1) && len > ref_stack.back()->max_size()))
6138 {
6139 JSON_THROW(out_of_range::create(408, "excessive object size: " + std::to_string(len), *ref_stack.back()));
6140 }
6141
6142 return true;
6143 }
6144
6145 bool key(string_t& val)
6146 {
6147 // add null at given key and store the reference for later
6148 object_element = &(ref_stack.back()->m_value.object->operator[](val));
6149 return true;
6150 }
6151
6152 bool end_object()
6153 {
6154 ref_stack.back()->set_parents();
6155 ref_stack.pop_back();
6156 return true;
6157 }
6158
6159 bool start_array(std::size_t len)
6160 {
6161 ref_stack.push_back(handle_value(BasicJsonType::value_t::array));
6162
6163 if (JSON_HEDLEY_UNLIKELY(len != std::size_t(-1) && len > ref_stack.back()->max_size()))
6164 {
6165 JSON_THROW(out_of_range::create(408, "excessive array size: " + std::to_string(len), *ref_stack.back()));
6166 }
6167
6168 return true;
6169 }
6170
6171 bool end_array()
6172 {
6173 ref_stack.back()->set_parents();
6174 ref_stack.pop_back();
6175 return true;
6176 }
6177
6178 template<class Exception>
6179 bool parse_error(std::size_t /*unused*/, const std::string& /*unused*/,
6180 const Exception& ex)
6181 {
6182 errored = true;
6183 static_cast<void>(ex);
6184 if (allow_exceptions)
6185 {
6186 JSON_THROW(ex);
6187 }
6188 return false;
6189 }
6190
6191 constexpr bool is_errored() const
6192 {
6193 return errored;
6194 }
6195
6196 private:
6203 template<typename Value>
6204
6205 BasicJsonType* handle_value(Value&& v)
6206 {
6207 if (ref_stack.empty())
6208 {
6209 root = BasicJsonType(std::forward<Value>(v));
6210 return &root;
6211 }
6212
6213 JSON_ASSERT(ref_stack.back()->is_array() || ref_stack.back()->is_object());
6214
6215 if (ref_stack.back()->is_array())
6216 {
6217 ref_stack.back()->m_value.array->emplace_back(std::forward<Value>(v));
6218 return &(ref_stack.back()->m_value.array->back());
6219 }
6220
6221 JSON_ASSERT(ref_stack.back()->is_object());
6222 JSON_ASSERT(object_element);
6223 *object_element = BasicJsonType(std::forward<Value>(v));
6224 return object_element;
6225 }
6226
6228 BasicJsonType& root;
6230 std::vector<BasicJsonType*> ref_stack {};
6232 BasicJsonType* object_element = nullptr;
6234 bool errored = false;
6236 const bool allow_exceptions = true;
6237};
6238
6239template<typename BasicJsonType>
6240class json_sax_dom_callback_parser
6241{
6242 public:
6243 using number_integer_t = typename BasicJsonType::number_integer_t;
6244 using number_unsigned_t = typename BasicJsonType::number_unsigned_t;
6245 using number_float_t = typename BasicJsonType::number_float_t;
6246 using string_t = typename BasicJsonType::string_t;
6247 using binary_t = typename BasicJsonType::binary_t;
6248 using parser_callback_t = typename BasicJsonType::parser_callback_t;
6249 using parse_event_t = typename BasicJsonType::parse_event_t;
6250
6251 json_sax_dom_callback_parser(BasicJsonType& r,
6252 const parser_callback_t cb,
6253 const bool allow_exceptions_ = true)
6254 : root(r), callback(cb), allow_exceptions(allow_exceptions_)
6255 {
6256 keep_stack.push_back(true);
6257 }
6258
6259 // make class move-only
6260 json_sax_dom_callback_parser(const json_sax_dom_callback_parser&) = delete;
6261 json_sax_dom_callback_parser(json_sax_dom_callback_parser&&) = default; // NOLINT(hicpp-noexcept-move,performance-noexcept-move-constructor)
6262 json_sax_dom_callback_parser& operator=(const json_sax_dom_callback_parser&) = delete;
6263 json_sax_dom_callback_parser& operator=(json_sax_dom_callback_parser&&) = default; // NOLINT(hicpp-noexcept-move,performance-noexcept-move-constructor)
6264 ~json_sax_dom_callback_parser() = default;
6265
6266 bool null()
6267 {
6268 handle_value(nullptr);
6269 return true;
6270 }
6271
6272 bool boolean(bool val)
6273 {
6274 handle_value(val);
6275 return true;
6276 }
6277
6279 {
6280 handle_value(val);
6281 return true;
6282 }
6283
6285 {
6286 handle_value(val);
6287 return true;
6288 }
6289
6290 bool number_float(number_float_t val, const string_t& /*unused*/)
6291 {
6292 handle_value(val);
6293 return true;
6294 }
6295
6296 bool string(string_t& val)
6297 {
6298 handle_value(val);
6299 return true;
6300 }
6301
6302 bool binary(binary_t& val)
6303 {
6304 handle_value(std::move(val));
6305 return true;
6306 }
6307
6308 bool start_object(std::size_t len)
6309 {
6310 // check callback for object start
6311 const bool keep = callback(static_cast<int>(ref_stack.size()), parse_event_t::object_start, discarded);
6312 keep_stack.push_back(keep);
6313
6314 auto val = handle_value(BasicJsonType::value_t::object, true);
6315 ref_stack.push_back(val.second);
6316
6317 // check object limit
6318 if (ref_stack.back() && JSON_HEDLEY_UNLIKELY(len != std::size_t(-1) && len > ref_stack.back()->max_size()))
6319 {
6320 JSON_THROW(out_of_range::create(408, "excessive object size: " + std::to_string(len), *ref_stack.back()));
6321 }
6322
6323 return true;
6324 }
6325
6326 bool key(string_t& val)
6327 {
6328 BasicJsonType k = BasicJsonType(val);
6329
6330 // check callback for key
6331 const bool keep = callback(static_cast<int>(ref_stack.size()), parse_event_t::key, k);
6332 key_keep_stack.push_back(keep);
6333
6334 // add discarded value at given key and store the reference for later
6335 if (keep && ref_stack.back())
6336 {
6337 object_element = &(ref_stack.back()->m_value.object->operator[](val) = discarded);
6338 }
6339
6340 return true;
6341 }
6342
6343 bool end_object()
6344 {
6345 if (ref_stack.back())
6346 {
6347 if (!callback(static_cast<int>(ref_stack.size()) - 1, parse_event_t::object_end, *ref_stack.back()))
6348 {
6349 // discard object
6350 *ref_stack.back() = discarded;
6351 }
6352 else
6353 {
6354 ref_stack.back()->set_parents();
6355 }
6356 }
6357
6358 JSON_ASSERT(!ref_stack.empty());
6359 JSON_ASSERT(!keep_stack.empty());
6360 ref_stack.pop_back();
6361 keep_stack.pop_back();
6362
6363 if (!ref_stack.empty() && ref_stack.back() && ref_stack.back()->is_structured())
6364 {
6365 // remove discarded value
6366 for (auto it = ref_stack.back()->begin(); it != ref_stack.back()->end(); ++it)
6367 {
6368 if (it->is_discarded())
6369 {
6370 ref_stack.back()->erase(it);
6371 break;
6372 }
6373 }
6374 }
6375
6376 return true;
6377 }
6378
6379 bool start_array(std::size_t len)
6380 {
6381 const bool keep = callback(static_cast<int>(ref_stack.size()), parse_event_t::array_start, discarded);
6382 keep_stack.push_back(keep);
6383
6384 auto val = handle_value(BasicJsonType::value_t::array, true);
6385 ref_stack.push_back(val.second);
6386
6387 // check array limit
6388 if (ref_stack.back() && JSON_HEDLEY_UNLIKELY(len != std::size_t(-1) && len > ref_stack.back()->max_size()))
6389 {
6390 JSON_THROW(out_of_range::create(408, "excessive array size: " + std::to_string(len), *ref_stack.back()));
6391 }
6392
6393 return true;
6394 }
6395
6396 bool end_array()
6397 {
6398 bool keep = true;
6399
6400 if (ref_stack.back())
6401 {
6402 keep = callback(static_cast<int>(ref_stack.size()) - 1, parse_event_t::array_end, *ref_stack.back());
6403 if (keep)
6404 {
6405 ref_stack.back()->set_parents();
6406 }
6407 else
6408 {
6409 // discard array
6410 *ref_stack.back() = discarded;
6411 }
6412 }
6413
6414 JSON_ASSERT(!ref_stack.empty());
6415 JSON_ASSERT(!keep_stack.empty());
6416 ref_stack.pop_back();
6417 keep_stack.pop_back();
6418
6419 // remove discarded value
6420 if (!keep && !ref_stack.empty() && ref_stack.back()->is_array())
6421 {
6422 ref_stack.back()->m_value.array->pop_back();
6423 }
6424
6425 return true;
6426 }
6427
6428 template<class Exception>
6429 bool parse_error(std::size_t /*unused*/, const std::string& /*unused*/,
6430 const Exception& ex)
6431 {
6432 errored = true;
6433 static_cast<void>(ex);
6434 if (allow_exceptions)
6435 {
6436 JSON_THROW(ex);
6437 }
6438 return false;
6439 }
6440
6441 constexpr bool is_errored() const
6442 {
6443 return errored;
6444 }
6445
6446 private:
6462 template<typename Value>
6463 std::pair<bool, BasicJsonType*> handle_value(Value&& v, const bool skip_callback = false)
6464 {
6465 JSON_ASSERT(!keep_stack.empty());
6466
6467 // do not handle this value if we know it would be added to a discarded
6468 // container
6469 if (!keep_stack.back())
6470 {
6471 return {false, nullptr};
6472 }
6473
6474 // create value
6475 auto value = BasicJsonType(std::forward<Value>(v));
6476
6477 // check callback
6478 const bool keep = skip_callback || callback(static_cast<int>(ref_stack.size()), parse_event_t::value, value);
6479
6480 // do not handle this value if we just learnt it shall be discarded
6481 if (!keep)
6482 {
6483 return {false, nullptr};
6484 }
6485
6486 if (ref_stack.empty())
6487 {
6488 root = std::move(value);
6489 return {true, &root};
6490 }
6491
6492 // skip this value if we already decided to skip the parent
6493 // (https://github.com/nlohmann/json/issues/971#issuecomment-413678360)
6494 if (!ref_stack.back())
6495 {
6496 return {false, nullptr};
6497 }
6498
6499 // we now only expect arrays and objects
6500 JSON_ASSERT(ref_stack.back()->is_array() || ref_stack.back()->is_object());
6501
6502 // array
6503 if (ref_stack.back()->is_array())
6504 {
6505 ref_stack.back()->m_value.array->emplace_back(std::move(value));
6506 return {true, &(ref_stack.back()->m_value.array->back())};
6507 }
6508
6509 // object
6510 JSON_ASSERT(ref_stack.back()->is_object());
6511 // check if we should store an element for the current key
6512 JSON_ASSERT(!key_keep_stack.empty());
6513 const bool store_element = key_keep_stack.back();
6514 key_keep_stack.pop_back();
6515
6516 if (!store_element)
6517 {
6518 return {false, nullptr};
6519 }
6520
6521 JSON_ASSERT(object_element);
6522 *object_element = std::move(value);
6523 return {true, object_element};
6524 }
6525
6527 BasicJsonType& root;
6529 std::vector<BasicJsonType*> ref_stack {};
6531 std::vector<bool> keep_stack {};
6533 std::vector<bool> key_keep_stack {};
6535 BasicJsonType* object_element = nullptr;
6537 bool errored = false;
6539 const parser_callback_t callback = nullptr;
6541 const bool allow_exceptions = true;
6543 BasicJsonType discarded = BasicJsonType::value_t::discarded;
6544};
6545
6546template<typename BasicJsonType>
6547class json_sax_acceptor
6548{
6549 public:
6550 using number_integer_t = typename BasicJsonType::number_integer_t;
6551 using number_unsigned_t = typename BasicJsonType::number_unsigned_t;
6552 using number_float_t = typename BasicJsonType::number_float_t;
6553 using string_t = typename BasicJsonType::string_t;
6554 using binary_t = typename BasicJsonType::binary_t;
6555
6556 bool null()
6557 {
6558 return true;
6559 }
6560
6561 bool boolean(bool /*unused*/)
6562 {
6563 return true;
6564 }
6565
6566 bool number_integer(number_integer_t /*unused*/)
6567 {
6568 return true;
6569 }
6570
6571 bool number_unsigned(number_unsigned_t /*unused*/)
6572 {
6573 return true;
6574 }
6575
6576 bool number_float(number_float_t /*unused*/, const string_t& /*unused*/)
6577 {
6578 return true;
6579 }
6580
6581 bool string(string_t& /*unused*/)
6582 {
6583 return true;
6584 }
6585
6586 bool binary(binary_t& /*unused*/)
6587 {
6588 return true;
6589 }
6590
6591 bool start_object(std::size_t /*unused*/ = std::size_t(-1))
6592 {
6593 return true;
6594 }
6595
6596 bool key(string_t& /*unused*/)
6597 {
6598 return true;
6599 }
6600
6601 bool end_object()
6602 {
6603 return true;
6604 }
6605
6606 bool start_array(std::size_t /*unused*/ = std::size_t(-1))
6607 {
6608 return true;
6609 }
6610
6611 bool end_array()
6612 {
6613 return true;
6614 }
6615
6616 bool parse_error(std::size_t /*unused*/, const std::string& /*unused*/, const detail::exception& /*unused*/)
6617 {
6618 return false;
6619 }
6620};
6621} // namespace detail
6622
6623} // namespace nlohmann
6624
6625// #include <nlohmann/detail/input/lexer.hpp>
6626
6627
6628#include <array> // array
6629#include <clocale> // localeconv
6630#include <cstddef> // size_t
6631#include <cstdio> // snprintf
6632#include <cstdlib> // strtof, strtod, strtold, strtoll, strtoull
6633#include <initializer_list> // initializer_list
6634#include <string> // char_traits, string
6635#include <utility> // move
6636#include <vector> // vector
6637
6638// #include <nlohmann/detail/input/input_adapters.hpp>
6639
6640// #include <nlohmann/detail/input/position_t.hpp>
6641
6642// #include <nlohmann/detail/macro_scope.hpp>
6643
6644
6645namespace nlohmann
6646{
6647namespace detail
6648{
6650// lexer //
6652
6653template<typename BasicJsonType>
6654class lexer_base
6655{
6656 public:
6658 enum class token_type
6659 {
6660 uninitialized,
6661 literal_true,
6662 literal_false,
6663 literal_null,
6664 value_string,
6665 value_unsigned,
6666 value_integer,
6667 value_float,
6668 begin_array,
6669 begin_object,
6670 end_array,
6671 end_object,
6672 name_separator,
6673 value_separator,
6674 parse_error,
6675 end_of_input,
6676 literal_or_value
6677 };
6678
6680
6681 JSON_HEDLEY_CONST
6682 static const char* token_type_name(const token_type t) noexcept
6683 {
6684 switch (t)
6685 {
6686 case token_type::uninitialized:
6687 return "<uninitialized>";
6688 case token_type::literal_true:
6689 return "true literal";
6690 case token_type::literal_false:
6691 return "false literal";
6692 case token_type::literal_null:
6693 return "null literal";
6694 case token_type::value_string:
6695 return "string literal";
6696 case token_type::value_unsigned:
6697 case token_type::value_integer:
6698 case token_type::value_float:
6699 return "number literal";
6700 case token_type::begin_array:
6701 return "'['";
6702 case token_type::begin_object:
6703 return "'{'";
6704 case token_type::end_array:
6705 return "']'";
6706 case token_type::end_object:
6707 return "'}'";
6708 case token_type::name_separator:
6709 return "':'";
6710 case token_type::value_separator:
6711 return "','";
6712 case token_type::parse_error:
6713 return "<parse error>";
6714 case token_type::end_of_input:
6715 return "end of input";
6716 case token_type::literal_or_value:
6717 return "'[', '{', or a literal";
6718 // LCOV_EXCL_START
6719 default: // catch non-enum values
6720 return "unknown token";
6721 // LCOV_EXCL_STOP
6722 }
6723 }
6724};
6730template<typename BasicJsonType, typename InputAdapterType>
6731class lexer : public lexer_base<BasicJsonType>
6732{
6733 using number_integer_t = typename BasicJsonType::number_integer_t;
6734 using number_unsigned_t = typename BasicJsonType::number_unsigned_t;
6735 using number_float_t = typename BasicJsonType::number_float_t;
6736 using string_t = typename BasicJsonType::string_t;
6737 using char_type = typename InputAdapterType::char_type;
6738 using char_int_type = typename std::char_traits<char_type>::int_type;
6739
6740 public:
6741 using token_type = typename lexer_base<BasicJsonType>::token_type;
6742
6743 explicit lexer(InputAdapterType&& adapter, bool ignore_comments_ = false) noexcept
6744 : ia(std::move(adapter))
6745 , ignore_comments(ignore_comments_)
6746 , decimal_point_char(static_cast<char_int_type>(get_decimal_point()))
6747 {}
6748
6749 // delete because of pointer members
6750 lexer(const lexer&) = delete;
6751 lexer(lexer&&) = default; // NOLINT(hicpp-noexcept-move,performance-noexcept-move-constructor)
6752 lexer& operator=(lexer&) = delete;
6753 lexer& operator=(lexer&&) = default; // NOLINT(hicpp-noexcept-move,performance-noexcept-move-constructor)
6754 ~lexer() = default;
6755
6756 private:
6758 // locales
6760
6762 JSON_HEDLEY_PURE
6763 static char get_decimal_point() noexcept
6764 {
6765 const auto* loc = localeconv();
6766 JSON_ASSERT(loc != nullptr);
6767 return (loc->decimal_point == nullptr) ? '.' : *(loc->decimal_point);
6768 }
6769
6771 // scan functions
6773
6789 int get_codepoint()
6790 {
6791 // this function only makes sense after reading `\u`
6792 JSON_ASSERT(current == 'u');
6793 int codepoint = 0;
6794
6795 const auto factors = { 12u, 8u, 4u, 0u };
6796 for (const auto factor : factors)
6797 {
6798 get();
6799
6800 if (current >= '0' && current <= '9')
6801 {
6802 codepoint += static_cast<int>((static_cast<unsigned int>(current) - 0x30u) << factor);
6803 }
6804 else if (current >= 'A' && current <= 'F')
6805 {
6806 codepoint += static_cast<int>((static_cast<unsigned int>(current) - 0x37u) << factor);
6807 }
6808 else if (current >= 'a' && current <= 'f')
6809 {
6810 codepoint += static_cast<int>((static_cast<unsigned int>(current) - 0x57u) << factor);
6811 }
6812 else
6813 {
6814 return -1;
6815 }
6816 }
6817
6818 JSON_ASSERT(0x0000 <= codepoint && codepoint <= 0xFFFF);
6819 return codepoint;
6820 }
6821
6837 bool next_byte_in_range(std::initializer_list<char_int_type> ranges)
6838 {
6839 JSON_ASSERT(ranges.size() == 2 || ranges.size() == 4 || ranges.size() == 6);
6840 add(current);
6841
6842 for (auto range = ranges.begin(); range != ranges.end(); ++range)
6843 {
6844 get();
6845 if (JSON_HEDLEY_LIKELY(*range <= current && current <= *(++range)))
6846 {
6847 add(current);
6848 }
6849 else
6850 {
6851 error_message = "invalid string: ill-formed UTF-8 byte";
6852 return false;
6853 }
6854 }
6855
6856 return true;
6857 }
6858
6874 token_type scan_string()
6875 {
6876 // reset token_buffer (ignore opening quote)
6877 reset();
6878
6879 // we entered the function by reading an open quote
6880 JSON_ASSERT(current == '\"');
6881
6882 while (true)
6883 {
6884 // get next character
6885 switch (get())
6886 {
6887 // end of file while parsing string
6888 case std::char_traits<char_type>::eof():
6889 {
6890 error_message = "invalid string: missing closing quote";
6891 return token_type::parse_error;
6892 }
6893
6894 // closing quote
6895 case '\"':
6896 {
6897 return token_type::value_string;
6898 }
6899
6900 // escapes
6901 case '\\':
6902 {
6903 switch (get())
6904 {
6905 // quotation mark
6906 case '\"':
6907 add('\"');
6908 break;
6909 // reverse solidus
6910 case '\\':
6911 add('\\');
6912 break;
6913 // solidus
6914 case '/':
6915 add('/');
6916 break;
6917 // backspace
6918 case 'b':
6919 add('\b');
6920 break;
6921 // form feed
6922 case 'f':
6923 add('\f');
6924 break;
6925 // line feed
6926 case 'n':
6927 add('\n');
6928 break;
6929 // carriage return
6930 case 'r':
6931 add('\r');
6932 break;
6933 // tab
6934 case 't':
6935 add('\t');
6936 break;
6937
6938 // unicode escapes
6939 case 'u':
6940 {
6941 const int codepoint1 = get_codepoint();
6942 int codepoint = codepoint1; // start with codepoint1
6943
6944 if (JSON_HEDLEY_UNLIKELY(codepoint1 == -1))
6945 {
6946 error_message = "invalid string: '\\u' must be followed by 4 hex digits";
6947 return token_type::parse_error;
6948 }
6949
6950 // check if code point is a high surrogate
6951 if (0xD800 <= codepoint1 && codepoint1 <= 0xDBFF)
6952 {
6953 // expect next \uxxxx entry
6954 if (JSON_HEDLEY_LIKELY(get() == '\\' && get() == 'u'))
6955 {
6956 const int codepoint2 = get_codepoint();
6957
6958 if (JSON_HEDLEY_UNLIKELY(codepoint2 == -1))
6959 {
6960 error_message = "invalid string: '\\u' must be followed by 4 hex digits";
6961 return token_type::parse_error;
6962 }
6963
6964 // check if codepoint2 is a low surrogate
6965 if (JSON_HEDLEY_LIKELY(0xDC00 <= codepoint2 && codepoint2 <= 0xDFFF))
6966 {
6967 // overwrite codepoint
6968 codepoint = static_cast<int>(
6969 // high surrogate occupies the most significant 22 bits
6970 (static_cast<unsigned int>(codepoint1) << 10u)
6971 // low surrogate occupies the least significant 15 bits
6972 + static_cast<unsigned int>(codepoint2)
6973 // there is still the 0xD800, 0xDC00 and 0x10000 noise
6974 // in the result so we have to subtract with:
6975 // (0xD800 << 10) + DC00 - 0x10000 = 0x35FDC00
6976 - 0x35FDC00u);
6977 }
6978 else
6979 {
6980 error_message = "invalid string: surrogate U+D800..U+DBFF must be followed by U+DC00..U+DFFF";
6981 return token_type::parse_error;
6982 }
6983 }
6984 else
6985 {
6986 error_message = "invalid string: surrogate U+D800..U+DBFF must be followed by U+DC00..U+DFFF";
6987 return token_type::parse_error;
6988 }
6989 }
6990 else
6991 {
6992 if (JSON_HEDLEY_UNLIKELY(0xDC00 <= codepoint1 && codepoint1 <= 0xDFFF))
6993 {
6994 error_message = "invalid string: surrogate U+DC00..U+DFFF must follow U+D800..U+DBFF";
6995 return token_type::parse_error;
6996 }
6997 }
6998
6999 // result of the above calculation yields a proper codepoint
7000 JSON_ASSERT(0x00 <= codepoint && codepoint <= 0x10FFFF);
7001
7002 // translate codepoint into bytes
7003 if (codepoint < 0x80)
7004 {
7005 // 1-byte characters: 0xxxxxxx (ASCII)
7006 add(static_cast<char_int_type>(codepoint));
7007 }
7008 else if (codepoint <= 0x7FF)
7009 {
7010 // 2-byte characters: 110xxxxx 10xxxxxx
7011 add(static_cast<char_int_type>(0xC0u | (static_cast<unsigned int>(codepoint) >> 6u)));
7012 add(static_cast<char_int_type>(0x80u | (static_cast<unsigned int>(codepoint) & 0x3Fu)));
7013 }
7014 else if (codepoint <= 0xFFFF)
7015 {
7016 // 3-byte characters: 1110xxxx 10xxxxxx 10xxxxxx
7017 add(static_cast<char_int_type>(0xE0u | (static_cast<unsigned int>(codepoint) >> 12u)));
7018 add(static_cast<char_int_type>(0x80u | ((static_cast<unsigned int>(codepoint) >> 6u) & 0x3Fu)));
7019 add(static_cast<char_int_type>(0x80u | (static_cast<unsigned int>(codepoint) & 0x3Fu)));
7020 }
7021 else
7022 {
7023 // 4-byte characters: 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx
7024 add(static_cast<char_int_type>(0xF0u | (static_cast<unsigned int>(codepoint) >> 18u)));
7025 add(static_cast<char_int_type>(0x80u | ((static_cast<unsigned int>(codepoint) >> 12u) & 0x3Fu)));
7026 add(static_cast<char_int_type>(0x80u | ((static_cast<unsigned int>(codepoint) >> 6u) & 0x3Fu)));
7027 add(static_cast<char_int_type>(0x80u | (st