Ark Server API 3.54
Serverside plugin support for Ark Survival Evolved.
Loading...
Searching...
No Matches
json.hpp
Go to the documentation of this file.
1/*
2 __ _____ _____ _____
3 __| | __| | | | JSON for Modern C++
4| | |__ | | | | | | version 3.10.2
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 2
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{
90 namespace detail
91 {
93 // JSON type enumeration //
95
120 enum class value_t : std::uint8_t
121 {
122 null,
123 object,
124 array,
125 string,
126 boolean,
130 binary,
131 discarded
132 };
133
147 inline 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> // 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(JSON_HEDLEY_WARN_UNUSED_RESULT)
1265#undef JSON_HEDLEY_WARN_UNUSED_RESULT
1266#endif
1267#if defined(JSON_HEDLEY_WARN_UNUSED_RESULT_MSG)
1268#undef JSON_HEDLEY_WARN_UNUSED_RESULT_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 JSON_HEDLEY_WARN_UNUSED_RESULT __attribute__((__warn_unused_result__))
1289#define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg) __attribute__((__warn_unused_result__))
1290#elif (JSON_HEDLEY_HAS_CPP_ATTRIBUTE(nodiscard) >= 201907L)
1291#define JSON_HEDLEY_WARN_UNUSED_RESULT JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[nodiscard]])
1292#define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[nodiscard(msg)]])
1293#elif JSON_HEDLEY_HAS_CPP_ATTRIBUTE(nodiscard)
1294#define JSON_HEDLEY_WARN_UNUSED_RESULT JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[nodiscard]])
1295#define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[nodiscard]])
1296#elif defined(_Check_return_) /* SAL */
1297#define JSON_HEDLEY_WARN_UNUSED_RESULT _Check_return_
1298#define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg) _Check_return_
1299#else
1300#define JSON_HEDLEY_WARN_UNUSED_RESULT
1301#define JSON_HEDLEY_WARN_UNUSED_RESULT_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
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
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(JSON_HEDLEY_RETURNS_NON_NULL)
1889#undef JSON_HEDLEY_RETURNS_NON_NULL
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 JSON_HEDLEY_RETURNS_NON_NULL __attribute__((__returns_nonnull__))
1896#elif defined(_Ret_notnull_) /* SAL */
1897#define JSON_HEDLEY_RETURNS_NON_NULL _Ret_notnull_
1898#else
1899#define JSON_HEDLEY_RETURNS_NON_NULL
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
2218// This file contains all internal macro definitions
2219// You MUST include macro_unscope.hpp at the end of json.hpp to undef all of them
2220
2221// exclude unsupported compilers
2222#if !defined(JSON_SKIP_UNSUPPORTED_COMPILER_CHECK)
2223#if defined(__clang__)
2224#if (__clang_major__ * 10000 + __clang_minor__ * 100 + __clang_patchlevel__) < 30400
2225#error "unsupported Clang version - see https://github.com/nlohmann/json#supported-compilers"
2226#endif
2227#elif defined(__GNUC__) && !(defined(__ICC) || defined(__INTEL_COMPILER))
2228#if (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) < 40800
2229#error "unsupported GCC version - see https://github.com/nlohmann/json#supported-compilers"
2230#endif
2231#endif
2232#endif
2233
2234// C++ language standard detection
2235// if the user manually specified the used c++ version this is skipped
2236#if !defined(JSON_HAS_CPP_20) && !defined(JSON_HAS_CPP_17) && !defined(JSON_HAS_CPP_14) && !defined(JSON_HAS_CPP_11)
2237#if (defined(__cplusplus) && __cplusplus >= 202002L) || (defined(_MSVC_LANG) && _MSVC_LANG >= 202002L)
2238#define JSON_HAS_CPP_20
2239#define JSON_HAS_CPP_17
2240#define JSON_HAS_CPP_14
2241#elif (defined(__cplusplus) && __cplusplus >= 201703L) || (defined(_HAS_CXX17) && _HAS_CXX17 == 1) // fix for issue #464
2242#define JSON_HAS_CPP_17
2243#define JSON_HAS_CPP_14
2244#elif (defined(__cplusplus) && __cplusplus >= 201402L) || (defined(_HAS_CXX14) && _HAS_CXX14 == 1)
2245#define JSON_HAS_CPP_14
2246#endif
2247// the cpp 11 flag is always specified because it is the minimal required version
2248#define JSON_HAS_CPP_11
2249#endif
2250
2251// disable documentation warnings on clang
2252#if defined(__clang__)
2253#pragma clang diagnostic push
2254#pragma clang diagnostic ignored "-Wdocumentation"
2255#pragma clang diagnostic ignored "-Wdocumentation-unknown-command"
2256#endif
2257
2258// allow to disable exceptions
2259#if (defined(__cpp_exceptions) || defined(__EXCEPTIONS) || defined(_CPPUNWIND)) && !defined(JSON_NOEXCEPTION)
2260#define JSON_THROW(exception) throw exception
2261#define JSON_TRY try
2262#define JSON_CATCH(exception) catch(exception)
2263#define JSON_INTERNAL_CATCH(exception) catch(exception)
2264#else
2265#include <cstdlib>
2266#define JSON_THROW(exception) std::abort()
2267#define JSON_TRY if(true)
2268#define JSON_CATCH(exception) if(false)
2269#define JSON_INTERNAL_CATCH(exception) if(false)
2270#endif
2271
2272// override exception macros
2273#if defined(JSON_THROW_USER)
2274#undef JSON_THROW
2275#define JSON_THROW JSON_THROW_USER
2276#endif
2277#if defined(JSON_TRY_USER)
2278#undef JSON_TRY
2279#define JSON_TRY JSON_TRY_USER
2280#endif
2281#if defined(JSON_CATCH_USER)
2282#undef JSON_CATCH
2283#define JSON_CATCH JSON_CATCH_USER
2284#undef JSON_INTERNAL_CATCH
2285#define JSON_INTERNAL_CATCH JSON_CATCH_USER
2286#endif
2287#if defined(JSON_INTERNAL_CATCH_USER)
2288#undef JSON_INTERNAL_CATCH
2289#define JSON_INTERNAL_CATCH JSON_INTERNAL_CATCH_USER
2290#endif
2291
2292// allow to override assert
2293#if !defined(JSON_ASSERT)
2294#include <cassert> // assert
2295#define JSON_ASSERT(x) assert(x)
2296#endif
2297
2298// allow to access some private functions (needed by the test suite)
2299#if defined(JSON_TESTS_PRIVATE)
2300#define JSON_PRIVATE_UNLESS_TESTED public
2301#else
2302#define JSON_PRIVATE_UNLESS_TESTED private
2303#endif
2304
2310#define NLOHMANN_JSON_SERIALIZE_ENUM(ENUM_TYPE, ...) \
2311 template<typename BasicJsonType> \
2312 inline void to_json(BasicJsonType& j, const ENUM_TYPE& e) \
2313 { \
2314 static_assert(std::is_enum<ENUM_TYPE>::value, #ENUM_TYPE " must be an enum!"); \
2315 static const std::pair<ENUM_TYPE, BasicJsonType> m[] = __VA_ARGS__; \
2316 auto it = std::find_if(std::begin(m), std::end(m), \
2317 [e](const std::pair<ENUM_TYPE, BasicJsonType>& ej_pair) -> bool \
2318 { \
2319 return ej_pair.first == e; \
2320 }); \
2321 j = ((it != std::end(m)) ? it : std::begin(m))->second; \
2322 } \
2323 template<typename BasicJsonType> \
2324 inline void from_json(const BasicJsonType& j, ENUM_TYPE& e) \
2325 { \
2326 static_assert(std::is_enum<ENUM_TYPE>::value, #ENUM_TYPE " must be an enum!"); \
2327 static const std::pair<ENUM_TYPE, BasicJsonType> m[] = __VA_ARGS__; \
2328 auto it = std::find_if(std::begin(m), std::end(m), \
2329 [&j](const std::pair<ENUM_TYPE, BasicJsonType>& ej_pair) -> bool \
2330 { \
2331 return ej_pair.second == j; \
2332 }); \
2333 e = ((it != std::end(m)) ? it : std::begin(m))->first; \
2334 }
2335
2336// Ugly macros to avoid uglier copy-paste when specializing basic_json. They
2337// may be removed in the future once the class is split.
2338
2339#define NLOHMANN_BASIC_JSON_TPL_DECLARATION \
2340 template<template<typename, typename, typename...> class ObjectType, \
2341 template<typename, typename...> class ArrayType, \
2342 class StringType, class BooleanType, class NumberIntegerType, \
2343 class NumberUnsignedType, class NumberFloatType, \
2344 template<typename> class AllocatorType, \
2345 template<typename, typename = void> class JSONSerializer, \
2346 class BinaryType>
2347
2348#define NLOHMANN_BASIC_JSON_TPL \
2349 basic_json<ObjectType, ArrayType, StringType, BooleanType, \
2350 NumberIntegerType, NumberUnsignedType, NumberFloatType, \
2351 AllocatorType, JSONSerializer, BinaryType>
2352
2353// Macros to simplify conversion from/to types
2354
2355#define NLOHMANN_JSON_EXPAND( x ) x
2356#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
2357#define NLOHMANN_JSON_PASTE(...) NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_GET_MACRO(__VA_ARGS__, \
2358 NLOHMANN_JSON_PASTE64, \
2359 NLOHMANN_JSON_PASTE63, \
2360 NLOHMANN_JSON_PASTE62, \
2361 NLOHMANN_JSON_PASTE61, \
2362 NLOHMANN_JSON_PASTE60, \
2363 NLOHMANN_JSON_PASTE59, \
2364 NLOHMANN_JSON_PASTE58, \
2365 NLOHMANN_JSON_PASTE57, \
2366 NLOHMANN_JSON_PASTE56, \
2367 NLOHMANN_JSON_PASTE55, \
2368 NLOHMANN_JSON_PASTE54, \
2369 NLOHMANN_JSON_PASTE53, \
2370 NLOHMANN_JSON_PASTE52, \
2371 NLOHMANN_JSON_PASTE51, \
2372 NLOHMANN_JSON_PASTE50, \
2373 NLOHMANN_JSON_PASTE49, \
2374 NLOHMANN_JSON_PASTE48, \
2375 NLOHMANN_JSON_PASTE47, \
2376 NLOHMANN_JSON_PASTE46, \
2377 NLOHMANN_JSON_PASTE45, \
2378 NLOHMANN_JSON_PASTE44, \
2379 NLOHMANN_JSON_PASTE43, \
2380 NLOHMANN_JSON_PASTE42, \
2381 NLOHMANN_JSON_PASTE41, \
2382 NLOHMANN_JSON_PASTE40, \
2383 NLOHMANN_JSON_PASTE39, \
2384 NLOHMANN_JSON_PASTE38, \
2385 NLOHMANN_JSON_PASTE37, \
2386 NLOHMANN_JSON_PASTE36, \
2387 NLOHMANN_JSON_PASTE35, \
2388 NLOHMANN_JSON_PASTE34, \
2389 NLOHMANN_JSON_PASTE33, \
2390 NLOHMANN_JSON_PASTE32, \
2391 NLOHMANN_JSON_PASTE31, \
2392 NLOHMANN_JSON_PASTE30, \
2393 NLOHMANN_JSON_PASTE29, \
2394 NLOHMANN_JSON_PASTE28, \
2395 NLOHMANN_JSON_PASTE27, \
2396 NLOHMANN_JSON_PASTE26, \
2397 NLOHMANN_JSON_PASTE25, \
2398 NLOHMANN_JSON_PASTE24, \
2399 NLOHMANN_JSON_PASTE23, \
2400 NLOHMANN_JSON_PASTE22, \
2401 NLOHMANN_JSON_PASTE21, \
2402 NLOHMANN_JSON_PASTE20, \
2403 NLOHMANN_JSON_PASTE19, \
2404 NLOHMANN_JSON_PASTE18, \
2405 NLOHMANN_JSON_PASTE17, \
2406 NLOHMANN_JSON_PASTE16, \
2407 NLOHMANN_JSON_PASTE15, \
2408 NLOHMANN_JSON_PASTE14, \
2409 NLOHMANN_JSON_PASTE13, \
2410 NLOHMANN_JSON_PASTE12, \
2411 NLOHMANN_JSON_PASTE11, \
2412 NLOHMANN_JSON_PASTE10, \
2413 NLOHMANN_JSON_PASTE9, \
2414 NLOHMANN_JSON_PASTE8, \
2415 NLOHMANN_JSON_PASTE7, \
2416 NLOHMANN_JSON_PASTE6, \
2417 NLOHMANN_JSON_PASTE5, \
2418 NLOHMANN_JSON_PASTE4, \
2419 NLOHMANN_JSON_PASTE3, \
2420 NLOHMANN_JSON_PASTE2, \
2421 NLOHMANN_JSON_PASTE1)(__VA_ARGS__))
2422#define NLOHMANN_JSON_PASTE2(func, v1) func(v1)
2423#define NLOHMANN_JSON_PASTE3(func, v1, v2) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE2(func, v2)
2424#define NLOHMANN_JSON_PASTE4(func, v1, v2, v3) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE3(func, v2, v3)
2425#define NLOHMANN_JSON_PASTE5(func, v1, v2, v3, v4) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE4(func, v2, v3, v4)
2426#define NLOHMANN_JSON_PASTE6(func, v1, v2, v3, v4, v5) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE5(func, v2, v3, v4, v5)
2427#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)
2428#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)
2429#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)
2430#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)
2431#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)
2432#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)
2433#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)
2434#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)
2435#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)
2436#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)
2437#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)
2438#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)
2439#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)
2440#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)
2441#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)
2442#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)
2443#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)
2444#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)
2445#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)
2446#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)
2447#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)
2448#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)
2449#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)
2450#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)
2451#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)
2452#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)
2453#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)
2454#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)
2455#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)
2456#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)
2457#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)
2458#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)
2459#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)
2460#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)
2461#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)
2462#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)
2463#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)
2464#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)
2465#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)
2466#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)
2467#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)
2468#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)
2469#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)
2470#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)
2471#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)
2472#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)
2473#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)
2474#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)
2475#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)
2476#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)
2477#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)
2478#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)
2479#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)
2480#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)
2481#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)
2482#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)
2483#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)
2484#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)
2485
2486#define NLOHMANN_JSON_TO(v1) nlohmann_json_j[#v1] = nlohmann_json_t.v1;
2487#define NLOHMANN_JSON_FROM(v1) nlohmann_json_j.at(#v1).get_to(nlohmann_json_t.v1);
2488
2494#define NLOHMANN_DEFINE_TYPE_INTRUSIVE(Type, ...) \
2495 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__)) } \
2496 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__)) }
2497
2503#define NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(Type, ...) \
2504 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__)) } \
2505 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__)) }
2506
2507#ifndef JSON_USE_IMPLICIT_CONVERSIONS
2508#define JSON_USE_IMPLICIT_CONVERSIONS 1
2509#endif
2510
2511#if JSON_USE_IMPLICIT_CONVERSIONS
2512#define JSON_EXPLICIT
2513#else
2514#define JSON_EXPLICIT explicit
2515#endif
2516
2517#ifndef JSON_DIAGNOSTICS
2518#define JSON_DIAGNOSTICS 0
2519#endif
2520
2521
2522namespace nlohmann
2523{
2524 namespace detail
2525 {
2526
2540 inline void replace_substring(std::string& s, const std::string& f,
2541 const std::string& t)
2542 {
2543 JSON_ASSERT(!f.empty());
2544 for (auto pos = s.find(f); // find first occurrence of f
2545 pos != std::string::npos; // make sure f was found
2546 s.replace(pos, f.size(), t), // replace with t, and
2547 pos = s.find(f, pos + t.size())) // find next occurrence of f
2548 {
2549 }
2550 }
2551
2559 inline std::string escape(std::string s)
2560 {
2561 replace_substring(s, "~", "~0");
2562 replace_substring(s, "/", "~1");
2563 return s;
2564 }
2565
2573 static void unescape(std::string& s)
2574 {
2575 replace_substring(s, "~1", "/");
2576 replace_substring(s, "~0", "~");
2577 }
2578
2579 } // namespace detail
2580} // namespace nlohmann
2581
2582// #include <nlohmann/detail/input/position_t.hpp>
2583
2584
2585#include <cstddef> // size_t
2586
2587namespace nlohmann
2588{
2589 namespace detail
2590 {
2593 {
2595 std::size_t chars_read_total = 0;
2599 std::size_t lines_read = 0;
2600
2602 constexpr operator size_t() const
2603 {
2604 return chars_read_total;
2605 }
2606 };
2607
2608 } // namespace detail
2609} // namespace nlohmann
2610
2611// #include <nlohmann/detail/macro_scope.hpp>
2612
2613
2614namespace nlohmann
2615{
2616 namespace detail
2617 {
2619 // exceptions //
2621
2650 class exception : public std::exception
2651 {
2652 public:
2654 const char* what() const noexcept override
2655 {
2656 return m.what();
2657 }
2658
2660 const int id; // NOLINT(cppcoreguidelines-non-private-member-variables-in-classes)
2661
2662 protected:
2664 exception(int id_, const char* what_arg) : id(id_), m(what_arg) {}
2665
2666 static std::string name(const std::string& ename, int id_)
2667 {
2668 return "[json.exception." + ename + "." + std::to_string(id_) + "] ";
2669 }
2670
2671 template<typename BasicJsonType>
2672 static std::string diagnostics(const BasicJsonType& leaf_element)
2673 {
2674#if JSON_DIAGNOSTICS
2675 std::vector<std::string> tokens;
2676 for (const auto* current = &leaf_element; current->m_parent != nullptr; current = current->m_parent)
2677 {
2678 switch (current->m_parent->type())
2679 {
2680 case value_t::array:
2681 {
2682 for (std::size_t i = 0; i < current->m_parent->m_value.array->size(); ++i)
2683 {
2684 if (&current->m_parent->m_value.array->operator[](i) == current)
2685 {
2686 tokens.emplace_back(std::to_string(i));
2687 break;
2688 }
2689 }
2690 break;
2691 }
2692
2693 case value_t::object:
2694 {
2695 for (const auto& element : *current->m_parent->m_value.object)
2696 {
2697 if (&element.second == current)
2698 {
2699 tokens.emplace_back(element.first.c_str());
2700 break;
2701 }
2702 }
2703 break;
2704 }
2705
2706 case value_t::null: // LCOV_EXCL_LINE
2707 case value_t::string: // LCOV_EXCL_LINE
2708 case value_t::boolean: // LCOV_EXCL_LINE
2709 case value_t::number_integer: // LCOV_EXCL_LINE
2710 case value_t::number_unsigned: // LCOV_EXCL_LINE
2711 case value_t::number_float: // LCOV_EXCL_LINE
2712 case value_t::binary: // LCOV_EXCL_LINE
2713 case value_t::discarded: // LCOV_EXCL_LINE
2714 default: // LCOV_EXCL_LINE
2715 break; // LCOV_EXCL_LINE
2716 }
2717 }
2718
2719 if (tokens.empty())
2720 {
2721 return "";
2722 }
2723
2724 return "(" + std::accumulate(tokens.rbegin(), tokens.rend(), std::string{},
2725 [](const std::string& a, const std::string& b)
2726 {
2727 return a + "/" + detail::escape(b);
2728 }) + ") ";
2729#else
2730 static_cast<void>(leaf_element);
2731 return "";
2732#endif
2733 }
2734
2735 private:
2737 std::runtime_error m;
2738 };
2739
2785 class parse_error : public exception
2786 {
2787 public:
2797 template<typename BasicJsonType>
2798 static parse_error create(int id_, const position_t& pos, const std::string& what_arg, const BasicJsonType& context)
2799 {
2800 std::string w = exception::name("parse_error", id_) + "parse error" +
2801 position_string(pos) + ": " + exception::diagnostics(context) + what_arg;
2802 return parse_error(id_, pos.chars_read_total, w.c_str());
2803 }
2804
2805 template<typename BasicJsonType>
2806 static parse_error create(int id_, std::size_t byte_, const std::string& what_arg, const BasicJsonType& context)
2807 {
2808 std::string w = exception::name("parse_error", id_) + "parse error" +
2809 (byte_ != 0 ? (" at byte " + std::to_string(byte_)) : "") +
2810 ": " + exception::diagnostics(context) + what_arg;
2811 return parse_error(id_, byte_, w.c_str());
2812 }
2813
2823 const std::size_t byte;
2824
2825 private:
2826 parse_error(int id_, std::size_t byte_, const char* what_arg)
2827 : exception(id_, what_arg), byte(byte_) {}
2828
2829 static std::string position_string(const position_t& pos)
2830 {
2831 return " at line " + std::to_string(pos.lines_read + 1) +
2832 ", column " + std::to_string(pos.chars_read_current_line);
2833 }
2834 };
2835
2874 {
2875 public:
2876 template<typename BasicJsonType>
2877 static invalid_iterator create(int id_, const std::string& what_arg, const BasicJsonType& context)
2878 {
2879 std::string w = exception::name("invalid_iterator", id_) + exception::diagnostics(context) + what_arg;
2880 return invalid_iterator(id_, w.c_str());
2881 }
2882
2883 private:
2885 invalid_iterator(int id_, const char* what_arg)
2886 : exception(id_, what_arg) {}
2887 };
2888
2928 class type_error : public exception
2929 {
2930 public:
2931 template<typename BasicJsonType>
2932 static type_error create(int id_, const std::string& what_arg, const BasicJsonType& context)
2933 {
2934 std::string w = exception::name("type_error", id_) + exception::diagnostics(context) + what_arg;
2935 return type_error(id_, w.c_str());
2936 }
2937
2938 private:
2940 type_error(int id_, const char* what_arg) : exception(id_, what_arg) {}
2941 };
2942
2977 {
2978 public:
2979 template<typename BasicJsonType>
2980 static out_of_range create(int id_, const std::string& what_arg, const BasicJsonType& context)
2981 {
2982 std::string w = exception::name("out_of_range", id_) + exception::diagnostics(context) + what_arg;
2983 return out_of_range(id_, w.c_str());
2984 }
2985
2986 private:
2988 out_of_range(int id_, const char* what_arg) : exception(id_, what_arg) {}
2989 };
2990
3015 class other_error : public exception
3016 {
3017 public:
3018 template<typename BasicJsonType>
3019 static other_error create(int id_, const std::string& what_arg, const BasicJsonType& context)
3020 {
3021 std::string w = exception::name("other_error", id_) + exception::diagnostics(context) + what_arg;
3022 return other_error(id_, w.c_str());
3023 }
3024
3025 private:
3027 other_error(int id_, const char* what_arg) : exception(id_, what_arg) {}
3028 };
3029 } // namespace detail
3030} // namespace nlohmann
3031
3032// #include <nlohmann/detail/macro_scope.hpp>
3033
3034// #include <nlohmann/detail/meta/cpp_future.hpp>
3035
3036
3037#include <cstddef> // size_t
3038#include <type_traits> // conditional, enable_if, false_type, integral_constant, is_constructible, is_integral, is_same, remove_cv, remove_reference, true_type
3039#include <utility> // index_sequence, make_index_sequence, index_sequence_for
3040
3041// #include <nlohmann/detail/macro_scope.hpp>
3042
3043
3044namespace nlohmann
3045{
3046 namespace detail
3047 {
3048
3049 template<typename T>
3050 using uncvref_t = typename std::remove_cv<typename std::remove_reference<T>::type>::type;
3051
3052#ifdef JSON_HAS_CPP_14
3053
3054 // the following utilities are natively available in C++14
3055 using std::enable_if_t;
3056 using std::index_sequence;
3057 using std::make_index_sequence;
3058 using std::index_sequence_for;
3059
3060#else
3061
3062 // alias templates to reduce boilerplate
3063 template<bool B, typename T = void>
3064 using enable_if_t = typename std::enable_if<B, T>::type;
3065
3066 // The following code is taken from https://github.com/abseil/abseil-cpp/blob/10cb35e459f5ecca5b2ff107635da0bfa41011b4/absl/utility/utility.h
3067 // which is part of Google Abseil (https://github.com/abseil/abseil-cpp), licensed under the Apache License 2.0.
3068
3070
3071 // integer_sequence
3072 //
3073 // Class template representing a compile-time integer sequence. An instantiation
3074 // of `integer_sequence<T, Ints...>` has a sequence of integers encoded in its
3075 // type through its template arguments (which is a common need when
3076 // working with C++11 variadic templates). `absl::integer_sequence` is designed
3077 // to be a drop-in replacement for C++14's `std::integer_sequence`.
3078 //
3079 // Example:
3080 //
3081 // template< class T, T... Ints >
3082 // void user_function(integer_sequence<T, Ints...>);
3083 //
3084 // int main()
3085 // {
3086 // // user_function's `T` will be deduced to `int` and `Ints...`
3087 // // will be deduced to `0, 1, 2, 3, 4`.
3088 // user_function(make_integer_sequence<int, 5>());
3089 // }
3090 template <typename T, T... Ints>
3092 {
3093 using value_type = T;
3094 static constexpr std::size_t size() noexcept
3095 {
3096 return sizeof...(Ints);
3097 }
3098 };
3099
3100 // index_sequence
3101 //
3102 // A helper template for an `integer_sequence` of `size_t`,
3103 // `absl::index_sequence` is designed to be a drop-in replacement for C++14's
3104 // `std::index_sequence`.
3105 template <size_t... Ints>
3106 using index_sequence = integer_sequence<size_t, Ints...>;
3107
3108 namespace utility_internal
3109 {
3110
3111 template <typename Seq, size_t SeqSize, size_t Rem>
3112 struct Extend;
3113
3114 // Note that SeqSize == sizeof...(Ints). It's passed explicitly for efficiency.
3115 template <typename T, T... Ints, size_t SeqSize>
3116 struct Extend<integer_sequence<T, Ints...>, SeqSize, 0>
3117 {
3118 using type = integer_sequence < T, Ints..., (Ints + SeqSize)... >;
3119 };
3120
3121 template <typename T, T... Ints, size_t SeqSize>
3122 struct Extend<integer_sequence<T, Ints...>, SeqSize, 1>
3123 {
3124 using type = integer_sequence < T, Ints..., (Ints + SeqSize)..., 2 * SeqSize >;
3125 };
3126
3127 // Recursion helper for 'make_integer_sequence<T, N>'.
3128 // 'Gen<T, N>::type' is an alias for 'integer_sequence<T, 0, 1, ... N-1>'.
3129 template <typename T, size_t N>
3130 struct Gen
3131 {
3132 using type =
3133 typename Extend < typename Gen < T, N / 2 >::type, N / 2, N % 2 >::type;
3134 };
3135
3136 template <typename T>
3137 struct Gen<T, 0>
3138 {
3140 };
3141
3142 } // namespace utility_internal
3143
3144 // Compile-time sequences of integers
3145
3146 // make_integer_sequence
3147 //
3148 // This template alias is equivalent to
3149 // `integer_sequence<int, 0, 1, ..., N-1>`, and is designed to be a drop-in
3150 // replacement for C++14's `std::make_integer_sequence`.
3151 template <typename T, T N>
3153
3154 // make_index_sequence
3155 //
3156 // This template alias is equivalent to `index_sequence<0, 1, ..., N-1>`,
3157 // and is designed to be a drop-in replacement for C++14's
3158 // `std::make_index_sequence`.
3159 template <size_t N>
3161
3162 // index_sequence_for
3163 //
3164 // Converts a typename pack into an index sequence of the same length, and
3165 // is designed to be a drop-in replacement for C++14's
3166 // `std::index_sequence_for()`
3167 template <typename... Ts>
3169
3171
3172#endif
3173
3174// dispatch utility (taken from ranges-v3)
3175 template<unsigned N> struct priority_tag : priority_tag < N - 1 > {};
3176 template<> struct priority_tag<0> {};
3177
3178 // taken from ranges-v3
3179 template<typename T>
3181 {
3182 static constexpr T value{};
3183 };
3184
3185 template<typename T>
3186 constexpr T static_const<T>::value;
3187
3188 } // namespace detail
3189} // namespace nlohmann
3190
3191// #include <nlohmann/detail/meta/identity_tag.hpp>
3192
3193
3194namespace nlohmann
3195{
3196 namespace detail
3197 {
3198 // dispatching helper struct
3199 template <class T> struct identity_tag {};
3200 } // namespace detail
3201} // namespace nlohmann
3202
3203// #include <nlohmann/detail/meta/type_traits.hpp>
3204
3205
3206#include <limits> // numeric_limits
3207#include <type_traits> // false_type, is_constructible, is_integral, is_same, true_type
3208#include <utility> // declval
3209#include <tuple> // tuple
3210
3211// #include <nlohmann/detail/iterators/iterator_traits.hpp>
3212
3213
3214#include <iterator> // random_access_iterator_tag
3215
3216// #include <nlohmann/detail/meta/void_t.hpp>
3217
3218
3219namespace nlohmann
3220{
3221 namespace detail
3222 {
3223 template<typename ...Ts> struct make_void
3224 {
3225 using type = void;
3226 };
3227 template<typename ...Ts> using void_t = typename make_void<Ts...>::type;
3228 } // namespace detail
3229} // namespace nlohmann
3230
3231// #include <nlohmann/detail/meta/cpp_future.hpp>
3232
3233
3234namespace nlohmann
3235{
3236 namespace detail
3237 {
3238 template<typename It, typename = void>
3240
3241 template<typename It>
3243 It,
3244 void_t<typename It::difference_type, typename It::value_type, typename It::pointer,
3245 typename It::reference, typename It::iterator_category >>
3246 {
3247 using difference_type = typename It::difference_type;
3248 using value_type = typename It::value_type;
3249 using pointer = typename It::pointer;
3250 using reference = typename It::reference;
3251 using iterator_category = typename It::iterator_category;
3252 };
3253
3254 // This is required as some compilers implement std::iterator_traits in a way that
3255 // doesn't work with SFINAE. See https://github.com/nlohmann/json/issues/1341.
3256 template<typename T, typename = void>
3258 {
3259 };
3260
3261 template<typename T>
3262 struct iterator_traits < T, enable_if_t < !std::is_pointer<T>::value >>
3263 : iterator_types<T>
3264 {
3265 };
3266
3267 template<typename T>
3269 {
3270 using iterator_category = std::random_access_iterator_tag;
3271 using value_type = T;
3272 using difference_type = ptrdiff_t;
3273 using pointer = T*;
3274 using reference = T&;
3275 };
3276 } // namespace detail
3277} // namespace nlohmann
3278
3279// #include <nlohmann/detail/macro_scope.hpp>
3280
3281// #include <nlohmann/detail/meta/cpp_future.hpp>
3282
3283// #include <nlohmann/detail/meta/detected.hpp>
3284
3285
3286#include <type_traits>
3287
3288// #include <nlohmann/detail/meta/void_t.hpp>
3289
3290
3291// https://en.cppreference.com/w/cpp/experimental/is_detected
3292namespace nlohmann
3293{
3294 namespace detail
3295 {
3297 {
3298 nonesuch() = delete;
3299 ~nonesuch() = delete;
3300 nonesuch(nonesuch const&) = delete;
3301 nonesuch(nonesuch const&&) = delete;
3302 void operator=(nonesuch const&) = delete;
3303 void operator=(nonesuch&&) = delete;
3304 };
3305
3306 template<class Default,
3307 class AlwaysVoid,
3308 template<class...> class Op,
3309 class... Args>
3311 {
3312 using value_t = std::false_type;
3313 using type = Default;
3314 };
3315
3316 template<class Default, template<class...> class Op, class... Args>
3317 struct detector<Default, void_t<Op<Args...>>, Op, Args...>
3318 {
3319 using value_t = std::true_type;
3320 using type = Op<Args...>;
3321 };
3322
3323 template<template<class...> class Op, class... Args>
3324 using is_detected = typename detector<nonesuch, void, Op, Args...>::value_t;
3325
3326 template<template<class...> class Op, class... Args>
3327 struct is_detected_lazy : is_detected<Op, Args...> { };
3328
3329 template<template<class...> class Op, class... Args>
3330 using detected_t = typename detector<nonesuch, void, Op, Args...>::type;
3331
3332 template<class Default, template<class...> class Op, class... Args>
3333 using detected_or = detector<Default, void, Op, Args...>;
3334
3335 template<class Default, template<class...> class Op, class... Args>
3336 using detected_or_t = typename detected_or<Default, Op, Args...>::type;
3337
3338 template<class Expected, template<class...> class Op, class... Args>
3339 using is_detected_exact = std::is_same<Expected, detected_t<Op, Args...>>;
3340
3341 template<class To, template<class...> class Op, class... Args>
3343 std::is_convertible<detected_t<Op, Args...>, To>;
3344 } // namespace detail
3345} // namespace nlohmann
3346
3347// #include <nlohmann/json_fwd.hpp>
3348#ifndef INCLUDE_NLOHMANN_JSON_FWD_HPP_
3349#define INCLUDE_NLOHMANN_JSON_FWD_HPP_
3350
3351#include <cstdint> // int64_t, uint64_t
3352#include <map> // map
3353#include <memory> // allocator
3354#include <string> // string
3355#include <vector> // vector
3356
3362namespace nlohmann
3363{
3371 template<typename T = void, typename SFINAE = void>
3372 struct adl_serializer;
3373
3374 template<template<typename U, typename V, typename... Args> class ObjectType =
3375 std::map,
3376 template<typename U, typename... Args> class ArrayType = std::vector,
3377 class StringType = std::string, class BooleanType = bool,
3378 class NumberIntegerType = std::int64_t,
3379 class NumberUnsignedType = std::uint64_t,
3380 class NumberFloatType = double,
3381 template<typename U> class AllocatorType = std::allocator,
3382 template<typename T, typename SFINAE = void> class JSONSerializer =
3383 adl_serializer,
3384 class BinaryType = std::vector<std::uint8_t>>
3385 class basic_json;
3386
3398 template<typename BasicJsonType>
3399 class json_pointer;
3400
3410
3411 template<class Key, class T, class IgnoredLess, class Allocator>
3412 struct ordered_map;
3413
3422
3423} // namespace nlohmann
3424
3425#endif // INCLUDE_NLOHMANN_JSON_FWD_HPP_
3426
3427
3428namespace nlohmann
3429{
3438 namespace detail
3439 {
3441 // helpers //
3443
3444 // Note to maintainers:
3445 //
3446 // Every trait in this file expects a non CV-qualified type.
3447 // The only exceptions are in the 'aliases for detected' section
3448 // (i.e. those of the form: decltype(T::member_function(std::declval<T>())))
3449 //
3450 // In this case, T has to be properly CV-qualified to constraint the function arguments
3451 // (e.g. to_json(BasicJsonType&, const T&))
3452
3453 template<typename> struct is_basic_json : std::false_type {};
3454
3456 struct is_basic_json<NLOHMANN_BASIC_JSON_TPL> : std::true_type {};
3457
3459 // json_ref helpers //
3461
3462 template<typename>
3463 class json_ref;
3464
3465 template<typename>
3466 struct is_json_ref : std::false_type {};
3467
3468 template<typename T>
3469 struct is_json_ref<json_ref<T>> : std::true_type {};
3470
3472 // aliases for detected //
3474
3475 template<typename T>
3476 using mapped_type_t = typename T::mapped_type;
3477
3478 template<typename T>
3479 using key_type_t = typename T::key_type;
3480
3481 template<typename T>
3482 using value_type_t = typename T::value_type;
3483
3484 template<typename T>
3485 using difference_type_t = typename T::difference_type;
3486
3487 template<typename T>
3488 using pointer_t = typename T::pointer;
3489
3490 template<typename T>
3491 using reference_t = typename T::reference;
3492
3493 template<typename T>
3494 using iterator_category_t = typename T::iterator_category;
3495
3496 template<typename T>
3497 using iterator_t = typename T::iterator;
3498
3499 template<typename T, typename... Args>
3500 using to_json_function = decltype(T::to_json(std::declval<Args>()...));
3501
3502 template<typename T, typename... Args>
3503 using from_json_function = decltype(T::from_json(std::declval<Args>()...));
3504
3505 template<typename T, typename U>
3506 using get_template_function = decltype(std::declval<T>().template get<U>());
3507
3508 // trait checking if JSONSerializer<T>::from_json(json const&, udt&) exists
3509 template<typename BasicJsonType, typename T, typename = void>
3510 struct has_from_json : std::false_type {};
3511
3512 // trait checking if j.get<T> is valid
3513 // use this trait instead of std::is_constructible or std::is_convertible,
3514 // both rely on, or make use of implicit conversions, and thus fail when T
3515 // has several constructors/operator= (see https://github.com/nlohmann/json/issues/958)
3516 template <typename BasicJsonType, typename T>
3518 {
3520 };
3521
3522 template<typename BasicJsonType, typename T>
3523 struct has_from_json < BasicJsonType, T, enable_if_t < !is_basic_json<T>::value >>
3524 {
3525 using serializer = typename BasicJsonType::template json_serializer<T, void>;
3526
3527 static constexpr bool value =
3529 const BasicJsonType&, T&>::value;
3530 };
3531
3532 // This trait checks if JSONSerializer<T>::from_json(json const&) exists
3533 // this overload is used for non-default-constructible user-defined-types
3534 template<typename BasicJsonType, typename T, typename = void>
3535 struct has_non_default_from_json : std::false_type {};
3536
3537 template<typename BasicJsonType, typename T>
3538 struct has_non_default_from_json < BasicJsonType, T, enable_if_t < !is_basic_json<T>::value >>
3539 {
3540 using serializer = typename BasicJsonType::template json_serializer<T, void>;
3541
3542 static constexpr bool value =
3544 const BasicJsonType&>::value;
3545 };
3546
3547 // This trait checks if BasicJsonType::json_serializer<T>::to_json exists
3548 // Do not evaluate the trait when T is a basic_json type, to avoid template instantiation infinite recursion.
3549 template<typename BasicJsonType, typename T, typename = void>
3550 struct has_to_json : std::false_type {};
3551
3552 template<typename BasicJsonType, typename T>
3553 struct has_to_json < BasicJsonType, T, enable_if_t < !is_basic_json<T>::value >>
3554 {
3555 using serializer = typename BasicJsonType::template json_serializer<T, void>;
3556
3557 static constexpr bool value =
3558 is_detected_exact<void, to_json_function, serializer, BasicJsonType&,
3559 T>::value;
3560 };
3561
3562
3564 // is_ functions //
3566
3567 // https://en.cppreference.com/w/cpp/types/conjunction
3568 template<class...> struct conjunction : std::true_type { };
3569 template<class B1> struct conjunction<B1> : B1 { };
3570 template<class B1, class... Bn>
3571 struct conjunction<B1, Bn...>
3572 : std::conditional<bool(B1::value), conjunction<Bn...>, B1>::type {};
3573
3574 // https://en.cppreference.com/w/cpp/types/negation
3575 template<class B> struct negation : std::integral_constant < bool, !B::value > { };
3576
3577 // Reimplementation of is_constructible and is_default_constructible, due to them being broken for
3578 // std::pair and std::tuple until LWG 2367 fix (see https://cplusplus.github.io/LWG/lwg-defects.html#2367).
3579 // This causes compile errors in e.g. clang 3.5 or gcc 4.9.
3580 template <typename T>
3581 struct is_default_constructible : std::is_default_constructible<T> {};
3582
3583 template <typename T1, typename T2>
3584 struct is_default_constructible<std::pair<T1, T2>>
3585 : conjunction<is_default_constructible<T1>, is_default_constructible<T2>> {};
3586
3587 template <typename T1, typename T2>
3588 struct is_default_constructible<const std::pair<T1, T2>>
3589 : conjunction<is_default_constructible<T1>, is_default_constructible<T2>> {};
3590
3591 template <typename... Ts>
3592 struct is_default_constructible<std::tuple<Ts...>>
3593 : conjunction<is_default_constructible<Ts>...> {};
3594
3595 template <typename... Ts>
3596 struct is_default_constructible<const std::tuple<Ts...>>
3597 : conjunction<is_default_constructible<Ts>...> {};
3598
3599
3600 template <typename T, typename... Args>
3601 struct is_constructible : std::is_constructible<T, Args...> {};
3602
3603 template <typename T1, typename T2>
3604 struct is_constructible<std::pair<T1, T2>> : is_default_constructible<std::pair<T1, T2>> {};
3605
3606 template <typename T1, typename T2>
3607 struct is_constructible<const std::pair<T1, T2>> : is_default_constructible<const std::pair<T1, T2>> {};
3608
3609 template <typename... Ts>
3610 struct is_constructible<std::tuple<Ts...>> : is_default_constructible<std::tuple<Ts...>> {};
3611
3612 template <typename... Ts>
3613 struct is_constructible<const std::tuple<Ts...>> : is_default_constructible<const std::tuple<Ts...>> {};
3614
3615
3616 template<typename T, typename = void>
3617 struct is_iterator_traits : std::false_type {};
3618
3619 template<typename T>
3621 {
3622 private:
3624
3625 public:
3626 static constexpr auto value =
3632 };
3633
3634 // The following implementation of is_complete_type is taken from
3635 // https://blogs.msdn.microsoft.com/vcblog/2015/12/02/partial-support-for-expression-sfinae-in-vs-2015-update-1/
3636 // and is written by Xiang Fan who agreed to using it in this library.
3637
3638 template<typename T, typename = void>
3639 struct is_complete_type : std::false_type {};
3640
3641 template<typename T>
3642 struct is_complete_type<T, decltype(void(sizeof(T)))> : std::true_type {};
3643
3644 template<typename BasicJsonType, typename CompatibleObjectType,
3645 typename = void>
3646 struct is_compatible_object_type_impl : std::false_type {};
3647
3648 template<typename BasicJsonType, typename CompatibleObjectType>
3650 BasicJsonType, CompatibleObjectType,
3651 enable_if_t < is_detected<mapped_type_t, CompatibleObjectType>::value&&
3652 is_detected<key_type_t, CompatibleObjectType>::value >>
3653 {
3654 using object_t = typename BasicJsonType::object_t;
3655
3656 // macOS's is_constructible does not play well with nonesuch...
3657 static constexpr bool value =
3658 is_constructible<typename object_t::key_type,
3659 typename CompatibleObjectType::key_type>::value &&
3660 is_constructible<typename object_t::mapped_type,
3661 typename CompatibleObjectType::mapped_type>::value;
3662 };
3663
3664 template<typename BasicJsonType, typename CompatibleObjectType>
3666 : is_compatible_object_type_impl<BasicJsonType, CompatibleObjectType> {};
3667
3668 template<typename BasicJsonType, typename ConstructibleObjectType,
3669 typename = void>
3670 struct is_constructible_object_type_impl : std::false_type {};
3671
3672 template<typename BasicJsonType, typename ConstructibleObjectType>
3674 BasicJsonType, ConstructibleObjectType,
3675 enable_if_t < is_detected<mapped_type_t, ConstructibleObjectType>::value&&
3676 is_detected<key_type_t, ConstructibleObjectType>::value >>
3677 {
3678 using object_t = typename BasicJsonType::object_t;
3679
3680 static constexpr bool value =
3682 (std::is_move_assignable<ConstructibleObjectType>::value ||
3683 std::is_copy_assignable<ConstructibleObjectType>::value) &&
3684 (is_constructible<typename ConstructibleObjectType::key_type,
3685 typename object_t::key_type>::value &&
3686 std::is_same <
3687 typename object_t::mapped_type,
3688 typename ConstructibleObjectType::mapped_type >::value)) ||
3689 (has_from_json<BasicJsonType,
3690 typename ConstructibleObjectType::mapped_type>::value ||
3692 BasicJsonType,
3693 typename ConstructibleObjectType::mapped_type >::value);
3694 };
3695
3696 template<typename BasicJsonType, typename ConstructibleObjectType>
3698 : is_constructible_object_type_impl<BasicJsonType,
3699 ConstructibleObjectType> {};
3700
3701 template<typename BasicJsonType, typename CompatibleStringType,
3702 typename = void>
3703 struct is_compatible_string_type_impl : std::false_type {};
3704
3705 template<typename BasicJsonType, typename CompatibleStringType>
3707 BasicJsonType, CompatibleStringType,
3708 enable_if_t<is_detected_exact<typename BasicJsonType::string_t::value_type,
3709 value_type_t, CompatibleStringType>::value >>
3710 {
3711 static constexpr auto value =
3713 };
3714
3715 template<typename BasicJsonType, typename ConstructibleStringType>
3717 : is_compatible_string_type_impl<BasicJsonType, ConstructibleStringType> {};
3718
3719 template<typename BasicJsonType, typename ConstructibleStringType,
3720 typename = void>
3721 struct is_constructible_string_type_impl : std::false_type {};
3722
3723 template<typename BasicJsonType, typename ConstructibleStringType>
3725 BasicJsonType, ConstructibleStringType,
3726 enable_if_t<is_detected_exact<typename BasicJsonType::string_t::value_type,
3727 value_type_t, ConstructibleStringType>::value >>
3728 {
3729 static constexpr auto value =
3730 is_constructible<ConstructibleStringType,
3731 typename BasicJsonType::string_t>::value;
3732 };
3733
3734 template<typename BasicJsonType, typename ConstructibleStringType>
3736 : is_constructible_string_type_impl<BasicJsonType, ConstructibleStringType> {};
3737
3738 template<typename BasicJsonType, typename CompatibleArrayType, typename = void>
3739 struct is_compatible_array_type_impl : std::false_type {};
3740
3741 template<typename BasicJsonType, typename CompatibleArrayType>
3743 BasicJsonType, CompatibleArrayType,
3744 enable_if_t < is_detected<value_type_t, CompatibleArrayType>::value&&
3745 is_detected<iterator_t, CompatibleArrayType>::value &&
3746 // This is needed because json_reverse_iterator has a ::iterator type...
3747 // Therefore it is detected as a CompatibleArrayType.
3748 // The real fix would be to have an Iterable concept.
3750 iterator_traits<CompatibleArrayType >>::value >>
3751 {
3752 static constexpr bool value =
3753 is_constructible<BasicJsonType,
3754 typename CompatibleArrayType::value_type>::value;
3755 };
3756
3757 template<typename BasicJsonType, typename CompatibleArrayType>
3759 : is_compatible_array_type_impl<BasicJsonType, CompatibleArrayType> {};
3760
3761 template<typename BasicJsonType, typename ConstructibleArrayType, typename = void>
3762 struct is_constructible_array_type_impl : std::false_type {};
3763
3764 template<typename BasicJsonType, typename ConstructibleArrayType>
3766 BasicJsonType, ConstructibleArrayType,
3767 enable_if_t<std::is_same<ConstructibleArrayType,
3768 typename BasicJsonType::value_type>::value >>
3769 : std::true_type {};
3770
3771 template<typename BasicJsonType, typename ConstructibleArrayType>
3773 BasicJsonType, ConstructibleArrayType,
3774 enable_if_t < !std::is_same<ConstructibleArrayType,
3775 typename BasicJsonType::value_type>::value&&
3776 is_default_constructible<ConstructibleArrayType>::value &&
3777 (std::is_move_assignable<ConstructibleArrayType>::value ||
3778 std::is_copy_assignable<ConstructibleArrayType>::value) &&
3779 is_detected<value_type_t, ConstructibleArrayType>::value&&
3780 is_detected<iterator_t, ConstructibleArrayType>::value&&
3782 detected_t<value_type_t, ConstructibleArrayType >>::value >>
3783 {
3784 static constexpr bool value =
3785 // This is needed because json_reverse_iterator has a ::iterator type,
3786 // furthermore, std::back_insert_iterator (and other iterators) have a
3787 // base class `iterator`... Therefore it is detected as a
3788 // ConstructibleArrayType. The real fix would be to have an Iterable
3789 // concept.
3791
3792 (std::is_same<typename ConstructibleArrayType::value_type,
3793 typename BasicJsonType::array_t::value_type>::value ||
3794 has_from_json<BasicJsonType,
3795 typename ConstructibleArrayType::value_type>::value ||
3797 BasicJsonType, typename ConstructibleArrayType::value_type >::value);
3798 };
3799
3800 template<typename BasicJsonType, typename ConstructibleArrayType>
3802 : is_constructible_array_type_impl<BasicJsonType, ConstructibleArrayType> {};
3803
3804 template<typename RealIntegerType, typename CompatibleNumberIntegerType,
3805 typename = void>
3806 struct is_compatible_integer_type_impl : std::false_type {};
3807
3808 template<typename RealIntegerType, typename CompatibleNumberIntegerType>
3810 RealIntegerType, CompatibleNumberIntegerType,
3811 enable_if_t < std::is_integral<RealIntegerType>::value&&
3812 std::is_integral<CompatibleNumberIntegerType>::value &&
3813 !std::is_same<bool, CompatibleNumberIntegerType>::value >>
3814 {
3815 // is there an assert somewhere on overflows?
3816 using RealLimits = std::numeric_limits<RealIntegerType>;
3817 using CompatibleLimits = std::numeric_limits<CompatibleNumberIntegerType>;
3818
3819 static constexpr auto value =
3820 is_constructible<RealIntegerType,
3821 CompatibleNumberIntegerType>::value &&
3822 CompatibleLimits::is_integer &&
3823 RealLimits::is_signed == CompatibleLimits::is_signed;
3824 };
3825
3826 template<typename RealIntegerType, typename CompatibleNumberIntegerType>
3828 : is_compatible_integer_type_impl<RealIntegerType,
3829 CompatibleNumberIntegerType> {};
3830
3831 template<typename BasicJsonType, typename CompatibleType, typename = void>
3832 struct is_compatible_type_impl : std::false_type {};
3833
3834 template<typename BasicJsonType, typename CompatibleType>
3836 BasicJsonType, CompatibleType,
3837 enable_if_t<is_complete_type<CompatibleType>::value >>
3838 {
3839 static constexpr bool value =
3841 };
3842
3843 template<typename BasicJsonType, typename CompatibleType>
3845 : is_compatible_type_impl<BasicJsonType, CompatibleType> {};
3846
3847 template<typename T1, typename T2>
3848 struct is_constructible_tuple : std::false_type {};
3849
3850 template<typename T1, typename... Args>
3851 struct is_constructible_tuple<T1, std::tuple<Args...>> : conjunction<is_constructible<T1, Args>...> {};
3852
3853 // a naive helper to check if a type is an ordered_map (exploits the fact that
3854 // ordered_map inherits capacity() from std::vector)
3855 template <typename T>
3857 {
3858 using one = char;
3859
3860 struct two
3861 {
3862 char x[2]; // NOLINT(cppcoreguidelines-avoid-c-arrays,hicpp-avoid-c-arrays,modernize-avoid-c-arrays)
3863 };
3864
3865 template <typename C> static one test(decltype(&C::capacity));
3866 template <typename C> static two test(...);
3867
3868 enum { value = sizeof(test<T>(nullptr)) == sizeof(char) }; // NOLINT(cppcoreguidelines-pro-type-vararg,hicpp-vararg)
3869 };
3870
3871 // to avoid useless casts (see https://github.com/nlohmann/json/issues/2893#issuecomment-889152324)
3872 template < typename T, typename U, enable_if_t < !std::is_same<T, U>::value, int > = 0 >
3874 {
3875 return static_cast<T>(value);
3876 }
3877
3878 template<typename T, typename U, enable_if_t<std::is_same<T, U>::value, int> = 0>
3880 {
3881 return value;
3882 }
3883
3884 } // namespace detail
3885} // namespace nlohmann
3886
3887// #include <nlohmann/detail/value_t.hpp>
3888
3889
3890namespace nlohmann
3891{
3892 namespace detail
3893 {
3894 template<typename BasicJsonType>
3895 void from_json(const BasicJsonType& j, typename std::nullptr_t& n)
3896 {
3897 if (JSON_HEDLEY_UNLIKELY(!j.is_null()))
3898 {
3899 JSON_THROW(type_error::create(302, "type must be null, but is " + std::string(j.type_name()), j));
3900 }
3901 n = nullptr;
3902 }
3903
3904 // overloads for basic_json template parameters
3905 template < typename BasicJsonType, typename ArithmeticType,
3906 enable_if_t < std::is_arithmetic<ArithmeticType>::value &&
3907 !std::is_same<ArithmeticType, typename BasicJsonType::boolean_t>::value,
3908 int > = 0 >
3909 void get_arithmetic_value(const BasicJsonType& j, ArithmeticType& val)
3910 {
3911 switch (static_cast<value_t>(j))
3912 {
3914 {
3915 val = static_cast<ArithmeticType>(*j.template get_ptr<const typename BasicJsonType::number_unsigned_t*>());
3916 break;
3917 }
3919 {
3920 val = static_cast<ArithmeticType>(*j.template get_ptr<const typename BasicJsonType::number_integer_t*>());
3921 break;
3922 }
3924 {
3925 val = static_cast<ArithmeticType>(*j.template get_ptr<const typename BasicJsonType::number_float_t*>());
3926 break;
3927 }
3928
3929 case value_t::null:
3930 case value_t::object:
3931 case value_t::array:
3932 case value_t::string:
3933 case value_t::boolean:
3934 case value_t::binary:
3935 case value_t::discarded:
3936 default:
3937 JSON_THROW(type_error::create(302, "type must be number, but is " + std::string(j.type_name()), j));
3938 }
3939 }
3940
3941 template<typename BasicJsonType>
3942 void from_json(const BasicJsonType& j, typename BasicJsonType::boolean_t& b)
3943 {
3944 if (JSON_HEDLEY_UNLIKELY(!j.is_boolean()))
3945 {
3946 JSON_THROW(type_error::create(302, "type must be boolean, but is " + std::string(j.type_name()), j));
3947 }
3948 b = *j.template get_ptr<const typename BasicJsonType::boolean_t*>();
3949 }
3950
3951 template<typename BasicJsonType>
3952 void from_json(const BasicJsonType& j, typename BasicJsonType::string_t& s)
3953 {
3954 if (JSON_HEDLEY_UNLIKELY(!j.is_string()))
3955 {
3956 JSON_THROW(type_error::create(302, "type must be string, but is " + std::string(j.type_name()), j));
3957 }
3958 s = *j.template get_ptr<const typename BasicJsonType::string_t*>();
3959 }
3960
3961 template <
3962 typename BasicJsonType, typename ConstructibleStringType,
3963 enable_if_t <
3964 is_constructible_string_type<BasicJsonType, ConstructibleStringType>::value &&
3965 !std::is_same<typename BasicJsonType::string_t,
3966 ConstructibleStringType>::value,
3967 int > = 0 >
3968 void from_json(const BasicJsonType& j, ConstructibleStringType& s)
3969 {
3970 if (JSON_HEDLEY_UNLIKELY(!j.is_string()))
3971 {
3972 JSON_THROW(type_error::create(302, "type must be string, but is " + std::string(j.type_name()), j));
3973 }
3974
3975 s = *j.template get_ptr<const typename BasicJsonType::string_t*>();
3976 }
3977
3978 template<typename BasicJsonType>
3979 void from_json(const BasicJsonType& j, typename BasicJsonType::number_float_t& val)
3980 {
3981 get_arithmetic_value(j, val);
3982 }
3983
3984 template<typename BasicJsonType>
3985 void from_json(const BasicJsonType& j, typename BasicJsonType::number_unsigned_t& val)
3986 {
3987 get_arithmetic_value(j, val);
3988 }
3989
3990 template<typename BasicJsonType>
3991 void from_json(const BasicJsonType& j, typename BasicJsonType::number_integer_t& val)
3992 {
3993 get_arithmetic_value(j, val);
3994 }
3995
3996 template<typename BasicJsonType, typename EnumType,
3997 enable_if_t<std::is_enum<EnumType>::value, int> = 0>
3998 void from_json(const BasicJsonType& j, EnumType& e)
3999 {
4000 typename std::underlying_type<EnumType>::type val;
4001 get_arithmetic_value(j, val);
4002 e = static_cast<EnumType>(val);
4003 }
4004
4005 // forward_list doesn't have an insert method
4006 template<typename BasicJsonType, typename T, typename Allocator,
4007 enable_if_t<is_getable<BasicJsonType, T>::value, int> = 0>
4008 void from_json(const BasicJsonType& j, std::forward_list<T, Allocator>& l)
4009 {
4010 if (JSON_HEDLEY_UNLIKELY(!j.is_array()))
4011 {
4012 JSON_THROW(type_error::create(302, "type must be array, but is " + std::string(j.type_name()), j));
4013 }
4014 l.clear();
4015 std::transform(j.rbegin(), j.rend(),
4016 std::front_inserter(l), [](const BasicJsonType& i)
4017 {
4018 return i.template get<T>();
4019 });
4020 }
4021
4022 // valarray doesn't have an insert method
4023 template<typename BasicJsonType, typename T,
4024 enable_if_t<is_getable<BasicJsonType, T>::value, int> = 0>
4025 void from_json(const BasicJsonType& j, std::valarray<T>& l)
4026 {
4027 if (JSON_HEDLEY_UNLIKELY(!j.is_array()))
4028 {
4029 JSON_THROW(type_error::create(302, "type must be array, but is " + std::string(j.type_name()), j));
4030 }
4031 l.resize(j.size());
4032 std::transform(j.begin(), j.end(), std::begin(l),
4033 [](const BasicJsonType& elem)
4034 {
4035 return elem.template get<T>();
4036 });
4037 }
4038
4039 template<typename BasicJsonType, typename T, std::size_t N>
4040 auto from_json(const BasicJsonType& j, T(&arr)[N]) // NOLINT(cppcoreguidelines-avoid-c-arrays,hicpp-avoid-c-arrays,modernize-avoid-c-arrays)
4041 -> decltype(j.template get<T>(), void())
4042 {
4043 for (std::size_t i = 0; i < N; ++i)
4044 {
4045 arr[i] = j.at(i).template get<T>();
4046 }
4047 }
4048
4049 template<typename BasicJsonType>
4050 void from_json_array_impl(const BasicJsonType& j, typename BasicJsonType::array_t& arr, priority_tag<3> /*unused*/)
4051 {
4052 arr = *j.template get_ptr<const typename BasicJsonType::array_t*>();
4053 }
4054
4055 template<typename BasicJsonType, typename T, std::size_t N>
4056 auto from_json_array_impl(const BasicJsonType& j, std::array<T, N>& arr,
4057 priority_tag<2> /*unused*/)
4058 -> decltype(j.template get<T>(), void())
4059 {
4060 for (std::size_t i = 0; i < N; ++i)
4061 {
4062 arr[i] = j.at(i).template get<T>();
4063 }
4064 }
4065
4066 template<typename BasicJsonType, typename ConstructibleArrayType,
4068 std::is_assignable<ConstructibleArrayType&, ConstructibleArrayType>::value,
4069 int> = 0>
4070 auto from_json_array_impl(const BasicJsonType& j, ConstructibleArrayType& arr, priority_tag<1> /*unused*/)
4071 -> decltype(
4072 arr.reserve(std::declval<typename ConstructibleArrayType::size_type>()),
4073 j.template get<typename ConstructibleArrayType::value_type>(),
4074 void())
4075 {
4076 using std::end;
4077
4078 ConstructibleArrayType ret;
4079 ret.reserve(j.size());
4080 std::transform(j.begin(), j.end(),
4081 std::inserter(ret, end(ret)), [](const BasicJsonType& i)
4082 {
4083 // get<BasicJsonType>() returns *this, this won't call a from_json
4084 // method when value_type is BasicJsonType
4085 return i.template get<typename ConstructibleArrayType::value_type>();
4086 });
4087 arr = std::move(ret);
4088 }
4089
4090 template<typename BasicJsonType, typename ConstructibleArrayType,
4092 std::is_assignable<ConstructibleArrayType&, ConstructibleArrayType>::value,
4093 int> = 0>
4094 void from_json_array_impl(const BasicJsonType& j, ConstructibleArrayType& arr,
4095 priority_tag<0> /*unused*/)
4096 {
4097 using std::end;
4098
4099 ConstructibleArrayType ret;
4100 std::transform(
4101 j.begin(), j.end(), std::inserter(ret, end(ret)),
4102 [](const BasicJsonType& i)
4103 {
4104 // get<BasicJsonType>() returns *this, this won't call a from_json
4105 // method when value_type is BasicJsonType
4106 return i.template get<typename ConstructibleArrayType::value_type>();
4107 });
4108 arr = std::move(ret);
4109 }
4110
4111 template < typename BasicJsonType, typename ConstructibleArrayType,
4112 enable_if_t <
4113 is_constructible_array_type<BasicJsonType, ConstructibleArrayType>::value &&
4114 !is_constructible_object_type<BasicJsonType, ConstructibleArrayType>::value &&
4115 !is_constructible_string_type<BasicJsonType, ConstructibleArrayType>::value &&
4116 !std::is_same<ConstructibleArrayType, typename BasicJsonType::binary_t>::value &&
4117 !is_basic_json<ConstructibleArrayType>::value,
4118 int > = 0 >
4119 auto from_json(const BasicJsonType& j, ConstructibleArrayType& arr)
4120 -> decltype(from_json_array_impl(j, arr, priority_tag<3> {}),
4121 j.template get<typename ConstructibleArrayType::value_type>(),
4122 void())
4123 {
4124 if (JSON_HEDLEY_UNLIKELY(!j.is_array()))
4125 {
4126 JSON_THROW(type_error::create(302, "type must be array, but is " + std::string(j.type_name()), j));
4127 }
4128
4129 from_json_array_impl(j, arr, priority_tag<3> {});
4130 }
4131
4132 template < typename BasicJsonType, typename T, std::size_t... Idx >
4133 std::array<T, sizeof...(Idx)> from_json_inplace_array_impl(BasicJsonType&& j,
4134 identity_tag<std::array<T, sizeof...(Idx)>> /*unused*/, index_sequence<Idx...> /*unused*/)
4135 {
4136 return { { std::forward<BasicJsonType>(j).at(Idx).template get<T>()... } };
4137 }
4138
4139 template < typename BasicJsonType, typename T, std::size_t N >
4140 auto from_json(BasicJsonType&& j, identity_tag<std::array<T, N>> tag)
4141 -> decltype(from_json_inplace_array_impl(std::forward<BasicJsonType>(j), tag, make_index_sequence<N> {}))
4142 {
4143 if (JSON_HEDLEY_UNLIKELY(!j.is_array()))
4144 {
4145 JSON_THROW(type_error::create(302, "type must be array, but is " + std::string(j.type_name()), j));
4146 }
4147
4148 return from_json_inplace_array_impl(std::forward<BasicJsonType>(j), tag, make_index_sequence<N> {});
4149 }
4150
4151 template<typename BasicJsonType>
4152 void from_json(const BasicJsonType& j, typename BasicJsonType::binary_t& bin)
4153 {
4154 if (JSON_HEDLEY_UNLIKELY(!j.is_binary()))
4155 {
4156 JSON_THROW(type_error::create(302, "type must be binary, but is " + std::string(j.type_name()), j));
4157 }
4158
4159 bin = *j.template get_ptr<const typename BasicJsonType::binary_t*>();
4160 }
4161
4162 template<typename BasicJsonType, typename ConstructibleObjectType,
4163 enable_if_t<is_constructible_object_type<BasicJsonType, ConstructibleObjectType>::value, int> = 0>
4164 void from_json(const BasicJsonType& j, ConstructibleObjectType& obj)
4165 {
4166 if (JSON_HEDLEY_UNLIKELY(!j.is_object()))
4167 {
4168 JSON_THROW(type_error::create(302, "type must be object, but is " + std::string(j.type_name()), j));
4169 }
4170
4171 ConstructibleObjectType ret;
4172 const auto* inner_object = j.template get_ptr<const typename BasicJsonType::object_t*>();
4173 using value_type = typename ConstructibleObjectType::value_type;
4174 std::transform(
4175 inner_object->begin(), inner_object->end(),
4176 std::inserter(ret, ret.begin()),
4177 [](typename BasicJsonType::object_t::value_type const& p)
4178 {
4179 return value_type(p.first, p.second.template get<typename ConstructibleObjectType::mapped_type>());
4180 });
4181 obj = std::move(ret);
4182 }
4183
4184 // overload for arithmetic types, not chosen for basic_json template arguments
4185 // (BooleanType, etc..); note: Is it really necessary to provide explicit
4186 // overloads for boolean_t etc. in case of a custom BooleanType which is not
4187 // an arithmetic type?
4188 template < typename BasicJsonType, typename ArithmeticType,
4189 enable_if_t <
4190 std::is_arithmetic<ArithmeticType>::value &&
4191 !std::is_same<ArithmeticType, typename BasicJsonType::number_unsigned_t>::value &&
4192 !std::is_same<ArithmeticType, typename BasicJsonType::number_integer_t>::value &&
4193 !std::is_same<ArithmeticType, typename BasicJsonType::number_float_t>::value &&
4194 !std::is_same<ArithmeticType, typename BasicJsonType::boolean_t>::value,
4195 int > = 0 >
4196 void from_json(const BasicJsonType& j, ArithmeticType& val)
4197 {
4198 switch (static_cast<value_t>(j))
4199 {
4201 {
4202 val = static_cast<ArithmeticType>(*j.template get_ptr<const typename BasicJsonType::number_unsigned_t*>());
4203 break;
4204 }
4206 {
4207 val = static_cast<ArithmeticType>(*j.template get_ptr<const typename BasicJsonType::number_integer_t*>());
4208 break;
4209 }
4211 {
4212 val = static_cast<ArithmeticType>(*j.template get_ptr<const typename BasicJsonType::number_float_t*>());
4213 break;
4214 }
4215 case value_t::boolean:
4216 {
4217 val = static_cast<ArithmeticType>(*j.template get_ptr<const typename BasicJsonType::boolean_t*>());
4218 break;
4219 }
4220
4221 case value_t::null:
4222 case value_t::object:
4223 case value_t::array:
4224 case value_t::string:
4225 case value_t::binary:
4226 case value_t::discarded:
4227 default:
4228 JSON_THROW(type_error::create(302, "type must be number, but is " + std::string(j.type_name()), j));
4229 }
4230 }
4231
4232 template<typename BasicJsonType, typename... Args, std::size_t... Idx>
4233 std::tuple<Args...> from_json_tuple_impl_base(BasicJsonType&& j, index_sequence<Idx...> /*unused*/)
4234 {
4235 return std::make_tuple(std::forward<BasicJsonType>(j).at(Idx).template get<Args>()...);
4236 }
4237
4238 template < typename BasicJsonType, class A1, class A2 >
4239 std::pair<A1, A2> from_json_tuple_impl(BasicJsonType&& j, identity_tag<std::pair<A1, A2>> /*unused*/, priority_tag<0> /*unused*/)
4240 {
4241 return { std::forward<BasicJsonType>(j).at(0).template get<A1>(),
4242 std::forward<BasicJsonType>(j).at(1).template get<A2>() };
4243 }
4244
4245 template<typename BasicJsonType, typename A1, typename A2>
4246 void from_json_tuple_impl(BasicJsonType&& j, std::pair<A1, A2>& p, priority_tag<1> /*unused*/)
4247 {
4248 p = from_json_tuple_impl(std::forward<BasicJsonType>(j), identity_tag<std::pair<A1, A2>> {}, priority_tag<0> {});
4249 }
4250
4251 template<typename BasicJsonType, typename... Args>
4252 std::tuple<Args...> from_json_tuple_impl(BasicJsonType&& j, identity_tag<std::tuple<Args...>> /*unused*/, priority_tag<2> /*unused*/)
4253 {
4254 return from_json_tuple_impl_base<BasicJsonType, Args...>(std::forward<BasicJsonType>(j), index_sequence_for<Args...> {});
4255 }
4256
4257 template<typename BasicJsonType, typename... Args>
4258 void from_json_tuple_impl(BasicJsonType&& j, std::tuple<Args...>& t, priority_tag<3> /*unused*/)
4259 {
4260 t = from_json_tuple_impl_base<BasicJsonType, Args...>(std::forward<BasicJsonType>(j), index_sequence_for<Args...> {});
4261 }
4262
4263 template<typename BasicJsonType, typename TupleRelated>
4264 auto from_json(BasicJsonType&& j, TupleRelated&& t)
4265 -> decltype(from_json_tuple_impl(std::forward<BasicJsonType>(j), std::forward<TupleRelated>(t), priority_tag<3> {}))
4266 {
4267 if (JSON_HEDLEY_UNLIKELY(!j.is_array()))
4268 {
4269 JSON_THROW(type_error::create(302, "type must be array, but is " + std::string(j.type_name()), j));
4270 }
4271
4272 return from_json_tuple_impl(std::forward<BasicJsonType>(j), std::forward<TupleRelated>(t), priority_tag<3> {});
4273 }
4274
4275 template < typename BasicJsonType, typename Key, typename Value, typename Compare, typename Allocator,
4276 typename = enable_if_t < !std::is_constructible <
4277 typename BasicJsonType::string_t, Key >::value >>
4278 void from_json(const BasicJsonType& j, std::map<Key, Value, Compare, Allocator>& m)
4279 {
4280 if (JSON_HEDLEY_UNLIKELY(!j.is_array()))
4281 {
4282 JSON_THROW(type_error::create(302, "type must be array, but is " + std::string(j.type_name()), j));
4283 }
4284 m.clear();
4285 for (const auto& p : j)
4286 {
4287 if (JSON_HEDLEY_UNLIKELY(!p.is_array()))
4288 {
4289 JSON_THROW(type_error::create(302, "type must be array, but is " + std::string(p.type_name()), j));
4290 }
4291 m.emplace(p.at(0).template get<Key>(), p.at(1).template get<Value>());
4292 }
4293 }
4294
4295 template < typename BasicJsonType, typename Key, typename Value, typename Hash, typename KeyEqual, typename Allocator,
4296 typename = enable_if_t < !std::is_constructible <
4297 typename BasicJsonType::string_t, Key >::value >>
4298 void from_json(const BasicJsonType& j, std::unordered_map<Key, Value, Hash, KeyEqual, Allocator>& m)
4299 {
4300 if (JSON_HEDLEY_UNLIKELY(!j.is_array()))
4301 {
4302 JSON_THROW(type_error::create(302, "type must be array, but is " + std::string(j.type_name()), j));
4303 }
4304 m.clear();
4305 for (const auto& p : j)
4306 {
4307 if (JSON_HEDLEY_UNLIKELY(!p.is_array()))
4308 {
4309 JSON_THROW(type_error::create(302, "type must be array, but is " + std::string(p.type_name()), j));
4310 }
4311 m.emplace(p.at(0).template get<Key>(), p.at(1).template get<Value>());
4312 }
4313 }
4314
4316 {
4317 template<typename BasicJsonType, typename T>
4318 auto operator()(const BasicJsonType& j, T&& val) const
4319 noexcept(noexcept(from_json(j, std::forward<T>(val))))
4320 -> decltype(from_json(j, std::forward<T>(val)))
4321 {
4322 return from_json(j, std::forward<T>(val));
4323 }
4324 };
4325 } // namespace detail
4326
4330 namespace // NOLINT(cert-dcl59-cpp,fuchsia-header-anon-namespaces,google-build-namespaces)
4331 {
4332 constexpr const auto& from_json = detail::static_const<detail::from_json_fn>::value; // NOLINT(misc-definitions-in-headers)
4333 } // namespace
4334} // namespace nlohmann
4335
4336// #include <nlohmann/detail/conversions/to_json.hpp>
4337
4338
4339#include <algorithm> // copy
4340#include <iterator> // begin, end
4341#include <string> // string
4342#include <tuple> // tuple, get
4343#include <type_traits> // is_same, is_constructible, is_floating_point, is_enum, underlying_type
4344#include <utility> // move, forward, declval, pair
4345#include <valarray> // valarray
4346#include <vector> // vector
4347
4348// #include <nlohmann/detail/iterators/iteration_proxy.hpp>
4349
4350
4351#include <cstddef> // size_t
4352#include <iterator> // input_iterator_tag
4353#include <string> // string, to_string
4354#include <tuple> // tuple_size, get, tuple_element
4355#include <utility> // move
4356
4357// #include <nlohmann/detail/meta/type_traits.hpp>
4358
4359// #include <nlohmann/detail/value_t.hpp>
4360
4361
4362namespace nlohmann
4363{
4364 namespace detail
4365 {
4366 template<typename string_type>
4367 void int_to_string(string_type& target, std::size_t value)
4368 {
4369 // For ADL
4370 using std::to_string;
4371 target = to_string(value);
4372 }
4373 template<typename IteratorType> class iteration_proxy_value
4374 {
4375 public:
4376 using difference_type = std::ptrdiff_t;
4380 using iterator_category = std::input_iterator_tag;
4381 using string_type = typename std::remove_cv< typename std::remove_reference<decltype(std::declval<IteratorType>().key()) >::type >::type;
4382
4383 private:
4385 IteratorType anchor;
4387 std::size_t array_index = 0;
4389 mutable std::size_t array_index_last = 0;
4394
4395 public:
4396 explicit iteration_proxy_value(IteratorType it) noexcept
4397 : anchor(std::move(it))
4398 {}
4399
4402 {
4403 return *this;
4404 }
4405
4408 {
4409 ++anchor;
4410 ++array_index;
4411
4412 return *this;
4413 }
4414
4417 {
4418 return anchor == o.anchor;
4419 }
4420
4423 {
4424 return anchor != o.anchor;
4425 }
4426
4428 const string_type& key() const
4429 {
4430 JSON_ASSERT(anchor.m_object != nullptr);
4431
4432 switch (anchor.m_object->type())
4433 {
4434 // use integer array index as key
4435 case value_t::array:
4436 {
4438 {
4441 }
4442 return array_index_str;
4443 }
4444
4445 // use key from the object
4446 case value_t::object:
4447 return anchor.key();
4448
4449 // use an empty key for all primitive types
4450 case value_t::null:
4451 case value_t::string:
4452 case value_t::boolean:
4456 case value_t::binary:
4457 case value_t::discarded:
4458 default:
4459 return empty_str;
4460 }
4461 }
4462
4464 typename IteratorType::reference value() const
4465 {
4466 return anchor.value();
4467 }
4468 };
4469
4471 template<typename IteratorType> class iteration_proxy
4472 {
4473 private:
4475 typename IteratorType::reference container;
4476
4477 public:
4479 explicit iteration_proxy(typename IteratorType::reference cont) noexcept
4480 : container(cont) {}
4481
4484 {
4486 }
4487
4490 {
4492 }
4493 };
4494 // Structured Bindings Support
4495 // For further reference see https://blog.tartanllama.xyz/structured-bindings/
4496 // And see https://github.com/nlohmann/json/pull/1391
4497 template<std::size_t N, typename IteratorType, enable_if_t<N == 0, int> = 0>
4499 {
4500 return i.key();
4501 }
4502 // Structured Bindings Support
4503 // For further reference see https://blog.tartanllama.xyz/structured-bindings/
4504 // And see https://github.com/nlohmann/json/pull/1391
4505 template<std::size_t N, typename IteratorType, enable_if_t<N == 1, int> = 0>
4506 auto get(const nlohmann::detail::iteration_proxy_value<IteratorType>& i) -> decltype(i.value())
4507 {
4508 return i.value();
4509 }
4510 } // namespace detail
4511} // namespace nlohmann
4512
4513// The Addition to the STD Namespace is required to add
4514// Structured Bindings Support to the iteration_proxy_value class
4515// For further reference see https://blog.tartanllama.xyz/structured-bindings/
4516// And see https://github.com/nlohmann/json/pull/1391
4517namespace std
4518{
4519#if defined(__clang__)
4520 // Fix: https://github.com/nlohmann/json/issues/1401
4521#pragma clang diagnostic push
4522#pragma clang diagnostic ignored "-Wmismatched-tags"
4523#endif
4524 template<typename IteratorType>
4525 class tuple_size<::nlohmann::detail::iteration_proxy_value<IteratorType>>
4526 : public std::integral_constant<std::size_t, 2> {};
4527
4528 template<std::size_t N, typename IteratorType>
4529 class tuple_element<N, ::nlohmann::detail::iteration_proxy_value<IteratorType >>
4530 {
4531 public:
4532 using type = decltype(
4533 get<N>(std::declval <
4535 };
4536#if defined(__clang__)
4537#pragma clang diagnostic pop
4538#endif
4539} // namespace std
4540
4541// #include <nlohmann/detail/meta/cpp_future.hpp>
4542
4543// #include <nlohmann/detail/meta/type_traits.hpp>
4544
4545// #include <nlohmann/detail/value_t.hpp>
4546
4547
4548namespace nlohmann
4549{
4550 namespace detail
4551 {
4553 // constructors //
4555
4556 /*
4557 * Note all external_constructor<>::construct functions need to call
4558 * j.m_value.destroy(j.m_type) to avoid a memory leak in case j contains an
4559 * allocated value (e.g., a string). See bug issue
4560 * https://github.com/nlohmann/json/issues/2865 for more information.
4561 */
4562
4563 template<value_t> struct external_constructor;
4564
4565 template<>
4567 {
4568 template<typename BasicJsonType>
4569 static void construct(BasicJsonType& j, typename BasicJsonType::boolean_t b) noexcept
4570 {
4571 j.m_value.destroy(j.m_type);
4572 j.m_type = value_t::boolean;
4573 j.m_value = b;
4574 j.assert_invariant();
4575 }
4576 };
4577
4578 template<>
4580 {
4581 template<typename BasicJsonType>
4582 static void construct(BasicJsonType& j, const typename BasicJsonType::string_t& s)
4583 {
4584 j.m_value.destroy(j.m_type);
4585 j.m_type = value_t::string;
4586 j.m_value = s;
4587 j.assert_invariant();
4588 }
4589
4590 template<typename BasicJsonType>
4591 static void construct(BasicJsonType& j, typename BasicJsonType::string_t&& s)
4592 {
4593 j.m_value.destroy(j.m_type);
4594 j.m_type = value_t::string;
4595 j.m_value = std::move(s);
4596 j.assert_invariant();
4597 }
4598
4599 template < typename BasicJsonType, typename CompatibleStringType,
4600 enable_if_t < !std::is_same<CompatibleStringType, typename BasicJsonType::string_t>::value,
4601 int > = 0 >
4602 static void construct(BasicJsonType& j, const CompatibleStringType& str)
4603 {
4604 j.m_value.destroy(j.m_type);
4605 j.m_type = value_t::string;
4606 j.m_value.string = j.template create<typename BasicJsonType::string_t>(str);
4607 j.assert_invariant();
4608 }
4609 };
4610
4611 template<>
4613 {
4614 template<typename BasicJsonType>
4615 static void construct(BasicJsonType& j, const typename BasicJsonType::binary_t& b)
4616 {
4617 j.m_value.destroy(j.m_type);
4618 j.m_type = value_t::binary;
4619 j.m_value = typename BasicJsonType::binary_t(b);
4620 j.assert_invariant();
4621 }
4622
4623 template<typename BasicJsonType>
4624 static void construct(BasicJsonType& j, typename BasicJsonType::binary_t&& b)
4625 {
4626 j.m_value.destroy(j.m_type);
4627 j.m_type = value_t::binary;
4628 j.m_value = typename BasicJsonType::binary_t(std::move(b));
4629 j.assert_invariant();
4630 }
4631 };
4632
4633 template<>
4635 {
4636 template<typename BasicJsonType>
4637 static void construct(BasicJsonType& j, typename BasicJsonType::number_float_t val) noexcept
4638 {
4639 j.m_value.destroy(j.m_type);
4640 j.m_type = value_t::number_float;
4641 j.m_value = val;
4642 j.assert_invariant();
4643 }
4644 };
4645
4646 template<>
4648 {
4649 template<typename BasicJsonType>
4650 static void construct(BasicJsonType& j, typename BasicJsonType::number_unsigned_t val) noexcept
4651 {
4652 j.m_value.destroy(j.m_type);
4653 j.m_type = value_t::number_unsigned;
4654 j.m_value = val;
4655 j.assert_invariant();
4656 }
4657 };
4658
4659 template<>
4661 {
4662 template<typename BasicJsonType>
4663 static void construct(BasicJsonType& j, typename BasicJsonType::number_integer_t val) noexcept
4664 {
4665 j.m_value.destroy(j.m_type);
4666 j.m_type = value_t::number_integer;
4667 j.m_value = val;
4668 j.assert_invariant();
4669 }
4670 };
4671
4672 template<>
4674 {
4675 template<typename BasicJsonType>
4676 static void construct(BasicJsonType& j, const typename BasicJsonType::array_t& arr)
4677 {
4678 j.m_value.destroy(j.m_type);
4679 j.m_type = value_t::array;
4680 j.m_value = arr;
4681 j.set_parents();
4682 j.assert_invariant();
4683 }
4684
4685 template<typename BasicJsonType>
4686 static void construct(BasicJsonType& j, typename BasicJsonType::array_t&& arr)
4687 {
4688 j.m_value.destroy(j.m_type);
4689 j.m_type = value_t::array;
4690 j.m_value = std::move(arr);
4691 j.set_parents();
4692 j.assert_invariant();
4693 }
4694
4695 template < typename BasicJsonType, typename CompatibleArrayType,
4696 enable_if_t < !std::is_same<CompatibleArrayType, typename BasicJsonType::array_t>::value,
4697 int > = 0 >
4698 static void construct(BasicJsonType& j, const CompatibleArrayType& arr)
4699 {
4700 using std::begin;
4701 using std::end;
4702
4703 j.m_value.destroy(j.m_type);
4704 j.m_type = value_t::array;
4705 j.m_value.array = j.template create<typename BasicJsonType::array_t>(begin(arr), end(arr));
4706 j.set_parents();
4707 j.assert_invariant();
4708 }
4709
4710 template<typename BasicJsonType>
4711 static void construct(BasicJsonType& j, const std::vector<bool>& arr)
4712 {
4713 j.m_value.destroy(j.m_type);
4714 j.m_type = value_t::array;
4715 j.m_value = value_t::array;
4716 j.m_value.array->reserve(arr.size());
4717 for (const bool x : arr)
4718 {
4719 j.m_value.array->push_back(x);
4720 j.set_parent(j.m_value.array->back());
4721 }
4722 j.assert_invariant();
4723 }
4724
4725 template<typename BasicJsonType, typename T,
4727 static void construct(BasicJsonType& j, const std::valarray<T>& arr)
4728 {
4729 j.m_value.destroy(j.m_type);
4730 j.m_type = value_t::array;
4731 j.m_value = value_t::array;
4732 j.m_value.array->resize(arr.size());
4733 if (arr.size() > 0)
4734 {
4735 std::copy(std::begin(arr), std::end(arr), j.m_value.array->begin());
4736 }
4737 j.set_parents();
4738 j.assert_invariant();
4739 }
4740 };
4741
4742 template<>
4744 {
4745 template<typename BasicJsonType>
4746 static void construct(BasicJsonType& j, const typename BasicJsonType::object_t& obj)
4747 {
4748 j.m_value.destroy(j.m_type);
4749 j.m_type = value_t::object;
4750 j.m_value = obj;
4751 j.set_parents();
4752 j.assert_invariant();
4753 }
4754
4755 template<typename BasicJsonType>
4756 static void construct(BasicJsonType& j, typename BasicJsonType::object_t&& obj)
4757 {
4758 j.m_value.destroy(j.m_type);
4759 j.m_type = value_t::object;
4760 j.m_value = std::move(obj);
4761 j.set_parents();
4762 j.assert_invariant();
4763 }
4764
4765 template < typename BasicJsonType, typename CompatibleObjectType,
4766 enable_if_t < !std::is_same<CompatibleObjectType, typename BasicJsonType::object_t>::value, int > = 0 >
4767 static void construct(BasicJsonType& j, const CompatibleObjectType& obj)
4768 {
4769 using std::begin;
4770 using std::end;
4771
4772 j.m_value.destroy(j.m_type);
4773 j.m_type = value_t::object;
4774 j.m_value.object = j.template create<typename BasicJsonType::object_t>(begin(obj), end(obj));
4775 j.set_parents();
4776 j.assert_invariant();
4777 }
4778 };
4779
4781 // to_json //
4783
4784 template<typename BasicJsonType, typename T,
4785 enable_if_t<std::is_same<T, typename BasicJsonType::boolean_t>::value, int> = 0>
4786 void to_json(BasicJsonType& j, T b) noexcept
4787 {
4789 }
4790
4791 template<typename BasicJsonType, typename CompatibleString,
4792 enable_if_t<std::is_constructible<typename BasicJsonType::string_t, CompatibleString>::value, int> = 0>
4793 void to_json(BasicJsonType& j, const CompatibleString& s)
4794 {
4796 }
4797
4798 template<typename BasicJsonType>
4799 void to_json(BasicJsonType& j, typename BasicJsonType::string_t&& s)
4800 {
4802 }
4803
4804 template<typename BasicJsonType, typename FloatType,
4805 enable_if_t<std::is_floating_point<FloatType>::value, int> = 0>
4806 void to_json(BasicJsonType& j, FloatType val) noexcept
4807 {
4808 external_constructor<value_t::number_float>::construct(j, static_cast<typename BasicJsonType::number_float_t>(val));
4809 }
4810
4811 template<typename BasicJsonType, typename CompatibleNumberUnsignedType,
4812 enable_if_t<is_compatible_integer_type<typename BasicJsonType::number_unsigned_t, CompatibleNumberUnsignedType>::value, int> = 0>
4813 void to_json(BasicJsonType& j, CompatibleNumberUnsignedType val) noexcept
4814 {
4815 external_constructor<value_t::number_unsigned>::construct(j, static_cast<typename BasicJsonType::number_unsigned_t>(val));
4816 }
4817
4818 template<typename BasicJsonType, typename CompatibleNumberIntegerType,
4819 enable_if_t<is_compatible_integer_type<typename BasicJsonType::number_integer_t, CompatibleNumberIntegerType>::value, int> = 0>
4820 void to_json(BasicJsonType& j, CompatibleNumberIntegerType val) noexcept
4821 {
4822 external_constructor<value_t::number_integer>::construct(j, static_cast<typename BasicJsonType::number_integer_t>(val));
4823 }
4824
4825 template<typename BasicJsonType, typename EnumType,
4826 enable_if_t<std::is_enum<EnumType>::value, int> = 0>
4827 void to_json(BasicJsonType& j, EnumType e) noexcept
4828 {
4829 using underlying_type = typename std::underlying_type<EnumType>::type;
4830 external_constructor<value_t::number_integer>::construct(j, static_cast<underlying_type>(e));
4831 }
4832
4833 template<typename BasicJsonType>
4834 void to_json(BasicJsonType& j, const std::vector<bool>& e)
4835 {
4837 }
4838
4839 template < typename BasicJsonType, typename CompatibleArrayType,
4840 enable_if_t < is_compatible_array_type<BasicJsonType,
4841 CompatibleArrayType>::value &&
4842 !is_compatible_object_type<BasicJsonType, CompatibleArrayType>::value &&
4843 !is_compatible_string_type<BasicJsonType, CompatibleArrayType>::value &&
4844 !std::is_same<typename BasicJsonType::binary_t, CompatibleArrayType>::value &&
4845 !is_basic_json<CompatibleArrayType>::value,
4846 int > = 0 >
4847 void to_json(BasicJsonType& j, const CompatibleArrayType& arr)
4848 {
4850 }
4851
4852 template<typename BasicJsonType>
4853 void to_json(BasicJsonType& j, const typename BasicJsonType::binary_t& bin)
4854 {
4856 }
4857
4858 template<typename BasicJsonType, typename T,
4859 enable_if_t<std::is_convertible<T, BasicJsonType>::value, int> = 0>
4860 void to_json(BasicJsonType& j, const std::valarray<T>& arr)
4861 {
4863 }
4864
4865 template<typename BasicJsonType>
4866 void to_json(BasicJsonType& j, typename BasicJsonType::array_t&& arr)
4867 {
4869 }
4870
4871 template < typename BasicJsonType, typename CompatibleObjectType,
4872 enable_if_t < is_compatible_object_type<BasicJsonType, CompatibleObjectType>::value && !is_basic_json<CompatibleObjectType>::value, int > = 0 >
4873 void to_json(BasicJsonType& j, const CompatibleObjectType& obj)
4874 {
4876 }
4877
4878 template<typename BasicJsonType>
4879 void to_json(BasicJsonType& j, typename BasicJsonType::object_t&& obj)
4880 {
4882 }
4883
4884 template <
4885 typename BasicJsonType, typename T, std::size_t N,
4886 enable_if_t < !std::is_constructible<typename BasicJsonType::string_t,
4887 const T(&)[N]>::value, // NOLINT(cppcoreguidelines-avoid-c-arrays,hicpp-avoid-c-arrays,modernize-avoid-c-arrays)
4888 int > = 0 >
4889 void to_json(BasicJsonType& j, const T(&arr)[N]) // NOLINT(cppcoreguidelines-avoid-c-arrays,hicpp-avoid-c-arrays,modernize-avoid-c-arrays)
4890 {
4892 }
4893
4894 template < typename BasicJsonType, typename T1, typename T2, enable_if_t < std::is_constructible<BasicJsonType, T1>::value&& std::is_constructible<BasicJsonType, T2>::value, int > = 0 >
4895 void to_json(BasicJsonType& j, const std::pair<T1, T2>& p)
4896 {
4897 j = { p.first, p.second };
4898 }
4899
4900 // for https://github.com/nlohmann/json/pull/1134
4901 template<typename BasicJsonType, typename T,
4902 enable_if_t<std::is_same<T, iteration_proxy_value<typename BasicJsonType::iterator>>::value, int> = 0>
4903 void to_json(BasicJsonType& j, const T& b)
4904 {
4905 j = { {b.key(), b.value()} };
4906 }
4907
4908 template<typename BasicJsonType, typename Tuple, std::size_t... Idx>
4909 void to_json_tuple_impl(BasicJsonType& j, const Tuple& t, index_sequence<Idx...> /*unused*/)
4910 {
4911 j = { std::get<Idx>(t)... };
4912 }
4913
4914 template<typename BasicJsonType, typename T, enable_if_t<is_constructible_tuple<BasicJsonType, T>::value, int > = 0>
4915 void to_json(BasicJsonType& j, const T& t)
4916 {
4917 to_json_tuple_impl(j, t, make_index_sequence<std::tuple_size<T>::value> {});
4918 }
4919
4921 {
4922 template<typename BasicJsonType, typename T>
4923 auto operator()(BasicJsonType& j, T&& val) const noexcept(noexcept(to_json(j, std::forward<T>(val))))
4924 -> decltype(to_json(j, std::forward<T>(val)), void())
4925 {
4926 return to_json(j, std::forward<T>(val));
4927 }
4928 };
4929 } // namespace detail
4930
4934 namespace // NOLINT(cert-dcl59-cpp,fuchsia-header-anon-namespaces,google-build-namespaces)
4935 {
4936 constexpr const auto& to_json = detail::static_const<detail::to_json_fn>::value; // NOLINT(misc-definitions-in-headers)
4937 } // namespace
4938} // namespace nlohmann
4939
4940// #include <nlohmann/detail/meta/identity_tag.hpp>
4941
4942// #include <nlohmann/detail/meta/type_traits.hpp>
4943
4944
4945namespace nlohmann
4946{
4947
4948 template<typename ValueType, typename>
4950 {
4962 template<typename BasicJsonType, typename TargetType = ValueType>
4963 static auto from_json(BasicJsonType&& j, TargetType& val) noexcept(
4964 noexcept(::nlohmann::from_json(std::forward<BasicJsonType>(j), val)))
4965 -> decltype(::nlohmann::from_json(std::forward<BasicJsonType>(j), val), void())
4966 {
4967 ::nlohmann::from_json(std::forward<BasicJsonType>(j), val);
4968 }
4969
4982 template<typename BasicJsonType, typename TargetType = ValueType>
4983 static auto from_json(BasicJsonType&& j) noexcept(
4984 noexcept(::nlohmann::from_json(std::forward<BasicJsonType>(j), detail::identity_tag<TargetType> {})))
4985 -> decltype(::nlohmann::from_json(std::forward<BasicJsonType>(j), detail::identity_tag<TargetType> {}))
4986 {
4987 return ::nlohmann::from_json(std::forward<BasicJsonType>(j), detail::identity_tag<TargetType> {});
4988 }
4989
4999 template<typename BasicJsonType, typename TargetType = ValueType>
5000 static auto to_json(BasicJsonType& j, TargetType&& val) noexcept(
5001 noexcept(::nlohmann::to_json(j, std::forward<TargetType>(val))))
5002 -> decltype(::nlohmann::to_json(j, std::forward<TargetType>(val)), void())
5003 {
5004 ::nlohmann::to_json(j, std::forward<TargetType>(val));
5005 }
5006 };
5007} // namespace nlohmann
5008
5009// #include <nlohmann/byte_container_with_subtype.hpp>
5010
5011
5012#include <cstdint> // uint8_t, uint64_t
5013#include <tuple> // tie
5014#include <utility> // move
5015
5016namespace nlohmann
5017{
5018
5032 template<typename BinaryType>
5033 class byte_container_with_subtype : public BinaryType
5034 {
5035 public:
5037 using container_type = BinaryType;
5039 using subtype_type = std::uint64_t;
5040
5042 : container_type()
5043 {}
5044
5046 : container_type(b)
5047 {}
5048
5051 {}
5052
5054 : container_type(b)
5055 , m_subtype(subtype_)
5056 , m_has_subtype(true)
5057 {}
5058
5061 , m_subtype(subtype_)
5062 , m_has_subtype(true)
5063 {}
5064
5066 {
5067 return std::tie(static_cast<const BinaryType&>(*this), m_subtype, m_has_subtype) ==
5068 std::tie(static_cast<const BinaryType&>(rhs), rhs.m_subtype, rhs.m_has_subtype);
5069 }
5070
5072 {
5073 return !(rhs == *this);
5074 }
5075
5094 void set_subtype(subtype_type subtype_) noexcept
5095 {
5096 m_subtype = subtype_;
5097 m_has_subtype = true;
5098 }
5099
5122 constexpr subtype_type subtype() const noexcept
5123 {
5124 return m_has_subtype ? m_subtype : subtype_type(-1);
5125 }
5126
5143 constexpr bool has_subtype() const noexcept
5144 {
5145 return m_has_subtype;
5146 }
5147
5167 void clear_subtype() noexcept
5168 {
5169 m_subtype = 0;
5170 m_has_subtype = false;
5171 }
5172
5173 private:
5175 bool m_has_subtype = false;
5176 };
5177
5178} // namespace nlohmann
5179
5180// #include <nlohmann/detail/conversions/from_json.hpp>
5181
5182// #include <nlohmann/detail/conversions/to_json.hpp>
5183
5184// #include <nlohmann/detail/exceptions.hpp>
5185
5186// #include <nlohmann/detail/hash.hpp>
5187
5188
5189#include <cstdint> // uint8_t
5190#include <cstddef> // size_t
5191#include <functional> // hash
5192
5193// #include <nlohmann/detail/macro_scope.hpp>
5194
5195// #include <nlohmann/detail/value_t.hpp>
5196
5197
5198namespace nlohmann
5199{
5200 namespace detail
5201 {
5202
5203 // boost::hash_combine
5204 inline std::size_t combine(std::size_t seed, std::size_t h) noexcept
5205 {
5206 seed ^= h + 0x9e3779b9 + (seed << 6U) + (seed >> 2U);
5207 return seed;
5208 }
5209
5221 template<typename BasicJsonType>
5222 std::size_t hash(const BasicJsonType& j)
5223 {
5224 using string_t = typename BasicJsonType::string_t;
5225 using number_integer_t = typename BasicJsonType::number_integer_t;
5226 using number_unsigned_t = typename BasicJsonType::number_unsigned_t;
5227 using number_float_t = typename BasicJsonType::number_float_t;
5228
5229 const auto type = static_cast<std::size_t>(j.type());
5230 switch (j.type())
5231 {
5232 case BasicJsonType::value_t::null:
5233 case BasicJsonType::value_t::discarded:
5234 {
5235 return combine(type, 0);
5236 }
5237
5238 case BasicJsonType::value_t::object:
5239 {
5240 auto seed = combine(type, j.size());
5241 for (const auto& element : j.items())
5242 {
5243 const auto h = std::hash<string_t>{}(element.key());
5244 seed = combine(seed, h);
5245 seed = combine(seed, hash(element.value()));
5246 }
5247 return seed;
5248 }
5249
5250 case BasicJsonType::value_t::array:
5251 {
5252 auto seed = combine(type, j.size());
5253 for (const auto& element : j)
5254 {
5255 seed = combine(seed, hash(element));
5256 }
5257 return seed;
5258 }
5259
5260 case BasicJsonType::value_t::string:
5261 {
5262 const auto h = std::hash<string_t>{}(j.template get_ref<const string_t&>());
5263 return combine(type, h);
5264 }
5265
5266 case BasicJsonType::value_t::boolean:
5267 {
5268 const auto h = std::hash<bool>{}(j.template get<bool>());
5269 return combine(type, h);
5270 }
5271
5272 case BasicJsonType::value_t::number_integer:
5273 {
5274 const auto h = std::hash<number_integer_t>{}(j.template get<number_integer_t>());
5275 return combine(type, h);
5276 }
5277
5278 case BasicJsonType::value_t::number_unsigned:
5279 {
5280 const auto h = std::hash<number_unsigned_t>{}(j.template get<number_unsigned_t>());
5281 return combine(type, h);
5282 }
5283
5284 case BasicJsonType::value_t::number_float:
5285 {
5286 const auto h = std::hash<number_float_t>{}(j.template get<number_float_t>());
5287 return combine(type, h);
5288 }
5289
5290 case BasicJsonType::value_t::binary:
5291 {
5292 auto seed = combine(type, j.get_binary().size());
5293 const auto h = std::hash<bool>{}(j.get_binary().has_subtype());
5294 seed = combine(seed, h);
5295 seed = combine(seed, static_cast<std::size_t>(j.get_binary().subtype()));
5296 for (const auto byte : j.get_binary())
5297 {
5298 seed = combine(seed, std::hash<std::uint8_t> {}(byte));
5299 }
5300 return seed;
5301 }
5302
5303 default: // LCOV_EXCL_LINE
5304 JSON_ASSERT(false); // NOLINT(cert-dcl03-c,hicpp-static-assert,misc-static-assert) LCOV_EXCL_LINE
5305 return 0; // LCOV_EXCL_LINE
5306 }
5307 }
5308
5309 } // namespace detail
5310} // namespace nlohmann
5311
5312// #include <nlohmann/detail/input/binary_reader.hpp>
5313
5314
5315#include <algorithm> // generate_n
5316#include <array> // array
5317#include <cmath> // ldexp
5318#include <cstddef> // size_t
5319#include <cstdint> // uint8_t, uint16_t, uint32_t, uint64_t
5320#include <cstdio> // snprintf
5321#include <cstring> // memcpy
5322#include <iterator> // back_inserter
5323#include <limits> // numeric_limits
5324#include <string> // char_traits, string
5325#include <utility> // make_pair, move
5326#include <vector> // vector
5327
5328// #include <nlohmann/detail/exceptions.hpp>
5329
5330// #include <nlohmann/detail/input/input_adapters.hpp>
5331
5332
5333#include <array> // array
5334#include <cstddef> // size_t
5335#include <cstring> // strlen
5336#include <iterator> // begin, end, iterator_traits, random_access_iterator_tag, distance, next
5337#include <memory> // shared_ptr, make_shared, addressof
5338#include <numeric> // accumulate
5339#include <string> // string, char_traits
5340#include <type_traits> // enable_if, is_base_of, is_pointer, is_integral, remove_pointer
5341#include <utility> // pair, declval
5342
5343#ifndef JSON_NO_IO
5344#include <cstdio> // FILE *
5345#include <istream> // istream
5346#endif // JSON_NO_IO
5347
5348// #include <nlohmann/detail/iterators/iterator_traits.hpp>
5349
5350// #include <nlohmann/detail/macro_scope.hpp>
5351
5352
5353namespace nlohmann
5354{
5355 namespace detail
5356 {
5359
5361 // input adapters //
5363
5364#ifndef JSON_NO_IO
5370 {
5371 public:
5372 using char_type = char;
5373
5375 explicit file_input_adapter(std::FILE* f) noexcept
5376 : m_file(f)
5377 {}
5378
5379 // make class move-only
5382 file_input_adapter& operator=(const file_input_adapter&) = delete;
5385
5386 std::char_traits<char>::int_type get_character() noexcept
5387 {
5388 return std::fgetc(m_file);
5389 }
5390
5391 private:
5393 std::FILE* m_file;
5394 };
5395
5396
5407 {
5408 public:
5409 using char_type = char;
5410
5412 {
5413 // clear stream flags; we use underlying streambuf I/O, do not
5414 // maintain ifstream flags, except eof
5415 if (is != nullptr)
5416 {
5417 is->clear(is->rdstate() & std::ios::eofbit);
5418 }
5419 }
5420
5421 explicit input_stream_adapter(std::istream& i)
5422 : is(&i), sb(i.rdbuf())
5423 {}
5424
5425 // delete because of pointer members
5429
5431 : is(rhs.is), sb(rhs.sb)
5432 {
5433 rhs.is = nullptr;
5434 rhs.sb = nullptr;
5435 }
5436
5437 // std::istream/std::streambuf use std::char_traits<char>::to_int_type, to
5438 // ensure that std::char_traits<char>::eof() and the character 0xFF do not
5439 // end up as the same value, eg. 0xFFFFFFFF.
5440 std::char_traits<char>::int_type get_character()
5441 {
5442 auto res = sb->sbumpc();
5443 // set eof manually, as we don't use the istream interface.
5444 if (JSON_HEDLEY_UNLIKELY(res == std::char_traits<char>::eof()))
5445 {
5446 is->clear(is->rdstate() | std::ios::eofbit);
5447 }
5448 return res;
5449 }
5450
5451 private:
5453 std::istream* is = nullptr;
5454 std::streambuf* sb = nullptr;
5455 };
5456#endif // JSON_NO_IO
5457
5458 // General-purpose iterator-based adapter. It might not be as fast as
5459 // theoretically possible for some containers, but it is extremely versatile.
5460 template<typename IteratorType>
5462 {
5463 public:
5464 using char_type = typename std::iterator_traits<IteratorType>::value_type;
5465
5466 iterator_input_adapter(IteratorType first, IteratorType last)
5467 : current(std::move(first)), end(std::move(last))
5468 {}
5469
5470 typename std::char_traits<char_type>::int_type get_character()
5471 {
5473 {
5474 auto result = std::char_traits<char_type>::to_int_type(*current);
5475 std::advance(current, 1);
5476 return result;
5477 }
5478
5479 return std::char_traits<char_type>::eof();
5480 }
5481
5482 private:
5483 IteratorType current;
5484 IteratorType end;
5485
5486 template<typename BaseInputAdapter, size_t T>
5488
5489 bool empty() const
5490 {
5491 return current == end;
5492 }
5493 };
5494
5495
5496 template<typename BaseInputAdapter, size_t T>
5498
5499 template<typename BaseInputAdapter>
5500 struct wide_string_input_helper<BaseInputAdapter, 4>
5501 {
5502 // UTF-32
5503 static void fill_buffer(BaseInputAdapter& input,
5504 std::array<std::char_traits<char>::int_type, 4>& utf8_bytes,
5505 size_t& utf8_bytes_index,
5506 size_t& utf8_bytes_filled)
5507 {
5508 utf8_bytes_index = 0;
5509
5510 if (JSON_HEDLEY_UNLIKELY(input.empty()))
5511 {
5512 utf8_bytes[0] = std::char_traits<char>::eof();
5513 utf8_bytes_filled = 1;
5514 }
5515 else
5516 {
5517 // get the current character
5518 const auto wc = input.get_character();
5519
5520 // UTF-32 to UTF-8 encoding
5521 if (wc < 0x80)
5522 {
5523 utf8_bytes[0] = static_cast<std::char_traits<char>::int_type>(wc);
5524 utf8_bytes_filled = 1;
5525 }
5526 else if (wc <= 0x7FF)
5527 {
5528 utf8_bytes[0] = static_cast<std::char_traits<char>::int_type>(0xC0u | ((static_cast<unsigned int>(wc) >> 6u) & 0x1Fu));
5529 utf8_bytes[1] = static_cast<std::char_traits<char>::int_type>(0x80u | (static_cast<unsigned int>(wc) & 0x3Fu));
5530 utf8_bytes_filled = 2;
5531 }
5532 else if (wc <= 0xFFFF)
5533 {
5534 utf8_bytes[0] = static_cast<std::char_traits<char>::int_type>(0xE0u | ((static_cast<unsigned int>(wc) >> 12u) & 0x0Fu));
5535 utf8_bytes[1] = static_cast<std::char_traits<char>::int_type>(0x80u | ((static_cast<unsigned int>(wc) >> 6u) & 0x3Fu));
5536 utf8_bytes[2] = static_cast<std::char_traits<char>::int_type>(0x80u | (static_cast<unsigned int>(wc) & 0x3Fu));
5537 utf8_bytes_filled = 3;
5538 }
5539 else if (wc <= 0x10FFFF)
5540 {
5541 utf8_bytes[0] = static_cast<std::char_traits<char>::int_type>(0xF0u | ((static_cast<unsigned int>(wc) >> 18u) & 0x07u));
5542 utf8_bytes[1] = static_cast<std::char_traits<char>::int_type>(0x80u | ((static_cast<unsigned int>(wc) >> 12u) & 0x3Fu));
5543 utf8_bytes[2] = static_cast<std::char_traits<char>::int_type>(0x80u | ((static_cast<unsigned int>(wc) >> 6u) & 0x3Fu));
5544 utf8_bytes[3] = static_cast<std::char_traits<char>::int_type>(0x80u | (static_cast<unsigned int>(wc) & 0x3Fu));
5545 utf8_bytes_filled = 4;
5546 }
5547 else
5548 {
5549 // unknown character
5550 utf8_bytes[0] = static_cast<std::char_traits<char>::int_type>(wc);
5551 utf8_bytes_filled = 1;
5552 }
5553 }
5554 }
5555 };
5556
5557 template<typename BaseInputAdapter>
5558 struct wide_string_input_helper<BaseInputAdapter, 2>
5559 {
5560 // UTF-16
5561 static void fill_buffer(BaseInputAdapter& input,
5562 std::array<std::char_traits<char>::int_type, 4>& utf8_bytes,
5563 size_t& utf8_bytes_index,
5564 size_t& utf8_bytes_filled)
5565 {
5566 utf8_bytes_index = 0;
5567
5568 if (JSON_HEDLEY_UNLIKELY(input.empty()))
5569 {
5570 utf8_bytes[0] = std::char_traits<char>::eof();
5571 utf8_bytes_filled = 1;
5572 }
5573 else
5574 {
5575 // get the current character
5576 const auto wc = input.get_character();
5577
5578 // UTF-16 to UTF-8 encoding
5579 if (wc < 0x80)
5580 {
5581 utf8_bytes[0] = static_cast<std::char_traits<char>::int_type>(wc);
5582 utf8_bytes_filled = 1;
5583 }
5584 else if (wc <= 0x7FF)
5585 {
5586 utf8_bytes[0] = static_cast<std::char_traits<char>::int_type>(0xC0u | ((static_cast<unsigned int>(wc) >> 6u)));
5587 utf8_bytes[1] = static_cast<std::char_traits<char>::int_type>(0x80u | (static_cast<unsigned int>(wc) & 0x3Fu));
5588 utf8_bytes_filled = 2;
5589 }
5590 else if (0xD800 > wc || wc >= 0xE000)
5591 {
5592 utf8_bytes[0] = static_cast<std::char_traits<char>::int_type>(0xE0u | ((static_cast<unsigned int>(wc) >> 12u)));
5593 utf8_bytes[1] = static_cast<std::char_traits<char>::int_type>(0x80u | ((static_cast<unsigned int>(wc) >> 6u) & 0x3Fu));
5594 utf8_bytes[2] = static_cast<std::char_traits<char>::int_type>(0x80u | (static_cast<unsigned int>(wc) & 0x3Fu));
5595 utf8_bytes_filled = 3;
5596 }
5597 else
5598 {
5599 if (JSON_HEDLEY_UNLIKELY(!input.empty()))
5600 {
5601 const auto wc2 = static_cast<unsigned int>(input.get_character());
5602 const auto charcode = 0x10000u + (((static_cast<unsigned int>(wc) & 0x3FFu) << 10u) | (wc2 & 0x3FFu));
5603 utf8_bytes[0] = static_cast<std::char_traits<char>::int_type>(0xF0u | (charcode >> 18u));
5604 utf8_bytes[1] = static_cast<std::char_traits<char>::int_type>(0x80u | ((charcode >> 12u) & 0x3Fu));
5605 utf8_bytes[2] = static_cast<std::char_traits<char>::int_type>(0x80u | ((charcode >> 6u) & 0x3Fu));
5606 utf8_bytes[3] = static_cast<std::char_traits<char>::int_type>(0x80u | (charcode & 0x3Fu));
5607 utf8_bytes_filled = 4;
5608 }
5609 else
5610 {
5611 utf8_bytes[0] = static_cast<std::char_traits<char>::int_type>(wc);
5612 utf8_bytes_filled = 1;
5613 }
5614 }
5615 }
5616 }
5617 };
5618
5619 // Wraps another input apdater to convert wide character types into individual bytes.
5620 template<typename BaseInputAdapter, typename WideCharType>
5622 {
5623 public:
5624 using char_type = char;
5625
5626 wide_string_input_adapter(BaseInputAdapter base)
5627 : base_adapter(base) {}
5628
5629 typename std::char_traits<char>::int_type get_character() noexcept
5630 {
5631 // check if buffer needs to be filled
5633 {
5634 fill_buffer<sizeof(WideCharType)>();
5635
5638 }
5639
5640 // use buffer
5643 return utf8_bytes[utf8_bytes_index++];
5644 }
5645
5646 private:
5647 BaseInputAdapter base_adapter;
5648
5649 template<size_t T>
5651 {
5653 }
5654
5656 std::array<std::char_traits<char>::int_type, 4> utf8_bytes = { {0, 0, 0, 0} };
5657
5659 std::size_t utf8_bytes_index = 0;
5661 std::size_t utf8_bytes_filled = 0;
5662 };
5663
5664
5665 template<typename IteratorType, typename Enable = void>
5667 {
5668 using iterator_type = IteratorType;
5669 using char_type = typename std::iterator_traits<iterator_type>::value_type;
5671
5672 static adapter_type create(IteratorType first, IteratorType last)
5673 {
5674 return adapter_type(std::move(first), std::move(last));
5675 }
5676 };
5677
5678 template<typename T>
5680 {
5681 using value_type = typename std::iterator_traits<T>::value_type;
5682 enum
5683 {
5684 value = sizeof(value_type) > 1
5685 };
5686 };
5687
5688 template<typename IteratorType>
5690 {
5691 using iterator_type = IteratorType;
5692 using char_type = typename std::iterator_traits<iterator_type>::value_type;
5695
5696 static adapter_type create(IteratorType first, IteratorType last)
5697 {
5698 return adapter_type(base_adapter_type(std::move(first), std::move(last)));
5699 }
5700 };
5701
5702 // General purpose iterator-based input
5703 template<typename IteratorType>
5705 {
5707 return factory_type::create(first, last);
5708 }
5709
5710 // Convenience shorthand from container to iterator
5711 // Enables ADL on begin(container) and end(container)
5712 // Encloses the using declarations in namespace for not to leak them to outside scope
5713
5714 namespace container_input_adapter_factory_impl
5715 {
5716
5717 using std::begin;
5718 using std::end;
5719
5720 template<typename ContainerType, typename Enable = void>
5722
5723 template<typename ContainerType>
5724 struct container_input_adapter_factory< ContainerType,
5725 void_t<decltype(begin(std::declval<ContainerType>()), end(std::declval<ContainerType>()))>>
5726 {
5727 using adapter_type = decltype(input_adapter(begin(std::declval<ContainerType>()), end(std::declval<ContainerType>())));
5728
5729 static adapter_type create(const ContainerType& container)
5730 {
5731 return input_adapter(begin(container), end(container));
5732 }
5733 };
5734
5735 } // namespace container_input_adapter_factory_impl
5736
5737 template<typename ContainerType>
5738 typename