39#ifndef INCLUDE_NLOHMANN_JSON_HPP_
40#define INCLUDE_NLOHMANN_JSON_HPP_
42#define NLOHMANN_JSON_VERSION_MAJOR 3
43#define NLOHMANN_JSON_VERSION_MINOR 10
44#define NLOHMANN_JSON_VERSION_PATCH 5
49#include <initializer_list>
71#include <forward_list>
77#include <unordered_map>
158 static constexpr std::array<std::uint8_t, 9> order = {{
165 const auto l_index =
static_cast<std::size_t
>(lhs);
166 const auto r_index =
static_cast<std::size_t
>(rhs);
167 return l_index < order.size() && r_index < order.size() && order[l_index] < order[r_index];
195#if !defined(JSON_HEDLEY_VERSION) || (JSON_HEDLEY_VERSION < 15)
196#if defined(JSON_HEDLEY_VERSION)
197 #undef JSON_HEDLEY_VERSION
199#define JSON_HEDLEY_VERSION 15
201#if defined(JSON_HEDLEY_STRINGIFY_EX)
202 #undef JSON_HEDLEY_STRINGIFY_EX
204#define JSON_HEDLEY_STRINGIFY_EX(x) #x
206#if defined(JSON_HEDLEY_STRINGIFY)
207 #undef JSON_HEDLEY_STRINGIFY
209#define JSON_HEDLEY_STRINGIFY(x) JSON_HEDLEY_STRINGIFY_EX(x)
211#if defined(JSON_HEDLEY_CONCAT_EX)
212 #undef JSON_HEDLEY_CONCAT_EX
214#define JSON_HEDLEY_CONCAT_EX(a,b) a##b
216#if defined(JSON_HEDLEY_CONCAT)
217 #undef JSON_HEDLEY_CONCAT
219#define JSON_HEDLEY_CONCAT(a,b) JSON_HEDLEY_CONCAT_EX(a,b)
221#if defined(JSON_HEDLEY_CONCAT3_EX)
222 #undef JSON_HEDLEY_CONCAT3_EX
224#define JSON_HEDLEY_CONCAT3_EX(a,b,c) a##b##c
226#if defined(JSON_HEDLEY_CONCAT3)
227 #undef JSON_HEDLEY_CONCAT3
229#define JSON_HEDLEY_CONCAT3(a,b,c) JSON_HEDLEY_CONCAT3_EX(a,b,c)
231#if defined(JSON_HEDLEY_VERSION_ENCODE)
232 #undef JSON_HEDLEY_VERSION_ENCODE
234#define JSON_HEDLEY_VERSION_ENCODE(major,minor,revision) (((major) * 1000000) + ((minor) * 1000) + (revision))
236#if defined(JSON_HEDLEY_VERSION_DECODE_MAJOR)
237 #undef JSON_HEDLEY_VERSION_DECODE_MAJOR
239#define JSON_HEDLEY_VERSION_DECODE_MAJOR(version) ((version) / 1000000)
241#if defined(JSON_HEDLEY_VERSION_DECODE_MINOR)
242 #undef JSON_HEDLEY_VERSION_DECODE_MINOR
244#define JSON_HEDLEY_VERSION_DECODE_MINOR(version) (((version) % 1000000) / 1000)
246#if defined(JSON_HEDLEY_VERSION_DECODE_REVISION)
247 #undef JSON_HEDLEY_VERSION_DECODE_REVISION
249#define JSON_HEDLEY_VERSION_DECODE_REVISION(version) ((version) % 1000)
251#if defined(JSON_HEDLEY_GNUC_VERSION)
252 #undef JSON_HEDLEY_GNUC_VERSION
254#if defined(__GNUC__) && defined(__GNUC_PATCHLEVEL__)
255 #define JSON_HEDLEY_GNUC_VERSION JSON_HEDLEY_VERSION_ENCODE(__GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__)
256#elif defined(__GNUC__)
257 #define JSON_HEDLEY_GNUC_VERSION JSON_HEDLEY_VERSION_ENCODE(__GNUC__, __GNUC_MINOR__, 0)
260#if defined(JSON_HEDLEY_GNUC_VERSION_CHECK)
261 #undef JSON_HEDLEY_GNUC_VERSION_CHECK
263#if defined(JSON_HEDLEY_GNUC_VERSION)
264 #define JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_GNUC_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
266 #define JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) (0)
269#if defined(JSON_HEDLEY_MSVC_VERSION)
270 #undef JSON_HEDLEY_MSVC_VERSION
272#if defined(_MSC_FULL_VER) && (_MSC_FULL_VER >= 140000000) && !defined(__ICL)
273 #define JSON_HEDLEY_MSVC_VERSION JSON_HEDLEY_VERSION_ENCODE(_MSC_FULL_VER / 10000000, (_MSC_FULL_VER % 10000000) / 100000, (_MSC_FULL_VER % 100000) / 100)
274#elif defined(_MSC_FULL_VER) && !defined(__ICL)
275 #define JSON_HEDLEY_MSVC_VERSION JSON_HEDLEY_VERSION_ENCODE(_MSC_FULL_VER / 1000000, (_MSC_FULL_VER % 1000000) / 10000, (_MSC_FULL_VER % 10000) / 10)
276#elif defined(_MSC_VER) && !defined(__ICL)
277 #define JSON_HEDLEY_MSVC_VERSION JSON_HEDLEY_VERSION_ENCODE(_MSC_VER / 100, _MSC_VER % 100, 0)
280#if defined(JSON_HEDLEY_MSVC_VERSION_CHECK)
281 #undef JSON_HEDLEY_MSVC_VERSION_CHECK
283#if !defined(JSON_HEDLEY_MSVC_VERSION)
284 #define JSON_HEDLEY_MSVC_VERSION_CHECK(major,minor,patch) (0)
285#elif defined(_MSC_VER) && (_MSC_VER >= 1400)
286 #define JSON_HEDLEY_MSVC_VERSION_CHECK(major,minor,patch) (_MSC_FULL_VER >= ((major * 10000000) + (minor * 100000) + (patch)))
287#elif defined(_MSC_VER) && (_MSC_VER >= 1200)
288 #define JSON_HEDLEY_MSVC_VERSION_CHECK(major,minor,patch) (_MSC_FULL_VER >= ((major * 1000000) + (minor * 10000) + (patch)))
290 #define JSON_HEDLEY_MSVC_VERSION_CHECK(major,minor,patch) (_MSC_VER >= ((major * 100) + (minor)))
293#if defined(JSON_HEDLEY_INTEL_VERSION)
294 #undef JSON_HEDLEY_INTEL_VERSION
296#if defined(__INTEL_COMPILER) && defined(__INTEL_COMPILER_UPDATE) && !defined(__ICL)
297 #define JSON_HEDLEY_INTEL_VERSION JSON_HEDLEY_VERSION_ENCODE(__INTEL_COMPILER / 100, __INTEL_COMPILER % 100, __INTEL_COMPILER_UPDATE)
298#elif defined(__INTEL_COMPILER) && !defined(__ICL)
299 #define JSON_HEDLEY_INTEL_VERSION JSON_HEDLEY_VERSION_ENCODE(__INTEL_COMPILER / 100, __INTEL_COMPILER % 100, 0)
302#if defined(JSON_HEDLEY_INTEL_VERSION_CHECK)
303 #undef JSON_HEDLEY_INTEL_VERSION_CHECK
305#if defined(JSON_HEDLEY_INTEL_VERSION)
306 #define JSON_HEDLEY_INTEL_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_INTEL_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
308 #define JSON_HEDLEY_INTEL_VERSION_CHECK(major,minor,patch) (0)
311#if defined(JSON_HEDLEY_INTEL_CL_VERSION)
312 #undef JSON_HEDLEY_INTEL_CL_VERSION
314#if defined(__INTEL_COMPILER) && defined(__INTEL_COMPILER_UPDATE) && defined(__ICL)
315 #define JSON_HEDLEY_INTEL_CL_VERSION JSON_HEDLEY_VERSION_ENCODE(__INTEL_COMPILER, __INTEL_COMPILER_UPDATE, 0)
318#if defined(JSON_HEDLEY_INTEL_CL_VERSION_CHECK)
319 #undef JSON_HEDLEY_INTEL_CL_VERSION_CHECK
321#if defined(JSON_HEDLEY_INTEL_CL_VERSION)
322 #define JSON_HEDLEY_INTEL_CL_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_INTEL_CL_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
324 #define JSON_HEDLEY_INTEL_CL_VERSION_CHECK(major,minor,patch) (0)
327#if defined(JSON_HEDLEY_PGI_VERSION)
328 #undef JSON_HEDLEY_PGI_VERSION
330#if defined(__PGI) && defined(__PGIC__) && defined(__PGIC_MINOR__) && defined(__PGIC_PATCHLEVEL__)
331 #define JSON_HEDLEY_PGI_VERSION JSON_HEDLEY_VERSION_ENCODE(__PGIC__, __PGIC_MINOR__, __PGIC_PATCHLEVEL__)
334#if defined(JSON_HEDLEY_PGI_VERSION_CHECK)
335 #undef JSON_HEDLEY_PGI_VERSION_CHECK
337#if defined(JSON_HEDLEY_PGI_VERSION)
338 #define JSON_HEDLEY_PGI_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_PGI_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
340 #define JSON_HEDLEY_PGI_VERSION_CHECK(major,minor,patch) (0)
343#if defined(JSON_HEDLEY_SUNPRO_VERSION)
344 #undef JSON_HEDLEY_SUNPRO_VERSION
346#if defined(__SUNPRO_C) && (__SUNPRO_C > 0x1000)
347 #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)
348#elif defined(__SUNPRO_C)
349 #define JSON_HEDLEY_SUNPRO_VERSION JSON_HEDLEY_VERSION_ENCODE((__SUNPRO_C >> 8) & 0xf, (__SUNPRO_C >> 4) & 0xf, (__SUNPRO_C) & 0xf)
350#elif defined(__SUNPRO_CC) && (__SUNPRO_CC > 0x1000)
351 #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)
352#elif defined(__SUNPRO_CC)
353 #define JSON_HEDLEY_SUNPRO_VERSION JSON_HEDLEY_VERSION_ENCODE((__SUNPRO_CC >> 8) & 0xf, (__SUNPRO_CC >> 4) & 0xf, (__SUNPRO_CC) & 0xf)
356#if defined(JSON_HEDLEY_SUNPRO_VERSION_CHECK)
357 #undef JSON_HEDLEY_SUNPRO_VERSION_CHECK
359#if defined(JSON_HEDLEY_SUNPRO_VERSION)
360 #define JSON_HEDLEY_SUNPRO_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_SUNPRO_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
362 #define JSON_HEDLEY_SUNPRO_VERSION_CHECK(major,minor,patch) (0)
365#if defined(JSON_HEDLEY_EMSCRIPTEN_VERSION)
366 #undef JSON_HEDLEY_EMSCRIPTEN_VERSION
368#if defined(__EMSCRIPTEN__)
369 #define JSON_HEDLEY_EMSCRIPTEN_VERSION JSON_HEDLEY_VERSION_ENCODE(__EMSCRIPTEN_major__, __EMSCRIPTEN_minor__, __EMSCRIPTEN_tiny__)
372#if defined(JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK)
373 #undef JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK
375#if defined(JSON_HEDLEY_EMSCRIPTEN_VERSION)
376 #define JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_EMSCRIPTEN_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
378 #define JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK(major,minor,patch) (0)
381#if defined(JSON_HEDLEY_ARM_VERSION)
382 #undef JSON_HEDLEY_ARM_VERSION
384#if defined(__CC_ARM) && defined(__ARMCOMPILER_VERSION)
385 #define JSON_HEDLEY_ARM_VERSION JSON_HEDLEY_VERSION_ENCODE(__ARMCOMPILER_VERSION / 1000000, (__ARMCOMPILER_VERSION % 1000000) / 10000, (__ARMCOMPILER_VERSION % 10000) / 100)
386#elif defined(__CC_ARM) && defined(__ARMCC_VERSION)
387 #define JSON_HEDLEY_ARM_VERSION JSON_HEDLEY_VERSION_ENCODE(__ARMCC_VERSION / 1000000, (__ARMCC_VERSION % 1000000) / 10000, (__ARMCC_VERSION % 10000) / 100)
390#if defined(JSON_HEDLEY_ARM_VERSION_CHECK)
391 #undef JSON_HEDLEY_ARM_VERSION_CHECK
393#if defined(JSON_HEDLEY_ARM_VERSION)
394 #define JSON_HEDLEY_ARM_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_ARM_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
396 #define JSON_HEDLEY_ARM_VERSION_CHECK(major,minor,patch) (0)
399#if defined(JSON_HEDLEY_IBM_VERSION)
400 #undef JSON_HEDLEY_IBM_VERSION
402#if defined(__ibmxl__)
403 #define JSON_HEDLEY_IBM_VERSION JSON_HEDLEY_VERSION_ENCODE(__ibmxl_version__, __ibmxl_release__, __ibmxl_modification__)
404#elif defined(__xlC__) && defined(__xlC_ver__)
405 #define JSON_HEDLEY_IBM_VERSION JSON_HEDLEY_VERSION_ENCODE(__xlC__ >> 8, __xlC__ & 0xff, (__xlC_ver__ >> 8) & 0xff)
406#elif defined(__xlC__)
407 #define JSON_HEDLEY_IBM_VERSION JSON_HEDLEY_VERSION_ENCODE(__xlC__ >> 8, __xlC__ & 0xff, 0)
410#if defined(JSON_HEDLEY_IBM_VERSION_CHECK)
411 #undef JSON_HEDLEY_IBM_VERSION_CHECK
413#if defined(JSON_HEDLEY_IBM_VERSION)
414 #define JSON_HEDLEY_IBM_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_IBM_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
416 #define JSON_HEDLEY_IBM_VERSION_CHECK(major,minor,patch) (0)
419#if defined(JSON_HEDLEY_TI_VERSION)
420 #undef JSON_HEDLEY_TI_VERSION
423 defined(__TI_COMPILER_VERSION__) && \
425 defined(__TMS470__) || defined(__TI_ARM__) || \
426 defined(__MSP430__) || \
427 defined(__TMS320C2000__) \
429#if (__TI_COMPILER_VERSION__ >= 16000000)
430 #define JSON_HEDLEY_TI_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000))
434#if defined(JSON_HEDLEY_TI_VERSION_CHECK)
435 #undef JSON_HEDLEY_TI_VERSION_CHECK
437#if defined(JSON_HEDLEY_TI_VERSION)
438 #define JSON_HEDLEY_TI_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
440 #define JSON_HEDLEY_TI_VERSION_CHECK(major,minor,patch) (0)
443#if defined(JSON_HEDLEY_TI_CL2000_VERSION)
444 #undef JSON_HEDLEY_TI_CL2000_VERSION
446#if defined(__TI_COMPILER_VERSION__) && defined(__TMS320C2000__)
447 #define JSON_HEDLEY_TI_CL2000_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000))
450#if defined(JSON_HEDLEY_TI_CL2000_VERSION_CHECK)
451 #undef JSON_HEDLEY_TI_CL2000_VERSION_CHECK
453#if defined(JSON_HEDLEY_TI_CL2000_VERSION)
454 #define JSON_HEDLEY_TI_CL2000_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_CL2000_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
456 #define JSON_HEDLEY_TI_CL2000_VERSION_CHECK(major,minor,patch) (0)
459#if defined(JSON_HEDLEY_TI_CL430_VERSION)
460 #undef JSON_HEDLEY_TI_CL430_VERSION
462#if defined(__TI_COMPILER_VERSION__) && defined(__MSP430__)
463 #define JSON_HEDLEY_TI_CL430_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000))
466#if defined(JSON_HEDLEY_TI_CL430_VERSION_CHECK)
467 #undef JSON_HEDLEY_TI_CL430_VERSION_CHECK
469#if defined(JSON_HEDLEY_TI_CL430_VERSION)
470 #define JSON_HEDLEY_TI_CL430_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_CL430_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
472 #define JSON_HEDLEY_TI_CL430_VERSION_CHECK(major,minor,patch) (0)
475#if defined(JSON_HEDLEY_TI_ARMCL_VERSION)
476 #undef JSON_HEDLEY_TI_ARMCL_VERSION
478#if defined(__TI_COMPILER_VERSION__) && (defined(__TMS470__) || defined(__TI_ARM__))
479 #define JSON_HEDLEY_TI_ARMCL_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000))
482#if defined(JSON_HEDLEY_TI_ARMCL_VERSION_CHECK)
483 #undef JSON_HEDLEY_TI_ARMCL_VERSION_CHECK
485#if defined(JSON_HEDLEY_TI_ARMCL_VERSION)
486 #define JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_ARMCL_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
488 #define JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(major,minor,patch) (0)
491#if defined(JSON_HEDLEY_TI_CL6X_VERSION)
492 #undef JSON_HEDLEY_TI_CL6X_VERSION
494#if defined(__TI_COMPILER_VERSION__) && defined(__TMS320C6X__)
495 #define JSON_HEDLEY_TI_CL6X_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000))
498#if defined(JSON_HEDLEY_TI_CL6X_VERSION_CHECK)
499 #undef JSON_HEDLEY_TI_CL6X_VERSION_CHECK
501#if defined(JSON_HEDLEY_TI_CL6X_VERSION)
502 #define JSON_HEDLEY_TI_CL6X_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_CL6X_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
504 #define JSON_HEDLEY_TI_CL6X_VERSION_CHECK(major,minor,patch) (0)
507#if defined(JSON_HEDLEY_TI_CL7X_VERSION)
508 #undef JSON_HEDLEY_TI_CL7X_VERSION
510#if defined(__TI_COMPILER_VERSION__) && defined(__C7000__)
511 #define JSON_HEDLEY_TI_CL7X_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000))
514#if defined(JSON_HEDLEY_TI_CL7X_VERSION_CHECK)
515 #undef JSON_HEDLEY_TI_CL7X_VERSION_CHECK
517#if defined(JSON_HEDLEY_TI_CL7X_VERSION)
518 #define JSON_HEDLEY_TI_CL7X_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_CL7X_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
520 #define JSON_HEDLEY_TI_CL7X_VERSION_CHECK(major,minor,patch) (0)
523#if defined(JSON_HEDLEY_TI_CLPRU_VERSION)
524 #undef JSON_HEDLEY_TI_CLPRU_VERSION
526#if defined(__TI_COMPILER_VERSION__) && defined(__PRU__)
527 #define JSON_HEDLEY_TI_CLPRU_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000))
530#if defined(JSON_HEDLEY_TI_CLPRU_VERSION_CHECK)
531 #undef JSON_HEDLEY_TI_CLPRU_VERSION_CHECK
533#if defined(JSON_HEDLEY_TI_CLPRU_VERSION)
534 #define JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_CLPRU_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
536 #define JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(major,minor,patch) (0)
539#if defined(JSON_HEDLEY_CRAY_VERSION)
540 #undef JSON_HEDLEY_CRAY_VERSION
543 #if defined(_RELEASE_PATCHLEVEL)
544 #define JSON_HEDLEY_CRAY_VERSION JSON_HEDLEY_VERSION_ENCODE(_RELEASE_MAJOR, _RELEASE_MINOR, _RELEASE_PATCHLEVEL)
546 #define JSON_HEDLEY_CRAY_VERSION JSON_HEDLEY_VERSION_ENCODE(_RELEASE_MAJOR, _RELEASE_MINOR, 0)
550#if defined(JSON_HEDLEY_CRAY_VERSION_CHECK)
551 #undef JSON_HEDLEY_CRAY_VERSION_CHECK
553#if defined(JSON_HEDLEY_CRAY_VERSION)
554 #define JSON_HEDLEY_CRAY_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_CRAY_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
556 #define JSON_HEDLEY_CRAY_VERSION_CHECK(major,minor,patch) (0)
559#if defined(JSON_HEDLEY_IAR_VERSION)
560 #undef JSON_HEDLEY_IAR_VERSION
562#if defined(__IAR_SYSTEMS_ICC__)
564 #define JSON_HEDLEY_IAR_VERSION JSON_HEDLEY_VERSION_ENCODE((__VER__ / 1000000), ((__VER__ / 1000) % 1000), (__VER__ % 1000))
566 #define JSON_HEDLEY_IAR_VERSION JSON_HEDLEY_VERSION_ENCODE(__VER__ / 100, __VER__ % 100, 0)
570#if defined(JSON_HEDLEY_IAR_VERSION_CHECK)
571 #undef JSON_HEDLEY_IAR_VERSION_CHECK
573#if defined(JSON_HEDLEY_IAR_VERSION)
574 #define JSON_HEDLEY_IAR_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_IAR_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
576 #define JSON_HEDLEY_IAR_VERSION_CHECK(major,minor,patch) (0)
579#if defined(JSON_HEDLEY_TINYC_VERSION)
580 #undef JSON_HEDLEY_TINYC_VERSION
582#if defined(__TINYC__)
583 #define JSON_HEDLEY_TINYC_VERSION JSON_HEDLEY_VERSION_ENCODE(__TINYC__ / 1000, (__TINYC__ / 100) % 10, __TINYC__ % 100)
586#if defined(JSON_HEDLEY_TINYC_VERSION_CHECK)
587 #undef JSON_HEDLEY_TINYC_VERSION_CHECK
589#if defined(JSON_HEDLEY_TINYC_VERSION)
590 #define JSON_HEDLEY_TINYC_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TINYC_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
592 #define JSON_HEDLEY_TINYC_VERSION_CHECK(major,minor,patch) (0)
595#if defined(JSON_HEDLEY_DMC_VERSION)
596 #undef JSON_HEDLEY_DMC_VERSION
599 #define JSON_HEDLEY_DMC_VERSION JSON_HEDLEY_VERSION_ENCODE(__DMC__ >> 8, (__DMC__ >> 4) & 0xf, __DMC__ & 0xf)
602#if defined(JSON_HEDLEY_DMC_VERSION_CHECK)
603 #undef JSON_HEDLEY_DMC_VERSION_CHECK
605#if defined(JSON_HEDLEY_DMC_VERSION)
606 #define JSON_HEDLEY_DMC_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_DMC_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
608 #define JSON_HEDLEY_DMC_VERSION_CHECK(major,minor,patch) (0)
611#if defined(JSON_HEDLEY_COMPCERT_VERSION)
612 #undef JSON_HEDLEY_COMPCERT_VERSION
614#if defined(__COMPCERT_VERSION__)
615 #define JSON_HEDLEY_COMPCERT_VERSION JSON_HEDLEY_VERSION_ENCODE(__COMPCERT_VERSION__ / 10000, (__COMPCERT_VERSION__ / 100) % 100, __COMPCERT_VERSION__ % 100)
618#if defined(JSON_HEDLEY_COMPCERT_VERSION_CHECK)
619 #undef JSON_HEDLEY_COMPCERT_VERSION_CHECK
621#if defined(JSON_HEDLEY_COMPCERT_VERSION)
622 #define JSON_HEDLEY_COMPCERT_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_COMPCERT_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
624 #define JSON_HEDLEY_COMPCERT_VERSION_CHECK(major,minor,patch) (0)
627#if defined(JSON_HEDLEY_PELLES_VERSION)
628 #undef JSON_HEDLEY_PELLES_VERSION
631 #define JSON_HEDLEY_PELLES_VERSION JSON_HEDLEY_VERSION_ENCODE(__POCC__ / 100, __POCC__ % 100, 0)
634#if defined(JSON_HEDLEY_PELLES_VERSION_CHECK)
635 #undef JSON_HEDLEY_PELLES_VERSION_CHECK
637#if defined(JSON_HEDLEY_PELLES_VERSION)
638 #define JSON_HEDLEY_PELLES_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_PELLES_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
640 #define JSON_HEDLEY_PELLES_VERSION_CHECK(major,minor,patch) (0)
643#if defined(JSON_HEDLEY_MCST_LCC_VERSION)
644 #undef JSON_HEDLEY_MCST_LCC_VERSION
646#if defined(__LCC__) && defined(__LCC_MINOR__)
647 #define JSON_HEDLEY_MCST_LCC_VERSION JSON_HEDLEY_VERSION_ENCODE(__LCC__ / 100, __LCC__ % 100, __LCC_MINOR__)
650#if defined(JSON_HEDLEY_MCST_LCC_VERSION_CHECK)
651 #undef JSON_HEDLEY_MCST_LCC_VERSION_CHECK
653#if defined(JSON_HEDLEY_MCST_LCC_VERSION)
654 #define JSON_HEDLEY_MCST_LCC_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_MCST_LCC_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
656 #define JSON_HEDLEY_MCST_LCC_VERSION_CHECK(major,minor,patch) (0)
659#if defined(JSON_HEDLEY_GCC_VERSION)
660 #undef JSON_HEDLEY_GCC_VERSION
663 defined(JSON_HEDLEY_GNUC_VERSION) && \
664 !defined(__clang__) && \
665 !defined(JSON_HEDLEY_INTEL_VERSION) && \
666 !defined(JSON_HEDLEY_PGI_VERSION) && \
667 !defined(JSON_HEDLEY_ARM_VERSION) && \
668 !defined(JSON_HEDLEY_CRAY_VERSION) && \
669 !defined(JSON_HEDLEY_TI_VERSION) && \
670 !defined(JSON_HEDLEY_TI_ARMCL_VERSION) && \
671 !defined(JSON_HEDLEY_TI_CL430_VERSION) && \
672 !defined(JSON_HEDLEY_TI_CL2000_VERSION) && \
673 !defined(JSON_HEDLEY_TI_CL6X_VERSION) && \
674 !defined(JSON_HEDLEY_TI_CL7X_VERSION) && \
675 !defined(JSON_HEDLEY_TI_CLPRU_VERSION) && \
676 !defined(__COMPCERT__) && \
677 !defined(JSON_HEDLEY_MCST_LCC_VERSION)
678 #define JSON_HEDLEY_GCC_VERSION JSON_HEDLEY_GNUC_VERSION
681#if defined(JSON_HEDLEY_GCC_VERSION_CHECK)
682 #undef JSON_HEDLEY_GCC_VERSION_CHECK
684#if defined(JSON_HEDLEY_GCC_VERSION)
685 #define JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_GCC_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
687 #define JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) (0)
690#if defined(JSON_HEDLEY_HAS_ATTRIBUTE)
691 #undef JSON_HEDLEY_HAS_ATTRIBUTE
694 defined(__has_attribute) && \
696 (!defined(JSON_HEDLEY_IAR_VERSION) || JSON_HEDLEY_IAR_VERSION_CHECK(8,5,9)) \
698# define JSON_HEDLEY_HAS_ATTRIBUTE(attribute) __has_attribute(attribute)
700# define JSON_HEDLEY_HAS_ATTRIBUTE(attribute) (0)
703#if defined(JSON_HEDLEY_GNUC_HAS_ATTRIBUTE)
704 #undef JSON_HEDLEY_GNUC_HAS_ATTRIBUTE
706#if defined(__has_attribute)
707 #define JSON_HEDLEY_GNUC_HAS_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_HAS_ATTRIBUTE(attribute)
709 #define JSON_HEDLEY_GNUC_HAS_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch)
712#if defined(JSON_HEDLEY_GCC_HAS_ATTRIBUTE)
713 #undef JSON_HEDLEY_GCC_HAS_ATTRIBUTE
715#if defined(__has_attribute)
716 #define JSON_HEDLEY_GCC_HAS_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_HAS_ATTRIBUTE(attribute)
718 #define JSON_HEDLEY_GCC_HAS_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch)
721#if defined(JSON_HEDLEY_HAS_CPP_ATTRIBUTE)
722 #undef JSON_HEDLEY_HAS_CPP_ATTRIBUTE
725 defined(__has_cpp_attribute) && \
726 defined(__cplusplus) && \
727 (!defined(JSON_HEDLEY_SUNPRO_VERSION) || JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,15,0))
728 #define JSON_HEDLEY_HAS_CPP_ATTRIBUTE(attribute) __has_cpp_attribute(attribute)
730 #define JSON_HEDLEY_HAS_CPP_ATTRIBUTE(attribute) (0)
733#if defined(JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS)
734 #undef JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS
736#if !defined(__cplusplus) || !defined(__has_cpp_attribute)
737 #define JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS(ns,attribute) (0)
739 !defined(JSON_HEDLEY_PGI_VERSION) && \
740 !defined(JSON_HEDLEY_IAR_VERSION) && \
741 (!defined(JSON_HEDLEY_SUNPRO_VERSION) || JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,15,0)) && \
742 (!defined(JSON_HEDLEY_MSVC_VERSION) || JSON_HEDLEY_MSVC_VERSION_CHECK(19,20,0))
743 #define JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS(ns,attribute) JSON_HEDLEY_HAS_CPP_ATTRIBUTE(ns::attribute)
745 #define JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS(ns,attribute) (0)
748#if defined(JSON_HEDLEY_GNUC_HAS_CPP_ATTRIBUTE)
749 #undef JSON_HEDLEY_GNUC_HAS_CPP_ATTRIBUTE
751#if defined(__has_cpp_attribute) && defined(__cplusplus)
752 #define JSON_HEDLEY_GNUC_HAS_CPP_ATTRIBUTE(attribute,major,minor,patch) __has_cpp_attribute(attribute)
754 #define JSON_HEDLEY_GNUC_HAS_CPP_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch)
757#if defined(JSON_HEDLEY_GCC_HAS_CPP_ATTRIBUTE)
758 #undef JSON_HEDLEY_GCC_HAS_CPP_ATTRIBUTE
760#if defined(__has_cpp_attribute) && defined(__cplusplus)
761 #define JSON_HEDLEY_GCC_HAS_CPP_ATTRIBUTE(attribute,major,minor,patch) __has_cpp_attribute(attribute)
763 #define JSON_HEDLEY_GCC_HAS_CPP_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch)
766#if defined(JSON_HEDLEY_HAS_BUILTIN)
767 #undef JSON_HEDLEY_HAS_BUILTIN
769#if defined(__has_builtin)
770 #define JSON_HEDLEY_HAS_BUILTIN(builtin) __has_builtin(builtin)
772 #define JSON_HEDLEY_HAS_BUILTIN(builtin) (0)
775#if defined(JSON_HEDLEY_GNUC_HAS_BUILTIN)
776 #undef JSON_HEDLEY_GNUC_HAS_BUILTIN
778#if defined(__has_builtin)
779 #define JSON_HEDLEY_GNUC_HAS_BUILTIN(builtin,major,minor,patch) __has_builtin(builtin)
781 #define JSON_HEDLEY_GNUC_HAS_BUILTIN(builtin,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch)
784#if defined(JSON_HEDLEY_GCC_HAS_BUILTIN)
785 #undef JSON_HEDLEY_GCC_HAS_BUILTIN
787#if defined(__has_builtin)
788 #define JSON_HEDLEY_GCC_HAS_BUILTIN(builtin,major,minor,patch) __has_builtin(builtin)
790 #define JSON_HEDLEY_GCC_HAS_BUILTIN(builtin,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch)
793#if defined(JSON_HEDLEY_HAS_FEATURE)
794 #undef JSON_HEDLEY_HAS_FEATURE
796#if defined(__has_feature)
797 #define JSON_HEDLEY_HAS_FEATURE(feature) __has_feature(feature)
799 #define JSON_HEDLEY_HAS_FEATURE(feature) (0)
802#if defined(JSON_HEDLEY_GNUC_HAS_FEATURE)
803 #undef JSON_HEDLEY_GNUC_HAS_FEATURE
805#if defined(__has_feature)
806 #define JSON_HEDLEY_GNUC_HAS_FEATURE(feature,major,minor,patch) __has_feature(feature)
808 #define JSON_HEDLEY_GNUC_HAS_FEATURE(feature,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch)
811#if defined(JSON_HEDLEY_GCC_HAS_FEATURE)
812 #undef JSON_HEDLEY_GCC_HAS_FEATURE
814#if defined(__has_feature)
815 #define JSON_HEDLEY_GCC_HAS_FEATURE(feature,major,minor,patch) __has_feature(feature)
817 #define JSON_HEDLEY_GCC_HAS_FEATURE(feature,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch)
820#if defined(JSON_HEDLEY_HAS_EXTENSION)
821 #undef JSON_HEDLEY_HAS_EXTENSION
823#if defined(__has_extension)
824 #define JSON_HEDLEY_HAS_EXTENSION(extension) __has_extension(extension)
826 #define JSON_HEDLEY_HAS_EXTENSION(extension) (0)
829#if defined(JSON_HEDLEY_GNUC_HAS_EXTENSION)
830 #undef JSON_HEDLEY_GNUC_HAS_EXTENSION
832#if defined(__has_extension)
833 #define JSON_HEDLEY_GNUC_HAS_EXTENSION(extension,major,minor,patch) __has_extension(extension)
835 #define JSON_HEDLEY_GNUC_HAS_EXTENSION(extension,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch)
838#if defined(JSON_HEDLEY_GCC_HAS_EXTENSION)
839 #undef JSON_HEDLEY_GCC_HAS_EXTENSION
841#if defined(__has_extension)
842 #define JSON_HEDLEY_GCC_HAS_EXTENSION(extension,major,minor,patch) __has_extension(extension)
844 #define JSON_HEDLEY_GCC_HAS_EXTENSION(extension,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch)
847#if defined(JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE)
848 #undef JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE
850#if defined(__has_declspec_attribute)
851 #define JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE(attribute) __has_declspec_attribute(attribute)
853 #define JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE(attribute) (0)
856#if defined(JSON_HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE)
857 #undef JSON_HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE
859#if defined(__has_declspec_attribute)
860 #define JSON_HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE(attribute,major,minor,patch) __has_declspec_attribute(attribute)
862 #define JSON_HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch)
865#if defined(JSON_HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE)
866 #undef JSON_HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE
868#if defined(__has_declspec_attribute)
869 #define JSON_HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE(attribute,major,minor,patch) __has_declspec_attribute(attribute)
871 #define JSON_HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch)
874#if defined(JSON_HEDLEY_HAS_WARNING)
875 #undef JSON_HEDLEY_HAS_WARNING
877#if defined(__has_warning)
878 #define JSON_HEDLEY_HAS_WARNING(warning) __has_warning(warning)
880 #define JSON_HEDLEY_HAS_WARNING(warning) (0)
883#if defined(JSON_HEDLEY_GNUC_HAS_WARNING)
884 #undef JSON_HEDLEY_GNUC_HAS_WARNING
886#if defined(__has_warning)
887 #define JSON_HEDLEY_GNUC_HAS_WARNING(warning,major,minor,patch) __has_warning(warning)
889 #define JSON_HEDLEY_GNUC_HAS_WARNING(warning,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch)
892#if defined(JSON_HEDLEY_GCC_HAS_WARNING)
893 #undef JSON_HEDLEY_GCC_HAS_WARNING
895#if defined(__has_warning)
896 #define JSON_HEDLEY_GCC_HAS_WARNING(warning,major,minor,patch) __has_warning(warning)
898 #define JSON_HEDLEY_GCC_HAS_WARNING(warning,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch)
902 (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)) || \
903 defined(__clang__) || \
904 JSON_HEDLEY_GCC_VERSION_CHECK(3,0,0) || \
905 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
906 JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) || \
907 JSON_HEDLEY_PGI_VERSION_CHECK(18,4,0) || \
908 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
909 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
910 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,7,0) || \
911 JSON_HEDLEY_TI_CL430_VERSION_CHECK(2,0,1) || \
912 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,1,0) || \
913 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,0,0) || \
914 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
915 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
916 JSON_HEDLEY_CRAY_VERSION_CHECK(5,0,0) || \
917 JSON_HEDLEY_TINYC_VERSION_CHECK(0,9,17) || \
918 JSON_HEDLEY_SUNPRO_VERSION_CHECK(8,0,0) || \
919 (JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) && defined(__C99_PRAGMA_OPERATOR))
920 #define JSON_HEDLEY_PRAGMA(value) _Pragma(#value)
921#elif JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0)
922 #define JSON_HEDLEY_PRAGMA(value) __pragma(value)
924 #define JSON_HEDLEY_PRAGMA(value)
927#if defined(JSON_HEDLEY_DIAGNOSTIC_PUSH)
928 #undef JSON_HEDLEY_DIAGNOSTIC_PUSH
930#if defined(JSON_HEDLEY_DIAGNOSTIC_POP)
931 #undef JSON_HEDLEY_DIAGNOSTIC_POP
933#if defined(__clang__)
934 #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("clang diagnostic push")
935 #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("clang diagnostic pop")
936#elif JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0)
937 #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("warning(push)")
938 #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("warning(pop)")
939#elif JSON_HEDLEY_GCC_VERSION_CHECK(4,6,0)
940 #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("GCC diagnostic push")
941 #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("GCC diagnostic pop")
943 JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0) || \
944 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
945 #define JSON_HEDLEY_DIAGNOSTIC_PUSH __pragma(warning(push))
946 #define JSON_HEDLEY_DIAGNOSTIC_POP __pragma(warning(pop))
947#elif JSON_HEDLEY_ARM_VERSION_CHECK(5,6,0)
948 #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("push")
949 #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("pop")
951 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
952 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
953 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,4,0) || \
954 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,1,0) || \
955 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
956 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0)
957 #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("diag_push")
958 #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("diag_pop")
959#elif JSON_HEDLEY_PELLES_VERSION_CHECK(2,90,0)
960 #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("warning(push)")
961 #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("warning(pop)")
963 #define JSON_HEDLEY_DIAGNOSTIC_PUSH
964 #define JSON_HEDLEY_DIAGNOSTIC_POP
969#if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_)
970 #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_
972#if defined(__cplusplus)
973# if JSON_HEDLEY_HAS_WARNING("-Wc++98-compat")
974# if JSON_HEDLEY_HAS_WARNING("-Wc++17-extensions")
975# if JSON_HEDLEY_HAS_WARNING("-Wc++1z-extensions")
976# define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(xpr) \
977 JSON_HEDLEY_DIAGNOSTIC_PUSH \
978 _Pragma("clang diagnostic ignored \"-Wc++98-compat\"") \
979 _Pragma("clang diagnostic ignored \"-Wc++17-extensions\"") \
980 _Pragma("clang diagnostic ignored \"-Wc++1z-extensions\"") \
982 JSON_HEDLEY_DIAGNOSTIC_POP
984# define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(xpr) \
985 JSON_HEDLEY_DIAGNOSTIC_PUSH \
986 _Pragma("clang diagnostic ignored \"-Wc++98-compat\"") \
987 _Pragma("clang diagnostic ignored \"-Wc++17-extensions\"") \
989 JSON_HEDLEY_DIAGNOSTIC_POP
992# define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(xpr) \
993 JSON_HEDLEY_DIAGNOSTIC_PUSH \
994 _Pragma("clang diagnostic ignored \"-Wc++98-compat\"") \
996 JSON_HEDLEY_DIAGNOSTIC_POP
1000#if !defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_)
1001 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(x) x
1004#if defined(JSON_HEDLEY_CONST_CAST)
1005 #undef JSON_HEDLEY_CONST_CAST
1007#if defined(__cplusplus)
1008# define JSON_HEDLEY_CONST_CAST(T, expr) (const_cast<T>(expr))
1010 JSON_HEDLEY_HAS_WARNING("-Wcast-qual") || \
1011 JSON_HEDLEY_GCC_VERSION_CHECK(4,6,0) || \
1012 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0)
1013# define JSON_HEDLEY_CONST_CAST(T, expr) (__extension__ ({ \
1014 JSON_HEDLEY_DIAGNOSTIC_PUSH \
1015 JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL \
1017 JSON_HEDLEY_DIAGNOSTIC_POP \
1020# define JSON_HEDLEY_CONST_CAST(T, expr) ((T) (expr))
1023#if defined(JSON_HEDLEY_REINTERPRET_CAST)
1024 #undef JSON_HEDLEY_REINTERPRET_CAST
1026#if defined(__cplusplus)
1027 #define JSON_HEDLEY_REINTERPRET_CAST(T, expr) (reinterpret_cast<T>(expr))
1029 #define JSON_HEDLEY_REINTERPRET_CAST(T, expr) ((T) (expr))
1032#if defined(JSON_HEDLEY_STATIC_CAST)
1033 #undef JSON_HEDLEY_STATIC_CAST
1035#if defined(__cplusplus)
1036 #define JSON_HEDLEY_STATIC_CAST(T, expr) (static_cast<T>(expr))
1038 #define JSON_HEDLEY_STATIC_CAST(T, expr) ((T) (expr))
1041#if defined(JSON_HEDLEY_CPP_CAST)
1042 #undef JSON_HEDLEY_CPP_CAST
1044#if defined(__cplusplus)
1045# if JSON_HEDLEY_HAS_WARNING("-Wold-style-cast")
1046# define JSON_HEDLEY_CPP_CAST(T, expr) \
1047 JSON_HEDLEY_DIAGNOSTIC_PUSH \
1048 _Pragma("clang diagnostic ignored \"-Wold-style-cast\"") \
1050 JSON_HEDLEY_DIAGNOSTIC_POP
1051# elif JSON_HEDLEY_IAR_VERSION_CHECK(8,3,0)
1052# define JSON_HEDLEY_CPP_CAST(T, expr) \
1053 JSON_HEDLEY_DIAGNOSTIC_PUSH \
1054 _Pragma("diag_suppress=Pe137") \
1055 JSON_HEDLEY_DIAGNOSTIC_POP
1057# define JSON_HEDLEY_CPP_CAST(T, expr) ((T) (expr))
1060# define JSON_HEDLEY_CPP_CAST(T, expr) (expr)
1063#if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED)
1064 #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED
1066#if JSON_HEDLEY_HAS_WARNING("-Wdeprecated-declarations")
1067 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("clang diagnostic ignored \"-Wdeprecated-declarations\"")
1068#elif JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0)
1069 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("warning(disable:1478 1786)")
1070#elif JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1071 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED __pragma(warning(disable:1478 1786))
1072#elif JSON_HEDLEY_PGI_VERSION_CHECK(20,7,0)
1073 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress 1215,1216,1444,1445")
1074#elif JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0)
1075 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress 1215,1444")
1076#elif JSON_HEDLEY_GCC_VERSION_CHECK(4,3,0)
1077 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"")
1078#elif JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0)
1079 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED __pragma(warning(disable:4996))
1080#elif JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1081 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress 1215,1444")
1083 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1084 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1085 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1086 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1087 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1088 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1089 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1090 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1091 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1092 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1093 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0)
1094 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress 1291,1718")
1095#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,13,0) && !defined(__cplusplus)
1096 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("error_messages(off,E_DEPRECATED_ATT,E_DEPRECATED_ATT_MESS)")
1097#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,13,0) && defined(__cplusplus)
1098 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("error_messages(off,symdeprecated,symdeprecated2)")
1099#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
1100 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress=Pe1444,Pe1215")
1101#elif JSON_HEDLEY_PELLES_VERSION_CHECK(2,90,0)
1102 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("warn(disable:2241)")
1104 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED
1107#if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS)
1108 #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS
1110#if JSON_HEDLEY_HAS_WARNING("-Wunknown-pragmas")
1111 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("clang diagnostic ignored \"-Wunknown-pragmas\"")
1112#elif JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0)
1113 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("warning(disable:161)")
1114#elif JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1115 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS __pragma(warning(disable:161))
1116#elif JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0)
1117 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress 1675")
1118#elif JSON_HEDLEY_GCC_VERSION_CHECK(4,3,0)
1119 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("GCC diagnostic ignored \"-Wunknown-pragmas\"")
1120#elif JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0)
1121 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS __pragma(warning(disable:4068))
1123 JSON_HEDLEY_TI_VERSION_CHECK(16,9,0) || \
1124 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,0,0) || \
1125 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1126 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,3,0)
1127 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress 163")
1128#elif JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,0,0)
1129 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress 163")
1130#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
1131 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress=Pe161")
1132#elif JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1133 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress 161")
1135 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS
1138#if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES)
1139 #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES
1141#if JSON_HEDLEY_HAS_WARNING("-Wunknown-attributes")
1142 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("clang diagnostic ignored \"-Wunknown-attributes\"")
1143#elif JSON_HEDLEY_GCC_VERSION_CHECK(4,6,0)
1144 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"")
1145#elif JSON_HEDLEY_INTEL_VERSION_CHECK(17,0,0)
1146 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("warning(disable:1292)")
1147#elif JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1148 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES __pragma(warning(disable:1292))
1149#elif JSON_HEDLEY_MSVC_VERSION_CHECK(19,0,0)
1150 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES __pragma(warning(disable:5030))
1151#elif JSON_HEDLEY_PGI_VERSION_CHECK(20,7,0)
1152 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress 1097,1098")
1153#elif JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0)
1154 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress 1097")
1155#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,14,0) && defined(__cplusplus)
1156 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("error_messages(off,attrskipunsup)")
1158 JSON_HEDLEY_TI_VERSION_CHECK(18,1,0) || \
1159 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,3,0) || \
1160 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0)
1161 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress 1173")
1162#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
1163 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress=Pe1097")
1164#elif JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1165 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress 1097")
1167 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES
1170#if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL)
1171 #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL
1173#if JSON_HEDLEY_HAS_WARNING("-Wcast-qual")
1174 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL _Pragma("clang diagnostic ignored \"-Wcast-qual\"")
1175#elif JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0)
1176 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL _Pragma("warning(disable:2203 2331)")
1177#elif JSON_HEDLEY_GCC_VERSION_CHECK(3,0,0)
1178 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL _Pragma("GCC diagnostic ignored \"-Wcast-qual\"")
1180 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL
1183#if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION)
1184 #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION
1186#if JSON_HEDLEY_HAS_WARNING("-Wunused-function")
1187 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION _Pragma("clang diagnostic ignored \"-Wunused-function\"")
1188#elif JSON_HEDLEY_GCC_VERSION_CHECK(3,4,0)
1189 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION _Pragma("GCC diagnostic ignored \"-Wunused-function\"")
1190#elif JSON_HEDLEY_MSVC_VERSION_CHECK(1,0,0)
1191 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION __pragma(warning(disable:4505))
1192#elif JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1193 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION _Pragma("diag_suppress 3142")
1195 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION
1198#if defined(JSON_HEDLEY_DEPRECATED)
1199 #undef JSON_HEDLEY_DEPRECATED
1201#if defined(JSON_HEDLEY_DEPRECATED_FOR)
1202 #undef JSON_HEDLEY_DEPRECATED_FOR
1205 JSON_HEDLEY_MSVC_VERSION_CHECK(14,0,0) || \
1206 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1207 #define JSON_HEDLEY_DEPRECATED(since) __declspec(deprecated("Since " # since))
1208 #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) __declspec(deprecated("Since " #since "; use " #replacement))
1210 (JSON_HEDLEY_HAS_EXTENSION(attribute_deprecated_with_message) && !defined(JSON_HEDLEY_IAR_VERSION)) || \
1211 JSON_HEDLEY_GCC_VERSION_CHECK(4,5,0) || \
1212 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1213 JSON_HEDLEY_ARM_VERSION_CHECK(5,6,0) || \
1214 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,13,0) || \
1215 JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) || \
1216 JSON_HEDLEY_TI_VERSION_CHECK(18,1,0) || \
1217 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(18,1,0) || \
1218 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,3,0) || \
1219 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1220 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,3,0) || \
1221 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1222 #define JSON_HEDLEY_DEPRECATED(since) __attribute__((__deprecated__("Since " #since)))
1223 #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) __attribute__((__deprecated__("Since " #since "; use " #replacement)))
1224#elif defined(__cplusplus) && (__cplusplus >= 201402L)
1225 #define JSON_HEDLEY_DEPRECATED(since) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[deprecated("Since " #since)]])
1226 #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[deprecated("Since " #since "; use " #replacement)]])
1228 JSON_HEDLEY_HAS_ATTRIBUTE(deprecated) || \
1229 JSON_HEDLEY_GCC_VERSION_CHECK(3,1,0) || \
1230 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1231 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1232 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1233 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1234 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1235 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1236 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1237 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1238 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1239 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1240 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1241 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1242 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) || \
1243 JSON_HEDLEY_IAR_VERSION_CHECK(8,10,0)
1244 #define JSON_HEDLEY_DEPRECATED(since) __attribute__((__deprecated__))
1245 #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) __attribute__((__deprecated__))
1247 JSON_HEDLEY_MSVC_VERSION_CHECK(13,10,0) || \
1248 JSON_HEDLEY_PELLES_VERSION_CHECK(6,50,0) || \
1249 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1250 #define JSON_HEDLEY_DEPRECATED(since) __declspec(deprecated)
1251 #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) __declspec(deprecated)
1252#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
1253 #define JSON_HEDLEY_DEPRECATED(since) _Pragma("deprecated")
1254 #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) _Pragma("deprecated")
1256 #define JSON_HEDLEY_DEPRECATED(since)
1257 #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement)
1260#if defined(JSON_HEDLEY_UNAVAILABLE)
1261 #undef JSON_HEDLEY_UNAVAILABLE
1264 JSON_HEDLEY_HAS_ATTRIBUTE(warning) || \
1265 JSON_HEDLEY_GCC_VERSION_CHECK(4,3,0) || \
1266 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1267 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1268 #define JSON_HEDLEY_UNAVAILABLE(available_since) __attribute__((__warning__("Not available until " #available_since)))
1270 #define JSON_HEDLEY_UNAVAILABLE(available_since)
1273#if defined(JSON_HEDLEY_WARN_UNUSED_RESULT)
1274 #undef JSON_HEDLEY_WARN_UNUSED_RESULT
1276#if defined(JSON_HEDLEY_WARN_UNUSED_RESULT_MSG)
1277 #undef JSON_HEDLEY_WARN_UNUSED_RESULT_MSG
1280 JSON_HEDLEY_HAS_ATTRIBUTE(warn_unused_result) || \
1281 JSON_HEDLEY_GCC_VERSION_CHECK(3,4,0) || \
1282 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1283 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1284 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1285 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1286 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1287 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1288 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1289 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1290 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1291 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1292 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1293 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1294 (JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,15,0) && defined(__cplusplus)) || \
1295 JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) || \
1296 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1297 #define JSON_HEDLEY_WARN_UNUSED_RESULT __attribute__((__warn_unused_result__))
1298 #define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg) __attribute__((__warn_unused_result__))
1299#elif (JSON_HEDLEY_HAS_CPP_ATTRIBUTE(nodiscard) >= 201907L)
1300 #define JSON_HEDLEY_WARN_UNUSED_RESULT JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[nodiscard]])
1301 #define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[nodiscard(msg)]])
1302#elif JSON_HEDLEY_HAS_CPP_ATTRIBUTE(nodiscard)
1303 #define JSON_HEDLEY_WARN_UNUSED_RESULT JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[nodiscard]])
1304 #define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[nodiscard]])
1305#elif defined(_Check_return_)
1306 #define JSON_HEDLEY_WARN_UNUSED_RESULT _Check_return_
1307 #define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg) _Check_return_
1309 #define JSON_HEDLEY_WARN_UNUSED_RESULT
1310 #define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg)
1313#if defined(JSON_HEDLEY_SENTINEL)
1314 #undef JSON_HEDLEY_SENTINEL
1317 JSON_HEDLEY_HAS_ATTRIBUTE(sentinel) || \
1318 JSON_HEDLEY_GCC_VERSION_CHECK(4,0,0) || \
1319 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1320 JSON_HEDLEY_ARM_VERSION_CHECK(5,4,0) || \
1321 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1322 #define JSON_HEDLEY_SENTINEL(position) __attribute__((__sentinel__(position)))
1324 #define JSON_HEDLEY_SENTINEL(position)
1327#if defined(JSON_HEDLEY_NO_RETURN)
1328 #undef JSON_HEDLEY_NO_RETURN
1330#if JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
1331 #define JSON_HEDLEY_NO_RETURN __noreturn
1333 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1334 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1335 #define JSON_HEDLEY_NO_RETURN __attribute__((__noreturn__))
1336#elif defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L
1337 #define JSON_HEDLEY_NO_RETURN _Noreturn
1338#elif defined(__cplusplus) && (__cplusplus >= 201103L)
1339 #define JSON_HEDLEY_NO_RETURN JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[noreturn]])
1341 JSON_HEDLEY_HAS_ATTRIBUTE(noreturn) || \
1342 JSON_HEDLEY_GCC_VERSION_CHECK(3,2,0) || \
1343 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \
1344 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1345 JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
1346 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1347 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1348 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1349 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1350 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1351 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1352 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1353 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1354 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1355 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1356 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1357 JSON_HEDLEY_IAR_VERSION_CHECK(8,10,0)
1358 #define JSON_HEDLEY_NO_RETURN __attribute__((__noreturn__))
1359#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0)
1360 #define JSON_HEDLEY_NO_RETURN _Pragma("does_not_return")
1362 JSON_HEDLEY_MSVC_VERSION_CHECK(13,10,0) || \
1363 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1364 #define JSON_HEDLEY_NO_RETURN __declspec(noreturn)
1365#elif JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6,0,0) && defined(__cplusplus)
1366 #define JSON_HEDLEY_NO_RETURN _Pragma("FUNC_NEVER_RETURNS;")
1367#elif JSON_HEDLEY_COMPCERT_VERSION_CHECK(3,2,0)
1368 #define JSON_HEDLEY_NO_RETURN __attribute((noreturn))
1369#elif JSON_HEDLEY_PELLES_VERSION_CHECK(9,0,0)
1370 #define JSON_HEDLEY_NO_RETURN __declspec(noreturn)
1372 #define JSON_HEDLEY_NO_RETURN
1375#if defined(JSON_HEDLEY_NO_ESCAPE)
1376 #undef JSON_HEDLEY_NO_ESCAPE
1378#if JSON_HEDLEY_HAS_ATTRIBUTE(noescape)
1379 #define JSON_HEDLEY_NO_ESCAPE __attribute__((__noescape__))
1381 #define JSON_HEDLEY_NO_ESCAPE
1384#if defined(JSON_HEDLEY_UNREACHABLE)
1385 #undef JSON_HEDLEY_UNREACHABLE
1387#if defined(JSON_HEDLEY_UNREACHABLE_RETURN)
1388 #undef JSON_HEDLEY_UNREACHABLE_RETURN
1390#if defined(JSON_HEDLEY_ASSUME)
1391 #undef JSON_HEDLEY_ASSUME
1394 JSON_HEDLEY_MSVC_VERSION_CHECK(13,10,0) || \
1395 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1396 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1397 #define JSON_HEDLEY_ASSUME(expr) __assume(expr)
1398#elif JSON_HEDLEY_HAS_BUILTIN(__builtin_assume)
1399 #define JSON_HEDLEY_ASSUME(expr) __builtin_assume(expr)
1401 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,2,0) || \
1402 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(4,0,0)
1403 #if defined(__cplusplus)
1404 #define JSON_HEDLEY_ASSUME(expr) std::_nassert(expr)
1406 #define JSON_HEDLEY_ASSUME(expr) _nassert(expr)
1410 (JSON_HEDLEY_HAS_BUILTIN(__builtin_unreachable) && (!defined(JSON_HEDLEY_ARM_VERSION))) || \
1411 JSON_HEDLEY_GCC_VERSION_CHECK(4,5,0) || \
1412 JSON_HEDLEY_PGI_VERSION_CHECK(18,10,0) || \
1413 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1414 JSON_HEDLEY_IBM_VERSION_CHECK(13,1,5) || \
1415 JSON_HEDLEY_CRAY_VERSION_CHECK(10,0,0) || \
1416 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1417 #define JSON_HEDLEY_UNREACHABLE() __builtin_unreachable()
1418#elif defined(JSON_HEDLEY_ASSUME)
1419 #define JSON_HEDLEY_UNREACHABLE() JSON_HEDLEY_ASSUME(0)
1421#if !defined(JSON_HEDLEY_ASSUME)
1422 #if defined(JSON_HEDLEY_UNREACHABLE)
1423 #define JSON_HEDLEY_ASSUME(expr) JSON_HEDLEY_STATIC_CAST(void, ((expr) ? 1 : (JSON_HEDLEY_UNREACHABLE(), 1)))
1425 #define JSON_HEDLEY_ASSUME(expr) JSON_HEDLEY_STATIC_CAST(void, expr)
1428#if defined(JSON_HEDLEY_UNREACHABLE)
1430 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,2,0) || \
1431 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(4,0,0)
1432 #define JSON_HEDLEY_UNREACHABLE_RETURN(value) return (JSON_HEDLEY_STATIC_CAST(void, JSON_HEDLEY_ASSUME(0)), (value))
1434 #define JSON_HEDLEY_UNREACHABLE_RETURN(value) JSON_HEDLEY_UNREACHABLE()
1437 #define JSON_HEDLEY_UNREACHABLE_RETURN(value) return (value)
1439#if !defined(JSON_HEDLEY_UNREACHABLE)
1440 #define JSON_HEDLEY_UNREACHABLE() JSON_HEDLEY_ASSUME(0)
1444#if JSON_HEDLEY_HAS_WARNING("-Wpedantic")
1445 #pragma clang diagnostic ignored "-Wpedantic"
1447#if JSON_HEDLEY_HAS_WARNING("-Wc++98-compat-pedantic") && defined(__cplusplus)
1448 #pragma clang diagnostic ignored "-Wc++98-compat-pedantic"
1450#if JSON_HEDLEY_GCC_HAS_WARNING("-Wvariadic-macros",4,0,0)
1451 #if defined(__clang__)
1452 #pragma clang diagnostic ignored "-Wvariadic-macros"
1453 #elif defined(JSON_HEDLEY_GCC_VERSION)
1454 #pragma GCC diagnostic ignored "-Wvariadic-macros"
1457#if defined(JSON_HEDLEY_NON_NULL)
1458 #undef JSON_HEDLEY_NON_NULL
1461 JSON_HEDLEY_HAS_ATTRIBUTE(nonnull) || \
1462 JSON_HEDLEY_GCC_VERSION_CHECK(3,3,0) || \
1463 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1464 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0)
1465 #define JSON_HEDLEY_NON_NULL(...) __attribute__((__nonnull__(__VA_ARGS__)))
1467 #define JSON_HEDLEY_NON_NULL(...)
1471#if defined(JSON_HEDLEY_PRINTF_FORMAT)
1472 #undef JSON_HEDLEY_PRINTF_FORMAT
1474#if defined(__MINGW32__) && JSON_HEDLEY_GCC_HAS_ATTRIBUTE(format,4,4,0) && !defined(__USE_MINGW_ANSI_STDIO)
1475 #define JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) __attribute__((__format__(ms_printf, string_idx, first_to_check)))
1476#elif defined(__MINGW32__) && JSON_HEDLEY_GCC_HAS_ATTRIBUTE(format,4,4,0) && defined(__USE_MINGW_ANSI_STDIO)
1477 #define JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) __attribute__((__format__(gnu_printf, string_idx, first_to_check)))
1479 JSON_HEDLEY_HAS_ATTRIBUTE(format) || \
1480 JSON_HEDLEY_GCC_VERSION_CHECK(3,1,0) || \
1481 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1482 JSON_HEDLEY_ARM_VERSION_CHECK(5,6,0) || \
1483 JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
1484 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1485 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1486 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1487 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1488 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1489 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1490 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1491 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1492 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1493 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1494 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1495 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1496 #define JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) __attribute__((__format__(__printf__, string_idx, first_to_check)))
1497#elif JSON_HEDLEY_PELLES_VERSION_CHECK(6,0,0)
1498 #define JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) __declspec(vaformat(printf,string_idx,first_to_check))
1500 #define JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check)
1503#if defined(JSON_HEDLEY_CONSTEXPR)
1504 #undef JSON_HEDLEY_CONSTEXPR
1506#if defined(__cplusplus)
1507 #if __cplusplus >= 201103L
1508 #define JSON_HEDLEY_CONSTEXPR JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(constexpr)
1511#if !defined(JSON_HEDLEY_CONSTEXPR)
1512 #define JSON_HEDLEY_CONSTEXPR
1515#if defined(JSON_HEDLEY_PREDICT)
1516 #undef JSON_HEDLEY_PREDICT
1518#if defined(JSON_HEDLEY_LIKELY)
1519 #undef JSON_HEDLEY_LIKELY
1521#if defined(JSON_HEDLEY_UNLIKELY)
1522 #undef JSON_HEDLEY_UNLIKELY
1524#if defined(JSON_HEDLEY_UNPREDICTABLE)
1525 #undef JSON_HEDLEY_UNPREDICTABLE
1527#if JSON_HEDLEY_HAS_BUILTIN(__builtin_unpredictable)
1528 #define JSON_HEDLEY_UNPREDICTABLE(expr) __builtin_unpredictable((expr))
1531 (JSON_HEDLEY_HAS_BUILTIN(__builtin_expect_with_probability) && !defined(JSON_HEDLEY_PGI_VERSION)) || \
1532 JSON_HEDLEY_GCC_VERSION_CHECK(9,0,0) || \
1533 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1534# define JSON_HEDLEY_PREDICT(expr, value, probability) __builtin_expect_with_probability( (expr), (value), (probability))
1535# define JSON_HEDLEY_PREDICT_TRUE(expr, probability) __builtin_expect_with_probability(!!(expr), 1 , (probability))
1536# define JSON_HEDLEY_PREDICT_FALSE(expr, probability) __builtin_expect_with_probability(!!(expr), 0 , (probability))
1537# define JSON_HEDLEY_LIKELY(expr) __builtin_expect (!!(expr), 1 )
1538# define JSON_HEDLEY_UNLIKELY(expr) __builtin_expect (!!(expr), 0 )
1540 (JSON_HEDLEY_HAS_BUILTIN(__builtin_expect) && !defined(JSON_HEDLEY_INTEL_CL_VERSION)) || \
1541 JSON_HEDLEY_GCC_VERSION_CHECK(3,0,0) || \
1542 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1543 (JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,15,0) && defined(__cplusplus)) || \
1544 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1545 JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
1546 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1547 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,7,0) || \
1548 JSON_HEDLEY_TI_CL430_VERSION_CHECK(3,1,0) || \
1549 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,1,0) || \
1550 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6,1,0) || \
1551 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1552 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1553 JSON_HEDLEY_TINYC_VERSION_CHECK(0,9,27) || \
1554 JSON_HEDLEY_CRAY_VERSION_CHECK(8,1,0) || \
1555 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1556# define JSON_HEDLEY_PREDICT(expr, expected, probability) \
1557 (((probability) >= 0.9) ? __builtin_expect((expr), (expected)) : (JSON_HEDLEY_STATIC_CAST(void, expected), (expr)))
1558# define JSON_HEDLEY_PREDICT_TRUE(expr, probability) \
1560 double hedley_probability_ = (probability); \
1561 ((hedley_probability_ >= 0.9) ? __builtin_expect(!!(expr), 1) : ((hedley_probability_ <= 0.1) ? __builtin_expect(!!(expr), 0) : !!(expr))); \
1563# define JSON_HEDLEY_PREDICT_FALSE(expr, probability) \
1565 double hedley_probability_ = (probability); \
1566 ((hedley_probability_ >= 0.9) ? __builtin_expect(!!(expr), 0) : ((hedley_probability_ <= 0.1) ? __builtin_expect(!!(expr), 1) : !!(expr))); \
1568# define JSON_HEDLEY_LIKELY(expr) __builtin_expect(!!(expr), 1)
1569# define JSON_HEDLEY_UNLIKELY(expr) __builtin_expect(!!(expr), 0)
1571# define JSON_HEDLEY_PREDICT(expr, expected, probability) (JSON_HEDLEY_STATIC_CAST(void, expected), (expr))
1572# define JSON_HEDLEY_PREDICT_TRUE(expr, probability) (!!(expr))
1573# define JSON_HEDLEY_PREDICT_FALSE(expr, probability) (!!(expr))
1574# define JSON_HEDLEY_LIKELY(expr) (!!(expr))
1575# define JSON_HEDLEY_UNLIKELY(expr) (!!(expr))
1577#if !defined(JSON_HEDLEY_UNPREDICTABLE)
1578 #define JSON_HEDLEY_UNPREDICTABLE(expr) JSON_HEDLEY_PREDICT(expr, 1, 0.5)
1581#if defined(JSON_HEDLEY_MALLOC)
1582 #undef JSON_HEDLEY_MALLOC
1585 JSON_HEDLEY_HAS_ATTRIBUTE(malloc) || \
1586 JSON_HEDLEY_GCC_VERSION_CHECK(3,1,0) || \
1587 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1588 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \
1589 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1590 JSON_HEDLEY_IBM_VERSION_CHECK(12,1,0) || \
1591 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1592 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1593 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1594 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1595 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1596 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1597 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1598 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1599 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1600 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1601 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1602 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1603 #define JSON_HEDLEY_MALLOC __attribute__((__malloc__))
1604#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0)
1605 #define JSON_HEDLEY_MALLOC _Pragma("returns_new_memory")
1607 JSON_HEDLEY_MSVC_VERSION_CHECK(14,0,0) || \
1608 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1609 #define JSON_HEDLEY_MALLOC __declspec(restrict)
1611 #define JSON_HEDLEY_MALLOC
1614#if defined(JSON_HEDLEY_PURE)
1615 #undef JSON_HEDLEY_PURE
1618 JSON_HEDLEY_HAS_ATTRIBUTE(pure) || \
1619 JSON_HEDLEY_GCC_VERSION_CHECK(2,96,0) || \
1620 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1621 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \
1622 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1623 JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
1624 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1625 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1626 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1627 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1628 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1629 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1630 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1631 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1632 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1633 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1634 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1635 JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) || \
1636 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1637# define JSON_HEDLEY_PURE __attribute__((__pure__))
1638#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0)
1639# define JSON_HEDLEY_PURE _Pragma("does_not_write_global_data")
1640#elif defined(__cplusplus) && \
1642 JSON_HEDLEY_TI_CL430_VERSION_CHECK(2,0,1) || \
1643 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(4,0,0) || \
1644 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) \
1646# define JSON_HEDLEY_PURE _Pragma("FUNC_IS_PURE;")
1648# define JSON_HEDLEY_PURE
1651#if defined(JSON_HEDLEY_CONST)
1652 #undef JSON_HEDLEY_CONST
1655 JSON_HEDLEY_HAS_ATTRIBUTE(const) || \
1656 JSON_HEDLEY_GCC_VERSION_CHECK(2,5,0) || \
1657 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1658 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \
1659 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1660 JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
1661 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1662 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1663 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1664 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1665 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1666 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1667 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1668 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1669 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1670 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1671 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1672 JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) || \
1673 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1674 #define JSON_HEDLEY_CONST __attribute__((__const__))
1676 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0)
1677 #define JSON_HEDLEY_CONST _Pragma("no_side_effect")
1679 #define JSON_HEDLEY_CONST JSON_HEDLEY_PURE
1682#if defined(JSON_HEDLEY_RESTRICT)
1683 #undef JSON_HEDLEY_RESTRICT
1685#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) && !defined(__cplusplus)
1686 #define JSON_HEDLEY_RESTRICT restrict
1688 JSON_HEDLEY_GCC_VERSION_CHECK(3,1,0) || \
1689 JSON_HEDLEY_MSVC_VERSION_CHECK(14,0,0) || \
1690 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1691 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) || \
1692 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1693 JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
1694 JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) || \
1695 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1696 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,2,4) || \
1697 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,1,0) || \
1698 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1699 (JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,14,0) && defined(__cplusplus)) || \
1700 JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) || \
1701 defined(__clang__) || \
1702 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1703 #define JSON_HEDLEY_RESTRICT __restrict
1704#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,3,0) && !defined(__cplusplus)
1705 #define JSON_HEDLEY_RESTRICT _Restrict
1707 #define JSON_HEDLEY_RESTRICT
1710#if defined(JSON_HEDLEY_INLINE)
1711 #undef JSON_HEDLEY_INLINE
1714 (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)) || \
1715 (defined(__cplusplus) && (__cplusplus >= 199711L))
1716 #define JSON_HEDLEY_INLINE inline
1718 defined(JSON_HEDLEY_GCC_VERSION) || \
1719 JSON_HEDLEY_ARM_VERSION_CHECK(6,2,0)
1720 #define JSON_HEDLEY_INLINE __inline__
1722 JSON_HEDLEY_MSVC_VERSION_CHECK(12,0,0) || \
1723 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) || \
1724 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1725 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,1,0) || \
1726 JSON_HEDLEY_TI_CL430_VERSION_CHECK(3,1,0) || \
1727 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,2,0) || \
1728 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,0,0) || \
1729 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1730 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1731 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1732 #define JSON_HEDLEY_INLINE __inline
1734 #define JSON_HEDLEY_INLINE
1737#if defined(JSON_HEDLEY_ALWAYS_INLINE)
1738 #undef JSON_HEDLEY_ALWAYS_INLINE
1741 JSON_HEDLEY_HAS_ATTRIBUTE(always_inline) || \
1742 JSON_HEDLEY_GCC_VERSION_CHECK(4,0,0) || \
1743 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1744 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \
1745 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1746 JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
1747 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1748 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1749 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1750 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1751 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1752 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1753 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1754 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1755 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1756 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1757 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1758 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) || \
1759 JSON_HEDLEY_IAR_VERSION_CHECK(8,10,0)
1760# define JSON_HEDLEY_ALWAYS_INLINE __attribute__((__always_inline__)) JSON_HEDLEY_INLINE
1762 JSON_HEDLEY_MSVC_VERSION_CHECK(12,0,0) || \
1763 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1764# define JSON_HEDLEY_ALWAYS_INLINE __forceinline
1765#elif defined(__cplusplus) && \
1767 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1768 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1769 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1770 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6,1,0) || \
1771 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1772 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) \
1774# define JSON_HEDLEY_ALWAYS_INLINE _Pragma("FUNC_ALWAYS_INLINE;")
1775#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
1776# define JSON_HEDLEY_ALWAYS_INLINE _Pragma("inline=forced")
1778# define JSON_HEDLEY_ALWAYS_INLINE JSON_HEDLEY_INLINE
1781#if defined(JSON_HEDLEY_NEVER_INLINE)
1782 #undef JSON_HEDLEY_NEVER_INLINE
1785 JSON_HEDLEY_HAS_ATTRIBUTE(noinline) || \
1786 JSON_HEDLEY_GCC_VERSION_CHECK(4,0,0) || \
1787 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1788 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \
1789 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1790 JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
1791 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1792 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1793 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1794 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1795 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1796 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1797 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1798 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1799 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1800 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1801 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1802 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) || \
1803 JSON_HEDLEY_IAR_VERSION_CHECK(8,10,0)
1804 #define JSON_HEDLEY_NEVER_INLINE __attribute__((__noinline__))
1806 JSON_HEDLEY_MSVC_VERSION_CHECK(13,10,0) || \
1807 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1808 #define JSON_HEDLEY_NEVER_INLINE __declspec(noinline)
1809#elif JSON_HEDLEY_PGI_VERSION_CHECK(10,2,0)
1810 #define JSON_HEDLEY_NEVER_INLINE _Pragma("noinline")
1811#elif JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6,0,0) && defined(__cplusplus)
1812 #define JSON_HEDLEY_NEVER_INLINE _Pragma("FUNC_CANNOT_INLINE;")
1813#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
1814 #define JSON_HEDLEY_NEVER_INLINE _Pragma("inline=never")
1815#elif JSON_HEDLEY_COMPCERT_VERSION_CHECK(3,2,0)
1816 #define JSON_HEDLEY_NEVER_INLINE __attribute((noinline))
1817#elif JSON_HEDLEY_PELLES_VERSION_CHECK(9,0,0)
1818 #define JSON_HEDLEY_NEVER_INLINE __declspec(noinline)
1820 #define JSON_HEDLEY_NEVER_INLINE
1823#if defined(JSON_HEDLEY_PRIVATE)
1824 #undef JSON_HEDLEY_PRIVATE
1826#if defined(JSON_HEDLEY_PUBLIC)
1827 #undef JSON_HEDLEY_PUBLIC
1829#if defined(JSON_HEDLEY_IMPORT)
1830 #undef JSON_HEDLEY_IMPORT
1832#if defined(_WIN32) || defined(__CYGWIN__)
1833# define JSON_HEDLEY_PRIVATE
1834# define JSON_HEDLEY_PUBLIC __declspec(dllexport)
1835# define JSON_HEDLEY_IMPORT __declspec(dllimport)
1838 JSON_HEDLEY_HAS_ATTRIBUTE(visibility) || \
1839 JSON_HEDLEY_GCC_VERSION_CHECK(3,3,0) || \
1840 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \
1841 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1842 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1843 JSON_HEDLEY_IBM_VERSION_CHECK(13,1,0) || \
1845 defined(__TI_EABI__) && \
1847 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1848 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) \
1851 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1852# define JSON_HEDLEY_PRIVATE __attribute__((__visibility__("hidden")))
1853# define JSON_HEDLEY_PUBLIC __attribute__((__visibility__("default")))
1855# define JSON_HEDLEY_PRIVATE
1856# define JSON_HEDLEY_PUBLIC
1858# define JSON_HEDLEY_IMPORT extern
1861#if defined(JSON_HEDLEY_NO_THROW)
1862 #undef JSON_HEDLEY_NO_THROW
1865 JSON_HEDLEY_HAS_ATTRIBUTE(nothrow) || \
1866 JSON_HEDLEY_GCC_VERSION_CHECK(3,3,0) || \
1867 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1868 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1869 #define JSON_HEDLEY_NO_THROW __attribute__((__nothrow__))
1871 JSON_HEDLEY_MSVC_VERSION_CHECK(13,1,0) || \
1872 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) || \
1873 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0)
1874 #define JSON_HEDLEY_NO_THROW __declspec(nothrow)
1876 #define JSON_HEDLEY_NO_THROW
1879#if defined(JSON_HEDLEY_FALL_THROUGH)
1880 #undef JSON_HEDLEY_FALL_THROUGH
1883 JSON_HEDLEY_HAS_ATTRIBUTE(fallthrough) || \
1884 JSON_HEDLEY_GCC_VERSION_CHECK(7,0,0) || \
1885 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1886 #define JSON_HEDLEY_FALL_THROUGH __attribute__((__fallthrough__))
1887#elif JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS(clang,fallthrough)
1888 #define JSON_HEDLEY_FALL_THROUGH JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[clang::fallthrough]])
1889#elif JSON_HEDLEY_HAS_CPP_ATTRIBUTE(fallthrough)
1890 #define JSON_HEDLEY_FALL_THROUGH JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[fallthrough]])
1891#elif defined(__fallthrough)
1892 #define JSON_HEDLEY_FALL_THROUGH __fallthrough
1894 #define JSON_HEDLEY_FALL_THROUGH
1897#if defined(JSON_HEDLEY_RETURNS_NON_NULL)
1898 #undef JSON_HEDLEY_RETURNS_NON_NULL
1901 JSON_HEDLEY_HAS_ATTRIBUTE(returns_nonnull) || \
1902 JSON_HEDLEY_GCC_VERSION_CHECK(4,9,0) || \
1903 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1904 #define JSON_HEDLEY_RETURNS_NON_NULL __attribute__((__returns_nonnull__))
1905#elif defined(_Ret_notnull_)
1906 #define JSON_HEDLEY_RETURNS_NON_NULL _Ret_notnull_
1908 #define JSON_HEDLEY_RETURNS_NON_NULL
1911#if defined(JSON_HEDLEY_ARRAY_PARAM)
1912 #undef JSON_HEDLEY_ARRAY_PARAM
1915 defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) && \
1916 !defined(__STDC_NO_VLA__) && \
1917 !defined(__cplusplus) && \
1918 !defined(JSON_HEDLEY_PGI_VERSION) && \
1919 !defined(JSON_HEDLEY_TINYC_VERSION)
1920 #define JSON_HEDLEY_ARRAY_PARAM(name) (name)
1922 #define JSON_HEDLEY_ARRAY_PARAM(name)
1925#if defined(JSON_HEDLEY_IS_CONSTANT)
1926 #undef JSON_HEDLEY_IS_CONSTANT
1928#if defined(JSON_HEDLEY_REQUIRE_CONSTEXPR)
1929 #undef JSON_HEDLEY_REQUIRE_CONSTEXPR
1933#if defined(JSON_HEDLEY_IS_CONSTEXPR_)
1934 #undef JSON_HEDLEY_IS_CONSTEXPR_
1937 JSON_HEDLEY_HAS_BUILTIN(__builtin_constant_p) || \
1938 JSON_HEDLEY_GCC_VERSION_CHECK(3,4,0) || \
1939 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1940 JSON_HEDLEY_TINYC_VERSION_CHECK(0,9,19) || \
1941 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1942 JSON_HEDLEY_IBM_VERSION_CHECK(13,1,0) || \
1943 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6,1,0) || \
1944 (JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0) && !defined(__cplusplus)) || \
1945 JSON_HEDLEY_CRAY_VERSION_CHECK(8,1,0) || \
1946 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1947 #define JSON_HEDLEY_IS_CONSTANT(expr) __builtin_constant_p(expr)
1949#if !defined(__cplusplus)
1951 JSON_HEDLEY_HAS_BUILTIN(__builtin_types_compatible_p) || \
1952 JSON_HEDLEY_GCC_VERSION_CHECK(3,4,0) || \
1953 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1954 JSON_HEDLEY_IBM_VERSION_CHECK(13,1,0) || \
1955 JSON_HEDLEY_CRAY_VERSION_CHECK(8,1,0) || \
1956 JSON_HEDLEY_ARM_VERSION_CHECK(5,4,0) || \
1957 JSON_HEDLEY_TINYC_VERSION_CHECK(0,9,24)
1958#if defined(__INTPTR_TYPE__)
1959 #define JSON_HEDLEY_IS_CONSTEXPR_(expr) __builtin_types_compatible_p(__typeof__((1 ? (void*) ((__INTPTR_TYPE__) ((expr) * 0)) : (int*) 0)), int*)
1962 #define JSON_HEDLEY_IS_CONSTEXPR_(expr) __builtin_types_compatible_p(__typeof__((1 ? (void*) ((intptr_t) ((expr) * 0)) : (int*) 0)), int*)
1966 defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L) && \
1967 !defined(JSON_HEDLEY_SUNPRO_VERSION) && \
1968 !defined(JSON_HEDLEY_PGI_VERSION) && \
1969 !defined(JSON_HEDLEY_IAR_VERSION)) || \
1970 (JSON_HEDLEY_HAS_EXTENSION(c_generic_selections) && !defined(JSON_HEDLEY_IAR_VERSION)) || \
1971 JSON_HEDLEY_GCC_VERSION_CHECK(4,9,0) || \
1972 JSON_HEDLEY_INTEL_VERSION_CHECK(17,0,0) || \
1973 JSON_HEDLEY_IBM_VERSION_CHECK(12,1,0) || \
1974 JSON_HEDLEY_ARM_VERSION_CHECK(5,3,0)
1975#if defined(__INTPTR_TYPE__)
1976 #define JSON_HEDLEY_IS_CONSTEXPR_(expr) _Generic((1 ? (void*) ((__INTPTR_TYPE__) ((expr) * 0)) : (int*) 0), int*: 1, void*: 0)
1979 #define JSON_HEDLEY_IS_CONSTEXPR_(expr) _Generic((1 ? (void*) ((intptr_t) * 0) : (int*) 0), int*: 1, void*: 0)
1982 defined(JSON_HEDLEY_GCC_VERSION) || \
1983 defined(JSON_HEDLEY_INTEL_VERSION) || \
1984 defined(JSON_HEDLEY_TINYC_VERSION) || \
1985 defined(JSON_HEDLEY_TI_ARMCL_VERSION) || \
1986 JSON_HEDLEY_TI_CL430_VERSION_CHECK(18,12,0) || \
1987 defined(JSON_HEDLEY_TI_CL2000_VERSION) || \
1988 defined(JSON_HEDLEY_TI_CL6X_VERSION) || \
1989 defined(JSON_HEDLEY_TI_CL7X_VERSION) || \
1990 defined(JSON_HEDLEY_TI_CLPRU_VERSION) || \
1992# define JSON_HEDLEY_IS_CONSTEXPR_(expr) ( \
1996 ((void*) ((expr) * 0L) ) : \
1997((struct { char v[sizeof(void) * 2]; } *) 1) \
2003#if defined(JSON_HEDLEY_IS_CONSTEXPR_)
2004 #if !defined(JSON_HEDLEY_IS_CONSTANT)
2005 #define JSON_HEDLEY_IS_CONSTANT(expr) JSON_HEDLEY_IS_CONSTEXPR_(expr)
2007 #define JSON_HEDLEY_REQUIRE_CONSTEXPR(expr) (JSON_HEDLEY_IS_CONSTEXPR_(expr) ? (expr) : (-1))
2009 #if !defined(JSON_HEDLEY_IS_CONSTANT)
2010 #define JSON_HEDLEY_IS_CONSTANT(expr) (0)
2012 #define JSON_HEDLEY_REQUIRE_CONSTEXPR(expr) (expr)
2015#if defined(JSON_HEDLEY_BEGIN_C_DECLS)
2016 #undef JSON_HEDLEY_BEGIN_C_DECLS
2018#if defined(JSON_HEDLEY_END_C_DECLS)
2019 #undef JSON_HEDLEY_END_C_DECLS
2021#if defined(JSON_HEDLEY_C_DECL)
2022 #undef JSON_HEDLEY_C_DECL
2024#if defined(__cplusplus)
2025 #define JSON_HEDLEY_BEGIN_C_DECLS extern "C" {
2026 #define JSON_HEDLEY_END_C_DECLS }
2027 #define JSON_HEDLEY_C_DECL extern "C"
2029 #define JSON_HEDLEY_BEGIN_C_DECLS
2030 #define JSON_HEDLEY_END_C_DECLS
2031 #define JSON_HEDLEY_C_DECL
2034#if defined(JSON_HEDLEY_STATIC_ASSERT)
2035 #undef JSON_HEDLEY_STATIC_ASSERT
2038 !defined(__cplusplus) && ( \
2039 (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L)) || \
2040 (JSON_HEDLEY_HAS_FEATURE(c_static_assert) && !defined(JSON_HEDLEY_INTEL_CL_VERSION)) || \
2041 JSON_HEDLEY_GCC_VERSION_CHECK(6,0,0) || \
2042 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
2043 defined(_Static_assert) \
2045# define JSON_HEDLEY_STATIC_ASSERT(expr, message) _Static_assert(expr, message)
2047 (defined(__cplusplus) && (__cplusplus >= 201103L)) || \
2048 JSON_HEDLEY_MSVC_VERSION_CHECK(16,0,0) || \
2049 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
2050# define JSON_HEDLEY_STATIC_ASSERT(expr, message) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(static_assert(expr, message))
2052# define JSON_HEDLEY_STATIC_ASSERT(expr, message)
2055#if defined(JSON_HEDLEY_NULL)
2056 #undef JSON_HEDLEY_NULL
2058#if defined(__cplusplus)
2059 #if __cplusplus >= 201103L
2060 #define JSON_HEDLEY_NULL JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(nullptr)
2062 #define JSON_HEDLEY_NULL NULL
2064 #define JSON_HEDLEY_NULL JSON_HEDLEY_STATIC_CAST(void*, 0)
2067 #define JSON_HEDLEY_NULL NULL
2069 #define JSON_HEDLEY_NULL ((void*) 0)
2072#if defined(JSON_HEDLEY_MESSAGE)
2073 #undef JSON_HEDLEY_MESSAGE
2075#if JSON_HEDLEY_HAS_WARNING("-Wunknown-pragmas")
2076# define JSON_HEDLEY_MESSAGE(msg) \
2077 JSON_HEDLEY_DIAGNOSTIC_PUSH \
2078 JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS \
2079 JSON_HEDLEY_PRAGMA(message msg) \
2080 JSON_HEDLEY_DIAGNOSTIC_POP
2082 JSON_HEDLEY_GCC_VERSION_CHECK(4,4,0) || \
2083 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0)
2084# define JSON_HEDLEY_MESSAGE(msg) JSON_HEDLEY_PRAGMA(message msg)
2085#elif JSON_HEDLEY_CRAY_VERSION_CHECK(5,0,0)
2086# define JSON_HEDLEY_MESSAGE(msg) JSON_HEDLEY_PRAGMA(_CRI message msg)
2087#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
2088# define JSON_HEDLEY_MESSAGE(msg) JSON_HEDLEY_PRAGMA(message(msg))
2089#elif JSON_HEDLEY_PELLES_VERSION_CHECK(2,0,0)
2090# define JSON_HEDLEY_MESSAGE(msg) JSON_HEDLEY_PRAGMA(message(msg))
2092# define JSON_HEDLEY_MESSAGE(msg)
2095#if defined(JSON_HEDLEY_WARNING)
2096 #undef JSON_HEDLEY_WARNING
2098#if JSON_HEDLEY_HAS_WARNING("-Wunknown-pragmas")
2099# define JSON_HEDLEY_WARNING(msg) \
2100 JSON_HEDLEY_DIAGNOSTIC_PUSH \
2101 JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS \
2102 JSON_HEDLEY_PRAGMA(clang warning msg) \
2103 JSON_HEDLEY_DIAGNOSTIC_POP
2105 JSON_HEDLEY_GCC_VERSION_CHECK(4,8,0) || \
2106 JSON_HEDLEY_PGI_VERSION_CHECK(18,4,0) || \
2107 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0)
2108# define JSON_HEDLEY_WARNING(msg) JSON_HEDLEY_PRAGMA(GCC warning msg)
2110 JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0) || \
2111 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
2112# define JSON_HEDLEY_WARNING(msg) JSON_HEDLEY_PRAGMA(message(msg))
2114# define JSON_HEDLEY_WARNING(msg) JSON_HEDLEY_MESSAGE(msg)
2117#if defined(JSON_HEDLEY_REQUIRE)
2118 #undef JSON_HEDLEY_REQUIRE
2120#if defined(JSON_HEDLEY_REQUIRE_MSG)
2121 #undef JSON_HEDLEY_REQUIRE_MSG
2123#if JSON_HEDLEY_HAS_ATTRIBUTE(diagnose_if)
2124# if JSON_HEDLEY_HAS_WARNING("-Wgcc-compat")
2125# define JSON_HEDLEY_REQUIRE(expr) \
2126 JSON_HEDLEY_DIAGNOSTIC_PUSH \
2127 _Pragma("clang diagnostic ignored \"-Wgcc-compat\"") \
2128 __attribute__((diagnose_if(!(expr), #expr, "error"))) \
2129 JSON_HEDLEY_DIAGNOSTIC_POP
2130# define JSON_HEDLEY_REQUIRE_MSG(expr,msg) \
2131 JSON_HEDLEY_DIAGNOSTIC_PUSH \
2132 _Pragma("clang diagnostic ignored \"-Wgcc-compat\"") \
2133 __attribute__((diagnose_if(!(expr), msg, "error"))) \
2134 JSON_HEDLEY_DIAGNOSTIC_POP
2136# define JSON_HEDLEY_REQUIRE(expr) __attribute__((diagnose_if(!(expr), #expr, "error")))
2137# define JSON_HEDLEY_REQUIRE_MSG(expr,msg) __attribute__((diagnose_if(!(expr), msg, "error")))
2140# define JSON_HEDLEY_REQUIRE(expr)
2141# define JSON_HEDLEY_REQUIRE_MSG(expr,msg)
2144#if defined(JSON_HEDLEY_FLAGS)
2145 #undef JSON_HEDLEY_FLAGS
2147#if JSON_HEDLEY_HAS_ATTRIBUTE(flag_enum) && (!defined(__cplusplus) || JSON_HEDLEY_HAS_WARNING("-Wbitfield-enum-conversion"))
2148 #define JSON_HEDLEY_FLAGS __attribute__((__flag_enum__))
2150 #define JSON_HEDLEY_FLAGS
2153#if defined(JSON_HEDLEY_FLAGS_CAST)
2154 #undef JSON_HEDLEY_FLAGS_CAST
2156#if JSON_HEDLEY_INTEL_VERSION_CHECK(19,0,0)
2157# define JSON_HEDLEY_FLAGS_CAST(T, expr) (__extension__ ({ \
2158 JSON_HEDLEY_DIAGNOSTIC_PUSH \
2159 _Pragma("warning(disable:188)") \
2161 JSON_HEDLEY_DIAGNOSTIC_POP \
2164# define JSON_HEDLEY_FLAGS_CAST(T, expr) JSON_HEDLEY_STATIC_CAST(T, expr)
2167#if defined(JSON_HEDLEY_EMPTY_BASES)
2168 #undef JSON_HEDLEY_EMPTY_BASES
2171 (JSON_HEDLEY_MSVC_VERSION_CHECK(19,0,23918) && !JSON_HEDLEY_MSVC_VERSION_CHECK(20,0,0)) || \
2172 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
2173 #define JSON_HEDLEY_EMPTY_BASES __declspec(empty_bases)
2175 #define JSON_HEDLEY_EMPTY_BASES
2180#if defined(JSON_HEDLEY_GCC_NOT_CLANG_VERSION_CHECK)
2181 #undef JSON_HEDLEY_GCC_NOT_CLANG_VERSION_CHECK
2183#if defined(__clang__)
2184 #define JSON_HEDLEY_GCC_NOT_CLANG_VERSION_CHECK(major,minor,patch) (0)
2186 #define JSON_HEDLEY_GCC_NOT_CLANG_VERSION_CHECK(major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch)
2189#if defined(JSON_HEDLEY_CLANG_HAS_ATTRIBUTE)
2190 #undef JSON_HEDLEY_CLANG_HAS_ATTRIBUTE
2192#define JSON_HEDLEY_CLANG_HAS_ATTRIBUTE(attribute) JSON_HEDLEY_HAS_ATTRIBUTE(attribute)
2194#if defined(JSON_HEDLEY_CLANG_HAS_CPP_ATTRIBUTE)
2195 #undef JSON_HEDLEY_CLANG_HAS_CPP_ATTRIBUTE
2197#define JSON_HEDLEY_CLANG_HAS_CPP_ATTRIBUTE(attribute) JSON_HEDLEY_HAS_CPP_ATTRIBUTE(attribute)
2199#if defined(JSON_HEDLEY_CLANG_HAS_BUILTIN)
2200 #undef JSON_HEDLEY_CLANG_HAS_BUILTIN
2202#define JSON_HEDLEY_CLANG_HAS_BUILTIN(builtin) JSON_HEDLEY_HAS_BUILTIN(builtin)
2204#if defined(JSON_HEDLEY_CLANG_HAS_FEATURE)
2205 #undef JSON_HEDLEY_CLANG_HAS_FEATURE
2207#define JSON_HEDLEY_CLANG_HAS_FEATURE(feature) JSON_HEDLEY_HAS_FEATURE(feature)
2209#if defined(JSON_HEDLEY_CLANG_HAS_EXTENSION)
2210 #undef JSON_HEDLEY_CLANG_HAS_EXTENSION
2212#define JSON_HEDLEY_CLANG_HAS_EXTENSION(extension) JSON_HEDLEY_HAS_EXTENSION(extension)
2214#if defined(JSON_HEDLEY_CLANG_HAS_DECLSPEC_DECLSPEC_ATTRIBUTE)
2215 #undef JSON_HEDLEY_CLANG_HAS_DECLSPEC_DECLSPEC_ATTRIBUTE
2217#define JSON_HEDLEY_CLANG_HAS_DECLSPEC_ATTRIBUTE(attribute) JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE(attribute)
2219#if defined(JSON_HEDLEY_CLANG_HAS_WARNING)
2220 #undef JSON_HEDLEY_CLANG_HAS_WARNING
2222#define JSON_HEDLEY_CLANG_HAS_WARNING(warning) JSON_HEDLEY_HAS_WARNING(warning)
2229#include <type_traits>
2262template<
class Default,
2264 template<
class...>
class Op,
2272template<
class Default,
template<
class...>
class Op,
class... Args>
2279template<
template<
class...>
class Op,
class... Args>
2282template<
template<
class...>
class Op,
class... Args>
2285template<
template<
class...>
class Op,
class... Args>
2288template<
class Default,
template<
class...>
class Op,
class... Args>
2291template<
class Default,
template<
class...>
class Op,
class... Args>
2294template<
class Expected,
template<
class...>
class Op,
class... Args>
2297template<
class To,
template<
class...>
class Op,
class... Args>
2299 std::is_convertible<
detected_t<Op, Args...>, To>;
2308#if !defined(JSON_SKIP_UNSUPPORTED_COMPILER_CHECK)
2309 #if defined(__clang__)
2310 #if (__clang_major__ * 10000 + __clang_minor__ * 100 + __clang_patchlevel__) < 30400
2311 #error "unsupported Clang version - see https://github.com/nlohmann/json#supported-compilers"
2313 #elif defined(__GNUC__) && !(defined(__ICC) || defined(__INTEL_COMPILER))
2314 #if (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) < 40800
2315 #error "unsupported GCC version - see https://github.com/nlohmann/json#supported-compilers"
2322#if !defined(JSON_HAS_CPP_20) && !defined(JSON_HAS_CPP_17) && !defined(JSON_HAS_CPP_14) && !defined(JSON_HAS_CPP_11)
2323 #if (defined(__cplusplus) && __cplusplus >= 202002L) || (defined(_MSVC_LANG) && _MSVC_LANG >= 202002L)
2324 #define JSON_HAS_CPP_20
2325 #define JSON_HAS_CPP_17
2326 #define JSON_HAS_CPP_14
2327 #elif (defined(__cplusplus) && __cplusplus >= 201703L) || (defined(_HAS_CXX17) && _HAS_CXX17 == 1)
2328 #define JSON_HAS_CPP_17
2329 #define JSON_HAS_CPP_14
2330 #elif (defined(__cplusplus) && __cplusplus >= 201402L) || (defined(_HAS_CXX14) && _HAS_CXX14 == 1)
2331 #define JSON_HAS_CPP_14
2334 #define JSON_HAS_CPP_11
2337#if !defined(JSON_HAS_FILESYSTEM) && !defined(JSON_HAS_EXPERIMENTAL_FILESYSTEM)
2338 #ifdef JSON_HAS_CPP_17
2339 #if defined(__cpp_lib_filesystem)
2340 #define JSON_HAS_FILESYSTEM 1
2341 #elif defined(__cpp_lib_experimental_filesystem)
2342 #define JSON_HAS_EXPERIMENTAL_FILESYSTEM 1
2343 #elif !defined(__has_include)
2344 #define JSON_HAS_EXPERIMENTAL_FILESYSTEM 1
2345 #elif __has_include(<filesystem>)
2346 #define JSON_HAS_FILESYSTEM 1
2347 #elif __has_include(<experimental/filesystem>)
2348 #define JSON_HAS_EXPERIMENTAL_FILESYSTEM 1
2352 #if defined(__MINGW32__) && defined(__GNUC__) && __GNUC__ == 8
2353 #undef JSON_HAS_FILESYSTEM
2354 #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM
2358 #if defined(__GNUC__) && !defined(__clang__) && __GNUC__ < 8
2359 #undef JSON_HAS_FILESYSTEM
2360 #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM
2364 #if defined(__clang_major__) && __clang_major__ < 7
2365 #undef JSON_HAS_FILESYSTEM
2366 #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM
2370 #if defined(_MSC_VER) && _MSC_VER < 1940
2371 #undef JSON_HAS_FILESYSTEM
2372 #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM
2376 #if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) && __IPHONE_OS_VERSION_MIN_REQUIRED < 130000
2377 #undef JSON_HAS_FILESYSTEM
2378 #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM
2382 #if defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && __MAC_OS_X_VERSION_MIN_REQUIRED < 101500
2383 #undef JSON_HAS_FILESYSTEM
2384 #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM
2389#ifndef JSON_HAS_EXPERIMENTAL_FILESYSTEM
2390 #define JSON_HAS_EXPERIMENTAL_FILESYSTEM 0
2393#ifndef JSON_HAS_FILESYSTEM
2394 #define JSON_HAS_FILESYSTEM 0
2398#if defined(__clang__)
2399 #pragma clang diagnostic push
2400 #pragma clang diagnostic ignored "-Wdocumentation"
2401 #pragma clang diagnostic ignored "-Wdocumentation-unknown-command"
2405#if (defined(__cpp_exceptions) || defined(__EXCEPTIONS) || defined(_CPPUNWIND)) && !defined(JSON_NOEXCEPTION)
2406 #define JSON_THROW(exception) throw exception
2407 #define JSON_TRY try
2408 #define JSON_CATCH(exception) catch(exception)
2409 #define JSON_INTERNAL_CATCH(exception) catch(exception)
2412 #define JSON_THROW(exception) std::abort()
2413 #define JSON_TRY if(true)
2414 #define JSON_CATCH(exception) if(false)
2415 #define JSON_INTERNAL_CATCH(exception) if(false)
2419#if defined(JSON_THROW_USER)
2421 #define JSON_THROW JSON_THROW_USER
2423#if defined(JSON_TRY_USER)
2425 #define JSON_TRY JSON_TRY_USER
2427#if defined(JSON_CATCH_USER)
2429 #define JSON_CATCH JSON_CATCH_USER
2430 #undef JSON_INTERNAL_CATCH
2431 #define JSON_INTERNAL_CATCH JSON_CATCH_USER
2433#if defined(JSON_INTERNAL_CATCH_USER)
2434 #undef JSON_INTERNAL_CATCH
2435 #define JSON_INTERNAL_CATCH JSON_INTERNAL_CATCH_USER
2439#if !defined(JSON_ASSERT)
2441 #define JSON_ASSERT(x) assert(x)
2445#if defined(JSON_TESTS_PRIVATE)
2446 #define JSON_PRIVATE_UNLESS_TESTED public
2448 #define JSON_PRIVATE_UNLESS_TESTED private
2456#define NLOHMANN_JSON_SERIALIZE_ENUM(ENUM_TYPE, ...) \
2457 template<typename BasicJsonType> \
2458 inline void to_json(BasicJsonType& j, const ENUM_TYPE& e) \
2460 static_assert(std::is_enum<ENUM_TYPE>::value, #ENUM_TYPE " must be an enum!"); \
2461 static const std::pair<ENUM_TYPE, BasicJsonType> m[] = __VA_ARGS__; \
2462 auto it = std::find_if(std::begin(m), std::end(m), \
2463 [e](const std::pair<ENUM_TYPE, BasicJsonType>& ej_pair) -> bool \
2465 return ej_pair.first == e; \
2467 j = ((it != std::end(m)) ? it : std::begin(m))->second; \
2469 template<typename BasicJsonType> \
2470 inline void from_json(const BasicJsonType& j, ENUM_TYPE& e) \
2472 static_assert(std::is_enum<ENUM_TYPE>::value, #ENUM_TYPE " must be an enum!"); \
2473 static const std::pair<ENUM_TYPE, BasicJsonType> m[] = __VA_ARGS__; \
2474 auto it = std::find_if(std::begin(m), std::end(m), \
2475 [&j](const std::pair<ENUM_TYPE, BasicJsonType>& ej_pair) -> bool \
2477 return ej_pair.second == j; \
2479 e = ((it != std::end(m)) ? it : std::begin(m))->first; \
2485#define NLOHMANN_BASIC_JSON_TPL_DECLARATION \
2486 template<template<typename, typename, typename...> class ObjectType, \
2487 template<typename, typename...> class ArrayType, \
2488 class StringType, class BooleanType, class NumberIntegerType, \
2489 class NumberUnsignedType, class NumberFloatType, \
2490 template<typename> class AllocatorType, \
2491 template<typename, typename = void> class JSONSerializer, \
2494#define NLOHMANN_BASIC_JSON_TPL \
2495 basic_json<ObjectType, ArrayType, StringType, BooleanType, \
2496 NumberIntegerType, NumberUnsignedType, NumberFloatType, \
2497 AllocatorType, JSONSerializer, BinaryType>
2501#define NLOHMANN_JSON_EXPAND( x ) x
2502#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
2503#define NLOHMANN_JSON_PASTE(...) NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_GET_MACRO(__VA_ARGS__, \
2504 NLOHMANN_JSON_PASTE64, \
2505 NLOHMANN_JSON_PASTE63, \
2506 NLOHMANN_JSON_PASTE62, \
2507 NLOHMANN_JSON_PASTE61, \
2508 NLOHMANN_JSON_PASTE60, \
2509 NLOHMANN_JSON_PASTE59, \
2510 NLOHMANN_JSON_PASTE58, \
2511 NLOHMANN_JSON_PASTE57, \
2512 NLOHMANN_JSON_PASTE56, \
2513 NLOHMANN_JSON_PASTE55, \
2514 NLOHMANN_JSON_PASTE54, \
2515 NLOHMANN_JSON_PASTE53, \
2516 NLOHMANN_JSON_PASTE52, \
2517 NLOHMANN_JSON_PASTE51, \
2518 NLOHMANN_JSON_PASTE50, \
2519 NLOHMANN_JSON_PASTE49, \
2520 NLOHMANN_JSON_PASTE48, \
2521 NLOHMANN_JSON_PASTE47, \
2522 NLOHMANN_JSON_PASTE46, \
2523 NLOHMANN_JSON_PASTE45, \
2524 NLOHMANN_JSON_PASTE44, \
2525 NLOHMANN_JSON_PASTE43, \
2526 NLOHMANN_JSON_PASTE42, \
2527 NLOHMANN_JSON_PASTE41, \
2528 NLOHMANN_JSON_PASTE40, \
2529 NLOHMANN_JSON_PASTE39, \
2530 NLOHMANN_JSON_PASTE38, \
2531 NLOHMANN_JSON_PASTE37, \
2532 NLOHMANN_JSON_PASTE36, \
2533 NLOHMANN_JSON_PASTE35, \
2534 NLOHMANN_JSON_PASTE34, \
2535 NLOHMANN_JSON_PASTE33, \
2536 NLOHMANN_JSON_PASTE32, \
2537 NLOHMANN_JSON_PASTE31, \
2538 NLOHMANN_JSON_PASTE30, \
2539 NLOHMANN_JSON_PASTE29, \
2540 NLOHMANN_JSON_PASTE28, \
2541 NLOHMANN_JSON_PASTE27, \
2542 NLOHMANN_JSON_PASTE26, \
2543 NLOHMANN_JSON_PASTE25, \
2544 NLOHMANN_JSON_PASTE24, \
2545 NLOHMANN_JSON_PASTE23, \
2546 NLOHMANN_JSON_PASTE22, \
2547 NLOHMANN_JSON_PASTE21, \
2548 NLOHMANN_JSON_PASTE20, \
2549 NLOHMANN_JSON_PASTE19, \
2550 NLOHMANN_JSON_PASTE18, \
2551 NLOHMANN_JSON_PASTE17, \
2552 NLOHMANN_JSON_PASTE16, \
2553 NLOHMANN_JSON_PASTE15, \
2554 NLOHMANN_JSON_PASTE14, \
2555 NLOHMANN_JSON_PASTE13, \
2556 NLOHMANN_JSON_PASTE12, \
2557 NLOHMANN_JSON_PASTE11, \
2558 NLOHMANN_JSON_PASTE10, \
2559 NLOHMANN_JSON_PASTE9, \
2560 NLOHMANN_JSON_PASTE8, \
2561 NLOHMANN_JSON_PASTE7, \
2562 NLOHMANN_JSON_PASTE6, \
2563 NLOHMANN_JSON_PASTE5, \
2564 NLOHMANN_JSON_PASTE4, \
2565 NLOHMANN_JSON_PASTE3, \
2566 NLOHMANN_JSON_PASTE2, \
2567 NLOHMANN_JSON_PASTE1)(__VA_ARGS__))
2568#define NLOHMANN_JSON_PASTE2(func, v1) func(v1)
2569#define NLOHMANN_JSON_PASTE3(func, v1, v2) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE2(func, v2)
2570#define NLOHMANN_JSON_PASTE4(func, v1, v2, v3) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE3(func, v2, v3)
2571#define NLOHMANN_JSON_PASTE5(func, v1, v2, v3, v4) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE4(func, v2, v3, v4)
2572#define NLOHMANN_JSON_PASTE6(func, v1, v2, v3, v4, v5) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE5(func, v2, v3, v4, v5)
2573#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)
2574#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)
2575#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)
2576#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)
2577#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)
2578#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)
2579#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)
2580#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)
2581#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)
2582#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)
2583#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)
2584#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)
2585#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)
2586#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)
2587#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)
2588#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)
2589#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)
2590#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)
2591#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)
2592#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)
2593#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)
2594#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)
2595#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)
2596#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)
2597#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)
2598#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)
2599#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)
2600#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)
2601#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)
2602#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)
2603#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)
2604#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)
2605#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)
2606#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)
2607#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)
2608#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)
2609#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)
2610#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)
2611#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)
2612#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)
2613#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)
2614#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)
2615#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)
2616#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)
2617#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)
2618#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)
2619#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)
2620#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)
2621#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)
2622#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)
2623#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)
2624#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)
2625#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)
2626#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)
2627#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)
2628#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)
2629#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)
2630#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)
2632#define NLOHMANN_JSON_TO(v1) nlohmann_json_j[#v1] = nlohmann_json_t.v1;
2633#define NLOHMANN_JSON_FROM(v1) nlohmann_json_j.at(#v1).get_to(nlohmann_json_t.v1);
2640#define NLOHMANN_DEFINE_TYPE_INTRUSIVE(Type, ...) \
2641 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__)) } \
2642 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__)) }
2649#define NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(Type, ...) \
2650 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__)) } \
2651 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__)) }
2660#define NLOHMANN_CAN_CALL_STD_FUNC_IMPL(std_name) \
2661 namespace detail { \
2662 using std::std_name; \
2664 template<typename... T> \
2665 using result_of_##std_name = decltype(std_name(std::declval<T>()...)); \
2668 namespace detail2 { \
2669 struct std_name##_tag \
2673 template<typename... T> \
2674 std_name##_tag std_name(T&&...); \
2676 template<typename... T> \
2677 using result_of_##std_name = decltype(std_name(std::declval<T>()...)); \
2679 template<typename... T> \
2680 struct would_call_std_##std_name \
2682 static constexpr auto const value = ::nlohmann::detail:: \
2683 is_detected_exact<std_name##_tag, result_of_##std_name, T...>::value; \
2687 template<typename... T> \
2688 struct would_call_std_##std_name : detail2::would_call_std_##std_name<T...> \
2692#ifndef JSON_USE_IMPLICIT_CONVERSIONS
2693 #define JSON_USE_IMPLICIT_CONVERSIONS 1
2696#if JSON_USE_IMPLICIT_CONVERSIONS
2697 #define JSON_EXPLICIT
2699 #define JSON_EXPLICIT explicit
2702#ifndef JSON_DIAGNOSTICS
2703 #define JSON_DIAGNOSTICS 0
2726 const std::string& t)
2729 for (
auto pos = s.find(f);
2730 pos != std::string::npos;
2731 s.replace(pos, f.size(), t),
2732 pos = s.find(f, pos + t.size()))
2786 constexpr operator size_t()
const
2812 const char*
what() const noexcept
override
2822 exception(
int id_, const
char* what_arg) :
id(id_),
m(what_arg) {}
2824 static std::string
name(
const std::string& ename,
int id_)
2826 return "[json.exception." + ename +
"." + std::to_string(id_) +
"] ";
2829 template<
typename BasicJsonType>
2833 std::vector<std::string> tokens;
2834 for (
const auto* current = &leaf_element; current->m_parent !=
nullptr; current = current->m_parent)
2836 switch (current->m_parent->type())
2840 for (std::size_t i = 0; i < current->m_parent->m_value.array->size(); ++i)
2842 if (¤t->m_parent->m_value.array->operator[](i) == current)
2844 tokens.emplace_back(std::to_string(i));
2853 for (
const auto& element : *current->m_parent->m_value.object)
2855 if (&element.second == current)
2857 tokens.emplace_back(element.first.c_str());
2882 return "(" + std::accumulate(tokens.rbegin(), tokens.rend(), std::string{},
2883 [](
const std::string & a,
const std::string & b)
2885 return a +
"/" + detail::escape(b);
2888 static_cast<void>(leaf_element);
2895 std::runtime_error
m;
2912 template<
typename BasicJsonType>
2920 template<
typename BasicJsonType>
2921 static parse_error create(
int id_, std::size_t byte_,
const std::string& what_arg,
const BasicJsonType& context)
2924 (byte_ != 0 ? (
" at byte " + std::to_string(byte_)) :
"") +
2926 return {id_, byte_, w.c_str()};
2946 return " at line " + std::to_string(pos.
lines_read + 1) +
2956 template<
typename BasicJsonType>
2960 return {id_, w.c_str()};
2974 template<
typename BasicJsonType>
2978 return {id_, w.c_str()};
2991 template<
typename BasicJsonType>
2995 return {id_, w.c_str()};
3008 template<
typename BasicJsonType>
3012 return {id_, w.c_str()};
3029#include <type_traits>
3041using uncvref_t =
typename std::remove_cv<typename std::remove_reference<T>::type>::type;
3043#ifdef JSON_HAS_CPP_14
3046using std::enable_if_t;
3047using std::index_sequence;
3048using std::make_index_sequence;
3049using std::index_sequence_for;
3054template<
bool B,
typename T =
void>
3081template <
typename T, T... Ints>
3085 static constexpr std::size_t
size() noexcept
3087 return sizeof...(Ints);
3096template <
size_t... Ints>
3099namespace utility_internal
3102template <
typename Seq,
size_t SeqSize,
size_t Rem>
3106template <
typename T, T... Ints,
size_t SeqSize>
3112template <
typename T, T... Ints,
size_t SeqSize>
3120template <
typename T,
size_t N>
3127template <
typename T>
3142template <
typename T, T N>
3158template <
typename... Ts>
3198#include <type_traits>
3219template<
typename It,
typename =
void>
3222template<
typename It>
3226 typename It::reference, typename It::iterator_category >>
3237template<
typename T,
typename =
void>
3287#ifndef INCLUDE_NLOHMANN_JSON_FWD_HPP_
3288#define INCLUDE_NLOHMANN_JSON_FWD_HPP_
3310template<
typename T =
void,
typename SFINAE =
void>
3311struct adl_serializer;
3315template<
template<
typename U,
typename V,
typename... Args>
class ObjectType =
3317 template<
typename U,
typename... Args>
class ArrayType = std::vector,
3318 class StringType = std::string,
class BooleanType = bool,
3319 class NumberIntegerType = std::int64_t,
3320 class NumberUnsignedType = std::uint64_t,
3321 class NumberFloatType = double,
3322 template<
typename U>
class AllocatorType = std::allocator,
3323 template<
typename T,
typename SFINAE =
void>
class JSONSerializer =
3325 class BinaryType = std::vector<std::uint8_t>>
3330template<
typename BasicJsonType>
3341template<
class Key,
class T,
class IgnoredLess,
class Allocator>
3421template<
typename T,
typename... Args>
3424template<
typename T,
typename... Args>
3427template<
typename T,
typename U>
3431template<
typename BasicJsonType,
typename T,
typename =
void>
3438template <
typename BasicJsonType,
typename T>
3444template<
typename BasicJsonType,
typename T>
3447 using serializer =
typename BasicJsonType::template json_serializer<T, void>;
3451 const BasicJsonType&, T&>
::value;
3456template<
typename BasicJsonType,
typename T,
typename =
void>
3459template<
typename BasicJsonType,
typename T>
3462 using serializer =
typename BasicJsonType::template json_serializer<T, void>;
3471template<
typename BasicJsonType,
typename T,
typename =
void>
3474template<
typename BasicJsonType,
typename T>
3477 using serializer =
typename BasicJsonType::template json_serializer<T, void>;
3492template<
class B1,
class... Bn>
3494: std::conditional<bool(B1::value), conjunction<Bn...>, B1>::type {};
3497template<
class B>
struct negation : std::integral_constant < bool, !B::value > { };
3502template <
typename T>
3505template <
typename T1,
typename T2>
3507 :
conjunction<is_default_constructible<T1>, is_default_constructible<T2>> {};
3509template <
typename T1,
typename T2>
3511 :
conjunction<is_default_constructible<T1>, is_default_constructible<T2>> {};
3513template <
typename... Ts>
3515 :
conjunction<is_default_constructible<Ts>...> {};
3517template <
typename... Ts>
3519 :
conjunction<is_default_constructible<Ts>...> {};
3522template <
typename T,
typename... Args>
3525template <
typename T1,
typename T2>
3528template <
typename T1,
typename T2>
3531template <
typename... Ts>
3534template <
typename... Ts>
3538template<
typename T,
typename =
void>
3560 using t_ref =
typename std::add_lvalue_reference<T>::type;
3572 static constexpr bool value = !std::is_same<iterator, nonesuch>::value && !std::is_same<sentinel, nonesuch>::value &&
is_iterator_begin;
3585template<
typename T,
typename =
void>
3591template<
typename BasicJsonType,
typename CompatibleObjectType,
3595template<
typename BasicJsonType,
typename CompatibleObjectType>
3597 BasicJsonType, CompatibleObjectType,
3606 typename CompatibleObjectType::key_type>
::value &&
3608 typename CompatibleObjectType::mapped_type>
::value;
3611template<
typename BasicJsonType,
typename CompatibleObjectType>
3615template<
typename BasicJsonType,
typename ConstructibleObjectType,
3619template<
typename BasicJsonType,
typename ConstructibleObjectType>
3621 BasicJsonType, ConstructibleObjectType,
3629 (std::is_move_assignable<ConstructibleObjectType>::value ||
3630 std::is_copy_assignable<ConstructibleObjectType>::value) &&
3632 typename object_t::key_type>
::value &&
3634 typename object_t::mapped_type,
3635 typename ConstructibleObjectType::mapped_type >
::value)) ||
3637 typename ConstructibleObjectType::mapped_type>
::value ||
3640 typename ConstructibleObjectType::mapped_type >
::value);
3643template<
typename BasicJsonType,
typename ConstructibleObjectType>
3646 ConstructibleObjectType> {};
3648template<
typename BasicJsonType,
typename CompatibleStringType>
3655template<
typename BasicJsonType,
typename ConstructibleStringType>
3660 typename BasicJsonType::string_t>
::value;
3663template<
typename BasicJsonType,
typename CompatibleArrayType,
typename =
void>
3666template<
typename BasicJsonType,
typename CompatibleArrayType>
3668 BasicJsonType, CompatibleArrayType,
3674 !std::is_same<CompatibleArrayType, detected_t<range_value_t, CompatibleArrayType>>
::value >>
3681template<
typename BasicJsonType,
typename CompatibleArrayType>
3685template<
typename BasicJsonType,
typename ConstructibleArrayType,
typename =
void>
3688template<
typename BasicJsonType,
typename ConstructibleArrayType>
3690 BasicJsonType, ConstructibleArrayType,
3692 typename BasicJsonType::value_type>
::value >>
3693 : std::true_type {};
3695template<
typename BasicJsonType,
typename ConstructibleArrayType>
3697 BasicJsonType, ConstructibleArrayType,
3699 typename BasicJsonType::value_type>
::value&&
3702(std::is_move_assignable<ConstructibleArrayType>::value ||
3703 std::is_copy_assignable<ConstructibleArrayType>::value)&&
3709!std::is_same<ConstructibleArrayType, detected_t<range_value_t, ConstructibleArrayType>>
::value&&
3711 detected_t<range_value_t, ConstructibleArrayType >>
::value >>
3717 typename BasicJsonType::array_t::value_type>
::value ||
3725template<
typename BasicJsonType,
typename ConstructibleArrayType>
3729template<
typename RealIntegerType,
typename CompatibleNumberIntegerType,
3733template<
typename RealIntegerType,
typename CompatibleNumberIntegerType>
3735 RealIntegerType, CompatibleNumberIntegerType,
3737 std::is_integral<CompatibleNumberIntegerType>
::value&&
3738 !std::is_same<bool, CompatibleNumberIntegerType>
::value >>
3746 CompatibleNumberIntegerType>
::value &&
3747 CompatibleLimits::is_integer &&
3748 RealLimits::is_signed == CompatibleLimits::is_signed;
3751template<
typename RealIntegerType,
typename CompatibleNumberIntegerType>
3754 CompatibleNumberIntegerType> {};
3756template<
typename BasicJsonType,
typename CompatibleType,
typename =
void>
3759template<
typename BasicJsonType,
typename CompatibleType>
3761 BasicJsonType, CompatibleType,
3768template<
typename BasicJsonType,
typename CompatibleType>
3772template<
typename T1,
typename T2>
3775template<
typename T1,
typename... Args>
3780template <
typename T>
3790 template <
typename C>
static one test(
decltype(&C::capacity) ) ;
3793 enum {
value =
sizeof(test<T>(
nullptr)) ==
sizeof(
char) };
3797template < typename T, typename U, enable_if_t < !std::is_same<T, U>::value,
int > = 0 >
3800 return static_cast<T
>(
value);
3803template<typename T, typename U, enable_if_t<std::is_same<T, U>::value,
int> = 0>
3815#if JSON_HAS_EXPERIMENTAL_FILESYSTEM
3816#include <experimental/filesystem>
3819namespace std_fs = std::experimental::filesystem;
3821#elif JSON_HAS_FILESYSTEM
3822#include <filesystem>
3825namespace std_fs = std::filesystem;
3833template<
typename BasicJsonType>
3834void from_json(
const BasicJsonType& j,
typename std::nullptr_t& n)
3844template <
typename BasicJsonType,
typename ArithmeticType,
3845 enable_if_t < std::is_arithmetic<ArithmeticType>::value&&
3846 !std::is_same<ArithmeticType, typename BasicJsonType::boolean_t>::value,
3850 switch (
static_cast<value_t>(j))
3854 val =
static_cast<ArithmeticType
>(*j.template get_ptr<const typename BasicJsonType::number_unsigned_t*>());
3859 val =
static_cast<ArithmeticType
>(*j.template get_ptr<const typename BasicJsonType::number_integer_t*>());
3864 val =
static_cast<ArithmeticType
>(*j.template get_ptr<const typename BasicJsonType::number_float_t*>());
3880template<
typename BasicJsonType>
3881void from_json(
const BasicJsonType& j,
typename BasicJsonType::boolean_t& b)
3887 b = *j.template get_ptr<const typename BasicJsonType::boolean_t*>();
3890template<
typename BasicJsonType>
3891void from_json(
const BasicJsonType& j,
typename BasicJsonType::string_t& s)
3897 s = *j.template get_ptr<const typename BasicJsonType::string_t*>();
3901 typename BasicJsonType,
typename ConstructibleStringType,
3904 !std::is_same<
typename BasicJsonType::string_t,
3905 ConstructibleStringType>
::value,
3907void from_json(
const BasicJsonType& j, ConstructibleStringType& s)
3914 s = *j.template get_ptr<const typename BasicJsonType::string_t*>();
3917template<
typename BasicJsonType>
3918void from_json(
const BasicJsonType& j,
typename BasicJsonType::number_float_t& val)
3923template<
typename BasicJsonType>
3924void from_json(
const BasicJsonType& j,
typename BasicJsonType::number_unsigned_t& val)
3929template<
typename BasicJsonType>
3930void from_json(
const BasicJsonType& j,
typename BasicJsonType::number_integer_t& val)
3935template<
typename BasicJsonType,
typename EnumType,
3936 enable_if_t<std::is_enum<EnumType>::value,
int> = 0>
3939 typename std::underlying_type<EnumType>::type val;
3941 e =
static_cast<EnumType
>(val);
3945template<
typename BasicJsonType,
typename T,
typename Allocator,
3946 enable_if_t<is_getable<BasicJsonType, T>::value,
int> = 0>
3947void from_json(
const BasicJsonType& j, std::forward_list<T, Allocator>& l)
3954 std::transform(j.rbegin(), j.rend(),
3955 std::front_inserter(l), [](
const BasicJsonType & i)
3957 return i.template get<T>();
3962template<
typename BasicJsonType,
typename T,
3963 enable_if_t<is_getable<BasicJsonType, T>::value,
int> = 0>
3971 std::transform(j.begin(), j.end(), std::begin(l),
3972 [](
const BasicJsonType & elem)
3974 return elem.template get<T>();
3978template<
typename BasicJsonType,
typename T, std::
size_t N>
3980->
decltype(j.template get<T>(), void())
3982 for (std::size_t i = 0; i < N; ++i)
3984 arr[i] = j.at(i).template get<T>();
3988template<
typename BasicJsonType>
3991 arr = *j.template get_ptr<const typename BasicJsonType::array_t*>();
3994template<
typename BasicJsonType,
typename T, std::
size_t N>
3997->
decltype(j.template get<T>(), void())
3999 for (std::size_t i = 0; i < N; ++i)
4001 arr[i] = j.at(i).template get<T>();
4005template<
typename BasicJsonType,
typename ConstructibleArrayType,
4007 std::is_assignable<ConstructibleArrayType&, ConstructibleArrayType>::value,
4011 arr.reserve(std::declval<typename ConstructibleArrayType::size_type>()),
4012 j.template get<typename ConstructibleArrayType::value_type>(),
4017 ConstructibleArrayType ret;
4018 ret.reserve(j.size());
4019 std::transform(j.begin(), j.end(),
4020 std::inserter(ret, end(ret)), [](
const BasicJsonType & i)
4024 return i.template get<typename ConstructibleArrayType::value_type>();
4026 arr = std::move(ret);
4029template<
typename BasicJsonType,
typename ConstructibleArrayType,
4031 std::is_assignable<ConstructibleArrayType&, ConstructibleArrayType>::value,
4038 ConstructibleArrayType ret;
4040 j.begin(), j.end(), std::inserter(ret, end(ret)),
4041 [](
const BasicJsonType & i)
4045 return i.template get<typename ConstructibleArrayType::value_type>();
4047 arr = std::move(ret);
4050template <
typename BasicJsonType,
typename ConstructibleArrayType,
4052 is_constructible_array_type<BasicJsonType, ConstructibleArrayType>::value&&
4053 !is_constructible_object_type<BasicJsonType, ConstructibleArrayType>::value&&
4055 !std::is_same<ConstructibleArrayType, typename BasicJsonType::binary_t>::value&&
4056 !is_basic_json<ConstructibleArrayType>::value,
4058auto from_json(
const BasicJsonType& j, ConstructibleArrayType& arr)
4060j.template get<typename ConstructibleArrayType::value_type>(),
4071template <
typename BasicJsonType,
typename T, std::size_t... Idx >
4075 return { { std::forward<BasicJsonType>(j).at(Idx).template get<T>()... } };
4078template <
typename BasicJsonType,
typename T, std::
size_t N >
4090template<
typename BasicJsonType>
4091void from_json(
const BasicJsonType& j,
typename BasicJsonType::binary_t& bin)
4098 bin = *j.template get_ptr<const typename BasicJsonType::binary_t*>();
4101template<
typename BasicJsonType,
typename ConstructibleObjectType,
4102 enable_if_t<is_constructible_object_type<BasicJsonType, ConstructibleObjectType>::value,
int> = 0>
4103void from_json(
const BasicJsonType& j, ConstructibleObjectType& obj)
4110 ConstructibleObjectType ret;
4111 const auto* inner_object = j.template get_ptr<const typename BasicJsonType::object_t*>();
4112 using value_type =
typename ConstructibleObjectType::value_type;
4114 inner_object->begin(), inner_object->end(),
4115 std::inserter(ret, ret.begin()),
4116 [](
typename BasicJsonType::object_t::value_type
const & p)
4118 return value_type(p.first, p.second.template get<typename ConstructibleObjectType::mapped_type>());
4120 obj = std::move(ret);
4127template <
typename BasicJsonType,
typename ArithmeticType,
4129 std::is_arithmetic<ArithmeticType>::value&&
4130 !std::is_same<ArithmeticType, typename BasicJsonType::number_unsigned_t>::value&&
4131 !std::is_same<ArithmeticType, typename BasicJsonType::number_integer_t>::value&&
4132 !std::is_same<ArithmeticType, typename BasicJsonType::number_float_t>::value&&
4133 !std::is_same<ArithmeticType, typename BasicJsonType::boolean_t>::value,
4137 switch (
static_cast<value_t>(j))
4141 val =
static_cast<ArithmeticType
>(*j.template get_ptr<const typename BasicJsonType::number_unsigned_t*>());
4146 val =
static_cast<ArithmeticType
>(*j.template get_ptr<const typename BasicJsonType::number_integer_t*>());
4151 val =
static_cast<ArithmeticType
>(*j.template get_ptr<const typename BasicJsonType::number_float_t*>());
4156 val =
static_cast<ArithmeticType
>(*j.template get_ptr<const typename BasicJsonType::boolean_t*>());
4171template<
typename BasicJsonType,
typename... Args, std::size_t... Idx>
4174 return std::make_tuple(std::forward<BasicJsonType>(j).at(Idx).
template get<Args>()...);
4177template <
typename BasicJsonType,
class A1,
class A2 >
4180 return {std::forward<BasicJsonType>(j).at(0).template get<A1>(),
4181 std::forward<BasicJsonType>(j).at(1).template get<A2>()};
4184template<
typename BasicJsonType,
typename A1,
typename A2>
4190template<
typename BasicJsonType,
typename... Args>
4196template<
typename BasicJsonType,
typename... Args>
4202template<
typename BasicJsonType,
typename TupleRelated>
4211 return from_json_tuple_impl(std::forward<BasicJsonType>(j), std::forward<TupleRelated>(t), priority_tag<3> {});
4214template <
typename BasicJsonType,
typename Key,
typename Value,
typename Compare,
typename Allocator,
4216 typename BasicJsonType::string_t, Key >
::value >>
4217void from_json(
const BasicJsonType& j, std::map<Key, Value, Compare, Allocator>& m)
4224 for (
const auto& p : j)
4230 m.emplace(p.at(0).template get<Key>(), p.at(1).template get<Value>());
4234template <
typename BasicJsonType,
typename Key,
typename Value,
typename Hash,
typename KeyEqual,
typename Allocator,
4236 typename BasicJsonType::string_t, Key >
::value >>
4237void from_json(
const BasicJsonType& j, std::unordered_map<Key, Value, Hash, KeyEqual, Allocator>& m)
4244 for (
const auto& p : j)
4250 m.emplace(p.at(0).template get<Key>(), p.at(1).template get<Value>());
4254#if JSON_HAS_FILESYSTEM || JSON_HAS_EXPERIMENTAL_FILESYSTEM
4255template<
typename BasicJsonType>
4256void from_json(
const BasicJsonType& j, std_fs::path& p)
4262 p = *j.template get_ptr<const typename BasicJsonType::string_t*>();
4268 template<
typename BasicJsonType,
typename T>
4270 noexcept(
noexcept(
from_json(j, std::forward<T>(val))))
4271 ->
decltype(
from_json(j, std::forward<T>(val)))
4273 return from_json(j, std::forward<T>(val));
4294#include <type_traits>
4319template<
typename string_type>
4323 using std::to_string;
4334 using string_type =
typename std::remove_cv< typename std::remove_reference<decltype( std::declval<IteratorType>().
key() ) >::type >::type;
4385 switch (
anchor.m_object->type())
4417 typename IteratorType::reference
value()
const
4450template<std::
size_t N,
typename IteratorType, enable_if_t<N == 0,
int> = 0>
4458template<std::
size_t N,
typename IteratorType, enable_if_t<N == 1,
int> = 0>
4472#if defined(__clang__)
4474 #pragma clang diagnostic push
4475 #pragma clang diagnostic ignored "-Wmismatched-tags"
4477template<
typename IteratorType>
4479 :
public std::integral_constant<std::size_t, 2> {};
4481template<std::
size_t N,
typename IteratorType>
4486 get<N>(std::declval <
4489#if defined(__clang__)
4490 #pragma clang diagnostic pop
4501#if JSON_HAS_EXPERIMENTAL_FILESYSTEM
4502#include <experimental/filesystem>
4505namespace std_fs = std::experimental::filesystem;
4507#elif JSON_HAS_FILESYSTEM
4508#include <filesystem>
4511namespace std_fs = std::filesystem;
4535 template<
typename BasicJsonType>
4536 static void construct(BasicJsonType& j,
typename BasicJsonType::boolean_t b)
noexcept
4538 j.m_value.destroy(j.m_type);
4541 j.assert_invariant();
4548 template<
typename BasicJsonType>
4549 static void construct(BasicJsonType& j,
const typename BasicJsonType::string_t& s)
4551 j.m_value.destroy(j.m_type);
4554 j.assert_invariant();
4557 template<
typename BasicJsonType>
4558 static void construct(BasicJsonType& j,
typename BasicJsonType::string_t&& s)
4560 j.m_value.destroy(j.m_type);
4562 j.m_value = std::move(s);
4563 j.assert_invariant();
4566 template <
typename BasicJsonType,
typename CompatibleStringType,
4567 enable_if_t < !std::is_same<CompatibleStringType, typename BasicJsonType::string_t>::value,
4569 static void construct(BasicJsonType& j,
const CompatibleStringType& str)
4571 j.m_value.destroy(j.m_type);
4573 j.m_value.string = j.template create<typename BasicJsonType::string_t>(str);
4574 j.assert_invariant();
4581 template<
typename BasicJsonType>
4582 static void construct(BasicJsonType& j,
const typename BasicJsonType::binary_t& b)
4584 j.m_value.destroy(j.m_type);
4586 j.m_value =
typename BasicJsonType::binary_t(b);
4587 j.assert_invariant();
4590 template<
typename BasicJsonType>
4591 static void construct(BasicJsonType& j,
typename BasicJsonType::binary_t&& b)
4593 j.m_value.destroy(j.m_type);
4595 j.m_value =
typename BasicJsonType::binary_t(std::move(b));
4596 j.assert_invariant();
4603 template<
typename BasicJsonType>
4604 static void construct(BasicJsonType& j,
typename BasicJsonType::number_float_t val)
noexcept
4606 j.m_value.destroy(j.m_type);
4609 j.assert_invariant();
4616 template<
typename BasicJsonType>
4617 static void construct(BasicJsonType& j,
typename BasicJsonType::number_unsigned_t val)
noexcept
4619 j.m_value.destroy(j.m_type);
4622 j.assert_invariant();
4629 template<
typename BasicJsonType>
4630 static void construct(BasicJsonType& j,
typename BasicJsonType::number_integer_t val)
noexcept
4632 j.m_value.destroy(j.m_type);
4635 j.assert_invariant();
4642 template<
typename BasicJsonType>
4643 static void construct(BasicJsonType& j,
const typename BasicJsonType::array_t& arr)
4645 j.m_value.destroy(j.m_type);
4649 j.assert_invariant();
4652 template<
typename BasicJsonType>
4653 static void construct(BasicJsonType& j,
typename BasicJsonType::array_t&& arr)
4655 j.m_value.destroy(j.m_type);
4657 j.m_value = std::move(arr);
4659 j.assert_invariant();
4662 template <
typename BasicJsonType,
typename CompatibleArrayType,
4663 enable_if_t < !std::is_same<CompatibleArrayType, typename BasicJsonType::array_t>::value,
4665 static void construct(BasicJsonType& j,
const CompatibleArrayType& arr)
4670 j.m_value.destroy(j.m_type);
4672 j.m_value.array = j.template create<typename BasicJsonType::array_t>(begin(arr), end(arr));
4674 j.assert_invariant();
4677 template<
typename BasicJsonType>
4678 static void construct(BasicJsonType& j,
const std::vector<bool>& arr)
4680 j.m_value.destroy(j.m_type);
4683 j.m_value.array->reserve(arr.size());
4684 for (
const bool x : arr)
4686 j.m_value.array->push_back(x);
4687 j.set_parent(j.m_value.array->back());
4689 j.assert_invariant();
4692 template<
typename BasicJsonType,
typename T,
4694 static void construct(BasicJsonType& j,
const std::valarray<T>& arr)
4696 j.m_value.destroy(j.m_type);
4699 j.m_value.array->resize(arr.size());
4702 std::copy(std::begin(arr), std::end(arr), j.m_value.array->begin());
4705 j.assert_invariant();
4712 template<
typename BasicJsonType>
4713 static void construct(BasicJsonType& j,
const typename BasicJsonType::object_t& obj)
4715 j.m_value.destroy(j.m_type);
4719 j.assert_invariant();
4722 template<
typename BasicJsonType>
4723 static void construct(BasicJsonType& j,
typename BasicJsonType::object_t&& obj)
4725 j.m_value.destroy(j.m_type);
4727 j.m_value = std::move(obj);
4729 j.assert_invariant();
4732 template <
typename BasicJsonType,
typename CompatibleObjectType,
4733 enable_if_t < !std::is_same<CompatibleObjectType, typename BasicJsonType::object_t>::value,
int > = 0 >
4734 static void construct(BasicJsonType& j,
const CompatibleObjectType& obj)
4739 j.m_value.destroy(j.m_type);
4741 j.m_value.object = j.template create<typename BasicJsonType::object_t>(begin(obj), end(obj));
4743 j.assert_invariant();
4751template<
typename BasicJsonType,
typename T,
4752 enable_if_t<std::is_same<T, typename BasicJsonType::boolean_t>::value,
int> = 0>
4758template<
typename BasicJsonType,
typename CompatibleString,
4759 enable_if_t<std::is_constructible<typename BasicJsonType::string_t, CompatibleString>::value,
int> = 0>
4760void to_json(BasicJsonType& j,
const CompatibleString& s)
4765template<
typename BasicJsonType>
4766void to_json(BasicJsonType& j,
typename BasicJsonType::string_t&& s)
4771template<
typename BasicJsonType,
typename FloatType,
4772 enable_if_t<std::is_floating_point<FloatType>::value,
int> = 0>
4773void to_json(BasicJsonType& j, FloatType val)
noexcept
4778template<
typename BasicJsonType,
typename CompatibleNumberUnsignedType,
4779 enable_if_t<is_compatible_integer_type<typename BasicJsonType::number_unsigned_t, CompatibleNumberUnsignedType>::value,
int> = 0>
4780void to_json(BasicJsonType& j, CompatibleNumberUnsignedType val)
noexcept
4785template<
typename BasicJsonType,
typename CompatibleNumberIntegerType,
4786 enable_if_t<is_compatible_integer_type<typename BasicJsonType::number_integer_t, CompatibleNumberIntegerType>::value,
int> = 0>
4787void to_json(BasicJsonType& j, CompatibleNumberIntegerType val)
noexcept
4792template<
typename BasicJsonType,
typename EnumType,
4793 enable_if_t<std::is_enum<EnumType>::value,
int> = 0>
4794void to_json(BasicJsonType& j, EnumType e)
noexcept
4796 using underlying_type =
typename std::underlying_type<EnumType>::type;
4800template<
typename BasicJsonType>
4801void to_json(BasicJsonType& j,
const std::vector<bool>& e)
4806template <
typename BasicJsonType,
typename CompatibleArrayType,
4807 enable_if_t < is_compatible_array_type<BasicJsonType,
4809 !is_compatible_object_type<BasicJsonType, CompatibleArrayType>::value&&
4811 !std::is_same<typename BasicJsonType::binary_t, CompatibleArrayType>::value&&
4812 !is_basic_json<CompatibleArrayType>::value,
4814void to_json(BasicJsonType& j,
const CompatibleArrayType& arr)
4819template<
typename BasicJsonType>
4820void to_json(BasicJsonType& j,
const typename BasicJsonType::binary_t& bin)
4825template<
typename BasicJsonType,
typename T,
4826 enable_if_t<std::is_convertible<T, BasicJsonType>::value,
int> = 0>
4827void to_json(BasicJsonType& j,
const std::valarray<T>& arr)
4832template<
typename BasicJsonType>
4833void to_json(BasicJsonType& j,
typename BasicJsonType::array_t&& arr)
4838template <
typename BasicJsonType,
typename CompatibleObjectType,
4839 enable_if_t < is_compatible_object_type<BasicJsonType, CompatibleObjectType>::value&& !is_basic_json<CompatibleObjectType>::value,
int > = 0 >
4840void to_json(BasicJsonType& j,
const CompatibleObjectType& obj)
4845template<
typename BasicJsonType>
4846void to_json(BasicJsonType& j,
typename BasicJsonType::object_t&& obj)
4852 typename BasicJsonType,
typename T, std::size_t N,
4853 enable_if_t < !std::is_constructible<
typename BasicJsonType::string_t,
4861template < typename BasicJsonType, typename T1, typename T2, enable_if_t < std::is_constructible<BasicJsonType, T1>::value&& std::is_constructible<BasicJsonType, T2>::value,
int > = 0 >
4862void to_json(BasicJsonType& j,
const std::pair<T1, T2>& p)
4864 j = { p.first, p.second };
4868template<
typename BasicJsonType,
typename T,
4869 enable_if_t<std::is_same<T, iteration_proxy_value<typename BasicJsonType::iterator>>
::value,
int> = 0>
4872 j = { {b.key(), b.value()} };
4875template<
typename BasicJsonType,
typename Tuple, std::size_t... Idx>
4878 j = { std::get<Idx>(t)... };
4881template<typename BasicJsonType, typename T, enable_if_t<is_constructible_tuple<BasicJsonType, T>::value,
int > = 0>
4882void to_json(BasicJsonType& j,
const T& t)
4887#if JSON_HAS_FILESYSTEM || JSON_HAS_EXPERIMENTAL_FILESYSTEM
4888template<
typename BasicJsonType>
4889void to_json(BasicJsonType& j,
const std_fs::path& p)
4897 template<
typename BasicJsonType,
typename T>
4898 auto operator()(BasicJsonType& j, T&& val)
const noexcept(
noexcept(
to_json(j, std::forward<T>(val))))
4899 ->
decltype(
to_json(j, std::forward<T>(val)), void())
4901 return to_json(j, std::forward<T>(val));
4924template<
typename ValueType,
typename>
4929 template<
typename BasicJsonType,
typename TargetType = ValueType>
4930 static auto from_json(BasicJsonType && j, TargetType& val)
noexcept(
4931 noexcept(::nlohmann::from_json(std::forward<BasicJsonType>(j), val)))
4932 ->
decltype(::nlohmann::from_json(std::forward<BasicJsonType>(j), val), void())
4934 ::nlohmann::from_json(std::forward<BasicJsonType>(j), val);
4939 template<
typename BasicJsonType,
typename TargetType = ValueType>
4944 return ::nlohmann::from_json(std::forward<BasicJsonType>(j), detail::identity_tag<TargetType> {});
4949 template<
typename BasicJsonType,
typename TargetType = ValueType>
4950 static auto to_json(BasicJsonType& j, TargetType && val)
noexcept(
4951 noexcept(::nlohmann::to_json(j, std::forward<TargetType>(val))))
4952 ->
decltype(::nlohmann::to_json(j, std::forward<TargetType>(val)), void())
4954 ::nlohmann::to_json(j, std::forward<TargetType>(val));
4971template<
typename BinaryType>
5015 return !(rhs == *
this);
5066#include <functional>
5079inline std::size_t
combine(std::size_t seed, std::size_t h)
noexcept
5081 seed ^= h + 0x9e3779b9 + (seed << 6U) + (seed >> 2U);
5096template<
typename BasicJsonType>
5097std::size_t
hash(
const BasicJsonType& j)
5099 using string_t =
typename BasicJsonType::string_t;
5100 using number_integer_t =
typename BasicJsonType::number_integer_t;
5101 using number_unsigned_t =
typename BasicJsonType::number_unsigned_t;
5102 using number_float_t =
typename BasicJsonType::number_float_t;
5104 const auto type =
static_cast<std::size_t
>(j.type());
5107 case BasicJsonType::value_t::null:
5108 case BasicJsonType::value_t::discarded:
5113 case BasicJsonType::value_t::object:
5115 auto seed =
combine(type, j.size());
5116 for (
const auto& element : j.items())
5118 const auto h = std::hash<string_t> {}(element.key());
5125 case BasicJsonType::value_t::array:
5127 auto seed =
combine(type, j.size());
5128 for (
const auto& element : j)
5135 case BasicJsonType::value_t::string:
5137 const auto h = std::hash<string_t> {}(j.template get_ref<const string_t&>());
5141 case BasicJsonType::value_t::boolean:
5143 const auto h = std::hash<bool> {}(j.template get<bool>());
5147 case BasicJsonType::value_t::number_integer:
5149 const auto h = std::hash<number_integer_t> {}(j.template get<number_integer_t>());
5153 case BasicJsonType::value_t::number_unsigned:
5155 const auto h = std::hash<number_unsigned_t> {}(j.template get<number_unsigned_t>());
5159 case BasicJsonType::value_t::number_float:
5161 const auto h = std::hash<number_float_t> {}(j.template get<number_float_t>());
5165 case BasicJsonType::value_t::binary:
5167 auto seed =
combine(type, j.get_binary().size());
5168 const auto h = std::hash<bool> {}(j.get_binary().has_subtype());
5170 seed =
combine(seed,
static_cast<std::size_t
>(j.get_binary().subtype()));
5171 for (
const auto byte : j.get_binary())
5173 seed =
combine(seed, std::hash<std::uint8_t> {}(byte));
5215#include <type_traits>
5263 return std::fgetc(
m_file);
5292 is->clear(
is->rdstate() & std::ios::eofbit);
5297 :
is(&i),
sb(i.rdbuf())
5306 :
is(rhs.is),
sb(rhs.sb)
5317 auto res =
sb->sbumpc();
5321 is->clear(
is->rdstate() | std::ios::eofbit);
5328 std::istream*
is =
nullptr;
5329 std::streambuf*
sb =
nullptr;
5335template<
typename IteratorType>
5339 using char_type =
typename std::iterator_traits<IteratorType>::value_type;
5349 auto result = std::char_traits<char_type>::to_int_type(*
current);
5354 return std::char_traits<char_type>::eof();
5361 template<
typename BaseInputAdapter,
size_t T>
5371template<
typename BaseInputAdapter,
size_t T>
5374template<
typename BaseInputAdapter>
5379 std::array<std::char_traits<char>::int_type, 4>& utf8_bytes,
5380 size_t& utf8_bytes_index,
5381 size_t& utf8_bytes_filled)
5383 utf8_bytes_index = 0;
5387 utf8_bytes[0] = std::char_traits<char>::eof();
5388 utf8_bytes_filled = 1;
5393 const auto wc = input.get_character();
5398 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(wc);
5399 utf8_bytes_filled = 1;
5401 else if (wc <= 0x7FF)
5403 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(0xC0u | ((
static_cast<unsigned int>(wc) >> 6u) & 0x1Fu));
5404 utf8_bytes[1] =
static_cast<std::char_traits<char>::int_type
>(0x80u | (
static_cast<unsigned int>(wc) & 0x3Fu));
5405 utf8_bytes_filled = 2;
5407 else if (wc <= 0xFFFF)
5409 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(0xE0u | ((
static_cast<unsigned int>(wc) >> 12u) & 0x0Fu));
5410 utf8_bytes[1] =
static_cast<std::char_traits<char>::int_type
>(0x80u | ((
static_cast<unsigned int>(wc) >> 6u) & 0x3Fu));
5411 utf8_bytes[2] =
static_cast<std::char_traits<char>::int_type
>(0x80u | (
static_cast<unsigned int>(wc) & 0x3Fu));
5412 utf8_bytes_filled = 3;
5414 else if (wc <= 0x10FFFF)
5416 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(0xF0u | ((
static_cast<unsigned int>(wc) >> 18u) & 0x07u));
5417 utf8_bytes[1] =
static_cast<std::char_traits<char>::int_type
>(0x80u | ((
static_cast<unsigned int>(wc) >> 12u) & 0x3Fu));
5418 utf8_bytes[2] =
static_cast<std::char_traits<char>::int_type
>(0x80u | ((
static_cast<unsigned int>(wc) >> 6u) & 0x3Fu));
5419 utf8_bytes[3] =
static_cast<std::char_traits<char>::int_type
>(0x80u | (
static_cast<unsigned int>(wc) & 0x3Fu));
5420 utf8_bytes_filled = 4;
5425 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(wc);
5426 utf8_bytes_filled = 1;
5432template<
typename BaseInputAdapter>
5437 std::array<std::char_traits<char>::int_type, 4>& utf8_bytes,
5438 size_t& utf8_bytes_index,
5439 size_t& utf8_bytes_filled)
5441 utf8_bytes_index = 0;
5445 utf8_bytes[0] = std::char_traits<char>::eof();
5446 utf8_bytes_filled = 1;
5451 const auto wc = input.get_character();
5456 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(wc);
5457 utf8_bytes_filled = 1;
5459 else if (wc <= 0x7FF)
5461 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(0xC0u | ((
static_cast<unsigned int>(wc) >> 6u)));
5462 utf8_bytes[1] =
static_cast<std::char_traits<char>::int_type
>(0x80u | (
static_cast<unsigned int>(wc) & 0x3Fu));
5463 utf8_bytes_filled = 2;
5465 else if (0xD800 > wc || wc >= 0xE000)
5467 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(0xE0u | ((
static_cast<unsigned int>(wc) >> 12u)));
5468 utf8_bytes[1] =
static_cast<std::char_traits<char>::int_type
>(0x80u | ((
static_cast<unsigned int>(wc) >> 6u) & 0x3Fu));
5469 utf8_bytes[2] =
static_cast<std::char_traits<char>::int_type
>(0x80u | (
static_cast<unsigned int>(wc) & 0x3Fu));
5470 utf8_bytes_filled = 3;
5476 const auto wc2 =
static_cast<unsigned int>(input.get_character());
5477 const auto charcode = 0x10000u + (((
static_cast<unsigned int>(wc) & 0x3FFu) << 10u) | (wc2 & 0x3FFu));
5478 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(0xF0u | (charcode >> 18u));
5479 utf8_bytes[1] =
static_cast<std::char_traits<char>::int_type
>(0x80u | ((charcode >> 12u) & 0x3Fu));
5480 utf8_bytes[2] =
static_cast<std::char_traits<char>::int_type
>(0x80u | ((charcode >> 6u) & 0x3Fu));
5481 utf8_bytes[3] =
static_cast<std::char_traits<char>::int_type
>(0x80u | (charcode & 0x3Fu));
5482 utf8_bytes_filled = 4;
5486 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(wc);
5487 utf8_bytes_filled = 1;
5495template<
typename BaseInputAdapter,
typename W
ideCharType>
5509 fill_buffer<sizeof(WideCharType)>();
5531 std::array<std::char_traits<char>::int_type, 4>
utf8_bytes = {{0, 0, 0, 0}};
5540template<
typename IteratorType,
typename Enable =
void>
5544 using char_type =
typename std::iterator_traits<iterator_type>::value_type;
5549 return adapter_type(std::move(first), std::move(last));
5563template<
typename IteratorType>
5567 using char_type =
typename std::iterator_traits<iterator_type>::value_type;
5578template<
typename IteratorType>
5582 return factory_type::create(first, last);
5589namespace container_input_adapter_factory_impl
5595template<
typename ContainerType,
typename Enable =
void>
5598template<
typename ContainerType>
5600 void_t<decltype(begin(
std::declval<ContainerType>()), end(std::declval<ContainerType>()))>>
5612template<
typename ContainerType>
5639template <
typename CharT,
5640 typename std::enable_if <
5641 std::is_pointer<CharT>::value&&
5642 !std::is_array<CharT>::value&&
5643 std::is_integral<typename std::remove_pointer<CharT>::type>
::value&&
5644 sizeof(
typename std::remove_pointer<CharT>::type) == 1,
5648 auto length = std::strlen(
reinterpret_cast<const char*
>(b));
5649 const auto* ptr =
reinterpret_cast<const char*
>(b);
5653template<
typename T, std::
size_t N>
5665 template <
typename CharT,
5666 typename std::enable_if <
5667 std::is_pointer<CharT>::value&&
5668 std::is_integral<typename std::remove_pointer<CharT>::type>
::value&&
5669 sizeof(
typename std::remove_pointer<CharT>::type) == 1,
5672 : ia(
reinterpret_cast<const char*
>(b),
reinterpret_cast<const char*
>(b) + l) {}
5674 template<
class IteratorType,
5675 typename std::enable_if<
5676 std::is_same<typename iterator_traits<IteratorType>::iterator_category, std::random_access_iterator_tag>
::value,
5683 return std::move(ia);
5716template<
typename BasicJsonType>
5820 const std::string& last_token,
5847template<
typename BasicJsonType>
5863 : root(r), allow_exceptions(allow_exceptions_)
5875 handle_value(
nullptr);
5911 handle_value(std::move(val));
5917 ref_stack.push_back(handle_value(BasicJsonType::value_t::object));
5919 if (
JSON_HEDLEY_UNLIKELY(len !=
static_cast<std::size_t
>(-1) && len > ref_stack.back()->max_size()))
5921 JSON_THROW(out_of_range::create(408,
"excessive object size: " + std::to_string(len), *ref_stack.back()));
5930 object_element = &(ref_stack.back()->m_value.object->operator[](val));
5936 ref_stack.back()->set_parents();
5937 ref_stack.pop_back();
5943 ref_stack.push_back(handle_value(BasicJsonType::value_t::array));
5945 if (
JSON_HEDLEY_UNLIKELY(len !=
static_cast<std::size_t
>(-1) && len > ref_stack.back()->max_size()))
5947 JSON_THROW(out_of_range::create(408,
"excessive array size: " + std::to_string(len), *ref_stack.back()));
5955 ref_stack.back()->set_parents();
5956 ref_stack.pop_back();
5960 template<
class Exception>
5962 const Exception& ex)
5965 static_cast<void>(ex);
5966 if (allow_exceptions)
5985 template<
typename Value>
5989 if (ref_stack.empty())
5991 root = BasicJsonType(std::forward<Value>(v));
5995 JSON_ASSERT(ref_stack.back()->is_array() || ref_stack.back()->is_object());
5997 if (ref_stack.back()->is_array())
5999 ref_stack.back()->m_value.array->emplace_back(std::forward<Value>(v));
6000 return &(ref_stack.back()->m_value.array->back());
6005 *object_element = BasicJsonType(std::forward<Value>(v));
6006 return object_element;
6012 std::vector<BasicJsonType*> ref_stack {};
6014 BasicJsonType* object_element =
nullptr;
6016 bool errored =
false;
6018 const bool allow_exceptions =
true;
6021template<
typename BasicJsonType>
6035 const bool allow_exceptions_ =
true)
6036 : root(r), callback(cb), allow_exceptions(allow_exceptions_)
6038 keep_stack.push_back(
true);
6050 handle_value(
nullptr);
6086 handle_value(std::move(val));
6093 const bool keep = callback(
static_cast<int>(ref_stack.size()), parse_event_t::object_start,
discarded);
6094 keep_stack.push_back(keep);
6096 auto val = handle_value(BasicJsonType::value_t::object,
true);
6097 ref_stack.push_back(val.second);
6100 if (ref_stack.back() &&
JSON_HEDLEY_UNLIKELY(len !=
static_cast<std::size_t
>(-1) && len > ref_stack.back()->max_size()))
6102 JSON_THROW(out_of_range::create(408,
"excessive object size: " + std::to_string(len), *ref_stack.back()));
6110 BasicJsonType k = BasicJsonType(val);
6113 const bool keep = callback(
static_cast<int>(ref_stack.size()), parse_event_t::key, k);
6114 key_keep_stack.push_back(keep);
6117 if (keep && ref_stack.back())
6119 object_element = &(ref_stack.back()->m_value.object->operator[](val) =
discarded);
6127 if (ref_stack.back())
6129 if (!callback(
static_cast<int>(ref_stack.size()) - 1, parse_event_t::object_end, *ref_stack.back()))
6136 ref_stack.back()->set_parents();
6142 ref_stack.pop_back();
6143 keep_stack.pop_back();
6145 if (!ref_stack.empty() && ref_stack.back() && ref_stack.back()->is_structured())
6148 for (
auto it = ref_stack.back()->begin(); it != ref_stack.back()->end(); ++it)
6150 if (it->is_discarded())
6152 ref_stack.back()->erase(it);
6163 const bool keep = callback(
static_cast<int>(ref_stack.size()), parse_event_t::array_start,
discarded);
6164 keep_stack.push_back(keep);
6166 auto val = handle_value(BasicJsonType::value_t::array,
true);
6167 ref_stack.push_back(val.second);
6170 if (ref_stack.back() &&
JSON_HEDLEY_UNLIKELY(len !=
static_cast<std::size_t
>(-1) && len > ref_stack.back()->max_size()))
6172 JSON_THROW(out_of_range::create(408,
"excessive array size: " + std::to_string(len), *ref_stack.back()));
6182 if (ref_stack.back())
6184 keep = callback(
static_cast<int>(ref_stack.size()) - 1, parse_event_t::array_end, *ref_stack.back());
6187 ref_stack.back()->set_parents();
6198 ref_stack.pop_back();
6199 keep_stack.pop_back();
6202 if (!keep && !ref_stack.empty() && ref_stack.back()->is_array())
6204 ref_stack.back()->m_value.array->pop_back();
6210 template<
class Exception>
6212 const Exception& ex)
6215 static_cast<void>(ex);
6216 if (allow_exceptions)
6244 template<
typename Value>
6245 std::pair<bool, BasicJsonType*>
handle_value(Value&& v,
const bool skip_callback =
false)
6251 if (!keep_stack.back())
6253 return {
false,
nullptr};
6257 auto value = BasicJsonType(std::forward<Value>(v));
6260 const bool keep = skip_callback || callback(
static_cast<int>(ref_stack.size()), parse_event_t::value,
value);
6265 return {
false,
nullptr};
6268 if (ref_stack.empty())
6270 root = std::move(
value);
6271 return {
true, &root};
6276 if (!ref_stack.back())
6278 return {
false,
nullptr};
6282 JSON_ASSERT(ref_stack.back()->is_array() || ref_stack.back()->is_object());
6285 if (ref_stack.back()->is_array())
6287 ref_stack.back()->m_value.array->emplace_back(std::move(
value));
6288 return {
true, &(ref_stack.back()->m_value.array->back())};
6295 const bool store_element = key_keep_stack.back();
6296 key_keep_stack.pop_back();
6300 return {
false,
nullptr};
6304 *object_element = std::move(
value);
6305 return {
true, object_element};
6311 std::vector<BasicJsonType*> ref_stack {};
6313 std::vector<bool> keep_stack {};
6315 std::vector<bool> key_keep_stack {};
6317 BasicJsonType* object_element =
nullptr;
6319 bool errored =
false;
6323 const bool allow_exceptions =
true;
6325 BasicJsonType
discarded = BasicJsonType::value_t::discarded;
6328template<
typename BasicJsonType>
6415#include <initializer_list>
6435template<
typename BasicJsonType>
6469 return "<uninitialized>";
6471 return "true literal";
6473 return "false literal";
6475 return "null literal";
6477 return "string literal";
6481 return "number literal";
6495 return "<parse error>";
6497 return "end of input";
6499 return "'[', '{', or a literal";
6502 return "unknown token";
6512template<
typename BasicJsonType,
typename InputAdapterType>
6525 explicit lexer(InputAdapterType&& adapter,
bool ignore_comments_ =
false) noexcept
6526 :
ia(
std::move(adapter))
6547 const auto* loc = localeconv();
6549 return (loc->decimal_point ==
nullptr) ?
'.' : *(loc->decimal_point);
6577 const auto factors = { 12u, 8u, 4u, 0u };
6578 for (
const auto factor : factors)
6584 codepoint +=
static_cast<int>((
static_cast<unsigned int>(
current) - 0x30u) << factor);
6588 codepoint +=
static_cast<int>((
static_cast<unsigned int>(
current) - 0x37u) << factor);
6592 codepoint +=
static_cast<int>((
static_cast<unsigned int>(
current) - 0x57u) << factor);
6600 JSON_ASSERT(0x0000 <= codepoint && codepoint <= 0xFFFF);
6621 JSON_ASSERT(ranges.size() == 2 || ranges.size() == 4 || ranges.size() == 6);
6624 for (
auto range = ranges.begin(); range != ranges.end(); ++range)
6670 case std::char_traits<char_type>::eof():
6673 return token_type::parse_error;
6679 return token_type::value_string;
6724 int codepoint = codepoint1;
6728 error_message =
"invalid string: '\\u' must be followed by 4 hex digits";
6729 return token_type::parse_error;
6733 if (0xD800 <= codepoint1 && codepoint1 <= 0xDBFF)
6742 error_message =
"invalid string: '\\u' must be followed by 4 hex digits";
6743 return token_type::parse_error;
6750 codepoint =
static_cast<int>(
6752 (
static_cast<unsigned int>(codepoint1) << 10u)
6754 +
static_cast<unsigned int>(codepoint2)
6762 error_message =
"invalid string: surrogate U+D800..U+DBFF must be followed by U+DC00..U+DFFF";
6763 return token_type::parse_error;
6768 error_message =
"invalid string: surrogate U+D800..U+DBFF must be followed by U+DC00..U+DFFF";
6769 return token_type::parse_error;
6776 error_message =
"invalid string: surrogate U+DC00..U+DFFF must follow U+D800..U+DBFF";
6777 return token_type::parse_error;
6782 JSON_ASSERT(0x00 <= codepoint && codepoint <= 0x10FFFF);
6785 if (codepoint < 0x80)
6790 else if (codepoint <= 0x7FF)
6793 add(
static_cast<char_int_type>(0xC0u | (
static_cast<unsigned int>(codepoint) >> 6u)));
6794 add(
static_cast<char_int_type>(0x80u | (
static_cast<unsigned int>(codepoint) & 0x3Fu)));
6796 else if (codepoint <= 0xFFFF)
6799 add(
static_cast<char_int_type>(0xE0u | (
static_cast<unsigned int>(codepoint) >> 12u)));
6800 add(
static_cast<char_int_type>(0x80u | ((
static_cast<unsigned int>(codepoint) >> 6u) & 0x3Fu)));
6801 add(
static_cast<char_int_type>(0x80u | (
static_cast<unsigned int>(codepoint) & 0x3Fu)));
6806 add(
static_cast<char_int_type>(0xF0u | (
static_cast<unsigned int>(codepoint) >> 18u)));
6807 add(
static_cast<char_int_type>(0x80u | ((
static_cast<unsigned int>(codepoint) >> 12u) & 0x3Fu)));
6808 add(
static_cast<char_int_type>(0x80u | ((
static_cast<unsigned int>(codepoint) >> 6u) & 0x3Fu)));
6809 add(
static_cast<char_int_type>(0x80u | (
static_cast<unsigned int>(codepoint) & 0x3Fu)));
6817 error_message =
"invalid string: forbidden character after backslash";
6818 return token_type::parse_error;
6827 error_message =
"invalid string: control character U+0000 (NUL) must be escaped to \\u0000";
6828 return token_type::parse_error;
6833 error_message =
"invalid string: control character U+0001 (SOH) must be escaped to \\u0001";
6834 return token_type::parse_error;
6839 error_message =
"invalid string: control character U+0002 (STX) must be escaped to \\u0002";
6840 return token_type::parse_error;
6845 error_message =
"invalid string: control character U+0003 (ETX) must be escaped to \\u0003";
6846 return token_type::parse_error;
6851 error_message =
"invalid string: control character U+0004 (EOT) must be escaped to \\u0004";
6852 return token_type::parse_error;
6857 error_message =
"invalid string: control character U+0005 (ENQ) must be escaped to \\u0005";
6858 return token_type::parse_error;
6863 error_message =
"invalid string: control character U+0006 (ACK) must be escaped to \\u0006";
6864 return token_type::parse_error;
6869 error_message =
"invalid string: control character U+0007 (BEL) must be escaped to \\u0007";
6870 return token_type::parse_error;
6875 error_message =
"invalid string: control character U+0008 (BS) must be escaped to \\u0008 or \\b";
6876 return token_type::parse_error;
6881 error_message =
"invalid string: control character U+0009 (HT) must be escaped to \\u0009 or \\t";
6882 return token_type::parse_error;
6887 error_message =
"invalid string: control character U+000A (LF) must be escaped to \\u000A or \\n";
6888 return token_type::parse_error;
6893 error_message =
"invalid string: control character U+000B (VT) must be escaped to \\u000B";
6894 return token_type::parse_error;
6899 error_message =
"invalid string: control character U+000C (FF) must be escaped to \\u000C or \\f";
6900 return token_type::parse_error;
6905 error_message =
"invalid string: control character U+000D (CR) must be escaped to \\u000D or \\r";
6906 return token_type::parse_error;
6911 error_message =
"invalid string: control character U+000E (SO) must be escaped to \\u000E";
6912 return token_type::parse_error;
6917 error_message =
"invalid string: control character U+000F (SI) must be escaped to \\u000F";
6918 return token_type::parse_error;
6923 error_message =
"invalid string: control character U+0010 (DLE) must be escaped to \\u0010";
6924 return token_type::parse_error;
6929 error_message =
"invalid string: control character U+0011 (DC1) must be escaped to \\u0011";
6930 return token_type::parse_error;
6935 error_message =
"invalid string: control character U+0012 (DC2) must be escaped to \\u0012";
6936 return token_type::parse_error;
6941 error_message =
"invalid string: control character U+0013 (DC3) must be escaped to \\u0013";
6942 return token_type::parse_error;
6947 error_message =
"invalid string: control character U+0014 (DC4) must be escaped to \\u0014";
6948 return token_type::parse_error;
6953 error_message =
"invalid string: control character U+0015 (NAK) must be escaped to \\u0015";
6954 return token_type::parse_error;
6959 error_message =
"invalid string: control character U+0016 (SYN) must be escaped to \\u0016";
6960 return token_type::parse_error;
6965 error_message =
"invalid string: control character U+0017 (ETB) must be escaped to \\u0017";
6966 return token_type::parse_error;
6971 error_message =
"invalid string: control character U+0018 (CAN) must be escaped to \\u0018";
6972 return token_type::parse_error;
6977 error_message =
"invalid string: control character U+0019 (EM) must be escaped to \\u0019";
6978 return token_type::parse_error;
6983 error_message =
"invalid string: control character U+001A (SUB) must be escaped to \\u001A";
6984 return token_type::parse_error;
6989 error_message =
"invalid string: control character U+001B (ESC) must be escaped to \\u001B";
6990 return token_type::parse_error;
6995 error_message =
"invalid string: control character U+001C (FS) must be escaped to \\u001C";
6996 return token_type::parse_error;
7001 error_message =
"invalid string: control character U+001D (GS) must be escaped to \\u001D";
7002 return token_type::parse_error;
7007 error_message =
"invalid string: control character U+001E (RS) must be escaped to \\u001E";
7008 return token_type::parse_error;
7013 error_message =
"invalid string: control character U+001F (US) must be escaped to \\u001F";
7014 return token_type::parse_error;
7151 return token_type::parse_error;
7161 return token_type::parse_error;
7185 return token_type::parse_error;
7195 return token_type::parse_error;
7205 return token_type::parse_error;
7217 return token_type::parse_error;
7227 return token_type::parse_error;
7236 return token_type::parse_error;
7259 case std::char_traits<char_type>::eof():
7276 case std::char_traits<char_type>::eof():
7307 error_message =
"invalid comment; expecting '/' or '*' after '/'";
7314 static
void strtof(
float& f, const
char* str,
char** endptr) noexcept
7316 f = std::strtof(str, endptr);
7320 static
void strtof(
double& f, const
char* str,
char** endptr) noexcept
7322 f = std::strtod(str, endptr);
7326 static
void strtof(
long double& f, const
char* str,
char** endptr) noexcept
7328 f = std::strtold(str, endptr);
7378 token_type number_type = token_type::value_unsigned;
7386 goto scan_number_minus;
7392 goto scan_number_zero;
7406 goto scan_number_any1;
7416 number_type = token_type::value_integer;
7422 goto scan_number_zero;
7436 goto scan_number_any1;
7442 return token_type::parse_error;
7453 goto scan_number_decimal1;
7460 goto scan_number_exponent;
7464 goto scan_number_done;
7483 goto scan_number_any1;
7489 goto scan_number_decimal1;
7496 goto scan_number_exponent;
7500 goto scan_number_done;
7503scan_number_decimal1:
7505 number_type = token_type::value_float;
7520 goto scan_number_decimal2;
7526 return token_type::parse_error;
7530scan_number_decimal2:
7546 goto scan_number_decimal2;
7553 goto scan_number_exponent;
7557 goto scan_number_done;
7560scan_number_exponent:
7562 number_type = token_type::value_float;
7569 goto scan_number_sign;
7584 goto scan_number_any2;
7590 "invalid number; expected '+', '-', or digit after exponent";
7591 return token_type::parse_error;
7611 goto scan_number_any2;
7616 error_message =
"invalid number; expected digit after exponent sign";
7617 return token_type::parse_error;
7637 goto scan_number_any2;
7641 goto scan_number_done;
7649 char* endptr =
nullptr;
7653 if (number_type == token_type::value_unsigned)
7655 const auto x = std::strtoull(
token_buffer.data(), &endptr, 10);
7665 return token_type::value_unsigned;
7669 else if (number_type == token_type::value_integer)
7671 const auto x = std::strtoll(
token_buffer.data(), &endptr, 10);
7681 return token_type::value_integer;
7693 return token_type::value_float;
7706 for (std::size_t i = 1; i < length; ++i)
7711 return token_type::parse_error;
7805 token_buffer.push_back(
static_cast<typename string_t::value_type
>(c));
7856 if (
static_cast<unsigned char>(c) <=
'\x1F')
7859 std::array<char, 9> cs{{}};
7860 static_cast<void>((std::snprintf)(cs.data(), cs.size(),
"<U+%.4X>",
static_cast<unsigned char>(c)));
7861 result += cs.data();
7866 result.push_back(
static_cast<std::string::value_type
>(c));
7893 return get() == 0xBB &&
get() == 0xBF;
7916 error_message =
"invalid BOM; must be 0xEF 0xBB 0xBF if given";
7917 return token_type::parse_error;
7928 return token_type::parse_error;
7939 return token_type::begin_array;
7941 return token_type::end_array;
7943 return token_type::begin_object;
7945 return token_type::end_object;
7947 return token_type::name_separator;
7949 return token_type::value_separator;
7955 return scan_literal(true_literal.data(), true_literal.size(), token_type::literal_true);
7960 return scan_literal(false_literal.data(), false_literal.size(), token_type::literal_false);
7965 return scan_literal(null_literal.data(), null_literal.size(), token_type::literal_null);
7989 case std::char_traits<char_type>::eof():
7990 return token_type::end_of_input;
7995 return token_type::parse_error;
8058 decltype(std::declval<T&>().boolean(std::declval<bool>()));
8060template<
typename T,
typename Integer>
8062 decltype(std::declval<T&>().number_integer(std::declval<Integer>()));
8064template<
typename T,
typename Un
signed>
8066 decltype(std::declval<T&>().number_unsigned(std::declval<Unsigned>()));
8068template<
typename T,
typename Float,
typename String>
8070 std::declval<Float>(), std::declval<const String&>()));
8072template<
typename T,
typename String>
8074 decltype(std::declval<T&>().string(std::declval<String&>()));
8076template<
typename T,
typename Binary>
8078 decltype(std::declval<T&>().binary(std::declval<Binary&>()));
8082 decltype(std::declval<T&>().start_object(std::declval<std::size_t>()));
8084template<
typename T,
typename String>
8086 decltype(std::declval<T&>().key(std::declval<String&>()));
8093 decltype(std::declval<T&>().start_array(std::declval<std::size_t>()));
8098template<
typename T,
typename Exception>
8100 std::declval<std::size_t>(), std::declval<const std::string&>(),
8101 std::declval<const Exception&>()));
8103template<
typename SAX,
typename BasicJsonType>
8108 "BasicJsonType must be of type basic_json<...>");
8134template<
typename SAX,
typename BasicJsonType>
8139 "BasicJsonType must be of type basic_json<...>");
8150 "Missing/invalid function: bool null()");
8152 "Missing/invalid function: bool boolean(bool)");
8154 "Missing/invalid function: bool boolean(bool)");
8158 "Missing/invalid function: bool number_integer(number_integer_t)");
8162 "Missing/invalid function: bool number_unsigned(number_unsigned_t)");
8165 "Missing/invalid function: bool number_float(number_float_t, const string_t&)");
8168 "Missing/invalid function: bool string(string_t&)");
8171 "Missing/invalid function: bool binary(binary_t&)");
8173 "Missing/invalid function: bool start_object(std::size_t)");
8175 "Missing/invalid function: bool key(string_t&)");
8177 "Missing/invalid function: bool end_object()");
8179 "Missing/invalid function: bool start_array(std::size_t)");
8181 "Missing/invalid function: bool end_array()");
8184 "Missing/invalid function: bool parse_error(std::size_t, const "
8185 "std::string&, const exception&)");
8217 return *
reinterpret_cast<char*
>(&num) == 1;
8228template<
typename BasicJsonType,
typename InputAdapterType,
typename SAX = json_sax_dom_parser<BasicJsonType>>
8269 const
bool strict = true,
8273 bool result =
false;
8331 std::int32_t document_size{};
8344 return sax->end_object();
8356 auto out = std::back_inserter(result);
8368 *out++ =
static_cast<typename string_t::value_type
>(
current);
8383 template<
typename NumberType>
8404 template<
typename NumberType>
8414 std::uint8_t subtype{};
8416 result.set_subtype(subtype);
8432 const std::size_t element_type_parse_position)
8434 switch (element_type)
8468 return sax->boolean(
get() != 0);
8478 std::int32_t
value{};
8484 std::int64_t
value{};
8490 std::array<char, 3> cr{{}};
8491 static_cast<void>((std::snprintf)(cr.data(), cr.size(),
"%.2hhX",
static_cast<unsigned char>(element_type)));
8492 return sax->parse_error(element_type_parse_position, std::string(cr.data()),
parse_error::create(114, element_type_parse_position,
"Unsupported BSON record type 0x" + std::string(cr.data()), BasicJsonType()));
8513 while (
auto element_type =
get())
8520 const std::size_t element_type_parse_position =
chars_read;
8526 if (!is_array && !
sax->key(
key))
8549 std::int32_t document_size{};
8562 return sax->end_array();
8583 case std::char_traits<char_type>::eof():
8615 std::uint8_t number{};
8621 std::uint16_t number{};
8627 std::uint32_t number{};
8633 std::uint64_t number{};
8662 return sax->number_integer(
static_cast<std::int8_t
>(0x20 - 1 -
current));
8666 std::uint8_t number{};
8672 std::uint16_t number{};
8678 std::uint32_t number{};
8684 std::uint64_t number{};
8784 return get_cbor_array(
static_cast<std::size_t
>(
static_cast<unsigned int>(
current) & 0x1Fu), tag_handler);
8794 std::uint16_t len{};
8800 std::uint32_t len{};
8806 std::uint64_t len{};
8811 return get_cbor_array(
static_cast<std::size_t
>(-1), tag_handler);
8838 return get_cbor_object(
static_cast<std::size_t
>(
static_cast<unsigned int>(
current) & 0x1Fu), tag_handler);
8848 std::uint16_t len{};
8854 std::uint32_t len{};
8860 std::uint64_t len{};
8887 switch (tag_handler)
8902 std::uint8_t subtype_to_ignore{};
8908 std::uint16_t subtype_to_ignore{};
8914 std::uint32_t subtype_to_ignore{};
8920 std::uint64_t subtype_to_ignore{};
8938 std::uint8_t subtype{};
8940 b.set_subtype(detail::conditional_static_cast<typename binary_t::subtype_type>(subtype));
8945 std::uint16_t subtype{};
8947 b.set_subtype(detail::conditional_static_cast<typename binary_t::subtype_type>(subtype));
8952 std::uint32_t subtype{};
8954 b.set_subtype(detail::conditional_static_cast<typename binary_t::subtype_type>(subtype));
8959 std::uint64_t subtype{};
8961 b.set_subtype(detail::conditional_static_cast<typename binary_t::subtype_type>(subtype));
8978 return sax->boolean(
false);
8981 return sax->boolean(
true);
8988 const auto byte1_raw =
get();
8993 const auto byte2_raw =
get();
8999 const auto byte1 =
static_cast<unsigned char>(byte1_raw);
9000 const auto byte2 =
static_cast<unsigned char>(byte2_raw);
9010 const auto half =
static_cast<unsigned int>((byte1 << 8u) + byte2);
9011 const double val = [&half]
9013 const int exp = (half >> 10u) & 0x1Fu;
9014 const unsigned int mant = half & 0x3FFu;
9020 return std::ldexp(mant, -24);
9023 ? std::numeric_limits<double>::infinity()
9024 : std::numeric_limits<double>::quiet_NaN();
9026 return std::ldexp(mant + 1024, exp - 25);
9029 return sax->number_float((half & 0x8000u) != 0
9111 std::uint16_t len{};
9117 std::uint32_t len{};
9123 std::uint64_t len{};
9129 while (
get() != 0xFF)
9136 result.append(chunk);
9207 std::uint16_t len{};
9214 std::uint32_t len{};
9221 std::uint64_t len{};
9228 while (
get() != 0xFF)
9235 result.insert(result.end(), chunk.begin(), chunk.end());
9262 if (len !=
static_cast<std::size_t
>(-1))
9264 for (std::size_t i = 0; i < len; ++i)
9274 while (
get() != 0xFF)
9283 return sax->end_array();
9303 if (len !=
static_cast<std::size_t
>(-1))
9305 for (std::size_t i = 0; i < len; ++i)
9322 while (
get() != 0xFF)
9338 return sax->end_object();
9353 case std::char_traits<char_type>::eof():
9570 return sax->boolean(
false);
9573 return sax->boolean(
true);
9605 std::uint8_t number{};
9611 std::uint16_t number{};
9617 std::uint32_t number{};
9623 std::uint64_t number{};
9629 std::int8_t number{};
9635 std::int16_t number{};
9641 std::int32_t number{};
9647 std::int64_t number{};
9653 std::uint16_t len{};
9659 std::uint32_t len{};
9665 std::uint16_t len{};
9671 std::uint32_t len{};
9708 return sax->number_integer(
static_cast<std::int8_t
>(
current));
9782 std::uint16_t len{};
9788 std::uint32_t len{};
9813 auto assign_and_return_true = [&result](std::int8_t subtype)
9815 result.set_subtype(
static_cast<std::uint8_t
>(subtype));
9830 std::uint16_t len{};
9837 std::uint32_t len{};
9845 std::int8_t subtype{};
9849 assign_and_return_true(subtype);
9854 std::uint16_t len{};
9855 std::int8_t subtype{};
9859 assign_and_return_true(subtype);
9864 std::uint32_t len{};
9865 std::int8_t subtype{};
9869 assign_and_return_true(subtype);
9874 std::int8_t subtype{};
9877 assign_and_return_true(subtype);
9882 std::int8_t subtype{};
9885 assign_and_return_true(subtype);
9890 std::int8_t subtype{};
9893 assign_and_return_true(subtype);
9898 std::int8_t subtype{};
9901 assign_and_return_true(subtype);
9906 std::int8_t subtype{};
9909 assign_and_return_true(subtype);
9928 for (std::size_t i = 0; i < len; ++i)
9936 return sax->end_array();
9951 for (std::size_t i = 0; i < len; ++i)
9966 return sax->end_object();
10015 std::uint8_t len{};
10027 std::int16_t len{};
10033 std::int32_t len{};
10039 std::int64_t len{};
10045 return sax->parse_error(
chars_read, last_token,
parse_error::create(113,
chars_read,
exception_message(
input_format_t::ubjson,
"expected length type specification (U, i, I, l, L); last byte: 0x" + last_token,
"string"), BasicJsonType()));
10059 std::uint8_t number{};
10064 result =
static_cast<std::size_t
>(number);
10070 std::int8_t number{};
10075 result =
static_cast<std::size_t
>(number);
10081 std::int16_t number{};
10086 result =
static_cast<std::size_t
>(number);
10092 std::int32_t number{};
10097 result =
static_cast<std::size_t
>(number);
10103 std::int64_t number{};
10108 result =
static_cast<std::size_t
>(number);
10115 return sax->parse_error(
chars_read, last_token,
parse_error::create(113,
chars_read,
exception_message(
input_format_t::ubjson,
"expected length type specification (U, i, I, l, L) after '#'; last byte: 0x" + last_token,
"size"), BasicJsonType()));
10132 result.first = string_t::npos;
10139 result.second =
get();
10175 case std::char_traits<char_type>::eof():
10179 return sax->boolean(
true);
10181 return sax->boolean(
false);
10184 return sax->null();
10188 std::uint8_t number{};
10194 std::int8_t number{};
10200 std::int16_t number{};
10206 std::int32_t number{};
10212 std::int64_t number{};
10246 return sax->string(s);
10274 std::pair<std::size_t, char_int_type> size_and_type;
10280 if (size_and_type.first != string_t::npos)
10287 if (size_and_type.second != 0)
10289 if (size_and_type.second !=
'N')
10291 for (std::size_t i = 0; i < size_and_type.first; ++i)
10302 for (std::size_t i = 0; i < size_and_type.first; ++i)
10328 return sax->end_array();
10336 std::pair<std::size_t, char_int_type> size_and_type;
10343 if (size_and_type.first != string_t::npos)
10350 if (size_and_type.second != 0)
10352 for (std::size_t i = 0; i < size_and_type.first; ++i)
10367 for (std::size_t i = 0; i < size_and_type.first; ++i)
10403 return sax->end_object();
10412 std::size_t size{};
10420 std::vector<char> number_vector;
10421 for (std::size_t i = 0; i < size; ++i)
10428 number_vector.push_back(
static_cast<char>(
current));
10434 const auto result_number = number_lexer.scan();
10435 const auto number_string = number_lexer.get_token_string();
10436 const auto result_remainder = number_lexer.scan();
10445 switch (result_number)
10447 case token_type::value_integer:
10448 return sax->number_integer(number_lexer.get_number_integer());
10449 case token_type::value_unsigned:
10450 return sax->number_unsigned(number_lexer.get_number_unsigned());
10451 case token_type::value_float:
10452 return sax->number_float(number_lexer.get_number_float(), std::move(number_string));
10453 case token_type::uninitialized:
10454 case token_type::literal_true:
10455 case token_type::literal_false:
10456 case token_type::literal_null:
10457 case token_type::value_string:
10458 case token_type::begin_array:
10459 case token_type::begin_object:
10460 case token_type::end_array:
10461 case token_type::end_object:
10462 case token_type::name_separator:
10463 case token_type::value_separator:
10464 case token_type::parse_error:
10465 case token_type::end_of_input:
10466 case token_type::literal_or_value:
10518 template<
typename NumberType,
bool InputIsLittleEndian = false>
10522 std::array<std::uint8_t,
sizeof(NumberType)> vec{};
10523 for (std::size_t i = 0; i <
sizeof(NumberType); ++i)
10534 vec[
sizeof(NumberType) - i - 1] =
static_cast<std::uint8_t
>(
current);
10538 vec[i] =
static_cast<std::uint8_t
>(
current);
10543 std::memcpy(&result, vec.data(),
sizeof(NumberType));
10561 template<
typename NumberType>
10563 const NumberType len,
10566 bool success =
true;
10567 for (NumberType i = 0; i < len; i++)
10575 result.push_back(
static_cast<typename string_t::value_type
>(
current));
10594 template<
typename NumberType>
10596 const NumberType len,
10599 bool success =
true;
10600 for (NumberType i = 0; i < len; i++)
10608 result.push_back(
static_cast<std::uint8_t
>(
current));
10634 std::array<char, 3> cr{{}};
10635 static_cast<void>((std::snprintf)(cr.data(), cr.size(),
"%.2hhX",
static_cast<unsigned char>(
current)));
10636 return std::string{cr.data()};
10646 const std::string& detail,
10647 const std::string& context)
const
10649 std::string error_msg =
"syntax error while parsing ";
10654 error_msg +=
"CBOR";
10658 error_msg +=
"MessagePack";
10662 error_msg +=
"UBJSON";
10666 error_msg +=
"BSON";
10674 return error_msg +
" " + context +
": " + detail;
10705#include <functional>
10749template<
typename BasicJsonType>
10751 std::function<bool(
int ,
parse_event_t , BasicJsonType& )>;
10758template<
typename BasicJsonType,
typename InputAdapterType>
10772 const bool allow_exceptions_ =
true,
10773 const bool skip_comments =
false)
10775 ,
m_lexer(
std::move(adapter), skip_comments)
10817 if (result.is_discarded())
10843 result.assert_invariant();
10858 template<
typename SAX>
10877 template<
typename SAX>
10883 std::vector<bool> states;
10885 bool skip_to_state_evaluation =
false;
10889 if (!skip_to_state_evaluation)
10894 case token_type::begin_object:
10902 if (
get_token() == token_type::end_object)
10932 states.push_back(
false);
10939 case token_type::begin_array:
10947 if (
get_token() == token_type::end_array)
10957 states.push_back(
true);
10963 case token_type::value_float:
10982 case token_type::literal_false:
10991 case token_type::literal_null:
11000 case token_type::literal_true:
11009 case token_type::value_integer:
11018 case token_type::value_string:
11027 case token_type::value_unsigned:
11036 case token_type::parse_error:
11044 case token_type::uninitialized:
11045 case token_type::end_array:
11046 case token_type::end_object:
11047 case token_type::name_separator:
11048 case token_type::value_separator:
11049 case token_type::end_of_input:
11050 case token_type::literal_or_value:
11061 skip_to_state_evaluation =
false;
11065 if (states.empty())
11074 if (
get_token() == token_type::value_separator)
11095 skip_to_state_evaluation =
true;
11107 if (
get_token() == token_type::value_separator)
11149 skip_to_state_evaluation =
true;
11167 std::string error_msg =
"syntax error ";
11169 if (!context.empty())
11171 error_msg +=
"while parsing " + context +
" ";
11186 if (expected != token_type::uninitialized)
11276 return lhs.m_it == rhs.m_it;
11281 return lhs.m_it < rhs.m_it;
11286 auto result = *
this;
11293 return lhs.m_it - rhs.m_it;
11304 auto result = *
this;
11317 auto result = *
this;
11364#include <type_traits>
11386template<
typename IteratorType>
class iteration_proxy;
11387template<
typename IteratorType>
class iteration_proxy_value;
11405template<
typename BasicJsonType>
11420 "iter_impl only accepts (const) basic_json");
11436 using pointer =
typename std::conditional<std::is_const<BasicJsonType>::value,
11437 typename BasicJsonType::const_pointer,
11438 typename BasicJsonType::pointer>::type;
11441 typename std::conditional<std::is_const<BasicJsonType>::value,
11442 typename BasicJsonType::const_reference,
11443 typename BasicJsonType::reference>::type;
11460 switch (m_object->m_type)
11507 : m_object(other.m_object),
m_it(other.m_it)
11518 if (&other !=
this)
11520 m_object = other.m_object;
11532 : m_object(other.m_object),
m_it(other.m_it)
11543 m_object = other.m_object;
11553 void set_begin() noexcept
11557 switch (m_object->m_type)
11601 switch (m_object->m_type)
11640 switch (m_object->m_type)
11684 switch (m_object->m_type)
11724 auto result = *
this;
11737 switch (m_object->m_type)
11775 auto result = *
this;
11788 switch (m_object->m_type)
11824 template <
typename IterImpl, detail::enable_if_t < (std::is_same<IterImpl, iter_impl>::value || std::is_same<IterImpl, other_iter_impl>::value), std::
nullptr_t > =
nullptr >
11835 switch (m_object->m_type)
11860 template <
typename IterImpl, detail::enable_if_t < (std::is_same<IterImpl, iter_impl>::value || std::is_same<IterImpl, other_iter_impl>::value), std::
nullptr_t > =
nullptr >
11880 switch (m_object->m_type)
11907 return !other.operator < (*this);
11936 switch (m_object->m_type)
11980 auto result = *
this;
12002 auto result = *
this;
12015 switch (m_object->m_type)
12044 switch (m_object->m_type)
12078 const typename object_t::key_type&
key()
const
12143template<
typename Base>
12217 auto it = --this->base();
12224 auto it = --this->base();
12225 return it.operator * ();
12236#include <algorithm>
12258template<
typename BasicJsonType>
12278 [](
const std::string & a,
const std::string & b)
12280 return a +
"/" + detail::escape(b);
12286 operator std::string()
const
12313 return *
this /= std::to_string(array_idx);
12408 static typename BasicJsonType::size_type
array_index(
const std::string& s)
12410 using size_type =
typename BasicJsonType::size_type;
12424 std::size_t processed_chars = 0;
12425 unsigned long long res = 0;
12428 res = std::stoull(s, &processed_chars);
12443 if (res >=
static_cast<unsigned long long>((std::numeric_limits<size_type>::max)()))
12448 return static_cast<size_type
>(res);
12485 if (reference_token ==
"0")
12557 if (ptr->is_null())
12561 std::all_of(reference_token.begin(), reference_token.end(),
12562 [](
const unsigned char x)
12564 return std::isdigit(x);
12568 *ptr = (nums || reference_token ==
"-")
12573 switch (ptr->type())
12578 ptr = &ptr->operator[](reference_token);
12584 if (reference_token ==
"-")
12587 ptr = &ptr->operator[](ptr->m_value.array->size());
12592 ptr = &ptr->operator[](
array_index(reference_token));
12623 switch (ptr->type())
12628 ptr = &ptr->at(reference_token);
12638 "array index '-' (" + std::to_string(ptr->m_value.array->size()) +
12639 ") is out of range", *ptr));
12680 switch (ptr->type())
12685 ptr = &ptr->operator[](reference_token);
12698 ptr = &ptr->operator[](
array_index(reference_token));
12728 switch (ptr->type())
12733 ptr = &ptr->at(reference_token);
12743 "array index '-' (" + std::to_string(ptr->m_value.array->size()) +
12744 ") is out of range", *ptr));
12776 switch (ptr->type())
12780 if (!ptr->contains(reference_token))
12786 ptr = &ptr->operator[](reference_token);
12797 if (
JSON_HEDLEY_UNLIKELY(reference_token.size() == 1 && !(
"0" <= reference_token && reference_token <=
"9")))
12809 for (std::size_t i = 1; i < reference_token.size(); i++)
12820 if (idx >= ptr->size())
12826 ptr = &ptr->operator[](idx);
12860 static std::vector<std::string>
split(
const std::string& reference_string)
12862 std::vector<std::string>
result;
12865 if (reference_string.empty())
12881 std::size_t slash = reference_string.find_first_of(
'/', 1),
12888 start = (slash == std::string::npos) ? 0 : slash + 1,
12890 slash = reference_string.find_first_of(
'/', start))
12894 auto reference_token = reference_string.substr(start, slash - start);
12897 for (std::size_t pos = reference_token.find_first_of(
'~');
12898 pos != std::string::npos;
12899 pos = reference_token.find_first_of(
'~', pos + 1))
12905 (reference_token[pos + 1] !=
'0' &&
12906 reference_token[pos + 1] !=
'1')))
12928 static void flatten(
const std::string& reference_string,
12932 switch (value.type())
12936 if (value.m_value.array->empty())
12939 result[reference_string] =
nullptr;
12944 for (std::size_t i = 0; i < value.m_value.array->size(); ++i)
12946 flatten(reference_string +
"/" + std::to_string(i),
12947 value.m_value.array->operator[](i),
result);
12955 if (value.m_value.object->empty())
12958 result[reference_string] =
nullptr;
12963 for (
const auto& element : *value.m_value.object)
12982 result[reference_string] = value;
13009 for (
const auto& element : *value.m_value.object)
13040 return lhs.reference_tokens == rhs.reference_tokens;
13057 return !(lhs == rhs);
13068#include <initializer_list>
13078template<
typename BasicJsonType>
13147#include <algorithm>
13163#include <algorithm>
13197template<typename CharType>
13201template<typename CharType, typename AllocatorType =
std::allocator<CharType>>
13215 void write_characters(const CharType* s,
std::
size_t length)
override
13217 std::copy(s, s + length, std::back_inserter(v));
13221 std::vector<CharType, AllocatorType>&
v;
13226template<
typename CharType>
13240 void write_characters(const CharType* s,
std::
size_t length)
override
13242 stream.write(s,
static_cast<std::streamsize
>(length));
13251template<
typename CharType,
typename StringType = std::basic_
string<CharType>>
13265 void write_characters(const CharType* s,
std::
size_t length)
override
13267 str.append(s, length);
13274template<
typename CharType,
typename StringType = std::basic_
string<CharType>>
13278 template<
typename AllocatorType = std::allocator<CharType>>
13313template<
typename BasicJsonType,
typename CharType>
13339 case value_t::object:
13341 write_bson_object(*j.m_value.object);
13345 case value_t::null:
13346 case value_t::array:
13347 case value_t::string:
13348 case value_t::boolean:
13349 case value_t::number_integer:
13350 case value_t::number_unsigned:
13351 case value_t::number_float:
13352 case value_t::binary:
13353 case value_t::discarded:
13356 JSON_THROW(type_error::create(317,
"to serialize to BSON, top-level type must be object, but is " + std::string(j.type_name()), j));
13368 case value_t::null:
13370 oa->write_character(to_char_type(0xF6));
13374 case value_t::boolean:
13376 oa->write_character(j.m_value.boolean
13377 ? to_char_type(0xF5)
13378 : to_char_type(0xF4));
13382 case value_t::number_integer:
13384 if (j.m_value.number_integer >= 0)
13389 if (j.m_value.number_integer <= 0x17)
13391 write_number(
static_cast<std::uint8_t
>(j.m_value.number_integer));
13393 else if (j.m_value.number_integer <= (std::numeric_limits<std::uint8_t>::max)())
13395 oa->write_character(to_char_type(0x18));
13396 write_number(
static_cast<std::uint8_t
>(j.m_value.number_integer));
13398 else if (j.m_value.number_integer <= (std::numeric_limits<std::uint16_t>::max)())
13400 oa->write_character(to_char_type(0x19));
13401 write_number(
static_cast<std::uint16_t
>(j.m_value.number_integer));
13403 else if (j.m_value.number_integer <= (std::numeric_limits<std::uint32_t>::max)())
13405 oa->write_character(to_char_type(0x1A));
13406 write_number(
static_cast<std::uint32_t
>(j.m_value.number_integer));
13410 oa->write_character(to_char_type(0x1B));
13411 write_number(
static_cast<std::uint64_t
>(j.m_value.number_integer));
13418 const auto positive_number = -1 - j.m_value.number_integer;
13419 if (j.m_value.number_integer >= -24)
13421 write_number(
static_cast<std::uint8_t
>(0x20 + positive_number));
13423 else if (positive_number <= (std::numeric_limits<std::uint8_t>::max)())
13425 oa->write_character(to_char_type(0x38));
13426 write_number(
static_cast<std::uint8_t
>(positive_number));
13428 else if (positive_number <= (std::numeric_limits<std::uint16_t>::max)())
13430 oa->write_character(to_char_type(0x39));
13431 write_number(
static_cast<std::uint16_t
>(positive_number));
13433 else if (positive_number <= (std::numeric_limits<std::uint32_t>::max)())
13435 oa->write_character(to_char_type(0x3A));
13436 write_number(
static_cast<std::uint32_t
>(positive_number));
13440 oa->write_character(to_char_type(0x3B));
13441 write_number(
static_cast<std::uint64_t
>(positive_number));
13447 case value_t::number_unsigned:
13449 if (j.m_value.number_unsigned <= 0x17)
13451 write_number(
static_cast<std::uint8_t
>(j.m_value.number_unsigned));
13453 else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint8_t>::max)())
13455 oa->write_character(to_char_type(0x18));
13456 write_number(
static_cast<std::uint8_t
>(j.m_value.number_unsigned));
13458 else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint16_t>::max)())
13460 oa->write_character(to_char_type(0x19));
13461 write_number(
static_cast<std::uint16_t
>(j.m_value.number_unsigned));
13463 else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint32_t>::max)())
13465 oa->write_character(to_char_type(0x1A));
13466 write_number(
static_cast<std::uint32_t
>(j.m_value.number_unsigned));
13470 oa->write_character(to_char_type(0x1B));
13471 write_number(
static_cast<std::uint64_t
>(j.m_value.number_unsigned));
13476 case value_t::number_float:
13478 if (std::isnan(j.m_value.number_float))
13481 oa->write_character(to_char_type(0xF9));
13482 oa->write_character(to_char_type(0x7E));
13483 oa->write_character(to_char_type(0x00));
13485 else if (std::isinf(j.m_value.number_float))
13488 oa->write_character(to_char_type(0xf9));
13489 oa->write_character(j.m_value.number_float > 0 ? to_char_type(0x7C) : to_char_type(0xFC));
13490 oa->write_character(to_char_type(0x00));
13499 case value_t::string:
13502 const auto N = j.m_value.string->size();
13505 write_number(
static_cast<std::uint8_t
>(0x60 + N));
13507 else if (N <= (std::numeric_limits<std::uint8_t>::max)())
13509 oa->write_character(to_char_type(0x78));
13510 write_number(
static_cast<std::uint8_t
>(N));
13512 else if (N <= (std::numeric_limits<std::uint16_t>::max)())
13514 oa->write_character(to_char_type(0x79));
13515 write_number(
static_cast<std::uint16_t
>(N));
13517 else if (N <= (std::numeric_limits<std::uint32_t>::max)())
13519 oa->write_character(to_char_type(0x7A));
13520 write_number(
static_cast<std::uint32_t
>(N));
13523 else if (N <= (std::numeric_limits<std::uint64_t>::max)())
13525 oa->write_character(to_char_type(0x7B));
13526 write_number(
static_cast<std::uint64_t
>(N));
13531 oa->write_characters(
13532 reinterpret_cast<const CharType*
>(j.m_value.string->c_str()),
13533 j.m_value.string->size());
13537 case value_t::array:
13540 const auto N = j.m_value.array->size();
13543 write_number(
static_cast<std::uint8_t
>(0x80 + N));
13545 else if (N <= (std::numeric_limits<std::uint8_t>::max)())
13547 oa->write_character(to_char_type(0x98));
13548 write_number(
static_cast<std::uint8_t
>(N));
13550 else if (N <= (std::numeric_limits<std::uint16_t>::max)())
13552 oa->write_character(to_char_type(0x99));
13553 write_number(
static_cast<std::uint16_t
>(N));
13555 else if (N <= (std::numeric_limits<std::uint32_t>::max)())
13557 oa->write_character(to_char_type(0x9A));
13558 write_number(
static_cast<std::uint32_t
>(N));
13561 else if (N <= (std::numeric_limits<std::uint64_t>::max)())
13563 oa->write_character(to_char_type(0x9B));
13564 write_number(
static_cast<std::uint64_t
>(N));
13569 for (
const auto& el : *j.m_value.array)
13576 case value_t::binary:
13578 if (j.m_value.binary->has_subtype())
13580 if (j.m_value.binary->subtype() <= (std::numeric_limits<std::uint8_t>::max)())
13582 write_number(
static_cast<std::uint8_t
>(0xd8));
13583 write_number(
static_cast<std::uint8_t
>(j.m_value.binary->subtype()));
13585 else if (j.m_value.binary->subtype() <= (std::numeric_limits<std::uint16_t>::max)())
13587 write_number(
static_cast<std::uint8_t
>(0xd9));
13588 write_number(
static_cast<std::uint16_t
>(j.m_value.binary->subtype()));
13590 else if (j.m_value.binary->subtype() <= (std::numeric_limits<std::uint32_t>::max)())
13592 write_number(
static_cast<std::uint8_t
>(0xda));
13593 write_number(
static_cast<std::uint32_t
>(j.m_value.binary->subtype()));
13595 else if (j.m_value.binary->subtype() <= (std::numeric_limits<std::uint64_t>::max)())
13597 write_number(
static_cast<std::uint8_t
>(0xdb));
13598 write_number(
static_cast<std::uint64_t
>(j.m_value.binary->subtype()));
13603 const auto N = j.m_value.binary->size();
13606 write_number(
static_cast<std::uint8_t
>(0x40 + N));
13608 else if (N <= (std::numeric_limits<std::uint8_t>::max)())
13610 oa->write_character(to_char_type(0x58));
13611 write_number(
static_cast<std::uint8_t
>(N));
13613 else if (N <= (std::numeric_limits<std::uint16_t>::max)())
13615 oa->write_character(to_char_type(0x59));
13616 write_number(
static_cast<std::uint16_t
>(N));
13618 else if (N <= (std::numeric_limits<std::uint32_t>::max)())
13620 oa->write_character(to_char_type(0x5A));
13621 write_number(
static_cast<std::uint32_t
>(N));
13624 else if (N <= (std::numeric_limits<std::uint64_t>::max)())
13626 oa->write_character(to_char_type(0x5B));
13627 write_number(
static_cast<std::uint64_t
>(N));
13632 oa->write_characters(
13633 reinterpret_cast<const CharType*
>(j.m_value.binary->data()),
13639 case value_t::object:
13642 const auto N = j.m_value.object->size();
13645 write_number(
static_cast<std::uint8_t
>(0xA0 + N));
13647 else if (N <= (std::numeric_limits<std::uint8_t>::max)())
13649 oa->write_character(to_char_type(0xB8));
13650 write_number(
static_cast<std::uint8_t
>(N));
13652 else if (N <= (std::numeric_limits<std::uint16_t>::max)())
13654 oa->write_character(to_char_type(0xB9));
13655 write_number(
static_cast<std::uint16_t
>(N));
13657 else if (N <= (std::numeric_limits<std::uint32_t>::max)())
13659 oa->write_character(to_char_type(0xBA));
13660 write_number(
static_cast<std::uint32_t
>(N));
13663 else if (N <= (std::numeric_limits<std::uint64_t>::max)())
13665 oa->write_character(to_char_type(0xBB));
13666 write_number(
static_cast<std::uint64_t
>(N));
13671 for (
const auto& el : *j.m_value.object)
13673 write_cbor(el.first);
13674 write_cbor(el.second);
13679 case value_t::discarded:
13692 case value_t::null:
13694 oa->write_character(to_char_type(0xC0));
13698 case value_t::boolean:
13700 oa->write_character(j.m_value.boolean
13701 ? to_char_type(0xC3)
13702 : to_char_type(0xC2));
13706 case value_t::number_integer:
13708 if (j.m_value.number_integer >= 0)
13713 if (j.m_value.number_unsigned < 128)
13716 write_number(
static_cast<std::uint8_t
>(j.m_value.number_integer));
13718 else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint8_t>::max)())
13721 oa->write_character(to_char_type(0xCC));
13722 write_number(
static_cast<std::uint8_t
>(j.m_value.number_integer));
13724 else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint16_t>::max)())
13727 oa->write_character(to_char_type(0xCD));
13728 write_number(
static_cast<std::uint16_t
>(j.m_value.number_integer));
13730 else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint32_t>::max)())
13733 oa->write_character(to_char_type(0xCE));
13734 write_number(
static_cast<std::uint32_t
>(j.m_value.number_integer));
13736 else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint64_t>::max)())
13739 oa->write_character(to_char_type(0xCF));
13740 write_number(
static_cast<std::uint64_t
>(j.m_value.number_integer));
13745 if (j.m_value.number_integer >= -32)
13748 write_number(
static_cast<std::int8_t
>(j.m_value.number_integer));
13750 else if (j.m_value.number_integer >= (std::numeric_limits<std::int8_t>::min)() &&
13751 j.m_value.number_integer <= (std::numeric_limits<std::int8_t>::max)())
13754 oa->write_character(to_char_type(0xD0));
13755 write_number(
static_cast<std::int8_t
>(j.m_value.number_integer));
13757 else if (j.m_value.number_integer >= (std::numeric_limits<std::int16_t>::min)() &&
13758 j.m_value.number_integer <= (std::numeric_limits<std::int16_t>::max)())
13761 oa->write_character(to_char_type(0xD1));
13762 write_number(
static_cast<std::int16_t
>(j.m_value.number_integer));
13764 else if (j.m_value.number_integer >= (std::numeric_limits<std::int32_t>::min)() &&
13765 j.m_value.number_integer <= (std::numeric_limits<std::int32_t>::max)())
13768 oa->write_character(to_char_type(0xD2));
13769 write_number(
static_cast<std::int32_t
>(j.m_value.number_integer));
13771 else if (j.m_value.number_integer >= (std::numeric_limits<std::int64_t>::min)() &&
13772 j.m_value.number_integer <= (std::numeric_limits<std::int64_t>::max)())
13775 oa->write_character(to_char_type(0xD3));
13776 write_number(
static_cast<std::int64_t
>(j.m_value.number_integer));
13782 case value_t::number_unsigned:
13784 if (j.m_value.number_unsigned < 128)
13787 write_number(
static_cast<std::uint8_t
>(j.m_value.number_integer));
13789 else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint8_t>::max)())
13792 oa->write_character(to_char_type(0xCC));
13793 write_number(
static_cast<std::uint8_t
>(j.m_value.number_integer));
13795 else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint16_t>::max)())
13798 oa->write_character(to_char_type(0xCD));
13799 write_number(
static_cast<std::uint16_t
>(j.m_value.number_integer));
13801 else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint32_t>::max)())
13804 oa->write_character(to_char_type(0xCE));
13805 write_number(
static_cast<std::uint32_t
>(j.m_value.number_integer));
13807 else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint64_t>::max)())
13810 oa->write_character(to_char_type(0xCF));
13811 write_number(
static_cast<std::uint64_t
>(j.m_value.number_integer));
13816 case value_t::number_float:
13822 case value_t::string:
13825 const auto N = j.m_value.string->size();
13829 write_number(
static_cast<std::uint8_t
>(0xA0 | N));
13831 else if (N <= (std::numeric_limits<std::uint8_t>::max)())
13834 oa->write_character(to_char_type(0xD9));
13835 write_number(
static_cast<std::uint8_t
>(N));
13837 else if (N <= (std::numeric_limits<std::uint16_t>::max)())
13840 oa->write_character(to_char_type(0xDA));
13841 write_number(
static_cast<std::uint16_t
>(N));
13843 else if (N <= (std::numeric_limits<std::uint32_t>::max)())
13846 oa->write_character(to_char_type(0xDB));
13847 write_number(
static_cast<std::uint32_t
>(N));
13851 oa->write_characters(
13852 reinterpret_cast<const CharType*
>(j.m_value.string->c_str()),
13853 j.m_value.string->size());
13857 case value_t::array:
13860 const auto N = j.m_value.array->size();
13864 write_number(
static_cast<std::uint8_t
>(0x90 | N));
13866 else if (N <= (std::numeric_limits<std::uint16_t>::max)())
13869 oa->write_character(to_char_type(0xDC));
13870 write_number(
static_cast<std::uint16_t
>(N));
13872 else if (N <= (std::numeric_limits<std::uint32_t>::max)())
13875 oa->write_character(to_char_type(0xDD));
13876 write_number(
static_cast<std::uint32_t
>(N));
13880 for (
const auto& el : *j.m_value.array)
13887 case value_t::binary:
13891 const bool use_ext = j.m_value.binary->has_subtype();
13894 const auto N = j.m_value.binary->size();
13895 if (N <= (std::numeric_limits<std::uint8_t>::max)())
13897 std::uint8_t output_type{};
13904 output_type = 0xD4;
13907 output_type = 0xD5;
13910 output_type = 0xD6;
13913 output_type = 0xD7;
13916 output_type = 0xD8;
13919 output_type = 0xC7;
13927 output_type = 0xC4;
13931 oa->write_character(to_char_type(output_type));
13934 write_number(
static_cast<std::uint8_t
>(N));
13937 else if (N <= (std::numeric_limits<std::uint16_t>::max)())
13939 std::uint8_t output_type = use_ext
13943 oa->write_character(to_char_type(output_type));
13944 write_number(
static_cast<std::uint16_t
>(N));
13946 else if (N <= (std::numeric_limits<std::uint32_t>::max)())
13948 std::uint8_t output_type = use_ext
13952 oa->write_character(to_char_type(output_type));
13953 write_number(
static_cast<std::uint32_t
>(N));
13959 write_number(
static_cast<std::int8_t
>(j.m_value.binary->subtype()));
13963 oa->write_characters(
13964 reinterpret_cast<const CharType*
>(j.m_value.binary->data()),
13970 case value_t::object:
13973 const auto N = j.m_value.object->size();
13977 write_number(
static_cast<std::uint8_t
>(0x80 | (N & 0xF)));
13979 else if (N <= (std::numeric_limits<std::uint16_t>::max)())
13982 oa->write_character(to_char_type(0xDE));
13983 write_number(
static_cast<std::uint16_t
>(N));
13985 else if (N <= (std::numeric_limits<std::uint32_t>::max)())
13988 oa->write_character(to_char_type(0xDF));
13989 write_number(
static_cast<std::uint32_t
>(N));
13993 for (
const auto& el : *j.m_value.object)
13995 write_msgpack(el.first);
13996 write_msgpack(el.second);
14001 case value_t::discarded:
14014 const bool use_type,
const bool add_prefix =
true)
14018 case value_t::null:
14022 oa->write_character(to_char_type(
'Z'));
14027 case value_t::boolean:
14031 oa->write_character(j.m_value.boolean
14032 ? to_char_type(
'T')
14033 : to_char_type(
'F'));
14038 case value_t::number_integer:
14040 write_number_with_ubjson_prefix(j.m_value.number_integer, add_prefix);
14044 case value_t::number_unsigned:
14046 write_number_with_ubjson_prefix(j.m_value.number_unsigned, add_prefix);
14050 case value_t::number_float:
14052 write_number_with_ubjson_prefix(j.m_value.number_float, add_prefix);
14056 case value_t::string:
14060 oa->write_character(to_char_type(
'S'));
14062 write_number_with_ubjson_prefix(j.m_value.string->size(),
true);
14063 oa->write_characters(
14064 reinterpret_cast<const CharType*
>(j.m_value.string->c_str()),
14065 j.m_value.string->size());
14069 case value_t::array:
14073 oa->write_character(to_char_type(
'['));
14076 bool prefix_required =
true;
14077 if (use_type && !j.m_value.array->empty())
14080 const CharType first_prefix = ubjson_prefix(j.front());
14081 const bool same_prefix = std::all_of(j.begin() + 1, j.end(),
14082 [
this, first_prefix](
const BasicJsonType & v)
14084 return ubjson_prefix(v) == first_prefix;
14089 prefix_required =
false;
14090 oa->write_character(to_char_type(
'$'));
14091 oa->write_character(first_prefix);
14097 oa->write_character(to_char_type(
'#'));
14098 write_number_with_ubjson_prefix(j.m_value.array->size(),
true);
14101 for (
const auto& el : *j.m_value.array)
14103 write_ubjson(el, use_count, use_type, prefix_required);
14108 oa->write_character(to_char_type(
']'));
14114 case value_t::binary:
14118 oa->write_character(to_char_type(
'['));
14121 if (use_type && !j.m_value.binary->empty())
14124 oa->write_character(to_char_type(
'$'));
14125 oa->write_character(
'U');
14130 oa->write_character(to_char_type(
'#'));
14131 write_number_with_ubjson_prefix(j.m_value.binary->size(),
true);
14136 oa->write_characters(
14137 reinterpret_cast<const CharType*
>(j.m_value.binary->data()),
14138 j.m_value.binary->size());
14142 for (
size_t i = 0; i < j.m_value.binary->size(); ++i)
14144 oa->write_character(to_char_type(
'U'));
14145 oa->write_character(j.m_value.binary->data()[i]);
14151 oa->write_character(to_char_type(
']'));
14157 case value_t::object:
14161 oa->write_character(to_char_type(
'{'));
14164 bool prefix_required =
true;
14165 if (use_type && !j.m_value.object->empty())
14168 const CharType first_prefix = ubjson_prefix(j.front());
14169 const bool same_prefix = std::all_of(j.begin(), j.end(),
14170 [
this, first_prefix](
const BasicJsonType & v)
14172 return ubjson_prefix(v) == first_prefix;
14177 prefix_required =
false;
14178 oa->write_character(to_char_type(
'$'));
14179 oa->write_character(first_prefix);
14185 oa->write_character(to_char_type(
'#'));
14186 write_number_with_ubjson_prefix(j.m_value.object->size(),
true);
14189 for (
const auto& el : *j.m_value.object)
14191 write_number_with_ubjson_prefix(el.first.size(),
true);
14192 oa->write_characters(
14193 reinterpret_cast<const CharType*
>(el.first.c_str()),
14195 write_ubjson(el.second, use_count, use_type, prefix_required);
14200 oa->write_character(to_char_type(
'}'));
14206 case value_t::discarded:
14223 const auto it = name.find(
static_cast<typename string_t::value_type
>(0));
14226 JSON_THROW(out_of_range::create(409,
"BSON key cannot contain code point U+0000 (at byte " + std::to_string(it) +
")", j));
14227 static_cast<void>(j);
14230 return 1ul + name.size() + 1u;
14237 const std::uint8_t element_type)
14239 oa->write_character(to_char_type(element_type));
14240 oa->write_characters(
14241 reinterpret_cast<const CharType*
>(name.c_str()),
14251 write_bson_entry_header(name, 0x08);
14252 oa->write_character(
value ? to_char_type(0x01) : to_char_type(0x00));
14259 const double value)
14261 write_bson_entry_header(name, 0x01);
14262 write_number<double, true>(
value);
14270 return sizeof(std::int32_t) +
value.size() + 1ul;
14279 write_bson_entry_header(name, 0x02);
14281 write_number<std::int32_t, true>(
static_cast<std::int32_t
>(
value.size() + 1ul));
14282 oa->write_characters(
14283 reinterpret_cast<const CharType*
>(
value.c_str()),
14292 write_bson_entry_header(name, 0x0A);
14300 return (std::numeric_limits<std::int32_t>::min)() <=
value &&
value <= (std::numeric_limits<std::int32_t>::max)()
14301 ?
sizeof(std::int32_t)
14302 :
sizeof(std::int64_t);
14309 const std::int64_t value)
14311 if ((std::numeric_limits<std::int32_t>::min)() <=
value &&
value <= (std::numeric_limits<std::int32_t>::max)())
14313 write_bson_entry_header(name, 0x10);
14314 write_number<std::int32_t, true>(
static_cast<std::int32_t
>(
value));
14318 write_bson_entry_header(name, 0x12);
14319 write_number<std::int64_t, true>(
static_cast<std::int64_t
>(
value));
14328 return (
value <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int32_t>::max)()))
14329 ?
sizeof(std::int32_t)
14330 :
sizeof(std::int64_t);
14337 const BasicJsonType& j)
14339 if (j.m_value.number_unsigned <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int32_t>::max)()))
14341 write_bson_entry_header(name, 0x10 );
14342 write_number<std::int32_t, true>(
static_cast<std::int32_t
>(j.m_value.number_unsigned));
14344 else if (j.m_value.number_unsigned <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int64_t>::max)()))
14346 write_bson_entry_header(name, 0x12 );
14347 write_number<std::int64_t, true>(
static_cast<std::int64_t
>(j.m_value.number_unsigned));
14351 JSON_THROW(out_of_range::create(407,
"integer number " + std::to_string(j.m_value.number_unsigned) +
" cannot be represented by BSON as it does not fit int64", j));
14359 const typename BasicJsonType::object_t& value)
14361 write_bson_entry_header(name, 0x03);
14362 write_bson_object(
value);
14370 std::size_t array_index = 0ul;
14372 const std::size_t embedded_document_size = std::accumulate(std::begin(
value), std::end(
value),
static_cast<std::size_t
>(0), [&array_index](std::size_t result,
const typename BasicJsonType::array_t::value_type & el)
14374 return result + calc_bson_element_size(std::to_string(array_index++), el);
14377 return sizeof(std::int32_t) + embedded_document_size + 1ul;
14385 return sizeof(std::int32_t) +
value.size() + 1ul;
14392 const typename BasicJsonType::array_t& value)
14394 write_bson_entry_header(name, 0x04);
14395 write_number<std::int32_t, true>(
static_cast<std::int32_t
>(calc_bson_array_size(
value)));
14397 std::size_t array_index = 0ul;
14399 for (
const auto& el :
value)
14401 write_bson_element(std::to_string(array_index++), el);
14404 oa->write_character(to_char_type(0x00));
14413 write_bson_entry_header(name, 0x05);
14415 write_number<std::int32_t, true>(
static_cast<std::int32_t
>(
value.size()));
14416 write_number(
value.has_subtype() ?
static_cast<std::uint8_t
>(
value.subtype()) :
static_cast<std::uint8_t
>(0x00));
14418 oa->write_characters(
reinterpret_cast<const CharType*
>(
value.data()),
value.size());
14426 const BasicJsonType& j)
14428 const auto header_size = calc_bson_entry_header_size(name, j);
14431 case value_t::object:
14432 return header_size + calc_bson_object_size(*j.m_value.object);
14434 case value_t::array:
14435 return header_size + calc_bson_array_size(*j.m_value.array);
14437 case value_t::binary:
14438 return header_size + calc_bson_binary_size(*j.m_value.binary);
14440 case value_t::boolean:
14441 return header_size + 1ul;
14443 case value_t::number_float:
14444 return header_size + 8ul;
14446 case value_t::number_integer:
14447 return header_size + calc_bson_integer_size(j.m_value.number_integer);
14449 case value_t::number_unsigned:
14450 return header_size + calc_bson_unsigned_size(j.m_value.number_unsigned);
14452 case value_t::string:
14453 return header_size + calc_bson_string_size(*j.m_value.string);
14455 case value_t::null:
14456 return header_size + 0ul;
14459 case value_t::discarded:
14474 const BasicJsonType& j)
14478 case value_t::object:
14479 return write_bson_object_entry(name, *j.m_value.object);
14481 case value_t::array:
14482 return write_bson_array(name, *j.m_value.array);
14484 case value_t::binary:
14485 return write_bson_binary(name, *j.m_value.binary);
14487 case value_t::boolean:
14488 return write_bson_boolean(name, j.m_value.boolean);
14490 case value_t::number_float:
14491 return write_bson_double(name, j.m_value.number_float);
14493 case value_t::number_integer:
14494 return write_bson_integer(name, j.m_value.number_integer);
14496 case value_t::number_unsigned:
14497 return write_bson_unsigned(name, j);
14499 case value_t::string:
14500 return write_bson_string(name, *j.m_value.string);
14502 case value_t::null:
14503 return write_bson_null(name);
14506 case value_t::discarded:
14522 std::size_t document_size = std::accumulate(
value.begin(),
value.end(),
static_cast<std::size_t
>(0),
14523 [](
size_t result,
const typename BasicJsonType::object_t::value_type & el)
14525 return result += calc_bson_element_size(el.first, el.second);
14528 return sizeof(std::int32_t) + document_size + 1ul;
14537 write_number<std::int32_t, true>(
static_cast<std::int32_t
>(calc_bson_object_size(
value)));
14539 for (
const auto& el :
value)
14541 write_bson_element(el.first, el.second);
14544 oa->write_character(to_char_type(0x00));
14553 return to_char_type(0xFA);
14558 return to_char_type(0xFB);
14567 return to_char_type(0xCA);
14572 return to_char_type(0xCB);
14580 template<
typename NumberType,
typename std::enable_if<
14581 std::is_floating_point<NumberType>::value,
int>::type = 0>
14583 const bool add_prefix)
14587 oa->write_character(get_ubjson_float_prefix(n));
14593 template<
typename NumberType,
typename std::enable_if<
14594 std::is_unsigned<NumberType>::value,
int>::type = 0>
14596 const bool add_prefix)
14598 if (n <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int8_t>::max)()))
14602 oa->write_character(to_char_type(
'i'));
14604 write_number(
static_cast<std::uint8_t
>(n));
14606 else if (n <= (std::numeric_limits<std::uint8_t>::max)())
14610 oa->write_character(to_char_type(
'U'));
14612 write_number(
static_cast<std::uint8_t
>(n));
14614 else if (n <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int16_t>::max)()))
14618 oa->write_character(to_char_type(
'I'));
14620 write_number(
static_cast<std::int16_t
>(n));
14622 else if (n <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int32_t>::max)()))
14626 oa->write_character(to_char_type(
'l'));
14628 write_number(
static_cast<std::int32_t
>(n));
14630 else if (n <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int64_t>::max)()))
14634 oa->write_character(to_char_type(
'L'));
14636 write_number(
static_cast<std::int64_t
>(n));
14642 oa->write_character(to_char_type(
'H'));
14645 const auto number = BasicJsonType(n).dump();
14646 write_number_with_ubjson_prefix(number.size(),
true);
14647 for (std::size_t i = 0; i < number.size(); ++i)
14649 oa->write_character(to_char_type(
static_cast<std::uint8_t
>(number[i])));
14655 template <
typename NumberType,
typename std::enable_if <
14656 std::is_signed<NumberType>::value&&
14657 !std::is_floating_point<NumberType>::value,
int >::type = 0 >
14659 const bool add_prefix)
14661 if ((std::numeric_limits<std::int8_t>::min)() <= n && n <= (std::numeric_limits<std::int8_t>::max)())
14665 oa->write_character(to_char_type(
'i'));
14667 write_number(
static_cast<std::int8_t
>(n));
14669 else if (
static_cast<std::int64_t
>((std::numeric_limits<std::uint8_t>::min)()) <= n && n <=
static_cast<std::int64_t
>((std::numeric_limits<std::uint8_t>::max)()))
14673 oa->write_character(to_char_type(
'U'));
14675 write_number(
static_cast<std::uint8_t
>(n));
14677 else if ((std::numeric_limits<std::int16_t>::min)() <= n && n <= (std::numeric_limits<std::int16_t>::max)())
14681 oa->write_character(to_char_type(
'I'));
14683 write_number(
static_cast<std::int16_t
>(n));
14685 else if ((std::numeric_limits<std::int32_t>::min)() <= n && n <= (std::numeric_limits<std::int32_t>::max)())
14689 oa->write_character(to_char_type(
'l'));
14691 write_number(
static_cast<std::int32_t
>(n));
14693 else if ((std::numeric_limits<std::int64_t>::min)() <= n && n <= (std::numeric_limits<std::int64_t>::max)())
14697 oa->write_character(to_char_type(
'L'));
14699 write_number(
static_cast<std::int64_t
>(n));
14706 oa->write_character(to_char_type(
'H'));
14709 const auto number = BasicJsonType(n).dump();
14710 write_number_with_ubjson_prefix(number.size(),
true);
14711 for (std::size_t i = 0; i < number.size(); ++i)
14713 oa->write_character(to_char_type(
static_cast<std::uint8_t
>(number[i])));
14726 case value_t::null:
14729 case value_t::boolean:
14730 return j.m_value.boolean ?
'T' :
'F';
14732 case value_t::number_integer:
14734 if ((std::numeric_limits<std::int8_t>::min)() <= j.m_value.number_integer && j.m_value.number_integer <= (std::numeric_limits<std::int8_t>::max)())
14738 if ((std::numeric_limits<std::uint8_t>::min)() <= j.m_value.number_integer && j.m_value.number_integer <= (std::numeric_limits<std::uint8_t>::max)())
14742 if ((std::numeric_limits<std::int16_t>::min)() <= j.m_value.number_integer && j.m_value.number_integer <= (std::numeric_limits<std::int16_t>::max)())
14746 if ((std::numeric_limits<std::int32_t>::min)() <= j.m_value.number_integer && j.m_value.number_integer <= (std::numeric_limits<std::int32_t>::max)())
14750 if ((std::numeric_limits<std::int64_t>::min)() <= j.m_value.number_integer && j.m_value.number_integer <= (std::numeric_limits<std::int64_t>::max)())
14758 case value_t::number_unsigned:
14760 if (j.m_value.number_unsigned <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int8_t>::max)()))
14764 if (j.m_value.number_unsigned <=
static_cast<std::uint64_t
>((std::numeric_limits<std::uint8_t>::max)()))
14768 if (j.m_value.number_unsigned <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int16_t>::max)()))
14772 if (j.m_value.number_unsigned <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int32_t>::max)()))
14776 if (j.m_value.number_unsigned <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int64_t>::max)()))
14784 case value_t::number_float:
14785 return get_ubjson_float_prefix(j.m_value.number_float);
14787 case value_t::string:
14790 case value_t::array:
14791 case value_t::binary:
14794 case value_t::object:
14797 case value_t::discarded:
14828 template<
typename NumberType,
bool OutputIsLittleEndian = false>
14832 std::array<CharType,
sizeof(NumberType)> vec{};
14833 std::memcpy(vec.data(), &n,
sizeof(NumberType));
14836 if (is_little_endian != OutputIsLittleEndian)
14839 std::reverse(vec.begin(), vec.end());
14842 oa->write_characters(vec.data(),
sizeof(NumberType));
14848#pragma GCC diagnostic push
14849#pragma GCC diagnostic ignored "-Wfloat-equal"
14851 if (
static_cast<double>(n) >=
static_cast<double>(std::numeric_limits<float>::lowest()) &&
14852 static_cast<double>(n) <=
static_cast<double>((std::numeric_limits<float>::max)()) &&
14853 static_cast<double>(
static_cast<float>(n)) ==
static_cast<double>(n))
14856 ? get_cbor_float_prefix(
static_cast<float>(n))
14857 : get_msgpack_float_prefix(
static_cast<float>(n)));
14858 write_number(
static_cast<float>(n));
14863 ? get_cbor_float_prefix(n)
14864 : get_msgpack_float_prefix(n));
14868#pragma GCC diagnostic pop
14877 template <
typename C = CharType,
14878 enable_if_t < std::is_signed<C>::value && std::is_signed<char>::value > * =
nullptr >
14881 return *
reinterpret_cast<char*
>(&x);
14884 template <
typename C = CharType,
14885 enable_if_t < std::is_signed<C>::value && std::is_unsigned<char>::value > * =
nullptr >
14888 static_assert(
sizeof(std::uint8_t) ==
sizeof(CharType),
"size of CharType must be equal to std::uint8_t");
14889 static_assert(std::is_trivial<CharType>::value,
"CharType must be trivial");
14891 std::memcpy(&result, &x,
sizeof(x));
14895 template<
typename C = CharType,
14902 template <
typename InputCharType,
typename C = CharType,
14904 std::is_signed<C>::value &&
14905 std::is_signed<char>::value &&
14906 std::is_same<char, typename std::remove_cv<InputCharType>::type>::value
14928#include <algorithm>
14939#include <type_traits>
14950#include <type_traits>
14982template<
typename Target,
typename Source>
14985 static_assert(
sizeof(Target) ==
sizeof(Source),
"size mismatch");
14988 std::memcpy(&target, &source,
sizeof(Source));
14999 constexpr diyfp(std::uint64_t f_,
int e_) noexcept :
f(f_),
e(e_) {}
15010 return {x.f - y.f, x.e};
15019 static_assert(
kPrecision == 64,
"internal error");
15044 const std::uint64_t u_lo = x.
f & 0xFFFFFFFFu;
15045 const std::uint64_t u_hi = x.f >> 32u;
15046 const std::uint64_t v_lo = y.f & 0xFFFFFFFFu;
15047 const std::uint64_t v_hi = y.f >> 32u;
15049 const std::uint64_t p0 = u_lo * v_lo;
15050 const std::uint64_t p1 = u_lo * v_hi;
15051 const std::uint64_t p2 = u_hi * v_lo;
15052 const std::uint64_t p3 = u_hi * v_hi;
15054 const std::uint64_t p0_hi = p0 >> 32u;
15055 const std::uint64_t p1_lo = p1 & 0xFFFFFFFFu;
15056 const std::uint64_t p1_hi = p1 >> 32u;
15057 const std::uint64_t p2_lo = p2 & 0xFFFFFFFFu;
15058 const std::uint64_t p2_hi = p2 >> 32u;
15060 std::uint64_t Q = p0_hi + p1_lo + p2_lo;
15071 Q += std::uint64_t{1} << (64u - 32u - 1u);
15073 const std::uint64_t h = p3 + p2_hi + p1_hi + (Q >> 32u);
15075 return {h, x.e + y.e + 64};
15086 while ((x.f >> 63u) == 0)
15101 const int delta = x.
e - target_exponent;
15106 return {x.f << delta, target_exponent};
15123template<
typename FloatType>
15136 static_assert(std::numeric_limits<FloatType>::is_iec559,
15137 "internal error: dtoa_short requires an IEEE-754 floating-point implementation");
15139 constexpr int kPrecision = std::numeric_limits<FloatType>::digits;
15140 constexpr int kBias = std::numeric_limits<FloatType>::max_exponent - 1 + (kPrecision - 1);
15141 constexpr int kMinExp = 1 - kBias;
15142 constexpr std::uint64_t kHiddenBit = std::uint64_t{1} << (kPrecision - 1);
15144 using bits_type =
typename std::conditional<kPrecision == 24, std::uint32_t, std::uint64_t >::type;
15146 const auto bits =
static_cast<std::uint64_t
>(reinterpret_bits<bits_type>(
value));
15147 const std::uint64_t E = bits >> (kPrecision - 1);
15148 const std::uint64_t F = bits & (kHiddenBit - 1);
15150 const bool is_denormal = E == 0;
15151 const diyfp v = is_denormal
15152 ?
diyfp(F, kMinExp)
15153 :
diyfp(F + kHiddenBit,
static_cast<int>(E) - kBias);
15176 const bool lower_boundary_is_closer = F == 0 && E > 1;
15178 const diyfp m_minus = lower_boundary_is_closer
15179 ?
diyfp(4 * v.
f - 1, v.
e - 2)
15180 :
diyfp(2 * v.
f - 1, v.
e - 1);
15315 constexpr int kCachedPowersMinDecExp = -300;
15316 constexpr int kCachedPowersDecStep = 8;
15318 static constexpr std::array<cached_power, 79> kCachedPowers =
15321 { 0xAB70FE17C79AC6CA, -1060, -300 },
15322 { 0xFF77B1FCBEBCDC4F, -1034, -292 },
15323 { 0xBE5691EF416BD60C, -1007, -284 },
15324 { 0x8DD01FAD907FFC3C, -980, -276 },
15325 { 0xD3515C2831559A83, -954, -268 },
15326 { 0x9D71AC8FADA6C9B5, -927, -260 },
15327 { 0xEA9C227723EE8BCB, -901, -252 },
15328 { 0xAECC49914078536D, -874, -244 },
15329 { 0x823C12795DB6CE57, -847, -236 },
15330 { 0xC21094364DFB5637, -821, -228 },
15331 { 0x9096EA6F3848984F, -794, -220 },
15332 { 0xD77485CB25823AC7, -768, -212 },
15333 { 0xA086CFCD97BF97F4, -741, -204 },
15334 { 0xEF340A98172AACE5, -715, -196 },
15335 { 0xB23867FB2A35B28E, -688, -188 },
15336 { 0x84C8D4DFD2C63F3B, -661, -180 },
15337 { 0xC5DD44271AD3CDBA, -635, -172 },
15338 { 0x936B9FCEBB25C996, -608, -164 },
15339 { 0xDBAC6C247D62A584, -582, -156 },
15340 { 0xA3AB66580D5FDAF6, -555, -148 },
15341 { 0xF3E2F893DEC3F126, -529, -140 },
15342 { 0xB5B5ADA8AAFF80B8, -502, -132 },
15343 { 0x87625F056C7C4A8B, -475, -124 },
15344 { 0xC9BCFF6034C13053, -449, -116 },
15345 { 0x964E858C91BA2655, -422, -108 },
15346 { 0xDFF9772470297EBD, -396, -100 },
15347 { 0xA6DFBD9FB8E5B88F, -369, -92 },
15348 { 0xF8A95FCF88747D94, -343, -84 },
15349 { 0xB94470938FA89BCF, -316, -76 },
15350 { 0x8A08F0F8BF0F156B, -289, -68 },
15351 { 0xCDB02555653131B6, -263, -60 },
15352 { 0x993FE2C6D07B7FAC, -236, -52 },
15353 { 0xE45C10C42A2B3B06, -210, -44 },
15354 { 0xAA242499697392D3, -183, -36 },
15355 { 0xFD87B5F28300CA0E, -157, -28 },
15356 { 0xBCE5086492111AEB, -130, -20 },
15357 { 0x8CBCCC096F5088CC, -103, -12 },
15358 { 0xD1B71758E219652C, -77, -4 },
15359 { 0x9C40000000000000, -50, 4 },
15360 { 0xE8D4A51000000000, -24, 12 },
15361 { 0xAD78EBC5AC620000, 3, 20 },
15362 { 0x813F3978F8940984, 30, 28 },
15363 { 0xC097CE7BC90715B3, 56, 36 },
15364 { 0x8F7E32CE7BEA5C70, 83, 44 },
15365 { 0xD5D238A4ABE98068, 109, 52 },
15366 { 0x9F4F2726179A2245, 136, 60 },
15367 { 0xED63A231D4C4FB27, 162, 68 },
15368 { 0xB0DE65388CC8ADA8, 189, 76 },
15369 { 0x83C7088E1AAB65DB, 216, 84 },
15370 { 0xC45D1DF942711D9A, 242, 92 },
15371 { 0x924D692CA61BE758, 269, 100 },
15372 { 0xDA01EE641A708DEA, 295, 108 },
15373 { 0xA26DA3999AEF774A, 322, 116 },
15374 { 0xF209787BB47D6B85, 348, 124 },
15375 { 0xB454E4A179DD1877, 375, 132 },
15376 { 0x865B86925B9BC5C2, 402, 140 },
15377 { 0xC83553C5C8965D3D, 428, 148 },
15378 { 0x952AB45CFA97A0B3, 455, 156 },
15379 { 0xDE469FBD99A05FE3, 481, 164 },
15380 { 0xA59BC234DB398C25, 508, 172 },
15381 { 0xF6C69A72A3989F5C, 534, 180 },
15382 { 0xB7DCBF5354E9BECE, 561, 188 },
15383 { 0x88FCF317F22241E2, 588, 196 },
15384 { 0xCC20CE9BD35C78A5, 614, 204 },
15385 { 0x98165AF37B2153DF, 641, 212 },
15386 { 0xE2A0B5DC971F303A, 667, 220 },
15387 { 0xA8D9D1535CE3B396, 694, 228 },
15388 { 0xFB9B7CD9A4A7443C, 720, 236 },
15389 { 0xBB764C4CA7A44410, 747, 244 },
15390 { 0x8BAB8EEFB6409C1A, 774, 252 },
15391 { 0xD01FEF10A657842C, 800, 260 },
15392 { 0x9B10A4E5E9913129, 827, 268 },
15393 { 0xE7109BFBA19C0C9D, 853, 276 },
15394 { 0xAC2820D9623BF429, 880, 284 },
15395 { 0x80444B5E7AA7CF85, 907, 292 },
15396 { 0xBF21E44003ACDD2D, 933, 300 },
15397 { 0x8E679C2F5E44FF8F, 960, 308 },
15398 { 0xD433179D9C8CB841, 986, 316 },
15399 { 0x9E19DB92B4E31BA9, 1013, 324 },
15409 const int f =
kAlpha - e - 1;
15410 const int k = (f * 78913) / (1 << 18) +
static_cast<int>(f > 0);
15412 const int index = (-kCachedPowersMinDecExp + k + (kCachedPowersDecStep - 1)) / kCachedPowersDecStep;
15414 JSON_ASSERT(
static_cast<std::size_t
>(index) < kCachedPowers.size());
15416 const cached_power cached = kCachedPowers[
static_cast<std::size_t
>(index)];
15430 if (n >= 1000000000)
15432 pow10 = 1000000000;
15436 if (n >= 100000000)
15481inline void grisu2_round(
char* buf,
int len, std::uint64_t dist, std::uint64_t delta,
15482 std::uint64_t rest, std::uint64_t ten_k)
15509 && delta - rest >= ten_k
15510 && (rest + ten_k < dist || dist - rest > rest + ten_k - dist))
15525 static_assert(
kAlpha >= -60,
"internal error");
15526 static_assert(
kGamma <= -32,
"internal error");
15543 std::uint64_t delta =
diyfp::sub(M_plus, M_minus).
f;
15553 const diyfp one(std::uint64_t{1} << -M_plus.
e, M_plus.
e);
15555 auto p1 =
static_cast<std::uint32_t
>(M_plus.
f >> -one.e);
15556 std::uint64_t p2 = M_plus.
f & (one.f - 1);
15564 std::uint32_t pow10{};
15592 const std::uint32_t d = p1 / pow10;
15593 const std::uint32_t r = p1 % pow10;
15599 buffer[length++] =
static_cast<char>(
'0' + d);
15618 const std::uint64_t rest = (std::uint64_t{p1} << -one.e) + p2;
15623 decimal_exponent += n;
15634 const std::uint64_t ten_n = std::uint64_t{pow10} << -one.e;
15635 grisu2_round(buffer, length, dist, delta, rest, ten_n);
15696 JSON_ASSERT(p2 <= (std::numeric_limits<std::uint64_t>::max)() / 10);
15698 const std::uint64_t d = p2 >> -one.e;
15699 const std::uint64_t r = p2 & (one.f - 1);
15706 buffer[length++] =
static_cast<char>(
'0' + d);
15731 decimal_exponent -= m;
15739 const std::uint64_t ten_m = one.f;
15763inline
void grisu2(
char* buf,
int& len,
int& decimal_exponent,
15780 const diyfp c_minus_k(cached.
f, cached.
e);
15808 const diyfp M_minus(w_minus.
f + 1, w_minus.
e);
15809 const diyfp M_plus (w_plus.
f - 1, w_plus.
e );
15811 decimal_exponent = -cached.
k;
15821template<
typename FloatType>
15826 "internal error: not enough precision");
15878 auto k =
static_cast<std::uint32_t
>(e);
15884 *buf++ =
static_cast<char>(
'0' + k);
15888 *buf++ =
static_cast<char>(
'0' + k / 10);
15890 *buf++ =
static_cast<char>(
'0' + k);
15894 *buf++ =
static_cast<char>(
'0' + k / 100);
15896 *buf++ =
static_cast<char>(
'0' + k / 10);
15898 *buf++ =
static_cast<char>(
'0' + k);
15916 int min_exp,
int max_exp)
15922 const int n = len + decimal_exponent;
15928 if (k <= n && n <= max_exp)
15933 std::memset(buf + k,
'0',
static_cast<size_t>(n) -
static_cast<size_t>(k));
15937 return buf + (
static_cast<size_t>(n) + 2);
15940 if (0 < n && n <= max_exp)
15947 std::memmove(buf + (
static_cast<size_t>(n) + 1), buf + n,
static_cast<size_t>(k) -
static_cast<size_t>(n));
15949 return buf + (
static_cast<size_t>(k) + 1U);
15952 if (min_exp < n && n <= 0)
15957 std::memmove(buf + (2 +
static_cast<size_t>(-n)), buf,
static_cast<size_t>(k));
15960 std::memset(buf + 2,
'0',
static_cast<size_t>(-n));
15961 return buf + (2U +
static_cast<size_t>(-n) +
static_cast<size_t>(k));
15976 std::memmove(buf + 2, buf + 1,
static_cast<size_t>(k) - 1);
15978 buf += 1 +
static_cast<size_t>(k);
15997template<
typename FloatType>
16002 static_cast<void>(last);
16006 if (std::signbit(
value))
16013#pragma GCC diagnostic push
16014#pragma GCC diagnostic ignored "-Wfloat-equal"
16025#pragma GCC diagnostic pop
16028 JSON_ASSERT(last - first >= std::numeric_limits<FloatType>::max_digits10);
16035 int decimal_exponent = 0;
16038 JSON_ASSERT(len <= std::numeric_limits<FloatType>::max_digits10);
16041 constexpr int kMinExp = -4;
16043 constexpr int kMaxExp = std::numeric_limits<FloatType>::digits10;
16046 JSON_ASSERT(last - first >= 2 + (-kMinExp - 1) + std::numeric_limits<FloatType>::max_digits10);
16047 JSON_ASSERT(last - first >= std::numeric_limits<FloatType>::max_digits10 + 6);
16084template<
typename BasicJsonType>
16104 ,
loc(
std::localeconv())
16142 const bool pretty_print,
16144 const unsigned int indent_step,
16145 const unsigned int current_indent = 0)
16147 switch (val.m_type)
16151 if (val.m_value.object->empty())
16153 o->write_characters(
"{}", 2);
16159 o->write_characters(
"{\n", 2);
16162 const auto new_indent = current_indent + indent_step;
16169 auto i = val.m_value.object->cbegin();
16170 for (std::size_t cnt = 0; cnt < val.m_value.object->size() - 1; ++cnt, ++i)
16173 o->write_character(
'\"');
16175 o->write_characters(
"\": ", 3);
16177 o->write_characters(
",\n", 2);
16182 JSON_ASSERT(std::next(i) == val.m_value.object->cend());
16184 o->write_character(
'\"');
16186 o->write_characters(
"\": ", 3);
16189 o->write_character(
'\n');
16190 o->write_characters(
indent_string.c_str(), current_indent);
16191 o->write_character(
'}');
16195 o->write_character(
'{');
16198 auto i = val.m_value.object->cbegin();
16199 for (std::size_t cnt = 0; cnt < val.m_value.object->size() - 1; ++cnt, ++i)
16201 o->write_character(
'\"');
16203 o->write_characters(
"\":", 2);
16205 o->write_character(
',');
16210 JSON_ASSERT(std::next(i) == val.m_value.object->cend());
16211 o->write_character(
'\"');
16213 o->write_characters(
"\":", 2);
16216 o->write_character(
'}');
16224 if (val.m_value.array->empty())
16226 o->write_characters(
"[]", 2);
16232 o->write_characters(
"[\n", 2);
16235 const auto new_indent = current_indent + indent_step;
16242 for (
auto i = val.m_value.array->cbegin();
16243 i != val.m_value.array->cend() - 1; ++i)
16247 o->write_characters(
",\n", 2);
16253 dump(val.m_value.array->back(),
true,
ensure_ascii, indent_step, new_indent);
16255 o->write_character(
'\n');
16256 o->write_characters(
indent_string.c_str(), current_indent);
16257 o->write_character(
']');
16261 o->write_character(
'[');
16264 for (
auto i = val.m_value.array->cbegin();
16265 i != val.m_value.array->cend() - 1; ++i)
16268 o->write_character(
',');
16273 dump(val.m_value.array->back(),
false,
ensure_ascii, indent_step, current_indent);
16275 o->write_character(
']');
16283 o->write_character(
'\"');
16285 o->write_character(
'\"');
16293 o->write_characters(
"{\n", 2);
16296 const auto new_indent = current_indent + indent_step;
16304 o->write_characters(
"\"bytes\": [", 10);
16306 if (!val.m_value.binary->empty())
16308 for (
auto i = val.m_value.binary->cbegin();
16309 i != val.m_value.binary->cend() - 1; ++i)
16312 o->write_characters(
", ", 2);
16314 dump_integer(val.m_value.binary->back());
16317 o->write_characters(
"],\n", 3);
16320 o->write_characters(
"\"subtype\": ", 11);
16321 if (val.m_value.binary->has_subtype())
16323 dump_integer(val.m_value.binary->subtype());
16327 o->write_characters(
"null", 4);
16329 o->write_character(
'\n');
16330 o->write_characters(
indent_string.c_str(), current_indent);
16331 o->write_character(
'}');
16335 o->write_characters(
"{\"bytes\":[", 10);
16337 if (!val.m_value.binary->empty())
16339 for (
auto i = val.m_value.binary->cbegin();
16340 i != val.m_value.binary->cend() - 1; ++i)
16343 o->write_character(
',');
16345 dump_integer(val.m_value.binary->back());
16348 o->write_characters(
"],\"subtype\":", 12);
16349 if (val.m_value.binary->has_subtype())
16351 dump_integer(val.m_value.binary->subtype());
16352 o->write_character(
'}');
16356 o->write_characters(
"null}", 5);
16364 if (val.m_value.boolean)
16366 o->write_characters(
"true", 4);
16370 o->write_characters(
"false", 5);
16377 dump_integer(val.m_value.number_integer);
16383 dump_integer(val.m_value.number_unsigned);
16389 dump_float(val.m_value.number_float);
16395 o->write_characters(
"<discarded>", 11);
16401 o->write_characters(
"null", 4);
16427 std::uint32_t codepoint{};
16435 for (std::size_t i = 0; i < s.size(); ++i)
16437 const auto byte =
static_cast<std::uint8_t
>(s[i]);
16439 switch (decode(
state, codepoint,
byte))
16498 if ((codepoint <= 0x1F) || (
ensure_ascii && (codepoint >= 0x7F)))
16500 if (codepoint <= 0xFFFF)
16504 static_cast<std::uint16_t
>(codepoint)));
16510 static_cast<void>((std::snprintf)(
string_buffer.data() +
bytes, 13,
"\\u%04x\\u%04x",
16511 static_cast<std::uint16_t
>(0xD7C0u + (codepoint >> 10u)),
16512 static_cast<std::uint16_t
>(0xDC00u + (codepoint & 0x3FFu))));
16547 std::stringstream ss;
16548 ss << std::uppercase << std::setfill(
'0') << std::setw(2) << std::hex << (
byte | 0);
16641 std::stringstream ss;
16642 ss << std::uppercase << std::setfill('0') << std::setw(2) << std::hex << (static_cast<std::uint8_t>(s.back()) | 0);
16660 o->write_characters(
"\\ufffd", 6);
16664 o->write_characters(
"\xEF\xBF\xBD", 3);
16686 unsigned int n_digits = 1;
16695 return n_digits + 1;
16699 return n_digits + 2;
16703 return n_digits + 3;
16711 template <typename NumberType, enable_if_t<std::is_signed<NumberType>::value,
int> = 0>
16712 bool is_negative_number(NumberType x)
16717 template < typename NumberType, enable_if_t <std::is_unsigned<NumberType>::value,
int > = 0 >
16718 bool is_negative_number(NumberType )
16733 std::is_integral<NumberType>::value ||
16734 std::is_same<NumberType, number_unsigned_t>::value ||
16735 std::is_same<NumberType, number_integer_t>::value ||
16736 std::is_same<NumberType, binary_char_t>::value,
16738 void dump_integer(NumberType x)
16740 static constexpr std::array<std::array<char, 2>, 100> digits_to_99
16743 {{
'0',
'0'}}, {{
'0',
'1'}}, {{
'0',
'2'}}, {{
'0',
'3'}}, {{
'0',
'4'}}, {{
'0',
'5'}}, {{
'0',
'6'}}, {{
'0',
'7'}}, {{
'0',
'8'}}, {{
'0',
'9'}},
16744 {{
'1',
'0'}}, {{
'1',
'1'}}, {{
'1',
'2'}}, {{
'1',
'3'}}, {{
'1',
'4'}}, {{
'1',
'5'}}, {{
'1',
'6'}}, {{
'1',
'7'}}, {{
'1',
'8'}}, {{
'1',
'9'}},
16745 {{
'2',
'0'}}, {{
'2',
'1'}}, {{
'2',
'2'}}, {{
'2',
'3'}}, {{
'2',
'4'}}, {{
'2',
'5'}}, {{
'2',
'6'}}, {{
'2',
'7'}}, {{
'2',
'8'}}, {{
'2',
'9'}},
16746 {{
'3',
'0'}}, {{
'3',
'1'}}, {{
'3',
'2'}}, {{
'3',
'3'}}, {{
'3',
'4'}}, {{
'3',
'5'}}, {{
'3',
'6'}}, {{
'3',
'7'}}, {{
'3',
'8'}}, {{
'3',
'9'}},
16747 {{
'4',
'0'}}, {{
'4',
'1'}}, {{
'4',
'2'}}, {{
'4',
'3'}}, {{
'4',
'4'}}, {{
'4',
'5'}}, {{
'4',
'6'}}, {{
'4',
'7'}}, {{
'4',
'8'}}, {{
'4',
'9'}},
16748 {{
'5',
'0'}}, {{
'5',
'1'}}, {{
'5',
'2'}}, {{
'5',
'3'}}, {{
'5',
'4'}}, {{
'5',
'5'}}, {{
'5',
'6'}}, {{
'5',
'7'}}, {{
'5',
'8'}}, {{
'5',
'9'}},
16749 {{
'6',
'0'}}, {{
'6',
'1'}}, {{
'6',
'2'}}, {{
'6',
'3'}}, {{
'6',
'4'}}, {{
'6',
'5'}}, {{
'6',
'6'}}, {{
'6',
'7'}}, {{
'6',
'8'}}, {{
'6',
'9'}},
16750 {{
'7',
'0'}}, {{
'7',
'1'}}, {{
'7',
'2'}}, {{
'7',
'3'}}, {{
'7',
'4'}}, {{
'7',
'5'}}, {{
'7',
'6'}}, {{
'7',
'7'}}, {{
'7',
'8'}}, {{
'7',
'9'}},
16751 {{
'8',
'0'}}, {{
'8',
'1'}}, {{
'8',
'2'}}, {{
'8',
'3'}}, {{
'8',
'4'}}, {{
'8',
'5'}}, {{
'8',
'6'}}, {{
'8',
'7'}}, {{
'8',
'8'}}, {{
'8',
'9'}},
16752 {{
'9',
'0'}}, {{
'9',
'1'}}, {{
'9',
'2'}}, {{
'9',
'3'}}, {{
'9',
'4'}}, {{
'9',
'5'}}, {{
'9',
'6'}}, {{
'9',
'7'}}, {{
'9',
'8'}}, {{
'9',
'9'}},
16759 o->write_character(
'0');
16768 unsigned int n_chars{};
16770 if (is_negative_number(x))
16776 n_chars = 1 + count_digits(abs_value);
16781 n_chars = count_digits(abs_value);
16789 buffer_ptr += n_chars;
16793 while (abs_value >= 100)
16795 const auto digits_index =
static_cast<unsigned>((abs_value % 100));
16797 *(--buffer_ptr) = digits_to_99[digits_index][1];
16798 *(--buffer_ptr) = digits_to_99[digits_index][0];
16801 if (abs_value >= 10)
16803 const auto digits_index =
static_cast<unsigned>(abs_value);
16804 *(--buffer_ptr) = digits_to_99[digits_index][1];
16805 *(--buffer_ptr) = digits_to_99[digits_index][0];
16809 *(--buffer_ptr) =
static_cast<char>(
'0' + abs_value);
16826 if (!std::isfinite(x))
16828 o->write_characters(
"null", 4);
16837 static constexpr bool is_ieee_single_or_double
16838 = (std::numeric_limits<number_float_t>::is_iec559 && std::numeric_limits<number_float_t>::digits == 24 && std::numeric_limits<number_float_t>::max_exponent == 128) ||
16839 (std::numeric_limits<number_float_t>::is_iec559 && std::numeric_limits<number_float_t>::digits == 53 && std::numeric_limits<number_float_t>::max_exponent == 1024);
16841 dump_float(x, std::integral_constant<bool, is_ieee_single_or_double>());
16849 o->write_characters(begin,
static_cast<size_t>(end - begin));
16855 static constexpr auto d = std::numeric_limits<number_float_t>::max_digits10;
16887 o->write_characters(
number_buffer.data(),
static_cast<std::size_t
>(len));
16890 const bool value_is_int_like =
16894 return c ==
'.' || c ==
'e';
16897 if (value_is_int_like)
16899 o->write_characters(
".0", 2);
16924 static std::uint8_t decode(std::uint8_t&
state, std::uint32_t& codep,
const std::uint8_t
byte)
noexcept
16926 static const std::array<std::uint8_t, 400> utf8d =
16929 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
16930 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
16931 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
16932 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
16933 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,
16934 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
16935 8, 8, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
16936 0xA, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x4, 0x3, 0x3,
16937 0xB, 0x6, 0x6, 0x6, 0x5, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8,
16938 0x0, 0x1, 0x2, 0x3, 0x5, 0x8, 0x7, 0x1, 0x1, 0x1, 0x4, 0x6, 0x1, 0x1, 0x1, 0x1,
16939 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1,
16940 1, 2, 1, 1, 1, 1, 1, 2, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1,
16941 1, 2, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 1, 3, 1, 1, 1, 1, 1, 1,
16942 1, 3, 1, 1, 1, 1, 1, 3, 1, 3, 1, 1, 1, 1, 1, 1, 1, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
16947 const std::uint8_t type = utf8d[byte];
16950 ? (
byte & 0x3fu) | (codep << 6u)
16951 : (0xFFu >> type) & (byte);
16953 std::size_t index = 256u +
static_cast<size_t>(
state) * 16u +
static_cast<size_t>(type);
16955 state = utf8d[index];
16981 JSON_ASSERT(x < 0 && x < (std::numeric_limits<number_integer_t>::max)());
16987 output_adapter_t<char> o =
nullptr;
17020#include <functional>
17021#include <initializer_list>
17024#include <stdexcept>
17025#include <type_traits>
17037template <
class Key,
class T,
class IgnoredLess = std::less<Key>,
17038 class Allocator = std::allocator<std::pair<const Key, T>>>
17043 using Container = std::vector<std::pair<const Key, T>, Allocator>;
17052 template <
class It>
17055 ordered_map(std::initializer_list<T> init,
const Allocator& alloc = Allocator() )
17060 for (
auto it = this->begin(); it != this->end(); ++it)
17062 if (it->first == key)
17064 return {it,
false};
17067 Container::emplace_back(key, t);
17068 return {--this->end(),
true};
17073 return emplace(key, T{}).first->second;
17083 for (
auto it = this->begin(); it != this->end(); ++it)
17085 if (it->first == key)
17091 JSON_THROW(std::out_of_range(
"key not found"));
17094 const T&
at(
const Key& key)
const
17096 for (
auto it = this->begin(); it != this->end(); ++it)
17098 if (it->first == key)
17104 JSON_THROW(std::out_of_range(
"key not found"));
17109 for (
auto it = this->begin(); it != this->end(); ++it)
17111 if (it->first == key)
17114 for (
auto next = it; ++next != this->end(); ++it)
17119 Container::pop_back();
17128 return erase(pos, std::next(pos));
17133 const auto elements_affected = std::distance(first, last);
17134 const auto offset = std::distance(Container::begin(), first);
17156 for (
auto it = first; std::next(it, elements_affected) != Container::end(); ++it)
17159 new (&*it)
value_type{std::move(*std::next(it, elements_affected))};
17167 Container::resize(this->size() -
static_cast<size_type>(elements_affected));
17176 return Container::begin() + offset;
17181 for (
auto it = this->begin(); it != this->end(); ++it)
17183 if (it->first == key)
17193 for (
auto it = this->begin(); it != this->end(); ++it)
17195 if (it->first == key)
17200 return Container::end();
17205 for (
auto it = this->begin(); it != this->end(); ++it)
17207 if (it->first == key)
17212 return Container::end();
17217 return emplace(value.first, std::move(value.second));
17222 for (
auto it = this->begin(); it != this->end(); ++it)
17224 if (it->first == value.first)
17226 return {it,
false};
17229 Container::push_back(value);
17230 return {--this->end(),
true};
17233 template<
typename InputIt>
17234 using require_input_iter =
typename std::enable_if<std::is_convertible<typename std::iterator_traits<InputIt>::iterator_category,
17235 std::input_iterator_tag>::value>::type;
17237 template<
typename InputIt,
typename = require_input_iter<InputIt>>
17240 for (
auto it = first; it != last; ++it)
17250#if defined(JSON_HAS_CPP_17)
17251 #include <string_view>
17285 friend ::nlohmann::json_pointer<basic_json>;
17287 template<
typename BasicJsonType,
typename InputType>
17288 friend class ::nlohmann::detail::parser;
17289 friend ::nlohmann::detail::serializer<basic_json>;
17290 template<
typename BasicJsonType>
17291 friend class ::nlohmann::detail::iter_impl;
17292 template<
typename BasicJsonType,
typename CharType>
17293 friend class ::nlohmann::detail::binary_writer;
17294 template<
typename BasicJsonType,
typename InputType,
typename SAX>
17295 friend class ::nlohmann::detail::binary_reader;
17296 template<
typename BasicJsonType>
17297 friend class ::nlohmann::detail::json_sax_dom_parser;
17298 template<
typename BasicJsonType>
17299 friend class ::nlohmann::detail::json_sax_dom_callback_parser;
17300 friend class ::nlohmann::detail::exception;
17309 template<
typename InputAdapterType>
17310 static ::nlohmann::detail::parser<basic_json, InputAdapterType>
parser(
17311 InputAdapterType adapter,
17313 const bool allow_exceptions =
true,
17314 const bool ignore_comments =
false
17317 return ::nlohmann::detail::parser<basic_json, InputAdapterType>(std::move(adapter),
17318 std::move(cb), allow_exceptions, ignore_comments);
17323 template<
typename BasicJsonType>
17325 template<
typename BasicJsonType>
17327 template<
typename Iterator>
17331 template<
typename CharType>
17334 template<
typename InputType>
17345 template<
typename T,
typename SFINAE>
17402 using pointer =
typename std::allocator_traits<allocator_type>::pointer;
17404 using const_pointer =
typename std::allocator_traits<allocator_type>::const_pointer;
17432 result[
"copyright"] =
"(C) 2013-2022 Niels Lohmann";
17433 result[
"name"] =
"JSON for Modern C++";
17434 result[
"url"] =
"https://github.com/nlohmann/json";
17435 result[
"version"][
"string"] =
17444 result[
"platform"] =
"win32";
17445#elif defined __linux__
17446 result[
"platform"] =
"linux";
17447#elif defined __APPLE__
17448 result[
"platform"] =
"apple";
17449#elif defined __unix__
17450 result[
"platform"] =
"unix";
17452 result[
"platform"] =
"unknown";
17455#if defined(__ICC) || defined(__INTEL_COMPILER)
17456 result[
"compiler"] = {{
"family",
"icc"}, {
"version", __INTEL_COMPILER}};
17457#elif defined(__clang__)
17458 result[
"compiler"] = {{
"family",
"clang"}, {
"version", __clang_version__}};
17459#elif defined(__GNUC__) || defined(__GNUG__)
17460 result[
"compiler"] = {{
"family",
"gcc"}, {
"version", std::to_string(__GNUC__) +
"." + std::to_string(__GNUC_MINOR__) +
"." + std::to_string(__GNUC_PATCHLEVEL__)}};
17461#elif defined(__HP_cc) || defined(__HP_aCC)
17462 result[
"compiler"] =
"hp"
17463#elif defined(__IBMCPP__)
17464 result[
"compiler"] = {{
"family",
"ilecpp"}, {
"version", __IBMCPP__}};
17465#elif defined(_MSC_VER)
17466 result[
"compiler"] = {{
"family",
"msvc"}, {
"version", _MSC_VER}};
17467#elif defined(__PGI)
17468 result[
"compiler"] = {{
"family",
"pgcpp"}, {
"version", __PGI}};
17469#elif defined(__SUNPRO_CC)
17470 result[
"compiler"] = {{
"family",
"sunpro"}, {
"version", __SUNPRO_CC}};
17472 result[
"compiler"] = {{
"family",
"unknown"}, {
"version",
"unknown"}};
17476 result[
"compiler"][
"c++"] = std::to_string(__cplusplus);
17478 result[
"compiler"][
"c++"] =
"unknown";
17495#if defined(JSON_HAS_CPP_14)
17508 AllocatorType<std::pair<
const StringType,
17513 using array_t = ArrayType<basic_json, AllocatorType<basic_json>>;
17544 template<
typename T,
typename... Args>
17548 AllocatorType<T> alloc;
17549 using AllocatorTraits = std::allocator_traits<AllocatorType<T>>;
17551 auto deleter = [&](T * obj)
17553 AllocatorTraits::deallocate(alloc, obj, 1);
17555 std::unique_ptr<T,
decltype(deleter)> obj(AllocatorTraits::allocate(alloc, 1), deleter);
17556 AllocatorTraits::construct(alloc, obj.get(), std::forward<Args>(args)...);
17558 return obj.release();
17625 case value_t::object:
17627 object = create<object_t>();
17631 case value_t::array:
17633 array = create<array_t>();
17637 case value_t::string:
17639 string = create<string_t>(
"");
17643 case value_t::binary:
17645 binary = create<binary_t>();
17649 case value_t::boolean:
17651 boolean =
static_cast<boolean_t>(
false);
17655 case value_t::number_integer:
17661 case value_t::number_unsigned:
17667 case value_t::number_float:
17673 case value_t::null:
17679 case value_t::discarded:
17724 if (t == value_t::array || t == value_t::object)
17727 std::vector<basic_json> stack;
17730 if (t == value_t::array)
17732 stack.reserve(
array->size());
17733 std::move(
array->begin(),
array->end(), std::back_inserter(stack));
17738 for (
auto&& it : *
object)
17740 stack.push_back(std::move(it.second));
17744 while (!stack.empty())
17747 basic_json current_item(std::move(stack.back()));
17754 std::move(current_item.
m_value.array->begin(), current_item.
m_value.array->end(), std::back_inserter(stack));
17756 current_item.
m_value.array->clear();
17760 for (
auto&& it : *current_item.
m_value.object)
17762 stack.push_back(std::move(it.second));
17765 current_item.
m_value.object->clear();
17775 case value_t::object:
17777 AllocatorType<object_t> alloc;
17778 std::allocator_traits<
decltype(alloc)>
::destroy(alloc,
object);
17779 std::allocator_traits<
decltype(alloc)>::deallocate(alloc,
object, 1);
17783 case value_t::array:
17785 AllocatorType<array_t> alloc;
17787 std::allocator_traits<
decltype(alloc)>::deallocate(alloc,
array, 1);
17791 case value_t::string:
17793 AllocatorType<string_t> alloc;
17794 std::allocator_traits<
decltype(alloc)>
::destroy(alloc,
string);
17795 std::allocator_traits<
decltype(alloc)>::deallocate(alloc,
string, 1);
17799 case value_t::binary:
17801 AllocatorType<binary_t> alloc;
17803 std::allocator_traits<
decltype(alloc)>::deallocate(alloc,
binary, 1);
17807 case value_t::null:
17808 case value_t::boolean:
17809 case value_t::number_integer:
17810 case value_t::number_unsigned:
17811 case value_t::number_float:
17812 case value_t::discarded:
17847#if JSON_DIAGNOSTICS
17853 return j.m_parent ==
this;
17858 static_cast<void>(check_parents);
17863#if JSON_DIAGNOSTICS
17866 case value_t::array:
17868 for (
auto& element : *
m_value.array)
17870 element.m_parent =
this;
17875 case value_t::object:
17877 for (
auto& element : *
m_value.object)
17879 element.second.m_parent =
this;
17884 case value_t::null:
17885 case value_t::string:
17886 case value_t::boolean:
17887 case value_t::number_integer:
17888 case value_t::number_unsigned:
17889 case value_t::number_float:
17890 case value_t::binary:
17891 case value_t::discarded:
17900#if JSON_DIAGNOSTICS
17903 (it + i)->m_parent =
this;
17906 static_cast<void>(count_set_parents);
17913#if JSON_DIAGNOSTICS
17914 if (old_capacity !=
static_cast<std::size_t
>(-1))
17928#ifdef JSON_HEDLEY_MSVC_VERSION
17929#pragma warning(push )
17930#pragma warning(disable : 4127)
17937#ifdef JSON_HEDLEY_MSVC_VERSION
17938#pragma warning( pop )
17943 static_cast<void>(j);
17944 static_cast<void>(old_capacity);
17989 template <
typename CompatibleType,
17994 JSONSerializer<U>::to_json(std::declval<basic_json_t&>(),
17995 std::forward<CompatibleType>(val))))
17997 JSONSerializer<U>::to_json(*
this, std::forward<CompatibleType>(val));
18004 template <
typename BasicJsonType,
18009 using other_boolean_t =
typename BasicJsonType::boolean_t;
18010 using other_number_float_t =
typename BasicJsonType::number_float_t;
18011 using other_number_integer_t =
typename BasicJsonType::number_integer_t;
18012 using other_number_unsigned_t =
typename BasicJsonType::number_unsigned_t;
18013 using other_string_t =
typename BasicJsonType::string_t;
18014 using other_object_t =
typename BasicJsonType::object_t;
18015 using other_array_t =
typename BasicJsonType::array_t;
18016 using other_binary_t =
typename BasicJsonType::binary_t;
18018 switch (val.type())
18020 case value_t::boolean:
18021 JSONSerializer<other_boolean_t>::to_json(*
this, val.template get<other_boolean_t>());
18023 case value_t::number_float:
18024 JSONSerializer<other_number_float_t>::to_json(*
this, val.template get<other_number_float_t>());
18026 case value_t::number_integer:
18027 JSONSerializer<other_number_integer_t>::to_json(*
this, val.template get<other_number_integer_t>());
18029 case value_t::number_unsigned:
18030 JSONSerializer<other_number_unsigned_t>::to_json(*
this, val.template get<other_number_unsigned_t>());
18032 case value_t::string:
18033 JSONSerializer<other_string_t>::to_json(*
this, val.template get_ref<const other_string_t&>());
18035 case value_t::object:
18036 JSONSerializer<other_object_t>::to_json(*
this, val.template get_ref<const other_object_t&>());
18038 case value_t::array:
18039 JSONSerializer<other_array_t>::to_json(*
this, val.template get_ref<const other_array_t&>());
18041 case value_t::binary:
18042 JSONSerializer<other_binary_t>::to_json(*
this, val.template get_ref<const other_binary_t&>());
18044 case value_t::null:
18047 case value_t::discarded:
18048 m_type = value_t::discarded;
18060 bool type_deduction =
true,
18061 value_t manual_type = value_t::array)
18065 bool is_an_object = std::all_of(init.begin(), init.end(),
18068 return element_ref->is_array() && element_ref->size() == 2 && (*element_ref)[0].is_string();
18072 if (!type_deduction)
18075 if (manual_type == value_t::array)
18077 is_an_object =
false;
18090 m_type = value_t::object;
18093 for (
auto& element_ref : init)
18097 std::move(*((*element.m_value.array)[0].m_value.string)),
18098 std::move((*element.m_value.array)[1]));
18104 m_type = value_t::array;
18105 m_value.array = create<array_t>(init.begin(), init.end());
18118 res.m_type = value_t::binary;
18119 res.m_value = init;
18129 res.m_type = value_t::binary;
18130 res.m_value =
binary_t(init, subtype);
18140 res.m_type = value_t::binary;
18141 res.m_value = std::move(init);
18151 res.m_type = value_t::binary;
18152 res.m_value =
binary_t(std::move(init), subtype);
18161 return basic_json(init,
false, value_t::array);
18169 return basic_json(init,
false, value_t::object);
18177 m_value.array = create<array_t>(cnt, val);
18184 template <
class InputIT,
typename std::enable_if <
18185 std::is_same<InputIT, typename basic_json_t::iterator>::value ||
18186 std::is_same<InputIT, typename basic_json_t::const_iterator>::value,
int >
::type = 0 >
18199 m_type = first.m_object->m_type;
18204 case value_t::boolean:
18205 case value_t::number_float:
18206 case value_t::number_integer:
18207 case value_t::number_unsigned:
18208 case value_t::string:
18211 || !last.m_it.primitive_iterator.is_end()))
18218 case value_t::null:
18219 case value_t::object:
18220 case value_t::array:
18221 case value_t::binary:
18222 case value_t::discarded:
18229 case value_t::number_integer:
18231 m_value.number_integer = first.m_object->m_value.number_integer;
18235 case value_t::number_unsigned:
18237 m_value.number_unsigned = first.m_object->m_value.number_unsigned;
18241 case value_t::number_float:
18243 m_value.number_float = first.m_object->m_value.number_float;
18247 case value_t::boolean:
18249 m_value.boolean = first.m_object->m_value.boolean;
18253 case value_t::string:
18255 m_value = *first.m_object->m_value.string;
18259 case value_t::object:
18261 m_value.object = create<object_t>(first.m_it.object_iterator,
18262 last.m_it.object_iterator);
18266 case value_t::array:
18268 m_value.array = create<array_t>(first.m_it.array_iterator,
18269 last.m_it.array_iterator);
18273 case value_t::binary:
18275 m_value = *first.m_object->m_value.binary;
18279 case value_t::null:
18280 case value_t::discarded:
18294 template<
typename JsonRef,
18296 std::is_same<typename JsonRef::value_type, basic_json>>
::value,
int> = 0 >
18302 : m_type(other.m_type)
18309 case value_t::object:
18315 case value_t::array:
18321 case value_t::string:
18327 case value_t::boolean:
18333 case value_t::number_integer:
18339 case value_t::number_unsigned:
18345 case value_t::number_float:
18351 case value_t::binary:
18357 case value_t::null:
18358 case value_t::discarded:
18370 : m_type(std::move(other.m_type)),
18371 m_value(std::move(other.m_value))
18374 other.assert_invariant(
false);
18377 other.m_type = value_t::null;
18378 other.m_value = {};
18387 std::is_nothrow_move_constructible<value_t>::value&&
18388 std::is_nothrow_move_assignable<value_t>::value&&
18389 std::is_nothrow_move_constructible<json_value>::value&&
18390 std::is_nothrow_move_assignable<json_value>::value
18397 swap(m_type, other.m_type);
18427 const char indent_char =
' ',
18428 const bool ensure_ascii =
false,
18436 s.dump(*
this,
true, ensure_ascii,
static_cast<unsigned int>(indent));
18440 s.dump(*
this,
false, ensure_ascii, 0);
18471 return m_type == value_t::null;
18478 return m_type == value_t::boolean;
18492 return m_type == value_t::number_integer || m_type == value_t::number_unsigned;
18499 return m_type == value_t::number_unsigned;
18506 return m_type == value_t::number_float;
18513 return m_type == value_t::object;
18520 return m_type == value_t::array;
18527 return m_type == value_t::string;
18534 return m_type == value_t::binary;
18541 return m_type == value_t::discarded;
18676 template<
typename ReferenceType,
typename ThisType>
18680 auto* ptr = obj.template get_ptr<typename std::add_pointer<ReferenceType>::type>();
18697 template<
typename PointerType,
typename std::enable_if<
18698 std::is_pointer<PointerType>::value,
int>
::type = 0>
18702 return get_impl_ptr(
static_cast<PointerType
>(
nullptr));
18707 template <
typename PointerType,
typename std::enable_if <
18708 std::is_pointer<PointerType>::value&&
18709 std::is_const<typename std::remove_pointer<PointerType>::type>
::value,
int >
::type = 0 >
18713 return get_impl_ptr(
static_cast<PointerType
>(
nullptr));
18755 template <
typename ValueType,
18761 JSONSerializer<ValueType>::from_json(std::declval<const basic_json_t&>(), std::declval<ValueType&>())))
18763 auto ret = ValueType();
18764 JSONSerializer<ValueType>::from_json(*
this, ret);
18798 template <
typename ValueType,
18803 JSONSerializer<ValueType>::from_json(std::declval<const basic_json_t&>())))
18805 return JSONSerializer<ValueType>::from_json(*
this);
18823 template <
typename BasicJsonType,
18846 template<
typename BasicJsonType,
18848 std::is_same<BasicJsonType, basic_json_t>::value,
18859 template<
typename PointerType,
18861 std::is_pointer<PointerType>::value,
18864 ->
decltype(std::declval<const basic_json_t&>().template get_ptr<PointerType>())
18867 return get_ptr<PointerType>();
18894 template <
typename ValueTypeCV,
typename ValueType = detail::uncvref_t<ValueTypeCV>>
18895#if defined(JSON_HAS_CPP_14)
18905 static_assert(!std::is_reference<ValueTypeCV>::value,
18906 "get() cannot be used with reference types, you might want to use get_ref()");
18907 return get_impl<ValueType>(detail::priority_tag<4> {});
18937 template<
typename PointerType,
typename std::enable_if<
18938 std::is_pointer<PointerType>::value,
int>
::type = 0>
18942 return get_ptr<PointerType>();
18947 template <
typename ValueType,
18952 ValueType &
get_to(ValueType& v)
const noexcept(
noexcept(
18953 JSONSerializer<ValueType>::from_json(std::declval<const basic_json_t&>(), v)))
18955 JSONSerializer<ValueType>::from_json(*
this, v);
18961 template<
typename ValueType,
18972 typename T, std::size_t N,
18973 typename Array = T (&)[N],
18977 noexcept(
noexcept(JSONSerializer<Array>::from_json(
18978 std::declval<const basic_json_t&>(), v)))
18980 JSONSerializer<Array>::from_json(*
this, v);
18986 template<
typename ReferenceType,
typename std::enable_if<
18987 std::is_reference<ReferenceType>::value,
int>
::type = 0>
18991 return get_ref_impl<ReferenceType>(*
this);
18996 template <
typename ReferenceType,
typename std::enable_if <
18997 std::is_reference<ReferenceType>::value&&
18998 std::is_const<typename std::remove_reference<ReferenceType>::type>
::value,
int >
::type = 0 >
19002 return get_ref_impl<ReferenceType>(*
this);
19034 template <
typename ValueType,
typename std::enable_if <
19042#if defined(JSON_HAS_CPP_17) && (defined(__GNUC__) || (defined(_MSC_VER) && _MSC_VER >= 1910 && _MSC_VER <= 1914))
19050 return get<ValueType>();
19062 return *get_ptr<binary_t*>();
19074 return *get_ptr<const binary_t*>();
19187 m_type = value_t::array;
19196 if (idx >=
m_value.array->size())
19198#if JSON_DIAGNOSTICS
19200 const auto old_size =
m_value.array->size();
19201 const auto old_capacity =
m_value.array->capacity();
19203 m_value.array->resize(idx + 1);
19205#if JSON_DIAGNOSTICS
19220 return m_value.array->operator[](idx);
19246 m_type = value_t::object;
19268 return m_value.object->find(key)->second;
19276 template<
typename T>
19283 m_type = value_t::object;
19299 template<
typename T>
19307 return m_value.object->find(key)->second;
19316 template <
class ValueType,
typename std::enable_if <
19318 && !std::is_same<value_t, ValueType>::value,
int >
::type = 0 >
19319 ValueType
value(
const typename object_t::key_type& key,
const ValueType& default_value)
const
19325 const auto it =
find(key);
19328 return it->template get<ValueType>();
19331 return default_value;
19340 string_t value(
const typename object_t::key_type& key,
const char* default_value)
const
19347 template<
class ValueType,
typename std::enable_if<
19357 return ptr.
get_checked(
this).template get<ValueType>();
19361 return default_value;
19411 template <
class IteratorType,
typename std::enable_if <
19412 std::is_same<IteratorType, typename basic_json_t::iterator>::value ||
19413 std::is_same<IteratorType, typename basic_json_t::const_iterator>::value,
int >
::type
19423 IteratorType result =
end();
19427 case value_t::boolean:
19428 case value_t::number_float:
19429 case value_t::number_integer:
19430 case value_t::number_unsigned:
19431 case value_t::string:
19432 case value_t::binary:
19441 AllocatorType<string_t> alloc;
19443 std::allocator_traits<
decltype(alloc)>::deallocate(alloc,
m_value.string, 1);
19448 AllocatorType<binary_t> alloc;
19450 std::allocator_traits<
decltype(alloc)>::deallocate(alloc,
m_value.binary, 1);
19454 m_type = value_t::null;
19459 case value_t::object:
19461 result.m_it.object_iterator =
m_value.object->erase(pos.m_it.object_iterator);
19465 case value_t::array:
19467 result.m_it.array_iterator =
m_value.array->erase(pos.m_it.array_iterator);
19471 case value_t::null:
19472 case value_t::discarded:
19482 template <
class IteratorType,
typename std::enable_if <
19483 std::is_same<IteratorType, typename basic_json_t::iterator>::value ||
19484 std::is_same<IteratorType, typename basic_json_t::const_iterator>::value,
int >
::type
19486 IteratorType
erase(IteratorType first, IteratorType last)
19494 IteratorType result =
end();
19498 case value_t::boolean:
19499 case value_t::number_float:
19500 case value_t::number_integer:
19501 case value_t::number_unsigned:
19502 case value_t::string:
19503 case value_t::binary:
19506 || !last.m_it.primitive_iterator.is_end()))
19513 AllocatorType<string_t> alloc;
19515 std::allocator_traits<
decltype(alloc)>::deallocate(alloc,
m_value.string, 1);
19520 AllocatorType<binary_t> alloc;
19522 std::allocator_traits<
decltype(alloc)>::deallocate(alloc,
m_value.binary, 1);
19526 m_type = value_t::null;
19531 case value_t::object:
19533 result.m_it.object_iterator =
m_value.object->erase(first.m_it.object_iterator,
19534 last.m_it.object_iterator);
19538 case value_t::array:
19540 result.m_it.array_iterator =
m_value.array->erase(first.m_it.array_iterator,
19541 last.m_it.array_iterator);
19545 case value_t::null:
19546 case value_t::discarded:
19561 return m_value.object->erase(key);
19599 template<
typename KeyT>
19602 auto result =
end();
19606 result.m_it.object_iterator =
m_value.object->find(std::forward<KeyT>(key));
19614 template<
typename KeyT>
19617 auto result =
cend();
19621 result.m_it.object_iterator =
m_value.object->find(std::forward<KeyT>(key));
19629 template<
typename KeyT>
19638 template <
typename KeyT,
typename std::enable_if <
19667 result.set_begin();
19683 result.set_begin();
19763 return ref.items();
19774 return ref.items();
19807 case value_t::null:
19813 case value_t::array:
19816 return m_value.array->empty();
19819 case value_t::object:
19822 return m_value.object->empty();
19825 case value_t::string:
19826 case value_t::boolean:
19827 case value_t::number_integer:
19828 case value_t::number_unsigned:
19829 case value_t::number_float:
19830 case value_t::binary:
19831 case value_t::discarded:
19846 case value_t::null:
19852 case value_t::array:
19855 return m_value.array->size();
19858 case value_t::object:
19861 return m_value.object->size();
19864 case value_t::string:
19865 case value_t::boolean:
19866 case value_t::number_integer:
19867 case value_t::number_unsigned:
19868 case value_t::number_float:
19869 case value_t::binary:
19870 case value_t::discarded:
19885 case value_t::array:
19888 return m_value.array->max_size();
19891 case value_t::object:
19894 return m_value.object->max_size();
19897 case value_t::null:
19898 case value_t::string:
19899 case value_t::boolean:
19900 case value_t::number_integer:
19901 case value_t::number_unsigned:
19902 case value_t::number_float:
19903 case value_t::binary:
19904 case value_t::discarded:
19929 case value_t::number_integer:
19935 case value_t::number_unsigned:
19941 case value_t::number_float:
19947 case value_t::boolean:
19953 case value_t::string:
19959 case value_t::binary:
19965 case value_t::array:
19971 case value_t::object:
19977 case value_t::null:
19978 case value_t::discarded:
19997 m_type = value_t::array;
20003 const auto old_capacity =
m_value.array->capacity();
20004 m_value.array->push_back(std::move(val));
20030 m_type = value_t::array;
20036 const auto old_capacity =
m_value.array->capacity();
20037 m_value.array->push_back(val);
20062 m_type = value_t::object;
20068 auto res =
m_value.object->insert(val);
20084 if (
is_object() && init.size() == 2 && (*init.begin())->is_string())
20086 basic_json&& key = init.begin()->moved_or_copied();
20087 push_back(
typename object_t::value_type(
20088 std::move(key.get_ref<
string_t&>()), (init.begin() + 1)->moved_or_copied()));
20106 template<
class... Args>
20118 m_type = value_t::array;
20124 const auto old_capacity =
m_value.array->capacity();
20125 m_value.array->emplace_back(std::forward<Args>(args)...);
20131 template<
class... Args>
20143 m_type = value_t::object;
20149 auto res =
m_value.object->emplace(std::forward<Args>(args)...);
20154 it.m_it.object_iterator = res.first;
20157 return {it, res.second};
20163 template<
typename... Args>
20205 return insert(pos, val);
20318 m_type = value_t::object;
20319 m_value.object = create<object_t>();
20340 for (
auto it = first; it != last; ++it)
20342 if (merge_objects && it.value().is_object())
20344 auto it2 =
m_value.object->find(it.key());
20345 if (it2 !=
m_value.object->end())
20347 it2->second.update(it.value(),
true);
20351 m_value.object->operator[](it.key()) = it.value();
20352#if JSON_DIAGNOSTICS
20353 m_value.object->operator[](it.key()).m_parent =
this;
20361 std::is_nothrow_move_constructible<value_t>::value&&
20362 std::is_nothrow_move_assignable<value_t>::value&&
20363 std::is_nothrow_move_constructible<json_value>::value&&
20364 std::is_nothrow_move_assignable<json_value>::value
20371 other.set_parents();
20378 std::is_nothrow_move_constructible<value_t>::value&&
20379 std::is_nothrow_move_assignable<value_t>::value&&
20380 std::is_nothrow_move_constructible<json_value>::value&&
20381 std::is_nothrow_move_assignable<json_value>::value
20477#pragma GCC diagnostic push
20478#pragma GCC diagnostic ignored "-Wfloat-equal"
20480 const auto lhs_type = lhs.type();
20481 const auto rhs_type = rhs.type();
20483 if (lhs_type == rhs_type)
20487 case value_t::array:
20488 return *lhs.m_value.array == *rhs.m_value.array;
20490 case value_t::object:
20491 return *lhs.m_value.object == *rhs.m_value.object;
20493 case value_t::null:
20496 case value_t::string:
20497 return *lhs.m_value.string == *rhs.m_value.string;
20499 case value_t::boolean:
20500 return lhs.m_value.boolean == rhs.m_value.boolean;
20502 case value_t::number_integer:
20503 return lhs.m_value.number_integer == rhs.m_value.number_integer;
20505 case value_t::number_unsigned:
20506 return lhs.m_value.number_unsigned == rhs.m_value.number_unsigned;
20508 case value_t::number_float:
20509 return lhs.m_value.number_float == rhs.m_value.number_float;
20511 case value_t::binary:
20512 return *lhs.m_value.binary == *rhs.m_value.binary;
20514 case value_t::discarded:
20519 else if (lhs_type == value_t::number_integer && rhs_type == value_t::number_float)
20521 return static_cast<number_float_t>(lhs.m_value.number_integer) == rhs.m_value.number_float;
20523 else if (lhs_type == value_t::number_float && rhs_type == value_t::number_integer)
20525 return lhs.m_value.number_float ==
static_cast<number_float_t>(rhs.m_value.number_integer);
20527 else if (lhs_type == value_t::number_unsigned && rhs_type == value_t::number_float)
20529 return static_cast<number_float_t>(lhs.m_value.number_unsigned) == rhs.m_value.number_float;
20531 else if (lhs_type == value_t::number_float && rhs_type == value_t::number_unsigned)
20533 return lhs.m_value.number_float ==
static_cast<number_float_t>(rhs.m_value.number_unsigned);
20535 else if (lhs_type == value_t::number_unsigned && rhs_type == value_t::number_integer)
20537 return static_cast<number_integer_t>(lhs.m_value.number_unsigned) == rhs.m_value.number_integer;
20539 else if (lhs_type == value_t::number_integer && rhs_type == value_t::number_unsigned)
20541 return lhs.m_value.number_integer ==
static_cast<number_integer_t>(rhs.m_value.number_unsigned);
20546#pragma GCC diagnostic pop
20552 template<
typename ScalarType,
typename std::enable_if<
20553 std::is_scalar<ScalarType>::value,
int>
::type = 0>
20561 template<
typename ScalarType,
typename std::enable_if<
20562 std::is_scalar<ScalarType>::value,
int>
::type = 0>
20572 return !(lhs == rhs);
20577 template<
typename ScalarType,
typename std::enable_if<
20578 std::is_scalar<ScalarType>::value,
int>
::type = 0>
20586 template<
typename ScalarType,
typename std::enable_if<
20587 std::is_scalar<ScalarType>::value,
int>
::type = 0>
20597 const auto lhs_type = lhs.type();
20598 const auto rhs_type = rhs.type();
20600 if (lhs_type == rhs_type)
20604 case value_t::array:
20607 return (*lhs.m_value.array) < (*rhs.m_value.array);
20609 case value_t::object:
20610 return (*lhs.m_value.object) < (*rhs.m_value.object);
20612 case value_t::null:
20615 case value_t::string:
20616 return (*lhs.m_value.string) < (*rhs.m_value.string);
20618 case value_t::boolean:
20619 return (lhs.m_value.boolean) < (rhs.m_value.boolean);
20621 case value_t::number_integer:
20622 return (lhs.m_value.number_integer) < (rhs.m_value.number_integer);
20624 case value_t::number_unsigned:
20625 return (lhs.m_value.number_unsigned) < (rhs.m_value.number_unsigned);
20627 case value_t::number_float:
20628 return (lhs.m_value.number_float) < (rhs.m_value.number_float);
20630 case value_t::binary:
20631 return (*lhs.m_value.binary) < (*rhs.m_value.binary);
20633 case value_t::discarded:
20638 else if (lhs_type == value_t::number_integer && rhs_type == value_t::number_float)
20640 return static_cast<number_float_t>(lhs.m_value.number_integer) < rhs.m_value.number_float;
20642 else if (lhs_type == value_t::number_float && rhs_type == value_t::number_integer)
20644 return lhs.m_value.number_float <
static_cast<number_float_t>(rhs.m_value.number_integer);
20646 else if (lhs_type == value_t::number_unsigned && rhs_type == value_t::number_float)
20648 return static_cast<number_float_t>(lhs.m_value.number_unsigned) < rhs.m_value.number_float;
20650 else if (lhs_type == value_t::number_float && rhs_type == value_t::number_unsigned)
20652 return lhs.m_value.number_float <
static_cast<number_float_t>(rhs.m_value.number_unsigned);
20654 else if (lhs_type == value_t::number_integer && rhs_type == value_t::number_unsigned)
20656 return lhs.m_value.number_integer <
static_cast<number_integer_t>(rhs.m_value.number_unsigned);
20658 else if (lhs_type == value_t::number_unsigned && rhs_type == value_t::number_integer)
20660 return static_cast<number_integer_t>(lhs.m_value.number_unsigned) < rhs.m_value.number_integer;
20671 template<
typename ScalarType,
typename std::enable_if<
20672 std::is_scalar<ScalarType>::value,
int>
::type = 0>
20680 template<
typename ScalarType,
typename std::enable_if<
20681 std::is_scalar<ScalarType>::value,
int>
::type = 0>
20691 return !(rhs < lhs);
20696 template<
typename ScalarType,
typename std::enable_if<
20697 std::is_scalar<ScalarType>::value,
int>
::type = 0>
20705 template<
typename ScalarType,
typename std::enable_if<
20706 std::is_scalar<ScalarType>::value,
int>
::type = 0>
20716 return !(lhs <= rhs);
20721 template<
typename ScalarType,
typename std::enable_if<
20722 std::is_scalar<ScalarType>::value,
int>
::type = 0>
20730 template<
typename ScalarType,
typename std::enable_if<
20731 std::is_scalar<ScalarType>::value,
int>
::type = 0>
20741 return !(lhs < rhs);
20746 template<
typename ScalarType,
typename std::enable_if<
20747 std::is_scalar<ScalarType>::value,
int>
::type = 0>
20755 template<
typename ScalarType,
typename std::enable_if<
20756 std::is_scalar<ScalarType>::value,
int>
::type = 0>
20776 const bool pretty_print = o.width() > 0;
20777 const auto indentation = pretty_print ? o.width() : 0;
20784 s.dump(j, pretty_print,
false,
static_cast<unsigned int>(indentation));
20812 template<
typename InputType>
20816 const bool allow_exceptions =
true,
20817 const bool ignore_comments =
false)
20826 template<
typename IteratorType>
20831 const bool allow_exceptions =
true,
20832 const bool ignore_comments =
false)
20843 const
bool allow_exceptions = true,
20844 const
bool ignore_comments = false)
20847 parser(i.get(), cb, allow_exceptions, ignore_comments).parse(
true, result);
20853 template<
typename InputType>
20855 const bool ignore_comments =
false)
20862 template<
typename IteratorType>
20863 static bool accept(IteratorType first, IteratorType last,
20864 const bool ignore_comments =
false)
20871 static
bool accept(detail::span_input_adapter&& i,
20872 const
bool ignore_comments = false)
20874 return parser(i.get(),
nullptr,
false, ignore_comments).accept(
true);
20879 template <
typename InputType,
typename SAX>
20883 const
bool strict = true,
20884 const
bool ignore_comments = false)
20887 return format == input_format_t::json
20888 ?
parser(std::move(ia),
nullptr,
true, ignore_comments).sax_parse(sax, strict)
20894 template<
class IteratorType,
class SAX>
20896 static
bool sax_parse(IteratorType first, IteratorType last, SAX* sax,
20898 const
bool strict = true,
20899 const
bool ignore_comments = false)
20902 return format == input_format_t::json
20903 ?
parser(std::move(ia),
nullptr,
true, ignore_comments).sax_parse(sax, strict)
20912 template <
typename SAX>
20917 const
bool strict = true,
20918 const
bool ignore_comments = false)
20921 return format == input_format_t::json
20923 ?
parser(std::move(ia),
nullptr,
true, ignore_comments).sax_parse(sax, strict)
20961 case value_t::null:
20963 case value_t::object:
20965 case value_t::array:
20967 case value_t::string:
20969 case value_t::boolean:
20971 case value_t::binary:
20973 case value_t::discarded:
20974 return "discarded";
20975 case value_t::number_integer:
20976 case value_t::number_unsigned:
20977 case value_t::number_float:
20990 value_t m_type = value_t::null;
20995#if JSON_DIAGNOSTICS
21012 std::vector<std::uint8_t> result;
21035 std::vector<std::uint8_t> result;
21057 const bool use_size =
false,
21058 const bool use_type =
false)
21060 std::vector<std::uint8_t> result;
21061 to_ubjson(j, result, use_size, use_type);
21068 const bool use_size =
false,
const bool use_type =
false)
21076 const bool use_size =
false,
const bool use_type =
false)
21085 std::vector<std::uint8_t> result;
21106 template<
typename InputType>
21109 const bool strict =
true,
21110 const bool allow_exceptions =
true,
21117 return res ? result :
basic_json(value_t::discarded);
21122 template<
typename IteratorType>
21125 const bool strict =
true,
21126 const bool allow_exceptions =
true,
21133 return res ? result :
basic_json(value_t::discarded);
21136 template<
typename T>
21140 const
bool strict = true,
21141 const
bool allow_exceptions = true,
21144 return from_cbor(ptr, ptr + len, strict, allow_exceptions, tag_handler);
21151 const
bool strict = true,
21152 const
bool allow_exceptions = true,
21160 return res ? result :
basic_json(value_t::discarded);
21165 template<
typename InputType>
21168 const bool strict =
true,
21169 const bool allow_exceptions =
true)
21175 return res ? result :
basic_json(value_t::discarded);
21180 template<
typename IteratorType>
21183 const bool strict =
true,
21184 const bool allow_exceptions =
true)
21190 return res ? result :
basic_json(value_t::discarded);
21193 template<
typename T>
21197 const
bool strict = true,
21198 const
bool allow_exceptions = true)
21200 return from_msgpack(ptr, ptr + len, strict, allow_exceptions);
21206 const
bool strict = true,
21207 const
bool allow_exceptions = true)
21214 return res ? result :
basic_json(value_t::discarded);
21219 template<
typename InputType>
21222 const bool strict =
true,
21223 const bool allow_exceptions =
true)
21229 return res ? result :
basic_json(value_t::discarded);
21234 template<
typename IteratorType>
21237 const bool strict =
true,
21238 const bool allow_exceptions =
true)
21244 return res ? result :
basic_json(value_t::discarded);
21247 template<
typename T>
21251 const
bool strict = true,
21252 const
bool allow_exceptions = true)
21254 return from_ubjson(ptr, ptr + len, strict, allow_exceptions);
21260 const
bool strict = true,
21261 const
bool allow_exceptions = true)
21268 return res ? result :
basic_json(value_t::discarded);
21273 template<
typename InputType>
21276 const bool strict =
true,
21277 const bool allow_exceptions =
true)
21283 return res ? result :
basic_json(value_t::discarded);
21288 template<
typename IteratorType>
21291 const bool strict =
true,
21292 const bool allow_exceptions =
true)
21298 return res ? result :
basic_json(value_t::discarded);
21301 template<
typename T>
21305 const
bool strict = true,
21306 const
bool allow_exceptions = true)
21308 return from_bson(ptr, ptr + len, strict, allow_exceptions);
21314 const
bool strict = true,
21315 const
bool allow_exceptions = true)
21322 return res ? result :
basic_json(value_t::discarded);
21394 enum class patch_operations {add, remove, replace, move, copy, test, invalid};
21396 const auto get_op = [](
const std::string & op)
21400 return patch_operations::add;
21402 if (op ==
"remove")
21404 return patch_operations::remove;
21406 if (op ==
"replace")
21408 return patch_operations::replace;
21412 return patch_operations::move;
21416 return patch_operations::copy;
21420 return patch_operations::test;
21423 return patch_operations::invalid;
21438 if (top_pointer != ptr)
21440 result.
at(top_pointer);
21444 const auto last_path = ptr.
back();
21448 switch (parent.m_type)
21450 case value_t::null:
21451 case value_t::object:
21454 parent[last_path] = val;
21458 case value_t::array:
21460 if (last_path ==
"-")
21481 case value_t::string:
21482 case value_t::boolean:
21483 case value_t::number_integer:
21484 case value_t::number_unsigned:
21485 case value_t::number_float:
21486 case value_t::binary:
21487 case value_t::discarded:
21494 const auto operation_remove = [
this, &result](
json_pointer & ptr)
21497 const auto last_path = ptr.
back();
21505 auto it = parent.
find(last_path);
21529 for (
const auto& val : json_patch)
21532 const auto get_value = [&val](
const std::string & op,
21533 const std::string & member,
21537 auto it = val.
m_value.object->find(member);
21540 const auto error_msg = (op ==
"op") ?
"operation" :
"operation '" + op +
"'";
21567 const auto op = get_value(
"op",
"op",
true).template get<std::string>();
21568 const auto path = get_value(op,
"path",
true).template get<std::string>();
21571 switch (get_op(op))
21573 case patch_operations::add:
21575 operation_add(ptr, get_value(
"add",
"value",
false));
21579 case patch_operations::remove:
21581 operation_remove(ptr);
21585 case patch_operations::replace:
21588 result.
at(ptr) = get_value(
"replace",
"value",
false);
21592 case patch_operations::move:
21594 const auto from_path = get_value(
"move",
"from",
true).template get<std::string>();
21604 operation_remove(from_ptr);
21605 operation_add(ptr, v);
21609 case patch_operations::copy:
21611 const auto from_path = get_value(
"copy",
"from",
true).template get<std::string>();
21620 operation_add(ptr, v);
21624 case patch_operations::test:
21626 bool success =
false;
21631 success = (result.
at(ptr) == get_value(
"test",
"value",
false));
21647 case patch_operations::invalid:
21664 const std::string& path =
"")
21670 if (source == target)
21675 if (source.
type() != target.
type())
21680 {
"op",
"replace"}, {
"path", path}, {
"value", target}
21685 switch (source.
type())
21687 case value_t::array:
21691 while (i < source.
size() && i < target.
size())
21694 auto temp_diff =
diff(source[i], target[i], path +
"/" + std::to_string(i));
21695 result.
insert(result.
end(), temp_diff.begin(), temp_diff.end());
21704 while (i < source.
size())
21711 {
"path", path +
"/" + std::to_string(i)}
21717 while (i < target.
size())
21722 {
"path", path +
"/-"},
21723 {
"value", target[i]}
21731 case value_t::object:
21734 for (
auto it = source.
cbegin(); it != source.
cend(); ++it)
21739 if (target.
find(it.key()) != target.
end())
21742 auto temp_diff =
diff(it.value(), target[it.key()], path_key);
21743 result.
insert(result.
end(), temp_diff.begin(), temp_diff.end());
21750 {
"op",
"remove"}, {
"path", path_key}
21756 for (
auto it = target.
cbegin(); it != target.
cend(); ++it)
21758 if (source.
find(it.key()) == source.
end())
21764 {
"op",
"add"}, {
"path", path_key},
21765 {
"value", it.value()}
21773 case value_t::null:
21774 case value_t::string:
21775 case value_t::boolean:
21776 case value_t::number_integer:
21777 case value_t::number_unsigned:
21778 case value_t::number_float:
21779 case value_t::binary:
21780 case value_t::discarded:
21786 {
"op",
"replace"}, {
"path", path}, {
"value", target}
21814 for (
auto it = apply_patch.
begin(); it != apply_patch.
end(); ++it)
21816 if (it.value().is_null())
21828 *
this = apply_patch;
21857 std::size_t
operator()(
const nlohmann::NLOHMANN_BASIC_JSON_TPL& j)
const
21879#ifndef JSON_HAS_CPP_20
21884inline void swap(nlohmann::NLOHMANN_BASIC_JSON_TPL& j1, nlohmann::NLOHMANN_BASIC_JSON_TPL& j2)
noexcept(
21885 is_nothrow_move_constructible<nlohmann::NLOHMANN_BASIC_JSON_TPL>::value&&
21886 is_nothrow_move_assignable<nlohmann::NLOHMANN_BASIC_JSON_TPL>::value)
21915#if defined(__clang__)
21916 #pragma clang diagnostic pop
21921#undef JSON_INTERNAL_CATCH
21925#undef JSON_PRIVATE_UNLESS_TESTED
21926#undef JSON_HAS_CPP_11
21927#undef JSON_HAS_CPP_14
21928#undef JSON_HAS_CPP_17
21929#undef JSON_HAS_CPP_20
21930#undef JSON_HAS_FILESYSTEM
21931#undef JSON_HAS_EXPERIMENTAL_FILESYSTEM
21932#undef NLOHMANN_BASIC_JSON_TPL_DECLARATION
21933#undef NLOHMANN_BASIC_JSON_TPL
21934#undef JSON_EXPLICIT
21935#undef NLOHMANN_CAN_CALL_STD_FUNC_IMPL
21940#undef JSON_HEDLEY_ALWAYS_INLINE
21941#undef JSON_HEDLEY_ARM_VERSION
21942#undef JSON_HEDLEY_ARM_VERSION_CHECK
21943#undef JSON_HEDLEY_ARRAY_PARAM
21944#undef JSON_HEDLEY_ASSUME
21945#undef JSON_HEDLEY_BEGIN_C_DECLS
21946#undef JSON_HEDLEY_CLANG_HAS_ATTRIBUTE
21947#undef JSON_HEDLEY_CLANG_HAS_BUILTIN
21948#undef JSON_HEDLEY_CLANG_HAS_CPP_ATTRIBUTE
21949#undef JSON_HEDLEY_CLANG_HAS_DECLSPEC_DECLSPEC_ATTRIBUTE
21950#undef JSON_HEDLEY_CLANG_HAS_EXTENSION
21951#undef JSON_HEDLEY_CLANG_HAS_FEATURE
21952#undef JSON_HEDLEY_CLANG_HAS_WARNING
21953#undef JSON_HEDLEY_COMPCERT_VERSION
21954#undef JSON_HEDLEY_COMPCERT_VERSION_CHECK
21955#undef JSON_HEDLEY_CONCAT
21956#undef JSON_HEDLEY_CONCAT3
21957#undef JSON_HEDLEY_CONCAT3_EX
21958#undef JSON_HEDLEY_CONCAT_EX
21959#undef JSON_HEDLEY_CONST
21960#undef JSON_HEDLEY_CONSTEXPR
21961#undef JSON_HEDLEY_CONST_CAST
21962#undef JSON_HEDLEY_CPP_CAST
21963#undef JSON_HEDLEY_CRAY_VERSION
21964#undef JSON_HEDLEY_CRAY_VERSION_CHECK
21965#undef JSON_HEDLEY_C_DECL
21966#undef JSON_HEDLEY_DEPRECATED
21967#undef JSON_HEDLEY_DEPRECATED_FOR
21968#undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL
21969#undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_
21970#undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED
21971#undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES
21972#undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS
21973#undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION
21974#undef JSON_HEDLEY_DIAGNOSTIC_POP
21975#undef JSON_HEDLEY_DIAGNOSTIC_PUSH
21976#undef JSON_HEDLEY_DMC_VERSION
21977#undef JSON_HEDLEY_DMC_VERSION_CHECK
21978#undef JSON_HEDLEY_EMPTY_BASES
21979#undef JSON_HEDLEY_EMSCRIPTEN_VERSION
21980#undef JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK
21981#undef JSON_HEDLEY_END_C_DECLS
21982#undef JSON_HEDLEY_FLAGS
21983#undef JSON_HEDLEY_FLAGS_CAST
21984#undef JSON_HEDLEY_GCC_HAS_ATTRIBUTE
21985#undef JSON_HEDLEY_GCC_HAS_BUILTIN
21986#undef JSON_HEDLEY_GCC_HAS_CPP_ATTRIBUTE
21987#undef JSON_HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE
21988#undef JSON_HEDLEY_GCC_HAS_EXTENSION
21989#undef JSON_HEDLEY_GCC_HAS_FEATURE
21990#undef JSON_HEDLEY_GCC_HAS_WARNING
21991#undef JSON_HEDLEY_GCC_NOT_CLANG_VERSION_CHECK
21992#undef JSON_HEDLEY_GCC_VERSION
21993#undef JSON_HEDLEY_GCC_VERSION_CHECK
21994#undef JSON_HEDLEY_GNUC_HAS_ATTRIBUTE
21995#undef JSON_HEDLEY_GNUC_HAS_BUILTIN
21996#undef JSON_HEDLEY_GNUC_HAS_CPP_ATTRIBUTE
21997#undef JSON_HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE
21998#undef JSON_HEDLEY_GNUC_HAS_EXTENSION
21999#undef JSON_HEDLEY_GNUC_HAS_FEATURE
22000#undef JSON_HEDLEY_GNUC_HAS_WARNING
22001#undef JSON_HEDLEY_GNUC_VERSION
22002#undef JSON_HEDLEY_GNUC_VERSION_CHECK
22003#undef JSON_HEDLEY_HAS_ATTRIBUTE
22004#undef JSON_HEDLEY_HAS_BUILTIN
22005#undef JSON_HEDLEY_HAS_CPP_ATTRIBUTE
22006#undef JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS
22007#undef JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE
22008#undef JSON_HEDLEY_HAS_EXTENSION
22009#undef JSON_HEDLEY_HAS_FEATURE
22010#undef JSON_HEDLEY_HAS_WARNING
22011#undef JSON_HEDLEY_IAR_VERSION
22012#undef JSON_HEDLEY_IAR_VERSION_CHECK
22013#undef JSON_HEDLEY_IBM_VERSION
22014#undef JSON_HEDLEY_IBM_VERSION_CHECK
22015#undef JSON_HEDLEY_IMPORT
22016#undef JSON_HEDLEY_INLINE
22017#undef JSON_HEDLEY_INTEL_CL_VERSION
22018#undef JSON_HEDLEY_INTEL_CL_VERSION_CHECK
22019#undef JSON_HEDLEY_INTEL_VERSION
22020#undef JSON_HEDLEY_INTEL_VERSION_CHECK
22021#undef JSON_HEDLEY_IS_CONSTANT
22022#undef JSON_HEDLEY_IS_CONSTEXPR_
22023#undef JSON_HEDLEY_LIKELY
22024#undef JSON_HEDLEY_MALLOC
22025#undef JSON_HEDLEY_MCST_LCC_VERSION
22026#undef JSON_HEDLEY_MCST_LCC_VERSION_CHECK
22027#undef JSON_HEDLEY_MESSAGE
22028#undef JSON_HEDLEY_MSVC_VERSION
22029#undef JSON_HEDLEY_MSVC_VERSION_CHECK
22030#undef JSON_HEDLEY_NEVER_INLINE
22031#undef JSON_HEDLEY_NON_NULL
22032#undef JSON_HEDLEY_NO_ESCAPE
22033#undef JSON_HEDLEY_NO_RETURN
22034#undef JSON_HEDLEY_NO_THROW
22035#undef JSON_HEDLEY_NULL
22036#undef JSON_HEDLEY_PELLES_VERSION
22037#undef JSON_HEDLEY_PELLES_VERSION_CHECK
22038#undef JSON_HEDLEY_PGI_VERSION
22039#undef JSON_HEDLEY_PGI_VERSION_CHECK
22040#undef JSON_HEDLEY_PREDICT
22041#undef JSON_HEDLEY_PRINTF_FORMAT
22042#undef JSON_HEDLEY_PRIVATE
22043#undef JSON_HEDLEY_PUBLIC
22044#undef JSON_HEDLEY_PURE
22045#undef JSON_HEDLEY_REINTERPRET_CAST
22046#undef JSON_HEDLEY_REQUIRE
22047#undef JSON_HEDLEY_REQUIRE_CONSTEXPR
22048#undef JSON_HEDLEY_REQUIRE_MSG
22049#undef JSON_HEDLEY_RESTRICT
22050#undef JSON_HEDLEY_RETURNS_NON_NULL
22051#undef JSON_HEDLEY_SENTINEL
22052#undef JSON_HEDLEY_STATIC_ASSERT
22053#undef JSON_HEDLEY_STATIC_CAST
22054#undef JSON_HEDLEY_STRINGIFY
22055#undef JSON_HEDLEY_STRINGIFY_EX
22056#undef JSON_HEDLEY_SUNPRO_VERSION
22057#undef JSON_HEDLEY_SUNPRO_VERSION_CHECK
22058#undef JSON_HEDLEY_TINYC_VERSION
22059#undef JSON_HEDLEY_TINYC_VERSION_CHECK
22060#undef JSON_HEDLEY_TI_ARMCL_VERSION
22061#undef JSON_HEDLEY_TI_ARMCL_VERSION_CHECK
22062#undef JSON_HEDLEY_TI_CL2000_VERSION
22063#undef JSON_HEDLEY_TI_CL2000_VERSION_CHECK
22064#undef JSON_HEDLEY_TI_CL430_VERSION
22065#undef JSON_HEDLEY_TI_CL430_VERSION_CHECK
22066#undef JSON_HEDLEY_TI_CL6X_VERSION
22067#undef JSON_HEDLEY_TI_CL6X_VERSION_CHECK
22068#undef JSON_HEDLEY_TI_CL7X_VERSION
22069#undef JSON_HEDLEY_TI_CL7X_VERSION_CHECK
22070#undef JSON_HEDLEY_TI_CLPRU_VERSION
22071#undef JSON_HEDLEY_TI_CLPRU_VERSION_CHECK
22072#undef JSON_HEDLEY_TI_VERSION
22073#undef JSON_HEDLEY_TI_VERSION_CHECK
22074#undef JSON_HEDLEY_UNAVAILABLE
22075#undef JSON_HEDLEY_UNLIKELY
22076#undef JSON_HEDLEY_UNPREDICTABLE
22077#undef JSON_HEDLEY_UNREACHABLE
22078#undef JSON_HEDLEY_UNREACHABLE_RETURN
22079#undef JSON_HEDLEY_VERSION
22080#undef JSON_HEDLEY_VERSION_DECODE_MAJOR
22081#undef JSON_HEDLEY_VERSION_DECODE_MINOR
22082#undef JSON_HEDLEY_VERSION_DECODE_REVISION
22083#undef JSON_HEDLEY_VERSION_ENCODE
22084#undef JSON_HEDLEY_WARNING
22085#undef JSON_HEDLEY_WARN_UNUSED_RESULT
22086#undef JSON_HEDLEY_WARN_UNUSED_RESULT_MSG
22087#undef JSON_HEDLEY_FALL_THROUGH
a class to store JSON values
ValueType & get_to(ValueType &v) const
void insert(const_iterator first, const_iterator last)
inserts range of elements into object
array_t * get_impl_ptr(array_t *) noexcept
get a pointer to the value (array)
detail::parser_callback_t< basic_json > parser_callback_t
per-element parser callback type
bool contains(KeyT &&key) const
check the existence of an element in a JSON object
iteration_proxy< iterator > items() noexcept
helper to access iterator member functions in range-based for
const_reverse_iterator crbegin() const noexcept
returns a const reverse iterator to the last element
constexpr const number_unsigned_t * get_impl_ptr(const number_unsigned_t *) const noexcept
get a pointer to the value (unsigned number)
number_unsigned_t number_unsigned
number (unsigned integer)
const_reference operator[](const json_pointer &ptr) const
access specified element via JSON Pointer
reference operator[](const json_pointer &ptr)
access specified element via JSON Pointer
friend bool operator==(const_reference lhs, ScalarType rhs) noexcept
comparison: equal
ValueType value(const typename object_t::key_type &key, const ValueType &default_value) const
access specified object element with default value
constexpr bool is_number_float() const noexcept
return whether value is a floating-point number
NumberIntegerType number_integer_t
a type for a number (integer)
friend bool operator==(const_reference lhs, const_reference rhs) noexcept
comparison: equal
NLOHMANN_BASIC_JSON_TPL basic_json_t
workaround type for MSVC
void update(const_reference j, bool merge_objects=false)
updates a JSON object from another object, overwriting existing keys
static bool sax_parse(InputType &&i, SAX *sax, input_format_t format=input_format_t::json, const bool strict=true, const bool ignore_comments=false)
generate SAX events
ReferenceType get_ref()
get a reference value (implicit)
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json parse(InputType &&i, const parser_callback_t cb=nullptr, const bool allow_exceptions=true, const bool ignore_comments=false)
deserialize from a compatible input
reference emplace_back(Args &&... args)
add an object to an array
const_iterator find(KeyT &&key) const
find an element in a JSON object
basic_json(const value_t v)
create an empty value with a given type
object_t * get_impl_ptr(object_t *) noexcept
get a pointer to the value (object)
size_type max_size() const noexcept
returns the maximum possible number of elements
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json diff(const basic_json &source, const basic_json &target, const std::string &path="")
creates a diff as a JSON patch
static std::vector< std::uint8_t > to_bson(const basic_json &j)
create a BSON serialization of a given JSON value
void erase(const size_type idx)
remove element from a JSON array given an index
const_reverse_iterator crend() const noexcept
returns a const reverse iterator to one before the first
const_reference at(const typename object_t::key_type &key) const
access specified object element with bounds checking
reference at(const typename object_t::key_type &key)
access specified object element with bounds checking
iterator begin() noexcept
returns an iterator to the first element
binary_t & get_binary()
get a binary value
basic_json(InputIT first, InputIT last)
construct a JSON container given an iterator range
static std::vector< std::uint8_t > to_msgpack(const basic_json &j)
create a MessagePack serialization of a given JSON value
friend bool operator==(ScalarType lhs, const_reference rhs) noexcept
comparison: equal
json_value(object_t &&value)
constructor for rvalue objects
basic_json(const JsonRef &ref)
static std::vector< std::uint8_t > to_cbor(const basic_json &j)
create a CBOR serialization of a given JSON value
basic_json & operator=(basic_json other) noexcept(std::is_nothrow_move_constructible< value_t >::value &&std::is_nothrow_move_assignable< value_t >::value &&std::is_nothrow_move_constructible< json_value >::value &&std::is_nothrow_move_assignable< json_value >::value)
copy assignment
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json array(initializer_list_t init={})
explicitly create an array from an initializer list
json_value(number_float_t v) noexcept
constructor for numbers (floating-point)
const_reverse_iterator rend() const noexcept
returns an iterator to the reverse-end
void assert_invariant(bool check_parents=true) const noexcept
checks the class invariants
json_value(string_t &&value)
constructor for rvalue strings
const_iterator cend() const noexcept
returns an iterator to one past the last element
json_value(number_integer_t v) noexcept
constructor for numbers (integer)
number_unsigned_t * get_impl_ptr(number_unsigned_t *) noexcept
get a pointer to the value (unsigned number)
reference back()
access the last element
boolean_t * get_impl_ptr(boolean_t *) noexcept
get a pointer to the value (boolean)
const binary_t & get_binary() const
get a binary value
constexpr const boolean_t * get_impl_ptr(const boolean_t *) const noexcept
get a pointer to the value (boolean)
static bool accept(InputType &&i, const bool ignore_comments=false)
check if the input is valid JSON
StringType string_t
a type for a string
size_type size() const noexcept
returns the number of elements
void push_back(const basic_json &val)
add an object to an array
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json meta()
returns version information on the library
ValueType value(const json_pointer &ptr, const ValueType &default_value) const
access specified object element via JSON Pointer with default value
std::size_t size_type
a type to represent container sizes
ValueType & get_to(ValueType &v) const noexcept(noexcept(JSONSerializer< ValueType >::from_json(std::declval< const basic_json_t & >(), v)))
get a value (explicit)
std::ptrdiff_t difference_type
a type to represent differences between iterators
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json binary(const typename binary_t::container_type &init)
explicitly create a binary array (without subtype)
reference operator[](const typename object_t::key_type &key)
access specified object element
json_value(number_unsigned_t v) noexcept
constructor for numbers (unsigned)
reference operator+=(basic_json &&val)
add an object to an array
basic_json(const BasicJsonType &val)
create a JSON value from an existing one
typename std::allocator_traits< allocator_type >::const_pointer const_pointer
the type of an element const pointer
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json from_bson(IteratorType first, IteratorType last, const bool strict=true, const bool allow_exceptions=true)
create a JSON value from an input in BSON format
typename std::allocator_traits< allocator_type >::pointer pointer
the type of an element pointer
constexpr const binary_t * get_impl_ptr(const binary_t *) const noexcept
get a pointer to the value (binary)
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json from_cbor(InputType &&i, const bool strict=true, const bool allow_exceptions=true, const cbor_tag_handler_t tag_handler=cbor_tag_handler_t::error)
create a JSON value from an input in CBOR format
BooleanType boolean_t
a type for a boolean
iterator set_parents(iterator it, typename iterator::difference_type count_set_parents)
void push_back(initializer_list_t init)
add an object to an object
boolean_t get_impl(boolean_t *) const
get a boolean (explicit)
string_t dump(const int indent=-1, const char indent_char=' ', const bool ensure_ascii=false, const error_handler_t error_handler=error_handler_t::strict) const
serialization
static bool accept(IteratorType first, IteratorType last, const bool ignore_comments=false)
check if the input is valid JSON
IteratorType erase(IteratorType pos)
remove element given an iterator
static void to_bson(const basic_json &j, detail::output_adapter< std::uint8_t > o)
create a BSON serialization of a given JSON value
friend bool operator!=(const_reference lhs, ScalarType rhs) noexcept
comparison: not equal
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json from_bson(InputType &&i, const bool strict=true, const bool allow_exceptions=true)
create a JSON value from an input in BSON format
constexpr bool is_structured() const noexcept
return whether type is structured
friend bool operator<=(ScalarType lhs, const_reference rhs) noexcept
comparison: less than or equal
const_iterator begin() const noexcept
returns an iterator to the first element
void update(const_iterator first, const_iterator last, bool merge_objects=false)
updates a JSON object from another object, overwriting existing keys
friend bool operator<(const_reference lhs, ScalarType rhs) noexcept
comparison: less than
reference at(size_type idx)
access specified array element with bounds checking
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json binary(typename binary_t::container_type &&init, typename binary_t::subtype_type subtype)
explicitly create a binary array (with subtype)
reference front()
access the first element
constexpr bool is_primitive() const noexcept
return whether type is primitive
constexpr bool is_number_unsigned() const noexcept
return whether value is an unsigned integer number
static void to_cbor(const basic_json &j, detail::output_adapter< char > o)
create a CBOR serialization of a given JSON value
void swap(object_t &other)
exchanges the values
constexpr bool is_object() const noexcept
return whether value is an object
const_reference front() const
access the first element
constexpr value_t type() const noexcept
return the type of the JSON value (explicit)
NumberFloatType number_float_t
a type for a number (floating-point)
json_reverse_iterator< typename basic_json::iterator > reverse_iterator
a reverse iterator for a basic_json container
friend std::ostream & operator<<(std::ostream &o, const basic_json &j)
serialize to stream
friend bool operator<=(const_reference lhs, const_reference rhs) noexcept
comparison: less than or equal
bool empty() const noexcept
checks whether the container is empty.
json_value(value_t t)
constructor for empty values of a given type
basic_json(const basic_json &other)
copy constructor
~basic_json() noexcept
destructor
static std::vector< std::uint8_t > to_ubjson(const basic_json &j, const bool use_size=false, const bool use_type=false)
create a UBJSON serialization of a given JSON value
basic_json(basic_json &&other) noexcept
move constructor
friend bool operator>(ScalarType lhs, const_reference rhs) noexcept
comparison: greater than
reference set_parent(reference j, std::size_t old_capacity=static_cast< std::size_t >(-1))
BasicJsonType get_impl(detail::priority_tag< 2 >) const
get special-case overload
static void to_ubjson(const basic_json &j, detail::output_adapter< char > o, const bool use_size=false, const bool use_type=false)
create a UBJSON serialization of a given JSON value
friend bool operator!=(const_reference lhs, const_reference rhs) noexcept
comparison: not equal
iterator insert(const_iterator pos, size_type cnt, const basic_json &val)
inserts copies of element into array
friend bool operator<(ScalarType lhs, const_reference rhs) noexcept
comparison: less than
json_value m_value
the value of the current element
void swap(typename binary_t::container_type &other)
exchanges the values
friend bool operator>=(const_reference lhs, const_reference rhs) noexcept
comparison: greater than or equal
void swap(array_t &other)
exchanges the values
ValueType get_impl(detail::priority_tag< 0 >) const noexcept(noexcept(JSONSerializer< ValueType >::from_json(std::declval< const basic_json_t & >(), std::declval< ValueType & >())))
get a value (explicit)
reverse_iterator rend() noexcept
returns an iterator to the reverse-end
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json binary(const typename binary_t::container_type &init, typename binary_t::subtype_type subtype)
explicitly create a binary array (with subtype)
static iteration_proxy< iterator > iterator_wrapper(reference ref) noexcept
wrapper to access iterator member functions in range-based for
json_value(const string_t &value)
constructor for strings
json_value(const binary_t &value)
constructor for binary arrays (internal type)
ReferenceType get_ref() const
get a reference value (implicit)
json_value(const array_t &value)
constructor for arrays
iterator insert(const_iterator pos, const_iterator first, const_iterator last)
inserts range of elements into array
auto get() noexcept -> decltype(std::declval< basic_json_t & >().template get_ptr< PointerType >())
get a pointer value (explicit)
const_reference at(const json_pointer &ptr) const
access specified element via JSON Pointer
const_iterator end() const noexcept
returns an iterator to one past the last element
void merge_patch(const basic_json &apply_patch)
applies a JSON Merge Patch
auto get_ptr() noexcept -> decltype(std::declval< basic_json_t & >().get_impl_ptr(std::declval< PointerType >()))
get a pointer value (implicit)
iteration_proxy< const_iterator > items() const noexcept
helper to access iterator member functions in range-based for
iterator insert(const_iterator pos, initializer_list_t ilist)
inserts elements from initializer list into array
ArrayType< basic_json, AllocatorType< basic_json > > array_t
a type for an array
Array get_to(T(&v)[N]) const noexcept(noexcept(JSONSerializer< Array >::from_json(std::declval< const basic_json_t & >(), v)))
friend bool operator>(const_reference lhs, const_reference rhs) noexcept
comparison: greater than
constexpr const number_integer_t * get_impl_ptr(const number_integer_t *) const noexcept
get a pointer to the value (integer number)
constexpr const string_t * get_impl_ptr(const string_t *) const noexcept
get a pointer to the value (string)
json_value(const object_t &value)
constructor for objects
IteratorType erase(IteratorType first, IteratorType last)
remove elements given an iterator range
json_value(typename binary_t::container_type &&value)
constructor for rvalue binary arrays
json_value(boolean_t v) noexcept
constructor for booleans
constexpr bool is_boolean() const noexcept
return whether value is a boolean
iterator end() noexcept
returns an iterator to one past the last element
void swap(reference other) noexcept(std::is_nothrow_move_constructible< value_t >::value &&std::is_nothrow_move_assignable< value_t >::value &&std::is_nothrow_move_constructible< json_value >::value &&std::is_nothrow_move_assignable< json_value >::value)
exchanges the values
void clear() noexcept
clears the contents
friend bool operator>=(ScalarType lhs, const_reference rhs) noexcept
comparison: greater than or equal
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json from_msgpack(IteratorType first, IteratorType last, const bool strict=true, const bool allow_exceptions=true)
create a JSON value from an input in MessagePack format
constexpr bool is_binary() const noexcept
return whether value is a binary array
static JSON_HEDLEY_RETURNS_NON_NULL T * create(Args &&... args)
helper for exception-safe object creation
binary_t * binary
binary (stored with pointer to save storage)
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json object(initializer_list_t init={})
explicitly create an object from an initializer list
iterator insert(const_iterator pos, basic_json &&val)
inserts element into array
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json from_ubjson(IteratorType first, IteratorType last, const bool strict=true, const bool allow_exceptions=true)
create a JSON value from an input in UBJSON format
reference operator[](size_type idx)
access specified array element
friend bool operator>(const_reference lhs, ScalarType rhs) noexcept
comparison: greater than
static void to_bson(const basic_json &j, detail::output_adapter< char > o)
create a BSON serialization of a given JSON value
reference at(const json_pointer &ptr)
access specified element via JSON Pointer
void swap(binary_t &other)
exchanges the values
json_reverse_iterator< typename basic_json::const_iterator > const_reverse_iterator
a const reverse iterator for a basic_json container
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json from_ubjson(InputType &&i, const bool strict=true, const bool allow_exceptions=true)
create a JSON value from an input in UBJSON format
::nlohmann::json_pointer< basic_json > json_pointer
JSON Pointer, see nlohmann::json_pointer.
friend bool operator!=(ScalarType lhs, const_reference rhs) noexcept
comparison: not equal
static void to_ubjson(const basic_json &j, detail::output_adapter< std::uint8_t > o, const bool use_size=false, const bool use_type=false)
create a UBJSON serialization of a given JSON value
const_reverse_iterator rbegin() const noexcept
returns an iterator to the reverse-beginning
void swap(string_t &other)
exchanges the values
const_reference back() const
access the last element
friend bool operator<(const_reference lhs, const_reference rhs) noexcept
comparison: less than
ValueType get_impl(detail::priority_tag< 1 >) const noexcept(noexcept(JSONSerializer< ValueType >::from_json(std::declval< const basic_json_t & >())))
get a value (explicit); special case
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json binary(typename binary_t::container_type &&init)
explicitly create a binary array
constexpr bool is_string() const noexcept
return whether value is a string
number_integer_t * get_impl_ptr(number_integer_t *) noexcept
get a pointer to the value (integer number)
constexpr bool is_array() const noexcept
return whether value is an array
iterator insert_iterator(const_iterator pos, Args &&... args)
basic_json flatten() const
return flattened JSON value
constexpr const number_float_t * get_impl_ptr(const number_float_t *) const noexcept
get a pointer to the value (floating-point number)
constexpr const array_t * get_impl_ptr(const array_t *) const noexcept
get a pointer to the value (array)
friend bool operator>=(const_reference lhs, ScalarType rhs) noexcept
comparison: greater than or equal
JSON_HEDLEY_RETURNS_NON_NULL const char * type_name() const noexcept
return the type as string
void push_back(basic_json &&val)
add an object to an array
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json from_cbor(IteratorType first, IteratorType last, const bool strict=true, const bool allow_exceptions=true, const cbor_tag_handler_t tag_handler=cbor_tag_handler_t::error)
create a JSON value from an input in CBOR format
size_type count(KeyT &&key) const
returns the number of occurrences of a key in a JSON object
json_value(const typename binary_t::container_type &value)
constructor for binary arrays
json_value()=default
default constructor (for null values)
constexpr bool is_number() const noexcept
return whether value is a number
number_float_t number_float
number (floating-point)
string_t * get_impl_ptr(string_t *) noexcept
get a pointer to the value (string)
friend std::ostream & operator>>(const basic_json &j, std::ostream &o)
serialize to stream
std::less< StringType > object_comparator_t
object key comparator type
string_t * string
string (stored with pointer to save storage)
reference operator+=(initializer_list_t init)
add an object to an object
::nlohmann::detail::output_adapter_t< CharType > output_adapter_t
constexpr bool is_number_integer() const noexcept
return whether value is an integer number
std::initializer_list< detail::json_ref< basic_json > > initializer_list_t
helper type for initializer lists of basic_json values
static void to_cbor(const basic_json &j, detail::output_adapter< std::uint8_t > o)
create a CBOR serialization of a given JSON value
number_float_t * get_impl_ptr(number_float_t *) noexcept
get a pointer to the value (floating-point number)
json_value(binary_t &&value)
constructor for rvalue binary arrays (internal type)
friend class ::nlohmann::detail::parser
static void to_msgpack(const basic_json &j, detail::output_adapter< char > o)
create a MessagePack serialization of a given JSON value
const_reference operator[](const typename object_t::key_type &key) const
access specified object element
iterator find(KeyT &&key)
find an element in a JSON object
basic_json(std::nullptr_t=nullptr) noexcept
create a null object
const_reference operator[](size_type idx) const
access specified array element
array_t * array
array (stored with pointer to save storage)
AllocatorType< basic_json > allocator_type
the allocator type
basic_json get_impl(detail::priority_tag< 3 >) const
get special-case overload
nlohmann::byte_container_with_subtype< BinaryType > binary_t
a type for a packed binary type
JSONSerializer< T, SFINAE > json_serializer
void push_back(const typename object_t::value_type &val)
add an object to an object
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json parse(IteratorType first, IteratorType last, const parser_callback_t cb=nullptr, const bool allow_exceptions=true, const bool ignore_comments=false)
deserialize from a pair of character iterators
number_integer_t number_integer
number (integer)
bool contains(const json_pointer &ptr) const
check the existence of an element in a JSON object given a JSON pointer
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json from_msgpack(InputType &&i, const bool strict=true, const bool allow_exceptions=true)
create a JSON value from an input in MessagePack format
basic_json patch(const basic_json &json_patch) const
applies a JSON patch
string_t value(const typename object_t::key_type &key, const char *default_value) const
access specified object element with default value
basic_json(CompatibleType &&val) noexcept(noexcept(//NOLINT(bugprone-forwarding-reference-overload, bugprone-exception-escape) JSONSerializer< U >::to_json(std::declval< basic_json_t & >(), std::forward< CompatibleType >(val))))
create a JSON value from compatible types
basic_json unflatten() const
unflatten a previously flattened JSON value
NumberUnsignedType number_unsigned_t
a type for a number (unsigned)
reference operator+=(const typename object_t::value_type &val)
add an object to an object
const_iterator cbegin() const noexcept
returns a const iterator to the first element
friend bool operator<=(const_reference lhs, ScalarType rhs) noexcept
comparison: less than or equal
friend std::istream & operator>>(std::istream &i, basic_json &j)
deserialize from stream
static ::nlohmann::detail::parser< basic_json, InputAdapterType > parser(InputAdapterType adapter, detail::parser_callback_t< basic_json >cb=nullptr, const bool allow_exceptions=true, const bool ignore_comments=false)
json_value(array_t &&value)
constructor for rvalue arrays
basic_json(initializer_list_t init, bool type_deduction=true, value_t manual_type=value_t::array)
create a container (array or object) from an initializer list
const_reference at(size_type idx) const
access specified array element with bounds checking
iterator insert(const_iterator pos, const basic_json &val)
inserts element into array
constexpr bool is_discarded() const noexcept
return whether value is discarded
constexpr auto get_impl(detail::priority_tag< 4 >) const noexcept -> decltype(std::declval< const basic_json_t & >().template get_ptr< PointerType >())
get a pointer value (explicit)
constexpr bool is_null() const noexcept
return whether value is null
friend void swap(reference left, reference right) noexcept(std::is_nothrow_move_constructible< value_t >::value &&std::is_nothrow_move_assignable< value_t >::value &&std::is_nothrow_move_constructible< json_value >::value &&std::is_nothrow_move_assignable< json_value >::value)
exchanges the values
binary_t * get_impl_ptr(binary_t *) noexcept
get a pointer to the value (binary)
ObjectType< StringType, basic_json, object_comparator_t, AllocatorType< std::pair< const StringType, basic_json > > > object_t
a type for an object
auto get() const noexcept(noexcept(std::declval< const basic_json_t & >().template get_impl< ValueType >(detail::priority_tag< 4 > {}))) -> decltype(std::declval< const basic_json_t & >().template get_impl< ValueType >(detail::priority_tag< 4 > {}))
get a (pointer) value (explicit)
std::pair< iterator, bool > emplace(Args &&... args)
add an object to an object if key does not exist
static void to_msgpack(const basic_json &j, detail::output_adapter< std::uint8_t > o)
create a MessagePack serialization of a given JSON value
reference operator+=(const basic_json &val)
add an object to an array
size_type erase(const typename object_t::key_type &key)
remove element from a JSON object given a key
static ReferenceType get_ref_impl(ThisType &obj)
helper function to implement get_ref()
basic_json(size_type cnt, const basic_json &val)
construct an array with count copies of given value
static allocator_type get_allocator()
returns the allocator associated with the container
constexpr const object_t * get_impl_ptr(const object_t *) const noexcept
get a pointer to the value (object)
constexpr auto get_ptr() const noexcept -> decltype(std::declval< const basic_json_t & >().get_impl_ptr(std::declval< PointerType >()))
get a pointer value (implicit)
reverse_iterator rbegin() noexcept
returns an iterator to the reverse-beginning
an internal type for a backed binary type
byte_container_with_subtype(const container_type &b, subtype_type subtype_) noexcept(noexcept(container_type(b)))
BinaryType container_type
byte_container_with_subtype(const container_type &b) noexcept(noexcept(container_type(b)))
byte_container_with_subtype(container_type &&b) noexcept(noexcept(container_type(std::move(b))))
bool operator!=(const byte_container_with_subtype &rhs) const
void clear_subtype() noexcept
clears the binary subtype
byte_container_with_subtype() noexcept(noexcept(container_type()))
byte_container_with_subtype(container_type &&b, subtype_type subtype_) noexcept(noexcept(container_type(std::move(b))))
constexpr bool has_subtype() const noexcept
return whether the value has a subtype
void set_subtype(subtype_type subtype_) noexcept
sets the binary subtype
constexpr subtype_type subtype() const noexcept
return the binary subtype
std::uint64_t subtype_type
bool operator==(const byte_container_with_subtype &rhs) const
deserialization of CBOR, MessagePack, and UBJSON values
typename BasicJsonType::number_unsigned_t number_unsigned_t
bool get_msgpack_array(const std::size_t len)
binary_reader & operator=(const binary_reader &)=delete
bool get_bson_string(const NumberType len, string_t &result)
Parses a zero-terminated string of length len from the BSON input.
bool parse_bson_element_internal(const char_int_type element_type, const std::size_t element_type_parse_position)
Read a BSON document element of the given element_type.
bool parse_bson_array()
Reads an array from the BSON input and passes it to the SAX-parser.
char_int_type get_ignore_noop()
bool get_ubjson_high_precision_number()
binary_reader(InputAdapterType &&adapter) noexcept
create a binary reader
typename BasicJsonType::number_integer_t number_integer_t
bool get_bson_cstr(string_t &result)
Parses a C-style string from the BSON input.
bool get_cbor_array(const std::size_t len, const cbor_tag_handler_t tag_handler)
bool get_msgpack_binary(binary_t &result)
reads a MessagePack byte array
bool get_cbor_object(const std::size_t len, const cbor_tag_handler_t tag_handler)
bool get_ubjson_string(string_t &result, const bool get_char=true)
reads a UBJSON string
bool parse_bson_element_list(const bool is_array)
Read a BSON element list (as specified in the BSON-spec)
bool parse_cbor_internal(const bool get_char, const cbor_tag_handler_t tag_handler)
bool get_string(const input_format_t format, const NumberType len, string_t &result)
create a string by reading characters from the input
bool get_cbor_string(string_t &result)
reads a CBOR string
InputAdapterType ia
input adapter
bool get_binary(const input_format_t format, const NumberType len, binary_t &result)
create a byte array by reading bytes from the input
bool parse_ubjson_internal(const bool get_char=true)
bool unexpect_eof(const input_format_t format, const char *context) const
binary_reader & operator=(binary_reader &&)=default
bool get_ubjson_size_type(std::pair< std::size_t, char_int_type > &result)
determine the type and size for a container
std::string get_token_string() const
bool get_ubjson_value(const char_int_type prefix)
typename BasicJsonType::string_t string_t
bool get_msgpack_object(const std::size_t len)
bool get_bson_binary(const NumberType len, binary_t &result)
Parses a byte array input of length len from the BSON input.
std::string exception_message(const input_format_t format, const std::string &detail, const std::string &context) const
std::size_t chars_read
the number of characters read
typename std::char_traits< char_type >::int_type char_int_type
binary_reader(const binary_reader &)=delete
char_int_type current
the current character
bool sax_parse(const input_format_t format, json_sax_t *sax_, const bool strict=true, const cbor_tag_handler_t tag_handler=cbor_tag_handler_t::error)
json_sax_t * sax
the SAX parser
bool get_ubjson_size_value(std::size_t &result)
typename InputAdapterType::char_type char_type
bool parse_bson_internal()
Reads in a BSON-object and passes it to the SAX-parser.
bool get_number(const input_format_t format, NumberType &result)
bool get_cbor_binary(binary_t &result)
reads a CBOR byte array
binary_reader(binary_reader &&)=default
typename BasicJsonType::binary_t binary_t
char_int_type get()
get next character from the input
const bool is_little_endian
whether we can assume little endianness
bool get_msgpack_string(string_t &result)
reads a MessagePack string
bool parse_msgpack_internal()
typename BasicJsonType::number_float_t number_float_t
serialization to CBOR and MessagePack values
void write_bson_array(const string_t &name, const typename BasicJsonType::array_t &value)
Writes a BSON element with key name and array value.
void write_number_with_ubjson_prefix(const NumberType n, const bool add_prefix)
void write_ubjson(const BasicJsonType &j, const bool use_count, const bool use_type, const bool add_prefix=true)
static std::size_t calc_bson_entry_header_size(const string_t &name, const BasicJsonType &j)
static constexpr CharType get_ubjson_float_prefix(double)
void write_bson_entry_header(const string_t &name, const std::uint8_t element_type)
Writes the given element_type and name to the output adapter.
static std::size_t calc_bson_element_size(const string_t &name, const BasicJsonType &j)
Calculates the size necessary to serialize the JSON value j with its name.
void write_bson_double(const string_t &name, const double value)
Writes a BSON element with key name and double value value.
void write_bson_object(const typename BasicJsonType::object_t &value)
typename BasicJsonType::string_t string_t
static constexpr CharType get_cbor_float_prefix(float)
static constexpr CharType to_char_type(InputCharType x) noexcept
typename BasicJsonType::binary_t binary_t
binary_writer(output_adapter_t< CharType > adapter)
create a binary writer
static constexpr CharType get_msgpack_float_prefix(double)
CharType ubjson_prefix(const BasicJsonType &j) const noexcept
determine the type prefix of container values
void write_bson_integer(const string_t &name, const std::int64_t value)
Writes a BSON element with key name and integer value.
static CharType to_char_type(std::uint8_t x) noexcept
void write_bson_string(const string_t &name, const string_t &value)
Writes a BSON element with key name and string value value.
void write_bson_object_entry(const string_t &name, const typename BasicJsonType::object_t &value)
Writes a BSON element with key name and object value.
static constexpr CharType get_ubjson_float_prefix(float)
void write_number(const NumberType n)
void write_bson_element(const string_t &name, const BasicJsonType &j)
Serializes the JSON value j to BSON and associates it with the key name.
void write_bson_binary(const string_t &name, const binary_t &value)
Writes a BSON element with key name and binary value value.
void write_bson_null(const string_t &name)
Writes a BSON element with key name and null value.
static std::size_t calc_bson_binary_size(const typename BasicJsonType::binary_t &value)
void write_bson(const BasicJsonType &j)
void write_cbor(const BasicJsonType &j)
static constexpr std::size_t calc_bson_unsigned_size(const std::uint64_t value) noexcept
static constexpr CharType to_char_type(std::uint8_t x) noexcept
typename BasicJsonType::number_float_t number_float_t
void write_bson_unsigned(const string_t &name, const BasicJsonType &j)
Writes a BSON element with key name and unsigned value.
static std::size_t calc_bson_object_size(const typename BasicJsonType::object_t &value)
Calculates the size of the BSON serialization of the given JSON-object j.
static constexpr CharType get_msgpack_float_prefix(float)
void write_bson_boolean(const string_t &name, const bool value)
Writes a BSON element with key name and boolean value value.
void write_msgpack(const BasicJsonType &j)
void write_compact_float(const number_float_t n, detail::input_format_t format)
static std::size_t calc_bson_string_size(const string_t &value)
static std::size_t calc_bson_integer_size(const std::int64_t value)
static std::size_t calc_bson_array_size(const typename BasicJsonType::array_t &value)
static constexpr CharType get_cbor_float_prefix(double)
general exception of the basic_json class
const int id
the id of the exception
static std::string diagnostics(const BasicJsonType &leaf_element)
static std::string name(const std::string &ename, int id_)
std::runtime_error m
an exception object as storage for error messages
const char * what() const noexcept override
returns the explanatory string
exception indicating errors with iterators
static invalid_iterator create(int id_, const std::string &what_arg, const BasicJsonType &context)
a template for a bidirectional iterator for the basic_json class This class implements a both iterato...
bool operator<(const iter_impl &other) const
comparison: smaller
iter_impl operator-(difference_type i) const
subtract from iterator
bool operator!=(const IterImpl &other) const
comparison: not equal
iter_impl const operator--(int)
post-decrement (it–)
void set_end() noexcept
set the iterator past the last value
typename BasicJsonType::difference_type difference_type
a type to represent differences between iterators
iter_impl & operator--()
pre-decrement (–it)
difference_type operator-(const iter_impl &other) const
return difference
iter_impl & operator=(const iter_impl< const BasicJsonType > &other) noexcept
converting assignment
typename std::conditional< std::is_const< BasicJsonType >::value, typename BasicJsonType::const_reference, typename BasicJsonType::reference >::type reference
defines a reference to the type iterated over (value_type)
reference operator*() const
return a reference to the value pointed to by the iterator
iter_impl(iter_impl &&) noexcept=default
bool operator>=(const iter_impl &other) const
comparison: greater than or equal
typename std::conditional< std::is_const< BasicJsonType >::value, typename BasicJsonType::const_pointer, typename BasicJsonType::pointer >::type pointer
defines a pointer to the type iterated over (value_type)
iter_impl & operator=(const iter_impl< typename std::remove_const< BasicJsonType >::type > &other) noexcept
converting assignment
pointer operator->() const
dereference the iterator
iter_impl(const iter_impl< const BasicJsonType > &other) noexcept
const copy constructor
iter_impl const operator++(int)
post-increment (it++)
iter_impl(const iter_impl< typename std::remove_const< BasicJsonType >::type > &other) noexcept
converting constructor
internal_iterator< typename std::remove_const< BasicJsonType >::type > m_it
the actual iterator of the associated instance
iter_impl operator+(difference_type i) const
add to iterator
friend iter_impl operator+(difference_type i, const iter_impl &it)
addition of distance and iterator
const object_t::key_type & key() const
return the key of an object iterator
bool operator==(const IterImpl &other) const
comparison: equal
bool operator>(const iter_impl &other) const
comparison: greater than
typename BasicJsonType::value_type value_type
the type of the values when the iterator is dereferenced
reference value() const
return the value of an iterator
typename BasicJsonType::object_t object_t
friend other_iter_impl
allow basic_json to access private members
iter_impl & operator++()
pre-increment (++it)
reference operator[](difference_type n) const
access to successor
bool operator<=(const iter_impl &other) const
comparison: less than or equal
std::bidirectional_iterator_tag iterator_category
iter_impl & operator+=(difference_type i)
add to iterator
typename BasicJsonType::array_t array_t
iter_impl & operator-=(difference_type i)
subtract from iterator
IteratorType anchor
the iterator
std::input_iterator_tag iterator_category
typename std::remove_cv< typename std::remove_reference< decltype(std::declval< IteratorType >().key()) >::type >::type string_type
const string_type empty_str
an empty string (to return a reference for primitive values)
iteration_proxy_value(IteratorType it) noexcept
bool operator!=(const iteration_proxy_value &o) const
inequality operator (needed for range-based for)
std::size_t array_index_last
last stringified array index
string_type array_index_str
a string representation of the array index
IteratorType::reference value() const
return value of the iterator
iteration_proxy_value & operator++()
increment operator (needed for range-based for)
std::size_t array_index
an index for arrays (used to create key names)
iteration_proxy_value & operator*()
dereference operator (needed for range-based for)
std::ptrdiff_t difference_type
const string_type & key() const
return key of the iterator
bool operator==(const iteration_proxy_value &o) const
equality operator (needed for InputIterator)
proxy class for the items() function
iteration_proxy_value< IteratorType > begin() noexcept
return iterator begin (needed for range-based for)
iteration_proxy_value< IteratorType > end() noexcept
return iterator end (needed for range-based for)
IteratorType::reference container
the container to iterate
iteration_proxy(typename IteratorType::reference cont) noexcept
construct iteration proxy from a container
value_type const * value_ref
json_ref(json_ref &&) noexcept=default
value_type const & operator*() const
json_ref(Args &&... args)
json_ref(const value_type &value)
value_type const * operator->() const
json_ref(std::initializer_list< json_ref > init)
json_ref(value_type &&value)
value_type moved_or_copied() const
a template for a reverse iterator class
json_reverse_iterator(const typename base_iterator::iterator_type &it) noexcept
create reverse iterator from iterator
json_reverse_iterator const operator--(int)
post-decrement (it–)
typename Base::reference reference
the reference type for the pointed-to element
json_reverse_iterator operator-(difference_type i) const
subtract from iterator
json_reverse_iterator & operator+=(difference_type i)
add to iterator
std::reverse_iterator< Base > base_iterator
shortcut to the reverse iterator adapter
json_reverse_iterator(const base_iterator &it) noexcept
create reverse iterator from base class
reference operator[](difference_type n) const
access to successor
std::ptrdiff_t difference_type
difference_type operator-(const json_reverse_iterator &other) const
return difference
json_reverse_iterator operator+(difference_type i) const
add to iterator
json_reverse_iterator const operator++(int)
post-increment (it++)
auto key() const -> decltype(std::declval< Base >().key())
return the key of an object iterator
json_reverse_iterator & operator--()
pre-decrement (–it)
reference value() const
return the value of an iterator
json_reverse_iterator & operator++()
pre-increment (++it)
bool start_object(std::size_t=static_cast< std::size_t >(-1))
typename BasicJsonType::string_t string_t
typename BasicJsonType::number_integer_t number_integer_t
typename BasicJsonType::number_float_t number_float_t
typename BasicJsonType::binary_t binary_t
bool start_array(std::size_t=static_cast< std::size_t >(-1))
bool parse_error(std::size_t, const std::string &, const detail::exception &)
bool number_integer(number_integer_t)
bool number_unsigned(number_unsigned_t)
typename BasicJsonType::number_unsigned_t number_unsigned_t
bool number_float(number_float_t, const string_t &)
typename BasicJsonType::string_t string_t
json_sax_dom_callback_parser & operator=(const json_sax_dom_callback_parser &)=delete
bool start_object(std::size_t len)
constexpr bool is_errored() const
typename BasicJsonType::number_unsigned_t number_unsigned_t
typename BasicJsonType::number_integer_t number_integer_t
std::pair< bool, BasicJsonType * > handle_value(Value &&v, const bool skip_callback=false)
typename BasicJsonType::parser_callback_t parser_callback_t
bool start_array(std::size_t len)
~json_sax_dom_callback_parser()=default
json_sax_dom_callback_parser(const json_sax_dom_callback_parser &)=delete
typename BasicJsonType::binary_t binary_t
bool binary(binary_t &val)
bool number_integer(number_integer_t val)
BasicJsonType & root
the parsed JSON value
typename BasicJsonType::number_float_t number_float_t
typename BasicJsonType::parse_event_t parse_event_t
bool number_unsigned(number_unsigned_t val)
json_sax_dom_callback_parser & operator=(json_sax_dom_callback_parser &&)=default
bool string(string_t &val)
bool number_float(number_float_t val, const string_t &)
json_sax_dom_callback_parser(json_sax_dom_callback_parser &&)=default
bool parse_error(std::size_t, const std::string &, const Exception &ex)
json_sax_dom_callback_parser(BasicJsonType &r, const parser_callback_t cb, const bool allow_exceptions_=true)
SAX implementation to create a JSON value from SAX events.
bool start_array(std::size_t len)
json_sax_dom_parser(const json_sax_dom_parser &)=delete
typename BasicJsonType::binary_t binary_t
json_sax_dom_parser & operator=(json_sax_dom_parser &&)=default
bool number_unsigned(number_unsigned_t val)
typename BasicJsonType::number_integer_t number_integer_t
~json_sax_dom_parser()=default
bool parse_error(std::size_t, const std::string &, const Exception &ex)
JSON_HEDLEY_RETURNS_NON_NULL BasicJsonType * handle_value(Value &&v)
bool string(string_t &val)
typename BasicJsonType::number_unsigned_t number_unsigned_t
bool start_object(std::size_t len)
bool binary(binary_t &val)
constexpr bool is_errored() const
json_sax_dom_parser(json_sax_dom_parser &&)=default
typename BasicJsonType::number_float_t number_float_t
json_sax_dom_parser & operator=(const json_sax_dom_parser &)=delete
BasicJsonType & root
the parsed JSON value
bool number_float(number_float_t val, const string_t &)
json_sax_dom_parser(BasicJsonType &r, const bool allow_exceptions_=true)
typename BasicJsonType::string_t string_t
bool number_integer(number_integer_t val)
JSON_HEDLEY_RETURNS_NON_NULL static JSON_HEDLEY_CONST const char * token_type_name(const token_type t) noexcept
return name of values of type token_type (only used for errors)
token_type
token types for the parser
@ value_float
an floating point number – use get_number_float() for actual value
@ begin_array
the character for array begin [
@ value_string
a string – use get_string() for actual value
@ end_array
the character for array end ]
@ uninitialized
indicating the scanner is uninitialized
@ parse_error
indicating a parse error
@ value_integer
a signed integer – use get_number_integer() for actual value
@ value_separator
the value separator ,
@ end_object
the character for object end }
@ literal_true
the true literal
@ begin_object
the character for object begin {
@ value_unsigned
an unsigned integer – use get_number_unsigned() for actual value
@ literal_null
the null literal
@ end_of_input
indicating the end of the input buffer
@ name_separator
the name separator :
@ literal_or_value
a literal or the begin of a value (only for diagnostics)
@ literal_false
the false literal
string_t & get_string()
return current string value (implicitly resets the token; useful only once)
number_float_t value_float
const bool ignore_comments
whether comments should be ignored (true) or signaled as errors (false)
void add(char_int_type c)
add a character to token_buffer
void reset() noexcept
reset token_buffer; current character is beginning of token
bool next_unget
whether the next get() call should just return current
char_int_type current
the current character
typename BasicJsonType::number_float_t number_float_t
typename std::char_traits< char_type >::int_type char_int_type
static JSON_HEDLEY_PURE char get_decimal_point() noexcept
return the locale-dependent decimal point
number_integer_t value_integer
InputAdapterType ia
input adapter
typename BasicJsonType::number_integer_t number_integer_t
lexer & operator=(lexer &&)=default
static void strtof(float &f, const char *str, char **endptr) noexcept
const char_int_type decimal_point_char
the decimal point
bool skip_bom()
skip the UTF-8 byte order mark
const char * error_message
a description of occurred lexer errors
lexer(InputAdapterType &&adapter, bool ignore_comments_=false) noexcept
position_t position
the start position of the current token
constexpr position_t get_position() const noexcept
return position of last read token
std::vector< char_type > token_string
raw input token string (for error messages)
constexpr number_integer_t get_number_integer() const noexcept
return integer value
typename lexer_base< BasicJsonType >::token_type token_type
typename InputAdapterType::char_type char_type
token_type scan_number()
scan a number literal
lexer & operator=(lexer &)=delete
void unget()
unget current character (read it again on next get)
token_type scan_string()
scan a string literal
lexer(const lexer &)=delete
constexpr number_unsigned_t get_number_unsigned() const noexcept
return unsigned integer value
string_t token_buffer
buffer for variable-length tokens (numbers, strings)
token_type scan_literal(const char_type *literal_text, const std::size_t length, token_type return_type)
constexpr number_float_t get_number_float() const noexcept
return floating-point value
int get_codepoint()
get codepoint from 4 hex characters following \u
std::string get_token_string() const
number_unsigned_t value_unsigned
typename BasicJsonType::number_unsigned_t number_unsigned_t
bool next_byte_in_range(std::initializer_list< char_int_type > ranges)
check if the next byte(s) are inside a given range
typename BasicJsonType::string_t string_t
bool scan_comment()
scan a comment
JSON_HEDLEY_RETURNS_NON_NULL constexpr const char * get_error_message() const noexcept
return syntax error message
exception indicating other library errors
static other_error create(int id_, const std::string &what_arg, const BasicJsonType &context)
exception indicating access out of the defined range
static out_of_range create(int id_, const std::string &what_arg, const BasicJsonType &context)
output_adapter(std::basic_ostream< CharType > &s)
output_adapter(std::vector< CharType, AllocatorType > &vec)
output_adapter(StringType &s)
output adapter for output streams
void write_character(CharType c) override
std::basic_ostream< CharType > & stream
output_stream_adapter(std::basic_ostream< CharType > &s) noexcept
output adapter for basic_string
void write_character(CharType c) override
output_string_adapter(StringType &s) noexcept
output adapter for byte vectors
output_vector_adapter(std::vector< CharType, AllocatorType > &vec) noexcept
void write_character(CharType c) override
std::vector< CharType, AllocatorType > & v
exception indicating a parse error
parse_error(int id_, std::size_t byte_, const char *what_arg)
static parse_error create(int id_, std::size_t byte_, const std::string &what_arg, const BasicJsonType &context)
const std::size_t byte
byte index of the parse error
static parse_error create(int id_, const position_t &pos, const std::string &what_arg, const BasicJsonType &context)
create a parse error exception
static std::string position_string(const position_t &pos)
bool sax_parse(SAX *sax, const bool strict=true)
token_type get_token()
get next token from lexer
token_type last_token
the type of the last read token
parser(InputAdapterType &&adapter, const parser_callback_t< BasicJsonType > cb=nullptr, const bool allow_exceptions_=true, const bool skip_comments=false)
a parser reading from an input adapter
bool accept(const bool strict=true)
public accept interface
typename BasicJsonType::string_t string_t
typename BasicJsonType::number_unsigned_t number_unsigned_t
typename lexer_t::token_type token_type
bool sax_parse_internal(SAX *sax)
const parser_callback_t< BasicJsonType > callback
callback function
void parse(const bool strict, BasicJsonType &result)
public parser interface
std::string exception_message(const token_type expected, const std::string &context)
typename BasicJsonType::number_float_t number_float_t
const bool allow_exceptions
whether to throw exceptions in case of errors
typename BasicJsonType::number_integer_t number_integer_t
primitive_iterator_t operator+(difference_type n) noexcept
primitive_iterator_t & operator++() noexcept
constexpr bool is_end() const noexcept
return whether the iterator is at end
primitive_iterator_t & operator-=(difference_type n) noexcept
constexpr bool is_begin() const noexcept
return whether the iterator can be dereferenced
friend constexpr bool operator<(primitive_iterator_t lhs, primitive_iterator_t rhs) noexcept
void set_begin() noexcept
set iterator to a defined beginning
primitive_iterator_t const operator++(int) noexcept
static constexpr difference_type end_value
friend constexpr bool operator==(primitive_iterator_t lhs, primitive_iterator_t rhs) noexcept
friend constexpr difference_type operator-(primitive_iterator_t lhs, primitive_iterator_t rhs) noexcept
primitive_iterator_t & operator--() noexcept
void set_end() noexcept
set iterator to a defined past the end
constexpr difference_type get_value() const noexcept
primitive_iterator_t const operator--(int) noexcept
std::ptrdiff_t difference_type
primitive_iterator_t & operator+=(difference_type n) noexcept
static constexpr difference_type begin_value
const error_handler_t error_handler
error_handler how to react on decoding errors
typename BasicJsonType::number_unsigned_t number_unsigned_t
const std::lconv * loc
the locale
std::array< char, 64 > number_buffer
a (hopefully) large enough character buffer
static constexpr std::uint8_t UTF8_ACCEPT
serializer(serializer &&)=delete
serializer & operator=(serializer &&)=delete
const char decimal_point
the locale's decimal point character
typename BasicJsonType::number_float_t number_float_t
const char thousands_sep
the locale's thousand separator character
serializer & operator=(const serializer &)=delete
std::size_t undumped_chars
static constexpr std::uint8_t UTF8_REJECT
void dump(const BasicJsonType &val, const bool pretty_print, const bool ensure_ascii, const unsigned int indent_step, const unsigned int current_indent=0)
internal implementation of the serialization function
const char indent_char
the indentation character
std::size_t bytes_after_last_accept
std::array< char, 512 > string_buffer
string buffer
typename BasicJsonType::binary_t::value_type binary_char_t
JSON_PRIVATE_UNLESS_TESTED const bool ensure_ascii
serializer(output_adapter_t< char > s, const char ichar, error_handler_t error_handler_=error_handler_t::strict)
typename BasicJsonType::string_t string_t
serializer(const serializer &)=delete
typename BasicJsonType::number_integer_t number_integer_t
string_t indent_string
the indentation string
exception indicating executing a member function with a wrong type
static type_error create(int id_, const std::string &what_arg, const BasicJsonType &context)
JSON Pointer defines a string syntax for identifying a specific value within a JSON document.
std::vector< std::string > reference_tokens
the reference tokens
JSON_PRIVATE_UNLESS_TESTED JSON pointer has no BasicJsonType()))
json_pointer & operator/=(std::string token)
append an unescaped reference token at the end of this JSON pointer
json_pointer & operator/=(const json_pointer &ptr)
append another JSON pointer at the end of this JSON pointer
friend json_pointer operator/(const json_pointer &lhs, std::size_t array_idx)
create a new JSON pointer by appending the array-index-token at the end of the JSON pointer
std::string to_string() const
return a string representation of the JSON pointer
const BasicJsonType & get_unchecked(const BasicJsonType *ptr) const
return a const reference to the pointed to value
friend bool operator==(json_pointer const &lhs, json_pointer const &rhs) noexcept
compares two JSON pointers for equality
void pop_back()
remove last reference token
const std::string & back() const
return last reference token
const BasicJsonType & get_checked(const BasicJsonType *ptr) const
bool empty() const noexcept
return whether pointer points to the root document
friend bool operator!=(json_pointer const &lhs, json_pointer const &rhs) noexcept
compares two JSON pointers for inequality
void push_back(const std::string &token)
append an unescaped token at the end of the reference pointer
json_pointer(const std::string &s="")
create JSON pointer
friend json_pointer operator/(const json_pointer &lhs, const json_pointer &rhs)
create a new JSON pointer by appending the right JSON pointer at the end of the left JSON pointer
bool contains(const BasicJsonType *ptr) const
static BasicJsonType unflatten(const BasicJsonType &value)
BasicJsonType & get_and_create(BasicJsonType &j) const
create and return a reference to the pointed to value
friend json_pointer operator/(const json_pointer &lhs, std::string token)
create a new JSON pointer by appending the unescaped token at the end of the JSON pointer
static void flatten(const std::string &reference_string, const BasicJsonType &value, BasicJsonType &result)
void push_back(std::string &&token)
append an unescaped token at the end of the reference pointer
BasicJsonType & get_checked(BasicJsonType *ptr) const
json_pointer & operator/=(std::size_t array_idx)
append an array index at the end of this JSON pointer
static BasicJsonType::size_type array_index(const std::string &s)
BasicJsonType & get_unchecked(BasicJsonType *ptr) const
return a reference to the pointed to value
json_pointer parent_pointer() const
returns the parent of this JSON pointer
static std::vector< std::string > split(const std::string &reference_string)
split the string input to reference tokens
decltype(get< N >(std::declval< ::nlohmann::detail::iteration_proxy_value< IteratorType > >())) type
#define NLOHMANN_BASIC_JSON_TPL_DECLARATION
#define JSON_HEDLEY_CONST
#define JSON_HEDLEY_DIAGNOSTIC_PUSH
#define JSON_HEDLEY_WARN_UNUSED_RESULT
#define JSON_PRIVATE_UNLESS_TESTED
#define NLOHMANN_JSON_VERSION_PATCH
#define JSON_HEDLEY_LIKELY(expr)
#define JSON_HEDLEY_NON_NULL(...)
#define JSON_INTERNAL_CATCH(exception)
#define JSON_HEDLEY_RETURNS_NON_NULL
#define JSON_CATCH(exception)
#define JSON_THROW(exception)
#define NLOHMANN_JSON_VERSION_MAJOR
#define NLOHMANN_BASIC_JSON_TPL
#define JSON_HEDLEY_UNLIKELY(expr)
#define NLOHMANN_JSON_VERSION_MINOR
#define NLOHMANN_CAN_CALL_STD_FUNC_IMPL(std_name)
#define JSON_HEDLEY_DIAGNOSTIC_POP
#define JSON_HEDLEY_DEPRECATED_FOR(since, replacement)
void grisu2(char *buf, int &len, int &decimal_exponent, diyfp m_minus, diyfp v, diyfp m_plus)
JSON_HEDLEY_RETURNS_NON_NULL char * format_buffer(char *buf, int len, int decimal_exponent, int min_exp, int max_exp)
prettify v = buf * 10^decimal_exponent
Target reinterpret_bits(const Source source)
boundaries compute_boundaries(FloatType value)
int find_largest_pow10(const std::uint32_t n, std::uint32_t &pow10)
void grisu2_round(char *buf, int len, std::uint64_t dist, std::uint64_t delta, std::uint64_t rest, std::uint64_t ten_k)
JSON_HEDLEY_RETURNS_NON_NULL char * append_exponent(char *buf, int e)
appends a decimal representation of e to buf
void grisu2_digit_gen(char *buffer, int &length, int &decimal_exponent, diyfp M_minus, diyfp w, diyfp M_plus)
cached_power get_cached_power_for_binary_exponent(int e)
detail namespace with internal helper functions
typename std::enable_if< B, T >::type enable_if_t
typename T::reference reference_t
bool operator<(const value_t lhs, const value_t rhs) noexcept
comparison operator for JSON types
static void unescape(std::string &s)
string unescaping as described in RFC 6901 (Sect. 4)
decltype(T::from_json(std::declval< Args >()...)) from_json_function
void to_json(BasicJsonType &j, T b) noexcept
value_type_t< iterator_traits< iterator_t< T > > > range_value_t
value_t
the JSON type enumeration
@ number_integer
number value (signed integer)
@ discarded
discarded by the parser callback function
@ binary
binary array (ordered collection of bytes)
@ object
object (unordered set of name/value pairs)
@ number_float
number value (floating-point)
@ number_unsigned
number value (unsigned integer)
@ array
array (ordered collection of values)
void from_json(const BasicJsonType &j, typename std::nullptr_t &n)
make_index_sequence< sizeof...(Ts)> index_sequence_for
decltype(std::declval< T & >().parse_error(std::declval< std::size_t >(), std::declval< const std::string & >(), std::declval< const Exception & >())) parse_error_function_t
typename T::pointer pointer_t
decltype(std::declval< T & >().string(std::declval< String & >())) string_function_t
std::function< bool(int, parse_event_t, BasicJsonType &)> parser_callback_t
typename T::difference_type difference_type_t
typename detector< nonesuch, void, Op, Args... >::type detected_t
void int_to_string(string_type &target, std::size_t value)
void from_json_array_impl(const BasicJsonType &j, typename BasicJsonType::array_t &arr, priority_tag< 3 >)
decltype(std::declval< T & >().key(std::declval< String & >())) key_function_t
decltype(std::declval< T & >().boolean(std::declval< bool >())) boolean_function_t
decltype(std::declval< T & >().binary(std::declval< Binary & >())) binary_function_t
decltype(std::declval< T & >().number_integer(std::declval< Integer >())) number_integer_function_t
JSON_HEDLEY_RETURNS_NON_NULL char * to_chars(char *first, const char *last, FloatType value)
generates a decimal representation of the floating-point number value in [first, last).
void to_json_tuple_impl(BasicJsonType &j, const Tuple &t, index_sequence< Idx... >)
enable_if_t< is_range< R >::value, result_of_begin< decltype(std::declval< R & >())> > iterator_t
std::is_convertible< detected_t< Op, Args... >, To > is_detected_convertible
typename std::remove_cv< typename std::remove_reference< T >::type >::type uncvref_t
cbor_tag_handler_t
how to treat CBOR tags
@ store
store tags as binary type
@ error
throw a parse_error exception in case of a tag
@ value
the parser finished reading a JSON value
@ key
the parser read a key of a value in an object
@ array_end
the parser read ] and finished processing a JSON array
@ array_start
the parser read [ and started to process a JSON array
@ object_start
the parser read { and started to process a JSON object
@ object_end
the parser read } and finished processing a JSON object
error_handler_t
how to treat decoding errors
@ strict
throw a type_error exception in case of invalid UTF-8
@ ignore
ignore invalid UTF-8 sequences
@ replace
replace invalid UTF-8 sequences with U+FFFD
decltype(std::declval< T & >().start_object(std::declval< std::size_t >())) start_object_function_t
iterator_input_adapter_factory< IteratorType >::adapter_type input_adapter(IteratorType first, IteratorType last)
typename T::key_type key_type_t
std::size_t combine(std::size_t seed, std::size_t h) noexcept
std::size_t hash(const BasicJsonType &j)
hash a JSON value
static bool little_endianness(int num=1) noexcept
determine system byte order
typename utility_internal::Gen< T, N >::type make_integer_sequence
decltype(std::declval< T & >().number_unsigned(std::declval< Unsigned >())) number_unsigned_function_t
std::is_same< Expected, detected_t< Op, Args... > > is_detected_exact
typename detected_or< Default, Op, Args... >::type detected_or_t
decltype(std::declval< T & >().start_array(std::declval< std::size_t >())) start_array_function_t
std::pair< A1, A2 > from_json_tuple_impl(BasicJsonType &&j, identity_tag< std::pair< A1, A2 > >, priority_tag< 0 >)
void get_arithmetic_value(const BasicJsonType &j, ArithmeticType &val)
typename detector< nonesuch, void, Op, Args... >::value_t is_detected
typename make_void< Ts... >::type void_t
make_integer_sequence< size_t, N > make_index_sequence
std::shared_ptr< output_adapter_protocol< CharType > > output_adapter_t
a type to simplify interfaces
typename T::mapped_type mapped_type_t
std::string escape(std::string s)
string escaping as described in RFC 6901 (Sect. 4)
input_format_t
the supported input formats
std::tuple< Args... > from_json_tuple_impl_base(BasicJsonType &&j, index_sequence< Idx... >)
decltype(std::declval< T >().template get< U >()) get_template_function
std::array< T, sizeof...(Idx)> from_json_inplace_array_impl(BasicJsonType &&j, identity_tag< std::array< T, sizeof...(Idx)> >, index_sequence< Idx... >)
decltype(input_adapter(std::declval< const char * >(), std::declval< const char * >())) contiguous_bytes_input_adapter
decltype(std::declval< T & >().null()) null_function_t
auto get(const nlohmann::detail::iteration_proxy_value< IteratorType > &i) -> decltype(i.key())
void replace_substring(std::string &s, const std::string &f, const std::string &t)
replace all occurrences of a substring by another string
typename T::iterator_category iterator_category_t
decltype(std::declval< T & >().number_float(std::declval< Float >(), std::declval< const String & >())) number_float_function_t
decltype(std::declval< T & >().end_array()) end_array_function_t
decltype(std::declval< T & >().end_object()) end_object_function_t
T conditional_static_cast(U value)
decltype(T::to_json(std::declval< Args >()...)) to_json_function
typename T::value_type value_type_t
namespace for Niels Lohmann
basic_json<> json
default specialization
NLOHMANN_BASIC_JSON_TPL_DECLARATION std::string to_string(const NLOHMANN_BASIC_JSON_TPL &j)
user-defined to_string function for JSON values
NLOHMANN_BASIC_JSON_TPL_DECLARATION void swap(nlohmann::NLOHMANN_BASIC_JSON_TPL &j1, nlohmann::NLOHMANN_BASIC_JSON_TPL &j2) noexcept(//NOLINT(readability-inconsistent-declaration-parameter-name) is_nothrow_move_constructible< nlohmann::NLOHMANN_BASIC_JSON_TPL >::value &&//NOLINT(misc-redundant-expression) is_nothrow_move_assignable< nlohmann::NLOHMANN_BASIC_JSON_TPL >::value)
exchanges the values of two JSON objects
default JSONSerializer template argument
static auto from_json(BasicJsonType &&j, TargetType &val) noexcept(noexcept(::nlohmann::from_json(std::forward< BasicJsonType >(j), val))) -> decltype(::nlohmann::from_json(std::forward< BasicJsonType >(j), val), void())
convert a JSON value to any value type
static auto from_json(BasicJsonType &&j) noexcept(noexcept(::nlohmann::from_json(std::forward< BasicJsonType >(j), detail::identity_tag< TargetType > {}))) -> decltype(::nlohmann::from_json(std::forward< BasicJsonType >(j), detail::identity_tag< TargetType > {}))
convert a JSON value to any value type
static auto to_json(BasicJsonType &j, TargetType &&val) noexcept(noexcept(::nlohmann::to_json(j, std::forward< TargetType >(val)))) -> decltype(::nlohmann::to_json(j, std::forward< TargetType >(val)), void())
convert any value type to a JSON value
static constexpr int kPrecision
static diyfp normalize(diyfp x) noexcept
normalize x such that the significand is >= 2^(q-1)
static diyfp normalize_to(const diyfp &x, const int target_exponent) noexcept
normalize x such that the result has the exponent E
static diyfp mul(const diyfp &x, const diyfp &y) noexcept
returns x * y
constexpr diyfp(std::uint64_t f_, int e_) noexcept
static diyfp sub(const diyfp &x, const diyfp &y) noexcept
returns x - y
static void construct(BasicJsonType &j, const CompatibleArrayType &arr)
static void construct(BasicJsonType &j, const std::valarray< T > &arr)
static void construct(BasicJsonType &j, const std::vector< bool > &arr)
static void construct(BasicJsonType &j, typename BasicJsonType::array_t &&arr)
static void construct(BasicJsonType &j, const typename BasicJsonType::array_t &arr)
static void construct(BasicJsonType &j, const typename BasicJsonType::binary_t &b)
static void construct(BasicJsonType &j, typename BasicJsonType::binary_t &&b)
static void construct(BasicJsonType &j, typename BasicJsonType::boolean_t b) noexcept
static void construct(BasicJsonType &j, typename BasicJsonType::number_float_t val) noexcept
static void construct(BasicJsonType &j, typename BasicJsonType::number_integer_t val) noexcept
static void construct(BasicJsonType &j, typename BasicJsonType::number_unsigned_t val) noexcept
static void construct(BasicJsonType &j, typename BasicJsonType::object_t &&obj)
static void construct(BasicJsonType &j, const typename BasicJsonType::object_t &obj)
static void construct(BasicJsonType &j, const CompatibleObjectType &obj)
static void construct(BasicJsonType &j, typename BasicJsonType::string_t &&s)
static void construct(BasicJsonType &j, const CompatibleStringType &str)
static void construct(BasicJsonType &j, const typename BasicJsonType::string_t &s)
auto operator()(const BasicJsonType &j, T &&val) const noexcept(noexcept(from_json(j, std::forward< T >(val)))) -> decltype(from_json(j, std::forward< T >(val)))
typename BasicJsonType::template json_serializer< T, void > serializer
typename BasicJsonType::template json_serializer< T, void > serializer
typename BasicJsonType::template json_serializer< T, void > serializer
static constexpr std::size_t size() noexcept
primitive_iterator_t primitive_iterator
generic iterator for all other types
BasicJsonType::array_t::iterator array_iterator
iterator for JSON arrays
BasicJsonType::object_t::iterator object_iterator
iterator for JSON objects
std::numeric_limits< CompatibleNumberIntegerType > CompatibleLimits
std::numeric_limits< RealIntegerType > RealLimits
typename BasicJsonType::object_t object_t
static constexpr auto value
nlohmann::detail::is_constructible_array_type_impl< BasicJsonType, ConstructibleArrayType, enable_if_t< !std::is_same< ConstructibleArrayType, typename BasicJsonType::value_type >::value &&!is_compatible_string_type< BasicJsonType, ConstructibleArrayType >::value &&is_default_constructible< ConstructibleArrayType >::value &&(std::is_move_assignable< ConstructibleArrayType >::value||std::is_copy_assignable< ConstructibleArrayType >::value)&&is_detected< iterator_t, ConstructibleArrayType >::value &&is_iterator_traits< iterator_traits< detected_t< iterator_t, ConstructibleArrayType > > >::value &&is_detected< range_value_t, ConstructibleArrayType >::value &&!std::is_same< ConstructibleArrayType, detected_t< range_value_t, ConstructibleArrayType > >::value &&is_complete_type< detected_t< range_value_t, ConstructibleArrayType > >::value > >::value_type range_value_t< ConstructibleArrayType > value_type
typename BasicJsonType::object_t object_t
static constexpr auto value
static constexpr bool value
typename std::iterator_traits< T >::value_type value_type
static one test(decltype(&C::capacity))
detected_t< result_of_end, t_ref > sentinel
detected_t< result_of_begin, t_ref > iterator
static constexpr auto is_iterator_begin
typename std::add_lvalue_reference< T >::type t_ref
static constexpr bool value
typename BasicJsonType::string_t string_t
typename BasicJsonType::exception exception_t
typename BasicJsonType::number_integer_t number_integer_t
typename BasicJsonType::number_float_t number_float_t
typename BasicJsonType::binary_t binary_t
typename BasicJsonType::number_unsigned_t number_unsigned_t
typename BasicJsonType::number_float_t number_float_t
typename BasicJsonType::number_unsigned_t number_unsigned_t
typename BasicJsonType::exception exception_t
static constexpr bool value
typename BasicJsonType::number_integer_t number_integer_t
typename BasicJsonType::string_t string_t
typename BasicJsonType::binary_t binary_t
std::random_access_iterator_tag iterator_category
ptrdiff_t difference_type
typename It::difference_type difference_type
typename It::reference reference
typename It::iterator_category iterator_category
typename It::pointer pointer
typename It::value_type value_type
nonesuch(nonesuch const &)=delete
void operator=(nonesuch &&)=delete
nonesuch(nonesuch const &&)=delete
void operator=(nonesuch const &)=delete
abstract output adapter interface
virtual void write_characters(const CharType *s, std::size_t length)=0
virtual void write_character(CharType c)=0
output_adapter_protocol(output_adapter_protocol &&) noexcept=default
virtual ~output_adapter_protocol()=default
output_adapter_protocol(const output_adapter_protocol &)=default
output_adapter_protocol()=default
struct to capture the start position of the current token
std::size_t lines_read
the number of lines read
std::size_t chars_read_current_line
the number of characters read in the current line
std::size_t chars_read_total
the total number of characters read
auto operator()(BasicJsonType &j, T &&val) const noexcept(noexcept(to_json(j, std::forward< T >(val)))) -> decltype(to_json(j, std::forward< T >(val)), void())
typename Extend< typename Gen< T, N/2 >::type, N/2, N % 2 >::type type
virtual bool start_object(std::size_t elements)=0
the beginning of an object was read
virtual bool string(string_t &val)=0
a string value was read
virtual bool null()=0
a null value was read
typename BasicJsonType::number_integer_t number_integer_t
typename BasicJsonType::binary_t binary_t
virtual bool end_array()=0
the end of an array was read
virtual bool key(string_t &val)=0
an object key was read
typename BasicJsonType::number_unsigned_t number_unsigned_t
virtual bool binary(binary_t &val)=0
a binary value was read
typename BasicJsonType::number_float_t number_float_t
virtual bool start_array(std::size_t elements)=0
the beginning of an array was read
virtual bool parse_error(std::size_t position, const std::string &last_token, const detail::exception &ex)=0
a parse error occurred
json_sax(json_sax &&) noexcept=default
virtual bool boolean(bool val)=0
a boolean value was read
json_sax(const json_sax &)=default
virtual bool end_object()=0
the end of an object was read
virtual bool number_unsigned(number_unsigned_t val)=0
an unsigned integer number was read
typename BasicJsonType::string_t string_t
virtual bool number_float(number_float_t val, const string_t &s)=0
a floating-point number was read
virtual bool number_integer(number_integer_t val)=0
an integer number was read
a minimal map-like container that preserves insertion order
ordered_map(std::initializer_list< T > init, const Allocator &alloc=Allocator())
std::vector< std::pair< const Key, T >, Allocator > Container
const T & at(const Key &key) const
iterator find(const Key &key)
iterator erase(iterator pos)
void insert(InputIt first, InputIt last)
std::pair< iterator, bool > insert(value_type &&value)
const_iterator find(const Key &key) const
size_type erase(const Key &key)
T & operator[](const Key &key)
iterator erase(iterator first, iterator last)
typename Container::const_iterator const_iterator
ordered_map(const Allocator &alloc=Allocator())
typename std::enable_if< std::is_convertible< typename std::iterator_traits< InputIt >::iterator_category, std::input_iterator_tag >::value >::type require_input_iter
ordered_map(It first, It last, const Allocator &alloc=Allocator())
std::pair< iterator, bool > insert(const value_type &value)
typename Container::size_type size_type
typename Container::value_type value_type
size_type count(const Key &key) const
typename Container::iterator iterator
std::pair< iterator, bool > emplace(const key_type &key, T &&t)
const T & operator[](const Key &key) const
std::size_t operator()(const nlohmann::NLOHMANN_BASIC_JSON_TPL &j) const
bool operator()(nlohmann::detail::value_t lhs, nlohmann::detail::value_t rhs) const noexcept
compare two value_t enum values