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>
69#include <forward_list>
75#include <unordered_map>
154 static constexpr std::array<std::uint8_t, 9> order = {{
155 0 , 3 , 4 , 5 , 1 , 2 , 2 ,
159 const auto l_index =
static_cast<std::size_t
>(lhs);
160 const auto r_index =
static_cast<std::size_t
>(
rhs);
161 return l_index < order.size() && r_index < order.size() && order[l_index] < order[r_index];
186#if !defined(JSON_HEDLEY_VERSION) || (JSON_HEDLEY_VERSION < 15)
187#if defined(JSON_HEDLEY_VERSION)
188#undef JSON_HEDLEY_VERSION
190#define JSON_HEDLEY_VERSION 15
192#if defined(JSON_HEDLEY_STRINGIFY_EX)
193#undef JSON_HEDLEY_STRINGIFY_EX
195#define JSON_HEDLEY_STRINGIFY_EX(x) #x
197#if defined(JSON_HEDLEY_STRINGIFY)
198#undef JSON_HEDLEY_STRINGIFY
200#define JSON_HEDLEY_STRINGIFY(x) JSON_HEDLEY_STRINGIFY_EX(x)
202#if defined(JSON_HEDLEY_CONCAT_EX)
203#undef JSON_HEDLEY_CONCAT_EX
205#define JSON_HEDLEY_CONCAT_EX(a, b) a##b
207#if defined(JSON_HEDLEY_CONCAT)
208#undef JSON_HEDLEY_CONCAT
210#define JSON_HEDLEY_CONCAT(a, b) JSON_HEDLEY_CONCAT_EX(a, b)
212#if defined(JSON_HEDLEY_CONCAT3_EX)
213#undef JSON_HEDLEY_CONCAT3_EX
215#define JSON_HEDLEY_CONCAT3_EX(a, b, c) a##b##c
217#if defined(JSON_HEDLEY_CONCAT3)
218#undef JSON_HEDLEY_CONCAT3
220#define JSON_HEDLEY_CONCAT3(a, b, c) JSON_HEDLEY_CONCAT3_EX(a, b, c)
222#if defined(JSON_HEDLEY_VERSION_ENCODE)
223#undef JSON_HEDLEY_VERSION_ENCODE
225#define JSON_HEDLEY_VERSION_ENCODE(major, minor, revision) (((major) * 1000000) + ((minor) * 1000) + (revision))
227#if defined(JSON_HEDLEY_VERSION_DECODE_MAJOR)
228#undef JSON_HEDLEY_VERSION_DECODE_MAJOR
230#define JSON_HEDLEY_VERSION_DECODE_MAJOR(version) ((version) / 1000000)
232#if defined(JSON_HEDLEY_VERSION_DECODE_MINOR)
233#undef JSON_HEDLEY_VERSION_DECODE_MINOR
235#define JSON_HEDLEY_VERSION_DECODE_MINOR(version) (((version) % 1000000) / 1000)
237#if defined(JSON_HEDLEY_VERSION_DECODE_REVISION)
238#undef JSON_HEDLEY_VERSION_DECODE_REVISION
240#define JSON_HEDLEY_VERSION_DECODE_REVISION(version) ((version) % 1000)
242#if defined(JSON_HEDLEY_GNUC_VERSION)
243#undef JSON_HEDLEY_GNUC_VERSION
245#if defined(__GNUC__) && defined(__GNUC_PATCHLEVEL__)
246#define JSON_HEDLEY_GNUC_VERSION JSON_HEDLEY_VERSION_ENCODE(__GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__)
247#elif defined(__GNUC__)
248#define JSON_HEDLEY_GNUC_VERSION JSON_HEDLEY_VERSION_ENCODE(__GNUC__, __GNUC_MINOR__, 0)
251#if defined(JSON_HEDLEY_GNUC_VERSION_CHECK)
252#undef JSON_HEDLEY_GNUC_VERSION_CHECK
254#if defined(JSON_HEDLEY_GNUC_VERSION)
255#define JSON_HEDLEY_GNUC_VERSION_CHECK(major, minor, patch) \
256 (JSON_HEDLEY_GNUC_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
258#define JSON_HEDLEY_GNUC_VERSION_CHECK(major, minor, patch) (0)
261#if defined(JSON_HEDLEY_MSVC_VERSION)
262#undef JSON_HEDLEY_MSVC_VERSION
264#if defined(_MSC_FULL_VER) && (_MSC_FULL_VER >= 140000000) && !defined(__ICL)
265#define JSON_HEDLEY_MSVC_VERSION \
266 JSON_HEDLEY_VERSION_ENCODE(_MSC_FULL_VER / 10000000, (_MSC_FULL_VER % 10000000) / 100000, \
267 (_MSC_FULL_VER % 100000) / 100)
268#elif defined(_MSC_FULL_VER) && !defined(__ICL)
269#define JSON_HEDLEY_MSVC_VERSION \
270 JSON_HEDLEY_VERSION_ENCODE(_MSC_FULL_VER / 1000000, (_MSC_FULL_VER % 1000000) / 10000, (_MSC_FULL_VER % 10000) / 10)
271#elif defined(_MSC_VER) && !defined(__ICL)
272#define JSON_HEDLEY_MSVC_VERSION JSON_HEDLEY_VERSION_ENCODE(_MSC_VER / 100, _MSC_VER % 100, 0)
275#if defined(JSON_HEDLEY_MSVC_VERSION_CHECK)
276#undef JSON_HEDLEY_MSVC_VERSION_CHECK
278#if !defined(JSON_HEDLEY_MSVC_VERSION)
279#define JSON_HEDLEY_MSVC_VERSION_CHECK(major, minor, patch) (0)
280#elif defined(_MSC_VER) && (_MSC_VER >= 1400)
281#define JSON_HEDLEY_MSVC_VERSION_CHECK(major, minor, patch) \
282 (_MSC_FULL_VER >= ((major * 10000000) + (minor * 100000) + (patch)))
283#elif defined(_MSC_VER) && (_MSC_VER >= 1200)
284#define JSON_HEDLEY_MSVC_VERSION_CHECK(major, minor, patch) \
285 (_MSC_FULL_VER >= ((major * 1000000) + (minor * 10000) + (patch)))
287#define JSON_HEDLEY_MSVC_VERSION_CHECK(major, minor, patch) (_MSC_VER >= ((major * 100) + (minor)))
290#if defined(JSON_HEDLEY_INTEL_VERSION)
291#undef JSON_HEDLEY_INTEL_VERSION
293#if defined(__INTEL_COMPILER) && defined(__INTEL_COMPILER_UPDATE) && !defined(__ICL)
294#define JSON_HEDLEY_INTEL_VERSION \
295 JSON_HEDLEY_VERSION_ENCODE(__INTEL_COMPILER / 100, __INTEL_COMPILER % 100, __INTEL_COMPILER_UPDATE)
296#elif defined(__INTEL_COMPILER) && !defined(__ICL)
297#define JSON_HEDLEY_INTEL_VERSION JSON_HEDLEY_VERSION_ENCODE(__INTEL_COMPILER / 100, __INTEL_COMPILER % 100, 0)
300#if defined(JSON_HEDLEY_INTEL_VERSION_CHECK)
301#undef JSON_HEDLEY_INTEL_VERSION_CHECK
303#if defined(JSON_HEDLEY_INTEL_VERSION)
304#define JSON_HEDLEY_INTEL_VERSION_CHECK(major, minor, patch) \
305 (JSON_HEDLEY_INTEL_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
307#define JSON_HEDLEY_INTEL_VERSION_CHECK(major, minor, patch) (0)
310#if defined(JSON_HEDLEY_INTEL_CL_VERSION)
311#undef JSON_HEDLEY_INTEL_CL_VERSION
313#if defined(__INTEL_COMPILER) && defined(__INTEL_COMPILER_UPDATE) && defined(__ICL)
314#define JSON_HEDLEY_INTEL_CL_VERSION JSON_HEDLEY_VERSION_ENCODE(__INTEL_COMPILER, __INTEL_COMPILER_UPDATE, 0)
317#if defined(JSON_HEDLEY_INTEL_CL_VERSION_CHECK)
318#undef JSON_HEDLEY_INTEL_CL_VERSION_CHECK
320#if defined(JSON_HEDLEY_INTEL_CL_VERSION)
321#define JSON_HEDLEY_INTEL_CL_VERSION_CHECK(major, minor, patch) \
322 (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) \
339 (JSON_HEDLEY_PGI_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
341#define JSON_HEDLEY_PGI_VERSION_CHECK(major, minor, patch) (0)
344#if defined(JSON_HEDLEY_SUNPRO_VERSION)
345#undef JSON_HEDLEY_SUNPRO_VERSION
347#if defined(__SUNPRO_C) && (__SUNPRO_C > 0x1000)
348#define JSON_HEDLEY_SUNPRO_VERSION \
349 JSON_HEDLEY_VERSION_ENCODE((((__SUNPRO_C >> 16) & 0xf) * 10) + ((__SUNPRO_C >> 12) & 0xf), \
350 (((__SUNPRO_C >> 8) & 0xf) * 10) + ((__SUNPRO_C >> 4) & 0xf), (__SUNPRO_C & 0xf) * 10)
351#elif defined(__SUNPRO_C)
352#define JSON_HEDLEY_SUNPRO_VERSION \
353 JSON_HEDLEY_VERSION_ENCODE((__SUNPRO_C >> 8) & 0xf, (__SUNPRO_C >> 4) & 0xf, (__SUNPRO_C) & 0xf)
354#elif defined(__SUNPRO_CC) && (__SUNPRO_CC > 0x1000)
355#define JSON_HEDLEY_SUNPRO_VERSION \
356 JSON_HEDLEY_VERSION_ENCODE((((__SUNPRO_CC >> 16) & 0xf) * 10) + ((__SUNPRO_CC >> 12) & 0xf), \
357 (((__SUNPRO_CC >> 8) & 0xf) * 10) + ((__SUNPRO_CC >> 4) & 0xf), \
358 (__SUNPRO_CC & 0xf) * 10)
359#elif defined(__SUNPRO_CC)
360#define JSON_HEDLEY_SUNPRO_VERSION \
361 JSON_HEDLEY_VERSION_ENCODE((__SUNPRO_CC >> 8) & 0xf, (__SUNPRO_CC >> 4) & 0xf, (__SUNPRO_CC) & 0xf)
364#if defined(JSON_HEDLEY_SUNPRO_VERSION_CHECK)
365#undef JSON_HEDLEY_SUNPRO_VERSION_CHECK
367#if defined(JSON_HEDLEY_SUNPRO_VERSION)
368#define JSON_HEDLEY_SUNPRO_VERSION_CHECK(major, minor, patch) \
369 (JSON_HEDLEY_SUNPRO_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
371#define JSON_HEDLEY_SUNPRO_VERSION_CHECK(major, minor, patch) (0)
374#if defined(JSON_HEDLEY_EMSCRIPTEN_VERSION)
375#undef JSON_HEDLEY_EMSCRIPTEN_VERSION
377#if defined(__EMSCRIPTEN__)
378#define JSON_HEDLEY_EMSCRIPTEN_VERSION \
379 JSON_HEDLEY_VERSION_ENCODE(__EMSCRIPTEN_major__, __EMSCRIPTEN_minor__, __EMSCRIPTEN_tiny__)
382#if defined(JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK)
383#undef JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK
385#if defined(JSON_HEDLEY_EMSCRIPTEN_VERSION)
386#define JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK(major, minor, patch) \
387 (JSON_HEDLEY_EMSCRIPTEN_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
389#define JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK(major, minor, patch) (0)
392#if defined(JSON_HEDLEY_ARM_VERSION)
393#undef JSON_HEDLEY_ARM_VERSION
395#if defined(__CC_ARM) && defined(__ARMCOMPILER_VERSION)
396#define JSON_HEDLEY_ARM_VERSION \
397 JSON_HEDLEY_VERSION_ENCODE(__ARMCOMPILER_VERSION / 1000000, (__ARMCOMPILER_VERSION % 1000000) / 10000, \
398 (__ARMCOMPILER_VERSION % 10000) / 100)
399#elif defined(__CC_ARM) && defined(__ARMCC_VERSION)
400#define JSON_HEDLEY_ARM_VERSION \
401 JSON_HEDLEY_VERSION_ENCODE(__ARMCC_VERSION / 1000000, (__ARMCC_VERSION % 1000000) / 10000, \
402 (__ARMCC_VERSION % 10000) / 100)
405#if defined(JSON_HEDLEY_ARM_VERSION_CHECK)
406#undef JSON_HEDLEY_ARM_VERSION_CHECK
408#if defined(JSON_HEDLEY_ARM_VERSION)
409#define JSON_HEDLEY_ARM_VERSION_CHECK(major, minor, patch) \
410 (JSON_HEDLEY_ARM_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
412#define JSON_HEDLEY_ARM_VERSION_CHECK(major, minor, patch) (0)
415#if defined(JSON_HEDLEY_IBM_VERSION)
416#undef JSON_HEDLEY_IBM_VERSION
418#if defined(__ibmxl__)
419#define JSON_HEDLEY_IBM_VERSION JSON_HEDLEY_VERSION_ENCODE(__ibmxl_version__, __ibmxl_release__, __ibmxl_modification__)
420#elif defined(__xlC__) && defined(__xlC_ver__)
421#define JSON_HEDLEY_IBM_VERSION JSON_HEDLEY_VERSION_ENCODE(__xlC__ >> 8, __xlC__ & 0xff, (__xlC_ver__ >> 8) & 0xff)
422#elif defined(__xlC__)
423#define JSON_HEDLEY_IBM_VERSION JSON_HEDLEY_VERSION_ENCODE(__xlC__ >> 8, __xlC__ & 0xff, 0)
426#if defined(JSON_HEDLEY_IBM_VERSION_CHECK)
427#undef JSON_HEDLEY_IBM_VERSION_CHECK
429#if defined(JSON_HEDLEY_IBM_VERSION)
430#define JSON_HEDLEY_IBM_VERSION_CHECK(major, minor, patch) \
431 (JSON_HEDLEY_IBM_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
433#define JSON_HEDLEY_IBM_VERSION_CHECK(major, minor, patch) (0)
436#if defined(JSON_HEDLEY_TI_VERSION)
437#undef JSON_HEDLEY_TI_VERSION
439#if defined(__TI_COMPILER_VERSION__) \
440 && (defined(__TMS470__) || defined(__TI_ARM__) || defined(__MSP430__) || defined(__TMS320C2000__))
441#if (__TI_COMPILER_VERSION__ >= 16000000)
442#define JSON_HEDLEY_TI_VERSION \
443 JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, \
444 (__TI_COMPILER_VERSION__ % 1000))
448#if defined(JSON_HEDLEY_TI_VERSION_CHECK)
449#undef JSON_HEDLEY_TI_VERSION_CHECK
451#if defined(JSON_HEDLEY_TI_VERSION)
452#define JSON_HEDLEY_TI_VERSION_CHECK(major, minor, patch) \
453 (JSON_HEDLEY_TI_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
455#define JSON_HEDLEY_TI_VERSION_CHECK(major, minor, patch) (0)
458#if defined(JSON_HEDLEY_TI_CL2000_VERSION)
459#undef JSON_HEDLEY_TI_CL2000_VERSION
461#if defined(__TI_COMPILER_VERSION__) && defined(__TMS320C2000__)
462#define JSON_HEDLEY_TI_CL2000_VERSION \
463 JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, \
464 (__TI_COMPILER_VERSION__ % 1000))
467#if defined(JSON_HEDLEY_TI_CL2000_VERSION_CHECK)
468#undef JSON_HEDLEY_TI_CL2000_VERSION_CHECK
470#if defined(JSON_HEDLEY_TI_CL2000_VERSION)
471#define JSON_HEDLEY_TI_CL2000_VERSION_CHECK(major, minor, patch) \
472 (JSON_HEDLEY_TI_CL2000_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
474#define JSON_HEDLEY_TI_CL2000_VERSION_CHECK(major, minor, patch) (0)
477#if defined(JSON_HEDLEY_TI_CL430_VERSION)
478#undef JSON_HEDLEY_TI_CL430_VERSION
480#if defined(__TI_COMPILER_VERSION__) && defined(__MSP430__)
481#define JSON_HEDLEY_TI_CL430_VERSION \
482 JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, \
483 (__TI_COMPILER_VERSION__ % 1000))
486#if defined(JSON_HEDLEY_TI_CL430_VERSION_CHECK)
487#undef JSON_HEDLEY_TI_CL430_VERSION_CHECK
489#if defined(JSON_HEDLEY_TI_CL430_VERSION)
490#define JSON_HEDLEY_TI_CL430_VERSION_CHECK(major, minor, patch) \
491 (JSON_HEDLEY_TI_CL430_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
493#define JSON_HEDLEY_TI_CL430_VERSION_CHECK(major, minor, patch) (0)
496#if defined(JSON_HEDLEY_TI_ARMCL_VERSION)
497#undef JSON_HEDLEY_TI_ARMCL_VERSION
499#if defined(__TI_COMPILER_VERSION__) && (defined(__TMS470__) || defined(__TI_ARM__))
500#define JSON_HEDLEY_TI_ARMCL_VERSION \
501 JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, \
502 (__TI_COMPILER_VERSION__ % 1000))
505#if defined(JSON_HEDLEY_TI_ARMCL_VERSION_CHECK)
506#undef JSON_HEDLEY_TI_ARMCL_VERSION_CHECK
508#if defined(JSON_HEDLEY_TI_ARMCL_VERSION)
509#define JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(major, minor, patch) \
510 (JSON_HEDLEY_TI_ARMCL_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
512#define JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(major, minor, patch) (0)
515#if defined(JSON_HEDLEY_TI_CL6X_VERSION)
516#undef JSON_HEDLEY_TI_CL6X_VERSION
518#if defined(__TI_COMPILER_VERSION__) && defined(__TMS320C6X__)
519#define JSON_HEDLEY_TI_CL6X_VERSION \
520 JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, \
521 (__TI_COMPILER_VERSION__ % 1000))
524#if defined(JSON_HEDLEY_TI_CL6X_VERSION_CHECK)
525#undef JSON_HEDLEY_TI_CL6X_VERSION_CHECK
527#if defined(JSON_HEDLEY_TI_CL6X_VERSION)
528#define JSON_HEDLEY_TI_CL6X_VERSION_CHECK(major, minor, patch) \
529 (JSON_HEDLEY_TI_CL6X_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
531#define JSON_HEDLEY_TI_CL6X_VERSION_CHECK(major, minor, patch) (0)
534#if defined(JSON_HEDLEY_TI_CL7X_VERSION)
535#undef JSON_HEDLEY_TI_CL7X_VERSION
537#if defined(__TI_COMPILER_VERSION__) && defined(__C7000__)
538#define JSON_HEDLEY_TI_CL7X_VERSION \
539 JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, \
540 (__TI_COMPILER_VERSION__ % 1000))
543#if defined(JSON_HEDLEY_TI_CL7X_VERSION_CHECK)
544#undef JSON_HEDLEY_TI_CL7X_VERSION_CHECK
546#if defined(JSON_HEDLEY_TI_CL7X_VERSION)
547#define JSON_HEDLEY_TI_CL7X_VERSION_CHECK(major, minor, patch) \
548 (JSON_HEDLEY_TI_CL7X_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
550#define JSON_HEDLEY_TI_CL7X_VERSION_CHECK(major, minor, patch) (0)
553#if defined(JSON_HEDLEY_TI_CLPRU_VERSION)
554#undef JSON_HEDLEY_TI_CLPRU_VERSION
556#if defined(__TI_COMPILER_VERSION__) && defined(__PRU__)
557#define JSON_HEDLEY_TI_CLPRU_VERSION \
558 JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, \
559 (__TI_COMPILER_VERSION__ % 1000))
562#if defined(JSON_HEDLEY_TI_CLPRU_VERSION_CHECK)
563#undef JSON_HEDLEY_TI_CLPRU_VERSION_CHECK
565#if defined(JSON_HEDLEY_TI_CLPRU_VERSION)
566#define JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(major, minor, patch) \
567 (JSON_HEDLEY_TI_CLPRU_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
569#define JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(major, minor, patch) (0)
572#if defined(JSON_HEDLEY_CRAY_VERSION)
573#undef JSON_HEDLEY_CRAY_VERSION
576#if defined(_RELEASE_PATCHLEVEL)
577#define JSON_HEDLEY_CRAY_VERSION JSON_HEDLEY_VERSION_ENCODE(_RELEASE_MAJOR, _RELEASE_MINOR, _RELEASE_PATCHLEVEL)
579#define JSON_HEDLEY_CRAY_VERSION JSON_HEDLEY_VERSION_ENCODE(_RELEASE_MAJOR, _RELEASE_MINOR, 0)
583#if defined(JSON_HEDLEY_CRAY_VERSION_CHECK)
584#undef JSON_HEDLEY_CRAY_VERSION_CHECK
586#if defined(JSON_HEDLEY_CRAY_VERSION)
587#define JSON_HEDLEY_CRAY_VERSION_CHECK(major, minor, patch) \
588 (JSON_HEDLEY_CRAY_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
590#define JSON_HEDLEY_CRAY_VERSION_CHECK(major, minor, patch) (0)
593#if defined(JSON_HEDLEY_IAR_VERSION)
594#undef JSON_HEDLEY_IAR_VERSION
596#if defined(__IAR_SYSTEMS_ICC__)
598#define JSON_HEDLEY_IAR_VERSION \
599 JSON_HEDLEY_VERSION_ENCODE((__VER__ / 1000000), ((__VER__ / 1000) % 1000), (__VER__ % 1000))
601#define JSON_HEDLEY_IAR_VERSION JSON_HEDLEY_VERSION_ENCODE(__VER__ / 100, __VER__ % 100, 0)
605#if defined(JSON_HEDLEY_IAR_VERSION_CHECK)
606#undef JSON_HEDLEY_IAR_VERSION_CHECK
608#if defined(JSON_HEDLEY_IAR_VERSION)
609#define JSON_HEDLEY_IAR_VERSION_CHECK(major, minor, patch) \
610 (JSON_HEDLEY_IAR_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
612#define JSON_HEDLEY_IAR_VERSION_CHECK(major, minor, patch) (0)
615#if defined(JSON_HEDLEY_TINYC_VERSION)
616#undef JSON_HEDLEY_TINYC_VERSION
618#if defined(__TINYC__)
619#define JSON_HEDLEY_TINYC_VERSION JSON_HEDLEY_VERSION_ENCODE(__TINYC__ / 1000, (__TINYC__ / 100) % 10, __TINYC__ % 100)
622#if defined(JSON_HEDLEY_TINYC_VERSION_CHECK)
623#undef JSON_HEDLEY_TINYC_VERSION_CHECK
625#if defined(JSON_HEDLEY_TINYC_VERSION)
626#define JSON_HEDLEY_TINYC_VERSION_CHECK(major, minor, patch) \
627 (JSON_HEDLEY_TINYC_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
629#define JSON_HEDLEY_TINYC_VERSION_CHECK(major, minor, patch) (0)
632#if defined(JSON_HEDLEY_DMC_VERSION)
633#undef JSON_HEDLEY_DMC_VERSION
636#define JSON_HEDLEY_DMC_VERSION JSON_HEDLEY_VERSION_ENCODE(__DMC__ >> 8, (__DMC__ >> 4) & 0xf, __DMC__ & 0xf)
639#if defined(JSON_HEDLEY_DMC_VERSION_CHECK)
640#undef JSON_HEDLEY_DMC_VERSION_CHECK
642#if defined(JSON_HEDLEY_DMC_VERSION)
643#define JSON_HEDLEY_DMC_VERSION_CHECK(major, minor, patch) \
644 (JSON_HEDLEY_DMC_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
646#define JSON_HEDLEY_DMC_VERSION_CHECK(major, minor, patch) (0)
649#if defined(JSON_HEDLEY_COMPCERT_VERSION)
650#undef JSON_HEDLEY_COMPCERT_VERSION
652#if defined(__COMPCERT_VERSION__)
653#define JSON_HEDLEY_COMPCERT_VERSION \
654 JSON_HEDLEY_VERSION_ENCODE(__COMPCERT_VERSION__ / 10000, (__COMPCERT_VERSION__ / 100) % 100, \
655 __COMPCERT_VERSION__ % 100)
658#if defined(JSON_HEDLEY_COMPCERT_VERSION_CHECK)
659#undef JSON_HEDLEY_COMPCERT_VERSION_CHECK
661#if defined(JSON_HEDLEY_COMPCERT_VERSION)
662#define JSON_HEDLEY_COMPCERT_VERSION_CHECK(major, minor, patch) \
663 (JSON_HEDLEY_COMPCERT_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
665#define JSON_HEDLEY_COMPCERT_VERSION_CHECK(major, minor, patch) (0)
668#if defined(JSON_HEDLEY_PELLES_VERSION)
669#undef JSON_HEDLEY_PELLES_VERSION
672#define JSON_HEDLEY_PELLES_VERSION JSON_HEDLEY_VERSION_ENCODE(__POCC__ / 100, __POCC__ % 100, 0)
675#if defined(JSON_HEDLEY_PELLES_VERSION_CHECK)
676#undef JSON_HEDLEY_PELLES_VERSION_CHECK
678#if defined(JSON_HEDLEY_PELLES_VERSION)
679#define JSON_HEDLEY_PELLES_VERSION_CHECK(major, minor, patch) \
680 (JSON_HEDLEY_PELLES_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
682#define JSON_HEDLEY_PELLES_VERSION_CHECK(major, minor, patch) (0)
685#if defined(JSON_HEDLEY_MCST_LCC_VERSION)
686#undef JSON_HEDLEY_MCST_LCC_VERSION
688#if defined(__LCC__) && defined(__LCC_MINOR__)
689#define JSON_HEDLEY_MCST_LCC_VERSION JSON_HEDLEY_VERSION_ENCODE(__LCC__ / 100, __LCC__ % 100, __LCC_MINOR__)
692#if defined(JSON_HEDLEY_MCST_LCC_VERSION_CHECK)
693#undef JSON_HEDLEY_MCST_LCC_VERSION_CHECK
695#if defined(JSON_HEDLEY_MCST_LCC_VERSION)
696#define JSON_HEDLEY_MCST_LCC_VERSION_CHECK(major, minor, patch) \
697 (JSON_HEDLEY_MCST_LCC_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
699#define JSON_HEDLEY_MCST_LCC_VERSION_CHECK(major, minor, patch) (0)
702#if defined(JSON_HEDLEY_GCC_VERSION)
703#undef JSON_HEDLEY_GCC_VERSION
705#if defined(JSON_HEDLEY_GNUC_VERSION) && !defined(__clang__) && !defined(JSON_HEDLEY_INTEL_VERSION) \
706 && !defined(JSON_HEDLEY_PGI_VERSION) && !defined(JSON_HEDLEY_ARM_VERSION) && !defined(JSON_HEDLEY_CRAY_VERSION) \
707 && !defined(JSON_HEDLEY_TI_VERSION) && !defined(JSON_HEDLEY_TI_ARMCL_VERSION) \
708 && !defined(JSON_HEDLEY_TI_CL430_VERSION) && !defined(JSON_HEDLEY_TI_CL2000_VERSION) \
709 && !defined(JSON_HEDLEY_TI_CL6X_VERSION) && !defined(JSON_HEDLEY_TI_CL7X_VERSION) \
710 && !defined(JSON_HEDLEY_TI_CLPRU_VERSION) && !defined(__COMPCERT__) && !defined(JSON_HEDLEY_MCST_LCC_VERSION)
711#define JSON_HEDLEY_GCC_VERSION JSON_HEDLEY_GNUC_VERSION
714#if defined(JSON_HEDLEY_GCC_VERSION_CHECK)
715#undef JSON_HEDLEY_GCC_VERSION_CHECK
717#if defined(JSON_HEDLEY_GCC_VERSION)
718#define JSON_HEDLEY_GCC_VERSION_CHECK(major, minor, patch) \
719 (JSON_HEDLEY_GCC_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
721#define JSON_HEDLEY_GCC_VERSION_CHECK(major, minor, patch) (0)
724#if defined(JSON_HEDLEY_HAS_ATTRIBUTE)
725#undef JSON_HEDLEY_HAS_ATTRIBUTE
727#if defined(__has_attribute) && ((!defined(JSON_HEDLEY_IAR_VERSION) || JSON_HEDLEY_IAR_VERSION_CHECK(8, 5, 9)))
728#define JSON_HEDLEY_HAS_ATTRIBUTE(attribute) __has_attribute(attribute)
730#define JSON_HEDLEY_HAS_ATTRIBUTE(attribute) (0)
733#if defined(JSON_HEDLEY_GNUC_HAS_ATTRIBUTE)
734#undef JSON_HEDLEY_GNUC_HAS_ATTRIBUTE
736#if defined(__has_attribute)
737#define JSON_HEDLEY_GNUC_HAS_ATTRIBUTE(attribute, major, minor, patch) JSON_HEDLEY_HAS_ATTRIBUTE(attribute)
739#define JSON_HEDLEY_GNUC_HAS_ATTRIBUTE(attribute, major, minor, patch) \
740 JSON_HEDLEY_GNUC_VERSION_CHECK(major, minor, patch)
743#if defined(JSON_HEDLEY_GCC_HAS_ATTRIBUTE)
744#undef JSON_HEDLEY_GCC_HAS_ATTRIBUTE
746#if defined(__has_attribute)
747#define JSON_HEDLEY_GCC_HAS_ATTRIBUTE(attribute, major, minor, patch) JSON_HEDLEY_HAS_ATTRIBUTE(attribute)
749#define JSON_HEDLEY_GCC_HAS_ATTRIBUTE(attribute, major, minor, patch) JSON_HEDLEY_GCC_VERSION_CHECK(major, minor, patch)
752#if defined(JSON_HEDLEY_HAS_CPP_ATTRIBUTE)
753#undef JSON_HEDLEY_HAS_CPP_ATTRIBUTE
755#if defined(__has_cpp_attribute) && defined(__cplusplus) \
756 && (!defined(JSON_HEDLEY_SUNPRO_VERSION) || JSON_HEDLEY_SUNPRO_VERSION_CHECK(5, 15, 0))
757#define JSON_HEDLEY_HAS_CPP_ATTRIBUTE(attribute) __has_cpp_attribute(attribute)
759#define JSON_HEDLEY_HAS_CPP_ATTRIBUTE(attribute) (0)
762#if defined(JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS)
763#undef JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS
765#if !defined(__cplusplus) || !defined(__has_cpp_attribute)
766#define JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS(ns, attribute) (0)
767#elif !defined(JSON_HEDLEY_PGI_VERSION) && !defined(JSON_HEDLEY_IAR_VERSION) \
768 && (!defined(JSON_HEDLEY_SUNPRO_VERSION) || JSON_HEDLEY_SUNPRO_VERSION_CHECK(5, 15, 0)) \
769 && (!defined(JSON_HEDLEY_MSVC_VERSION) || JSON_HEDLEY_MSVC_VERSION_CHECK(19, 20, 0))
770#define JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS(ns, attribute) JSON_HEDLEY_HAS_CPP_ATTRIBUTE(ns::attribute)
772#define JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS(ns, attribute) (0)
775#if defined(JSON_HEDLEY_GNUC_HAS_CPP_ATTRIBUTE)
776#undef JSON_HEDLEY_GNUC_HAS_CPP_ATTRIBUTE
778#if defined(__has_cpp_attribute) && defined(__cplusplus)
779#define JSON_HEDLEY_GNUC_HAS_CPP_ATTRIBUTE(attribute, major, minor, patch) __has_cpp_attribute(attribute)
781#define JSON_HEDLEY_GNUC_HAS_CPP_ATTRIBUTE(attribute, major, minor, patch) \
782 JSON_HEDLEY_GNUC_VERSION_CHECK(major, minor, patch)
785#if defined(JSON_HEDLEY_GCC_HAS_CPP_ATTRIBUTE)
786#undef JSON_HEDLEY_GCC_HAS_CPP_ATTRIBUTE
788#if defined(__has_cpp_attribute) && defined(__cplusplus)
789#define JSON_HEDLEY_GCC_HAS_CPP_ATTRIBUTE(attribute, major, minor, patch) __has_cpp_attribute(attribute)
791#define JSON_HEDLEY_GCC_HAS_CPP_ATTRIBUTE(attribute, major, minor, patch) \
792 JSON_HEDLEY_GCC_VERSION_CHECK(major, minor, patch)
795#if defined(JSON_HEDLEY_HAS_BUILTIN)
796#undef JSON_HEDLEY_HAS_BUILTIN
798#if defined(__has_builtin)
799#define JSON_HEDLEY_HAS_BUILTIN(builtin) __has_builtin(builtin)
801#define JSON_HEDLEY_HAS_BUILTIN(builtin) (0)
804#if defined(JSON_HEDLEY_GNUC_HAS_BUILTIN)
805#undef JSON_HEDLEY_GNUC_HAS_BUILTIN
807#if defined(__has_builtin)
808#define JSON_HEDLEY_GNUC_HAS_BUILTIN(builtin, major, minor, patch) __has_builtin(builtin)
810#define JSON_HEDLEY_GNUC_HAS_BUILTIN(builtin, major, minor, patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major, minor, patch)
813#if defined(JSON_HEDLEY_GCC_HAS_BUILTIN)
814#undef JSON_HEDLEY_GCC_HAS_BUILTIN
816#if defined(__has_builtin)
817#define JSON_HEDLEY_GCC_HAS_BUILTIN(builtin, major, minor, patch) __has_builtin(builtin)
819#define JSON_HEDLEY_GCC_HAS_BUILTIN(builtin, major, minor, patch) JSON_HEDLEY_GCC_VERSION_CHECK(major, minor, patch)
822#if defined(JSON_HEDLEY_HAS_FEATURE)
823#undef JSON_HEDLEY_HAS_FEATURE
825#if defined(__has_feature)
826#define JSON_HEDLEY_HAS_FEATURE(feature) __has_feature(feature)
828#define JSON_HEDLEY_HAS_FEATURE(feature) (0)
831#if defined(JSON_HEDLEY_GNUC_HAS_FEATURE)
832#undef JSON_HEDLEY_GNUC_HAS_FEATURE
834#if defined(__has_feature)
835#define JSON_HEDLEY_GNUC_HAS_FEATURE(feature, major, minor, patch) __has_feature(feature)
837#define JSON_HEDLEY_GNUC_HAS_FEATURE(feature, major, minor, patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major, minor, patch)
840#if defined(JSON_HEDLEY_GCC_HAS_FEATURE)
841#undef JSON_HEDLEY_GCC_HAS_FEATURE
843#if defined(__has_feature)
844#define JSON_HEDLEY_GCC_HAS_FEATURE(feature, major, minor, patch) __has_feature(feature)
846#define JSON_HEDLEY_GCC_HAS_FEATURE(feature, major, minor, patch) JSON_HEDLEY_GCC_VERSION_CHECK(major, minor, patch)
849#if defined(JSON_HEDLEY_HAS_EXTENSION)
850#undef JSON_HEDLEY_HAS_EXTENSION
852#if defined(__has_extension)
853#define JSON_HEDLEY_HAS_EXTENSION(extension) __has_extension(extension)
855#define JSON_HEDLEY_HAS_EXTENSION(extension) (0)
858#if defined(JSON_HEDLEY_GNUC_HAS_EXTENSION)
859#undef JSON_HEDLEY_GNUC_HAS_EXTENSION
861#if defined(__has_extension)
862#define JSON_HEDLEY_GNUC_HAS_EXTENSION(extension, major, minor, patch) __has_extension(extension)
864#define JSON_HEDLEY_GNUC_HAS_EXTENSION(extension, major, minor, patch) \
865 JSON_HEDLEY_GNUC_VERSION_CHECK(major, minor, patch)
868#if defined(JSON_HEDLEY_GCC_HAS_EXTENSION)
869#undef JSON_HEDLEY_GCC_HAS_EXTENSION
871#if defined(__has_extension)
872#define JSON_HEDLEY_GCC_HAS_EXTENSION(extension, major, minor, patch) __has_extension(extension)
874#define JSON_HEDLEY_GCC_HAS_EXTENSION(extension, major, minor, patch) JSON_HEDLEY_GCC_VERSION_CHECK(major, minor, patch)
877#if defined(JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE)
878#undef JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE
880#if defined(__has_declspec_attribute)
881#define JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE(attribute) __has_declspec_attribute(attribute)
883#define JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE(attribute) (0)
886#if defined(JSON_HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE)
887#undef JSON_HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE
889#if defined(__has_declspec_attribute)
890#define JSON_HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE(attribute, major, minor, patch) __has_declspec_attribute(attribute)
892#define JSON_HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE(attribute, major, minor, patch) \
893 JSON_HEDLEY_GNUC_VERSION_CHECK(major, minor, patch)
896#if defined(JSON_HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE)
897#undef JSON_HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE
899#if defined(__has_declspec_attribute)
900#define JSON_HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE(attribute, major, minor, patch) __has_declspec_attribute(attribute)
902#define JSON_HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE(attribute, major, minor, patch) \
903 JSON_HEDLEY_GCC_VERSION_CHECK(major, minor, patch)
906#if defined(JSON_HEDLEY_HAS_WARNING)
907#undef JSON_HEDLEY_HAS_WARNING
909#if defined(__has_warning)
910#define JSON_HEDLEY_HAS_WARNING(warning) __has_warning(warning)
912#define JSON_HEDLEY_HAS_WARNING(warning) (0)
915#if defined(JSON_HEDLEY_GNUC_HAS_WARNING)
916#undef JSON_HEDLEY_GNUC_HAS_WARNING
918#if defined(__has_warning)
919#define JSON_HEDLEY_GNUC_HAS_WARNING(warning, major, minor, patch) __has_warning(warning)
921#define JSON_HEDLEY_GNUC_HAS_WARNING(warning, major, minor, patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major, minor, patch)
924#if defined(JSON_HEDLEY_GCC_HAS_WARNING)
925#undef JSON_HEDLEY_GCC_HAS_WARNING
927#if defined(__has_warning)
928#define JSON_HEDLEY_GCC_HAS_WARNING(warning, major, minor, patch) __has_warning(warning)
930#define JSON_HEDLEY_GCC_HAS_WARNING(warning, major, minor, patch) JSON_HEDLEY_GCC_VERSION_CHECK(major, minor, patch)
933#if (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)) || defined(__clang__) \
934 || JSON_HEDLEY_GCC_VERSION_CHECK(3, 0, 0) || JSON_HEDLEY_INTEL_VERSION_CHECK(13, 0, 0) \
935 || JSON_HEDLEY_IAR_VERSION_CHECK(8, 0, 0) || JSON_HEDLEY_PGI_VERSION_CHECK(18, 4, 0) \
936 || JSON_HEDLEY_ARM_VERSION_CHECK(4, 1, 0) || JSON_HEDLEY_TI_VERSION_CHECK(15, 12, 0) \
937 || JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4, 7, 0) || JSON_HEDLEY_TI_CL430_VERSION_CHECK(2, 0, 1) \
938 || JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6, 1, 0) || JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7, 0, 0) \
939 || JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1, 2, 0) || JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2, 1, 0) \
940 || JSON_HEDLEY_CRAY_VERSION_CHECK(5, 0, 0) || JSON_HEDLEY_TINYC_VERSION_CHECK(0, 9, 17) \
941 || JSON_HEDLEY_SUNPRO_VERSION_CHECK(8, 0, 0) \
942 || (JSON_HEDLEY_IBM_VERSION_CHECK(10, 1, 0) && defined(__C99_PRAGMA_OPERATOR))
943#define JSON_HEDLEY_PRAGMA(value) _Pragma(#value)
944#elif JSON_HEDLEY_MSVC_VERSION_CHECK(15, 0, 0)
945#define JSON_HEDLEY_PRAGMA(value) __pragma(value)
947#define JSON_HEDLEY_PRAGMA(value)
950#if defined(JSON_HEDLEY_DIAGNOSTIC_PUSH)
951#undef JSON_HEDLEY_DIAGNOSTIC_PUSH
953#if defined(JSON_HEDLEY_DIAGNOSTIC_POP)
954#undef JSON_HEDLEY_DIAGNOSTIC_POP
956#if defined(__clang__)
957#define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("clang diagnostic push")
958#define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("clang diagnostic pop")
959#elif JSON_HEDLEY_INTEL_VERSION_CHECK(13, 0, 0)
960#define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("warning(push)")
961#define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("warning(pop)")
962#elif JSON_HEDLEY_GCC_VERSION_CHECK(4, 6, 0)
963#define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("GCC diagnostic push")
964#define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("GCC diagnostic pop")
965#elif JSON_HEDLEY_MSVC_VERSION_CHECK(15, 0, 0) || JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021, 1, 0)
966#define JSON_HEDLEY_DIAGNOSTIC_PUSH __pragma(warning(push))
967#define JSON_HEDLEY_DIAGNOSTIC_POP __pragma(warning(pop))
968#elif JSON_HEDLEY_ARM_VERSION_CHECK(5, 6, 0)
969#define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("push")
970#define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("pop")
971#elif JSON_HEDLEY_TI_VERSION_CHECK(15, 12, 0) || JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5, 2, 0) \
972 || JSON_HEDLEY_TI_CL430_VERSION_CHECK(4, 4, 0) || JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8, 1, 0) \
973 || JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1, 2, 0) || JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2, 1, 0)
974#define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("diag_push")
975#define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("diag_pop")
976#elif JSON_HEDLEY_PELLES_VERSION_CHECK(2, 90, 0)
977#define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("warning(push)")
978#define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("warning(pop)")
980#define JSON_HEDLEY_DIAGNOSTIC_PUSH
981#define JSON_HEDLEY_DIAGNOSTIC_POP
986#if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_)
987#undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_
989#if defined(__cplusplus)
990#if JSON_HEDLEY_HAS_WARNING("-Wc++98-compat")
991#if JSON_HEDLEY_HAS_WARNING("-Wc++17-extensions")
992#if JSON_HEDLEY_HAS_WARNING("-Wc++1z-extensions")
993#define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(xpr) \
994 JSON_HEDLEY_DIAGNOSTIC_PUSH \
995 _Pragma("clang diagnostic ignored \"-Wc++98-compat\"") _Pragma("clang diagnostic ignored \"-Wc++17-extensions\"") \
996 _Pragma("clang diagnostic ignored \"-Wc++1z-extensions\"") xpr JSON_HEDLEY_DIAGNOSTIC_POP
998#define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(xpr) \
999 JSON_HEDLEY_DIAGNOSTIC_PUSH \
1000 _Pragma("clang diagnostic ignored \"-Wc++98-compat\"") _Pragma("clang diagnostic ignored \"-Wc++17-extensions\"") \
1001 xpr JSON_HEDLEY_DIAGNOSTIC_POP
1004#define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(xpr) \
1005 JSON_HEDLEY_DIAGNOSTIC_PUSH \
1006 _Pragma("clang diagnostic ignored \"-Wc++98-compat\"") xpr JSON_HEDLEY_DIAGNOSTIC_POP
1010#if !defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_)
1011#define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(x) x
1014#if defined(JSON_HEDLEY_CONST_CAST)
1015#undef JSON_HEDLEY_CONST_CAST
1017#if defined(__cplusplus)
1018#define JSON_HEDLEY_CONST_CAST(T, expr) (const_cast<T>(expr))
1019#elif JSON_HEDLEY_HAS_WARNING("-Wcast-qual") || JSON_HEDLEY_GCC_VERSION_CHECK(4, 6, 0) \
1020 || JSON_HEDLEY_INTEL_VERSION_CHECK(13, 0, 0)
1021#define JSON_HEDLEY_CONST_CAST(T, expr) \
1023 JSON_HEDLEY_DIAGNOSTIC_PUSH \
1024 JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL((T)(expr)); \
1025 JSON_HEDLEY_DIAGNOSTIC_POP \
1028#define JSON_HEDLEY_CONST_CAST(T, expr) ((T)(expr))
1031#if defined(JSON_HEDLEY_REINTERPRET_CAST)
1032#undef JSON_HEDLEY_REINTERPRET_CAST
1034#if defined(__cplusplus)
1035#define JSON_HEDLEY_REINTERPRET_CAST(T, expr) (reinterpret_cast<T>(expr))
1037#define JSON_HEDLEY_REINTERPRET_CAST(T, expr) ((T)(expr))
1040#if defined(JSON_HEDLEY_STATIC_CAST)
1041#undef JSON_HEDLEY_STATIC_CAST
1043#if defined(__cplusplus)
1044#define JSON_HEDLEY_STATIC_CAST(T, expr) (static_cast<T>(expr))
1046#define JSON_HEDLEY_STATIC_CAST(T, expr) ((T)(expr))
1049#if defined(JSON_HEDLEY_CPP_CAST)
1050#undef JSON_HEDLEY_CPP_CAST
1052#if defined(__cplusplus)
1053#if JSON_HEDLEY_HAS_WARNING("-Wold-style-cast")
1054#define JSON_HEDLEY_CPP_CAST(T, expr) \
1055 JSON_HEDLEY_DIAGNOSTIC_PUSH \
1056 _Pragma("clang diagnostic ignored \"-Wold-style-cast\"")((T)(expr)) JSON_HEDLEY_DIAGNOSTIC_POP
1057#elif JSON_HEDLEY_IAR_VERSION_CHECK(8, 3, 0)
1058#define JSON_HEDLEY_CPP_CAST(T, expr) \
1059 JSON_HEDLEY_DIAGNOSTIC_PUSH \
1060 _Pragma("diag_suppress=Pe137") JSON_HEDLEY_DIAGNOSTIC_POP
1062#define JSON_HEDLEY_CPP_CAST(T, expr) ((T)(expr))
1065#define JSON_HEDLEY_CPP_CAST(T, expr) (expr)
1068#if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED)
1069#undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED
1071#if JSON_HEDLEY_HAS_WARNING("-Wdeprecated-declarations")
1072#define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("clang diagnostic ignored \"-Wdeprecated-declarations\"")
1073#elif JSON_HEDLEY_INTEL_VERSION_CHECK(13, 0, 0)
1074#define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("warning(disable:1478 1786)")
1075#elif JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021, 1, 0)
1076#define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED __pragma(warning(disable : 1478 1786))
1077#elif JSON_HEDLEY_PGI_VERSION_CHECK(20, 7, 0)
1078#define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress 1215,1216,1444,1445")
1079#elif JSON_HEDLEY_PGI_VERSION_CHECK(17, 10, 0)
1080#define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress 1215,1444")
1081#elif JSON_HEDLEY_GCC_VERSION_CHECK(4, 3, 0)
1082#define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"")
1083#elif JSON_HEDLEY_MSVC_VERSION_CHECK(15, 0, 0)
1084#define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED __pragma(warning(disable : 4996))
1085#elif JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1, 25, 10)
1086#define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress 1215,1444")
1087#elif JSON_HEDLEY_TI_VERSION_CHECK(15, 12, 0) \
1088 || (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4, 8, 0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) \
1089 || JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5, 2, 0) \
1090 || (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6, 0, 0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) \
1091 || JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6, 4, 0) \
1092 || (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4, 0, 0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) \
1093 || JSON_HEDLEY_TI_CL430_VERSION_CHECK(4, 3, 0) \
1094 || (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7, 2, 0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) \
1095 || JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7, 5, 0) || JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1, 2, 0) \
1096 || JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2, 1, 0)
1097#define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress 1291,1718")
1098#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5, 13, 0) && !defined(__cplusplus)
1099#define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("error_messages(off,E_DEPRECATED_ATT,E_DEPRECATED_ATT_MESS)")
1100#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5, 13, 0) && defined(__cplusplus)
1101#define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("error_messages(off,symdeprecated,symdeprecated2)")
1102#elif JSON_HEDLEY_IAR_VERSION_CHECK(8, 0, 0)
1103#define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress=Pe1444,Pe1215")
1104#elif JSON_HEDLEY_PELLES_VERSION_CHECK(2, 90, 0)
1105#define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("warn(disable:2241)")
1107#define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED
1110#if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS)
1111#undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS
1113#if JSON_HEDLEY_HAS_WARNING("-Wunknown-pragmas")
1114#define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("clang diagnostic ignored \"-Wunknown-pragmas\"")
1115#elif JSON_HEDLEY_INTEL_VERSION_CHECK(13, 0, 0)
1116#define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("warning(disable:161)")
1117#elif JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021, 1, 0)
1118#define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS __pragma(warning(disable : 161))
1119#elif JSON_HEDLEY_PGI_VERSION_CHECK(17, 10, 0)
1120#define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress 1675")
1121#elif JSON_HEDLEY_GCC_VERSION_CHECK(4, 3, 0)
1122#define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("GCC diagnostic ignored \"-Wunknown-pragmas\"")
1123#elif JSON_HEDLEY_MSVC_VERSION_CHECK(15, 0, 0)
1124#define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS __pragma(warning(disable : 4068))
1125#elif JSON_HEDLEY_TI_VERSION_CHECK(16, 9, 0) || JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8, 0, 0) \
1126 || JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1, 2, 0) || 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 \
1143 _Pragma("clang diagnostic ignored \"-Wunknown-attributes\"")
1144#elif JSON_HEDLEY_GCC_VERSION_CHECK(4, 6, 0)
1145#define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES \
1146 _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"")
1147#elif JSON_HEDLEY_INTEL_VERSION_CHECK(17, 0, 0)
1148#define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("warning(disable:1292)")
1149#elif JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021, 1, 0)
1150#define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES __pragma(warning(disable : 1292))
1151#elif JSON_HEDLEY_MSVC_VERSION_CHECK(19, 0, 0)
1152#define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES __pragma(warning(disable : 5030))
1153#elif JSON_HEDLEY_PGI_VERSION_CHECK(20, 7, 0)
1154#define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress 1097,1098")
1155#elif JSON_HEDLEY_PGI_VERSION_CHECK(17, 10, 0)
1156#define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress 1097")
1157#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5, 14, 0) && defined(__cplusplus)
1158#define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("error_messages(off,attrskipunsup)")
1159#elif JSON_HEDLEY_TI_VERSION_CHECK(18, 1, 0) || 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
1204#if JSON_HEDLEY_MSVC_VERSION_CHECK(14, 0, 0) || JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021, 1, 0)
1205#define JSON_HEDLEY_DEPRECATED(since) __declspec(deprecated("Since " #since))
1206#define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) __declspec(deprecated("Since " #since "; use " #replacement))
1207#elif (JSON_HEDLEY_HAS_EXTENSION(attribute_deprecated_with_message) && !defined(JSON_HEDLEY_IAR_VERSION)) \
1208 || JSON_HEDLEY_GCC_VERSION_CHECK(4, 5, 0) || JSON_HEDLEY_INTEL_VERSION_CHECK(13, 0, 0) \
1209 || JSON_HEDLEY_ARM_VERSION_CHECK(5, 6, 0) || JSON_HEDLEY_SUNPRO_VERSION_CHECK(5, 13, 0) \
1210 || JSON_HEDLEY_PGI_VERSION_CHECK(17, 10, 0) || JSON_HEDLEY_TI_VERSION_CHECK(18, 1, 0) \
1211 || JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(18, 1, 0) || JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8, 3, 0) \
1212 || JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1, 2, 0) || JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2, 3, 0) \
1213 || JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1, 25, 10)
1214#define JSON_HEDLEY_DEPRECATED(since) __attribute__((__deprecated__("Since " #since)))
1215#define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) \
1216 __attribute__((__deprecated__("Since " #since "; use " #replacement)))
1217#elif defined(__cplusplus) && (__cplusplus >= 201402L)
1218#define JSON_HEDLEY_DEPRECATED(since) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[deprecated("Since " #since)]])
1219#define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) \
1220 JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[deprecated("Since " #since "; use " #replacement)]])
1221#elif JSON_HEDLEY_HAS_ATTRIBUTE(deprecated) || JSON_HEDLEY_GCC_VERSION_CHECK(3, 1, 0) \
1222 || JSON_HEDLEY_ARM_VERSION_CHECK(4, 1, 0) || JSON_HEDLEY_TI_VERSION_CHECK(15, 12, 0) \
1223 || (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4, 8, 0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) \
1224 || JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5, 2, 0) \
1225 || (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6, 0, 0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) \
1226 || JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6, 4, 0) \
1227 || (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4, 0, 0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) \
1228 || JSON_HEDLEY_TI_CL430_VERSION_CHECK(4, 3, 0) \
1229 || (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7, 2, 0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) \
1230 || JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7, 5, 0) || JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1, 2, 0) \
1231 || JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2, 1, 0) || JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1, 25, 10) \
1232 || JSON_HEDLEY_IAR_VERSION_CHECK(8, 10, 0)
1233#define JSON_HEDLEY_DEPRECATED(since) __attribute__((__deprecated__))
1234#define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) __attribute__((__deprecated__))
1235#elif JSON_HEDLEY_MSVC_VERSION_CHECK(13, 10, 0) || JSON_HEDLEY_PELLES_VERSION_CHECK(6, 50, 0) \
1236 || JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021, 1, 0)
1237#define JSON_HEDLEY_DEPRECATED(since) __declspec(deprecated)
1238#define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) __declspec(deprecated)
1239#elif JSON_HEDLEY_IAR_VERSION_CHECK(8, 0, 0)
1240#define JSON_HEDLEY_DEPRECATED(since) _Pragma("deprecated")
1241#define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) _Pragma("deprecated")
1243#define JSON_HEDLEY_DEPRECATED(since)
1244#define JSON_HEDLEY_DEPRECATED_FOR(since, replacement)
1247#if defined(JSON_HEDLEY_UNAVAILABLE)
1248#undef JSON_HEDLEY_UNAVAILABLE
1250#if JSON_HEDLEY_HAS_ATTRIBUTE(warning) || JSON_HEDLEY_GCC_VERSION_CHECK(4, 3, 0) \
1251 || JSON_HEDLEY_INTEL_VERSION_CHECK(13, 0, 0) || JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1, 25, 10)
1252#define JSON_HEDLEY_UNAVAILABLE(available_since) __attribute__((__warning__("Not available until " #available_since)))
1254#define JSON_HEDLEY_UNAVAILABLE(available_since)
1257#if defined(JSON_HEDLEY_WARN_UNUSED_RESULT)
1258#undef JSON_HEDLEY_WARN_UNUSED_RESULT
1260#if defined(JSON_HEDLEY_WARN_UNUSED_RESULT_MSG)
1261#undef JSON_HEDLEY_WARN_UNUSED_RESULT_MSG
1263#if JSON_HEDLEY_HAS_ATTRIBUTE(warn_unused_result) || JSON_HEDLEY_GCC_VERSION_CHECK(3, 4, 0) \
1264 || JSON_HEDLEY_INTEL_VERSION_CHECK(13, 0, 0) || JSON_HEDLEY_TI_VERSION_CHECK(15, 12, 0) \
1265 || (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4, 8, 0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) \
1266 || JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5, 2, 0) \
1267 || (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6, 0, 0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) \
1268 || JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6, 4, 0) \
1269 || (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4, 0, 0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) \
1270 || JSON_HEDLEY_TI_CL430_VERSION_CHECK(4, 3, 0) \
1271 || (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7, 2, 0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) \
1272 || JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7, 5, 0) || JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1, 2, 0) \
1273 || JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2, 1, 0) \
1274 || (JSON_HEDLEY_SUNPRO_VERSION_CHECK(5, 15, 0) && defined(__cplusplus)) \
1275 || JSON_HEDLEY_PGI_VERSION_CHECK(17, 10, 0) || JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1, 25, 10)
1276#define JSON_HEDLEY_WARN_UNUSED_RESULT __attribute__((__warn_unused_result__))
1277#define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg) __attribute__((__warn_unused_result__))
1278#elif (JSON_HEDLEY_HAS_CPP_ATTRIBUTE(nodiscard) >= 201907L)
1279#define JSON_HEDLEY_WARN_UNUSED_RESULT JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[nodiscard]])
1280#define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[nodiscard(msg)]])
1281#elif JSON_HEDLEY_HAS_CPP_ATTRIBUTE(nodiscard)
1282#define JSON_HEDLEY_WARN_UNUSED_RESULT JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[nodiscard]])
1283#define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[nodiscard]])
1284#elif defined(_Check_return_)
1285#define JSON_HEDLEY_WARN_UNUSED_RESULT _Check_return_
1286#define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg) _Check_return_
1288#define JSON_HEDLEY_WARN_UNUSED_RESULT
1289#define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg)
1292#if defined(JSON_HEDLEY_SENTINEL)
1293#undef JSON_HEDLEY_SENTINEL
1295#if JSON_HEDLEY_HAS_ATTRIBUTE(sentinel) || JSON_HEDLEY_GCC_VERSION_CHECK(4, 0, 0) \
1296 || JSON_HEDLEY_INTEL_VERSION_CHECK(13, 0, 0) || JSON_HEDLEY_ARM_VERSION_CHECK(5, 4, 0) \
1297 || JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1, 25, 10)
1298#define JSON_HEDLEY_SENTINEL(position) __attribute__((__sentinel__(position)))
1300#define JSON_HEDLEY_SENTINEL(position)
1303#if defined(JSON_HEDLEY_NO_RETURN)
1304#undef JSON_HEDLEY_NO_RETURN
1306#if JSON_HEDLEY_IAR_VERSION_CHECK(8, 0, 0)
1307#define JSON_HEDLEY_NO_RETURN __noreturn
1308#elif JSON_HEDLEY_INTEL_VERSION_CHECK(13, 0, 0) || JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1, 25, 10)
1309#define JSON_HEDLEY_NO_RETURN __attribute__((__noreturn__))
1310#elif defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L
1311#define JSON_HEDLEY_NO_RETURN _Noreturn
1312#elif defined(__cplusplus) && (__cplusplus >= 201103L)
1313#define JSON_HEDLEY_NO_RETURN JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[noreturn]])
1314#elif JSON_HEDLEY_HAS_ATTRIBUTE(noreturn) || JSON_HEDLEY_GCC_VERSION_CHECK(3, 2, 0) \
1315 || JSON_HEDLEY_SUNPRO_VERSION_CHECK(5, 11, 0) || JSON_HEDLEY_ARM_VERSION_CHECK(4, 1, 0) \
1316 || JSON_HEDLEY_IBM_VERSION_CHECK(10, 1, 0) || JSON_HEDLEY_TI_VERSION_CHECK(15, 12, 0) \
1317 || (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4, 8, 0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) \
1318 || JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5, 2, 0) \
1319 || (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6, 0, 0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) \
1320 || JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6, 4, 0) \
1321 || (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4, 0, 0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) \
1322 || JSON_HEDLEY_TI_CL430_VERSION_CHECK(4, 3, 0) \
1323 || (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7, 2, 0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) \
1324 || JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7, 5, 0) || JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1, 2, 0) \
1325 || JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2, 1, 0) || JSON_HEDLEY_IAR_VERSION_CHECK(8, 10, 0)
1326#define JSON_HEDLEY_NO_RETURN __attribute__((__noreturn__))
1327#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5, 10, 0)
1328#define JSON_HEDLEY_NO_RETURN _Pragma("does_not_return")
1329#elif JSON_HEDLEY_MSVC_VERSION_CHECK(13, 10, 0) || JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021, 1, 0)
1330#define JSON_HEDLEY_NO_RETURN __declspec(noreturn)
1331#elif JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6, 0, 0) && defined(__cplusplus)
1332#define JSON_HEDLEY_NO_RETURN _Pragma("FUNC_NEVER_RETURNS;")
1333#elif JSON_HEDLEY_COMPCERT_VERSION_CHECK(3, 2, 0)
1334#define JSON_HEDLEY_NO_RETURN __attribute((noreturn))
1335#elif JSON_HEDLEY_PELLES_VERSION_CHECK(9, 0, 0)
1336#define JSON_HEDLEY_NO_RETURN __declspec(noreturn)
1338#define JSON_HEDLEY_NO_RETURN
1341#if defined(JSON_HEDLEY_NO_ESCAPE)
1342#undef JSON_HEDLEY_NO_ESCAPE
1344#if JSON_HEDLEY_HAS_ATTRIBUTE(noescape)
1345#define JSON_HEDLEY_NO_ESCAPE __attribute__((__noescape__))
1347#define JSON_HEDLEY_NO_ESCAPE
1350#if defined(JSON_HEDLEY_UNREACHABLE)
1351#undef JSON_HEDLEY_UNREACHABLE
1353#if defined(JSON_HEDLEY_UNREACHABLE_RETURN)
1354#undef JSON_HEDLEY_UNREACHABLE_RETURN
1356#if defined(JSON_HEDLEY_ASSUME)
1357#undef JSON_HEDLEY_ASSUME
1359#if JSON_HEDLEY_MSVC_VERSION_CHECK(13, 10, 0) || JSON_HEDLEY_INTEL_VERSION_CHECK(13, 0, 0) \
1360 || JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021, 1, 0)
1361#define JSON_HEDLEY_ASSUME(expr) __assume(expr)
1362#elif JSON_HEDLEY_HAS_BUILTIN(__builtin_assume)
1363#define JSON_HEDLEY_ASSUME(expr) __builtin_assume(expr)
1364#elif JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6, 2, 0) || JSON_HEDLEY_TI_CL6X_VERSION_CHECK(4, 0, 0)
1365#if defined(__cplusplus)
1366#define JSON_HEDLEY_ASSUME(expr) std::_nassert(expr)
1368#define JSON_HEDLEY_ASSUME(expr) _nassert(expr)
1371#if (JSON_HEDLEY_HAS_BUILTIN(__builtin_unreachable) && (!defined(JSON_HEDLEY_ARM_VERSION))) \
1372 || JSON_HEDLEY_GCC_VERSION_CHECK(4, 5, 0) || JSON_HEDLEY_PGI_VERSION_CHECK(18, 10, 0) \
1373 || JSON_HEDLEY_INTEL_VERSION_CHECK(13, 0, 0) || JSON_HEDLEY_IBM_VERSION_CHECK(13, 1, 5) \
1374 || JSON_HEDLEY_CRAY_VERSION_CHECK(10, 0, 0) || JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1, 25, 10)
1375#define JSON_HEDLEY_UNREACHABLE() __builtin_unreachable()
1376#elif defined(JSON_HEDLEY_ASSUME)
1377#define JSON_HEDLEY_UNREACHABLE() JSON_HEDLEY_ASSUME(0)
1379#if !defined(JSON_HEDLEY_ASSUME)
1380#if defined(JSON_HEDLEY_UNREACHABLE)
1381#define JSON_HEDLEY_ASSUME(expr) JSON_HEDLEY_STATIC_CAST(void, ((expr) ? 1 : (JSON_HEDLEY_UNREACHABLE(), 1)))
1383#define JSON_HEDLEY_ASSUME(expr) JSON_HEDLEY_STATIC_CAST(void, expr)
1386#if defined(JSON_HEDLEY_UNREACHABLE)
1387#if JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6, 2, 0) || JSON_HEDLEY_TI_CL6X_VERSION_CHECK(4, 0, 0)
1388#define JSON_HEDLEY_UNREACHABLE_RETURN(value) return (JSON_HEDLEY_STATIC_CAST(void, JSON_HEDLEY_ASSUME(0)), (value))
1390#define JSON_HEDLEY_UNREACHABLE_RETURN(value) JSON_HEDLEY_UNREACHABLE()
1393#define JSON_HEDLEY_UNREACHABLE_RETURN(value) return (value)
1395#if !defined(JSON_HEDLEY_UNREACHABLE)
1396#define JSON_HEDLEY_UNREACHABLE() JSON_HEDLEY_ASSUME(0)
1400#if JSON_HEDLEY_HAS_WARNING("-Wpedantic")
1401#pragma clang diagnostic ignored "-Wpedantic"
1403#if JSON_HEDLEY_HAS_WARNING("-Wc++98-compat-pedantic") && defined(__cplusplus)
1404#pragma clang diagnostic ignored "-Wc++98-compat-pedantic"
1406#if JSON_HEDLEY_GCC_HAS_WARNING("-Wvariadic-macros", 4, 0, 0)
1407#if defined(__clang__)
1408#pragma clang diagnostic ignored "-Wvariadic-macros"
1409#elif defined(JSON_HEDLEY_GCC_VERSION)
1410#pragma GCC diagnostic ignored "-Wvariadic-macros"
1413#if defined(JSON_HEDLEY_NON_NULL)
1414#undef JSON_HEDLEY_NON_NULL
1416#if JSON_HEDLEY_HAS_ATTRIBUTE(nonnull) || JSON_HEDLEY_GCC_VERSION_CHECK(3, 3, 0) \
1417 || JSON_HEDLEY_INTEL_VERSION_CHECK(13, 0, 0) || JSON_HEDLEY_ARM_VERSION_CHECK(4, 1, 0)
1418#define JSON_HEDLEY_NON_NULL(...) __attribute__((__nonnull__(__VA_ARGS__)))
1420#define JSON_HEDLEY_NON_NULL(...)
1424#if defined(JSON_HEDLEY_PRINTF_FORMAT)
1425#undef JSON_HEDLEY_PRINTF_FORMAT
1427#if defined(__MINGW32__) && JSON_HEDLEY_GCC_HAS_ATTRIBUTE(format, 4, 4, 0) && !defined(__USE_MINGW_ANSI_STDIO)
1428#define JSON_HEDLEY_PRINTF_FORMAT(string_idx, first_to_check) \
1429 __attribute__((__format__(ms_printf, string_idx, first_to_check)))
1430#elif defined(__MINGW32__) && JSON_HEDLEY_GCC_HAS_ATTRIBUTE(format, 4, 4, 0) && defined(__USE_MINGW_ANSI_STDIO)
1431#define JSON_HEDLEY_PRINTF_FORMAT(string_idx, first_to_check) \
1432 __attribute__((__format__(gnu_printf, string_idx, first_to_check)))
1433#elif JSON_HEDLEY_HAS_ATTRIBUTE(format) || JSON_HEDLEY_GCC_VERSION_CHECK(3, 1, 0) \
1434 || JSON_HEDLEY_INTEL_VERSION_CHECK(13, 0, 0) || JSON_HEDLEY_ARM_VERSION_CHECK(5, 6, 0) \
1435 || JSON_HEDLEY_IBM_VERSION_CHECK(10, 1, 0) || JSON_HEDLEY_TI_VERSION_CHECK(15, 12, 0) \
1436 || (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4, 8, 0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) \
1437 || JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5, 2, 0) \
1438 || (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6, 0, 0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) \
1439 || JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6, 4, 0) \
1440 || (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4, 0, 0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) \
1441 || JSON_HEDLEY_TI_CL430_VERSION_CHECK(4, 3, 0) \
1442 || (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7, 2, 0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) \
1443 || JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7, 5, 0) || JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1, 2, 0) \
1444 || JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2, 1, 0) || JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1, 25, 10)
1445#define JSON_HEDLEY_PRINTF_FORMAT(string_idx, first_to_check) \
1446 __attribute__((__format__(__printf__, string_idx, first_to_check)))
1447#elif JSON_HEDLEY_PELLES_VERSION_CHECK(6, 0, 0)
1448#define JSON_HEDLEY_PRINTF_FORMAT(string_idx, first_to_check) __declspec(vaformat(printf, string_idx, first_to_check))
1450#define JSON_HEDLEY_PRINTF_FORMAT(string_idx, first_to_check)
1453#if defined(JSON_HEDLEY_CONSTEXPR)
1454#undef JSON_HEDLEY_CONSTEXPR
1456#if defined(__cplusplus)
1457#if __cplusplus >= 201103L
1458#define JSON_HEDLEY_CONSTEXPR JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(constexpr)
1461#if !defined(JSON_HEDLEY_CONSTEXPR)
1462#define JSON_HEDLEY_CONSTEXPR
1465#if defined(JSON_HEDLEY_PREDICT)
1466#undef JSON_HEDLEY_PREDICT
1468#if defined(JSON_HEDLEY_LIKELY)
1469#undef JSON_HEDLEY_LIKELY
1471#if defined(JSON_HEDLEY_UNLIKELY)
1472#undef JSON_HEDLEY_UNLIKELY
1474#if defined(JSON_HEDLEY_UNPREDICTABLE)
1475#undef JSON_HEDLEY_UNPREDICTABLE
1477#if JSON_HEDLEY_HAS_BUILTIN(__builtin_unpredictable)
1478#define JSON_HEDLEY_UNPREDICTABLE(expr) __builtin_unpredictable((expr))
1480#if (JSON_HEDLEY_HAS_BUILTIN(__builtin_expect_with_probability) && !defined(JSON_HEDLEY_PGI_VERSION)) \
1481 || JSON_HEDLEY_GCC_VERSION_CHECK(9, 0, 0) || JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1, 25, 10)
1482#define JSON_HEDLEY_PREDICT(expr, value, probability) __builtin_expect_with_probability((expr), (value), (probability))
1483#define JSON_HEDLEY_PREDICT_TRUE(expr, probability) __builtin_expect_with_probability(!!(expr), 1, (probability))
1484#define JSON_HEDLEY_PREDICT_FALSE(expr, probability) __builtin_expect_with_probability(!!(expr), 0, (probability))
1485#define JSON_HEDLEY_LIKELY(expr) __builtin_expect(!!(expr), 1)
1486#define JSON_HEDLEY_UNLIKELY(expr) __builtin_expect(!!(expr), 0)
1487#elif (JSON_HEDLEY_HAS_BUILTIN(__builtin_expect) && !defined(JSON_HEDLEY_INTEL_CL_VERSION)) \
1488 || JSON_HEDLEY_GCC_VERSION_CHECK(3, 0, 0) || JSON_HEDLEY_INTEL_VERSION_CHECK(13, 0, 0) \
1489 || (JSON_HEDLEY_SUNPRO_VERSION_CHECK(5, 15, 0) && defined(__cplusplus)) || JSON_HEDLEY_ARM_VERSION_CHECK(4, 1, 0) \
1490 || JSON_HEDLEY_IBM_VERSION_CHECK(10, 1, 0) || JSON_HEDLEY_TI_VERSION_CHECK(15, 12, 0) \
1491 || JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4, 7, 0) || JSON_HEDLEY_TI_CL430_VERSION_CHECK(3, 1, 0) \
1492 || JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6, 1, 0) || JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6, 1, 0) \
1493 || JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1, 2, 0) || JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2, 1, 0) \
1494 || JSON_HEDLEY_TINYC_VERSION_CHECK(0, 9, 27) || JSON_HEDLEY_CRAY_VERSION_CHECK(8, 1, 0) \
1495 || JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1, 25, 10)
1496#define JSON_HEDLEY_PREDICT(expr, expected, probability) \
1497 (((probability) >= 0.9) ? __builtin_expect((expr), (expected)) : (JSON_HEDLEY_STATIC_CAST(void, expected), (expr)))
1498#define JSON_HEDLEY_PREDICT_TRUE(expr, probability) \
1500 double hedley_probability_ = (probability); \
1501 ((hedley_probability_ >= 0.9) ? __builtin_expect(!!(expr), 1) \
1502 : ((hedley_probability_ <= 0.1) ? __builtin_expect(!!(expr), 0) : !!(expr))); \
1504#define JSON_HEDLEY_PREDICT_FALSE(expr, probability) \
1506 double hedley_probability_ = (probability); \
1507 ((hedley_probability_ >= 0.9) ? __builtin_expect(!!(expr), 0) \
1508 : ((hedley_probability_ <= 0.1) ? __builtin_expect(!!(expr), 1) : !!(expr))); \
1510#define JSON_HEDLEY_LIKELY(expr) __builtin_expect(!!(expr), 1)
1511#define JSON_HEDLEY_UNLIKELY(expr) __builtin_expect(!!(expr), 0)
1513#define JSON_HEDLEY_PREDICT(expr, expected, probability) (JSON_HEDLEY_STATIC_CAST(void, expected), (expr))
1514#define JSON_HEDLEY_PREDICT_TRUE(expr, probability) (!!(expr))
1515#define JSON_HEDLEY_PREDICT_FALSE(expr, probability) (!!(expr))
1516#define JSON_HEDLEY_LIKELY(expr) (!!(expr))
1517#define JSON_HEDLEY_UNLIKELY(expr) (!!(expr))
1519#if !defined(JSON_HEDLEY_UNPREDICTABLE)
1520#define JSON_HEDLEY_UNPREDICTABLE(expr) JSON_HEDLEY_PREDICT(expr, 1, 0.5)
1523#if defined(JSON_HEDLEY_MALLOC)
1524#undef JSON_HEDLEY_MALLOC
1526#if JSON_HEDLEY_HAS_ATTRIBUTE(malloc) || JSON_HEDLEY_GCC_VERSION_CHECK(3, 1, 0) \
1527 || JSON_HEDLEY_INTEL_VERSION_CHECK(13, 0, 0) || JSON_HEDLEY_SUNPRO_VERSION_CHECK(5, 11, 0) \
1528 || JSON_HEDLEY_ARM_VERSION_CHECK(4, 1, 0) || JSON_HEDLEY_IBM_VERSION_CHECK(12, 1, 0) \
1529 || JSON_HEDLEY_TI_VERSION_CHECK(15, 12, 0) \
1530 || (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4, 8, 0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) \
1531 || JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5, 2, 0) \
1532 || (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6, 0, 0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) \
1533 || JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6, 4, 0) \
1534 || (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4, 0, 0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) \
1535 || JSON_HEDLEY_TI_CL430_VERSION_CHECK(4, 3, 0) \
1536 || (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7, 2, 0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) \
1537 || JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7, 5, 0) || JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1, 2, 0) \
1538 || JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2, 1, 0) || JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1, 25, 10)
1539#define JSON_HEDLEY_MALLOC __attribute__((__malloc__))
1540#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5, 10, 0)
1541#define JSON_HEDLEY_MALLOC _Pragma("returns_new_memory")
1542#elif JSON_HEDLEY_MSVC_VERSION_CHECK(14, 0, 0) || JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021, 1, 0)
1543#define JSON_HEDLEY_MALLOC __declspec(restrict)
1545#define JSON_HEDLEY_MALLOC
1548#if defined(JSON_HEDLEY_PURE)
1549#undef JSON_HEDLEY_PURE
1551#if JSON_HEDLEY_HAS_ATTRIBUTE(pure) || JSON_HEDLEY_GCC_VERSION_CHECK(2, 96, 0) \
1552 || JSON_HEDLEY_INTEL_VERSION_CHECK(13, 0, 0) || JSON_HEDLEY_SUNPRO_VERSION_CHECK(5, 11, 0) \
1553 || JSON_HEDLEY_ARM_VERSION_CHECK(4, 1, 0) || JSON_HEDLEY_IBM_VERSION_CHECK(10, 1, 0) \
1554 || JSON_HEDLEY_TI_VERSION_CHECK(15, 12, 0) \
1555 || (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4, 8, 0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) \
1556 || JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5, 2, 0) \
1557 || (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6, 0, 0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) \
1558 || JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6, 4, 0) \
1559 || (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4, 0, 0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) \
1560 || JSON_HEDLEY_TI_CL430_VERSION_CHECK(4, 3, 0) \
1561 || (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7, 2, 0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) \
1562 || JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7, 5, 0) || JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1, 2, 0) \
1563 || JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2, 1, 0) || JSON_HEDLEY_PGI_VERSION_CHECK(17, 10, 0) \
1564 || JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1, 25, 10)
1565#define JSON_HEDLEY_PURE __attribute__((__pure__))
1566#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5, 10, 0)
1567#define JSON_HEDLEY_PURE _Pragma("does_not_write_global_data")
1568#elif defined(__cplusplus) \
1569 && (JSON_HEDLEY_TI_CL430_VERSION_CHECK(2, 0, 1) || JSON_HEDLEY_TI_CL6X_VERSION_CHECK(4, 0, 0) \
1570 || JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1, 2, 0))
1571#define JSON_HEDLEY_PURE _Pragma("FUNC_IS_PURE;")
1573#define JSON_HEDLEY_PURE
1576#if defined(JSON_HEDLEY_CONST)
1577#undef JSON_HEDLEY_CONST
1579#if JSON_HEDLEY_HAS_ATTRIBUTE(const) || JSON_HEDLEY_GCC_VERSION_CHECK(2, 5, 0) \
1580 || JSON_HEDLEY_INTEL_VERSION_CHECK(13, 0, 0) || JSON_HEDLEY_SUNPRO_VERSION_CHECK(5, 11, 0) \
1581 || JSON_HEDLEY_ARM_VERSION_CHECK(4, 1, 0) || JSON_HEDLEY_IBM_VERSION_CHECK(10, 1, 0) \
1582 || JSON_HEDLEY_TI_VERSION_CHECK(15, 12, 0) \
1583 || (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4, 8, 0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) \
1584 || JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5, 2, 0) \
1585 || (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6, 0, 0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) \
1586 || JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6, 4, 0) \
1587 || (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4, 0, 0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) \
1588 || JSON_HEDLEY_TI_CL430_VERSION_CHECK(4, 3, 0) \
1589 || (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7, 2, 0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) \
1590 || JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7, 5, 0) || JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1, 2, 0) \
1591 || JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2, 1, 0) || JSON_HEDLEY_PGI_VERSION_CHECK(17, 10, 0) \
1592 || JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1, 25, 10)
1593#define JSON_HEDLEY_CONST __attribute__((__const__))
1594#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5, 10, 0)
1595#define JSON_HEDLEY_CONST _Pragma("no_side_effect")
1597#define JSON_HEDLEY_CONST JSON_HEDLEY_PURE
1600#if defined(JSON_HEDLEY_RESTRICT)
1601#undef JSON_HEDLEY_RESTRICT
1603#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) && !defined(__cplusplus)
1604#define JSON_HEDLEY_RESTRICT restrict
1605#elif JSON_HEDLEY_GCC_VERSION_CHECK(3, 1, 0) || JSON_HEDLEY_MSVC_VERSION_CHECK(14, 0, 0) \
1606 || JSON_HEDLEY_INTEL_VERSION_CHECK(13, 0, 0) || JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021, 1, 0) \
1607 || JSON_HEDLEY_ARM_VERSION_CHECK(4, 1, 0) || JSON_HEDLEY_IBM_VERSION_CHECK(10, 1, 0) \
1608 || JSON_HEDLEY_PGI_VERSION_CHECK(17, 10, 0) || JSON_HEDLEY_TI_CL430_VERSION_CHECK(4, 3, 0) \
1609 || JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6, 2, 4) || JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8, 1, 0) \
1610 || JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1, 2, 0) \
1611 || (JSON_HEDLEY_SUNPRO_VERSION_CHECK(5, 14, 0) && defined(__cplusplus)) || JSON_HEDLEY_IAR_VERSION_CHECK(8, 0, 0) \
1612 || defined(__clang__) || JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1, 25, 10)
1613#define JSON_HEDLEY_RESTRICT __restrict
1614#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5, 3, 0) && !defined(__cplusplus)
1615#define JSON_HEDLEY_RESTRICT _Restrict
1617#define JSON_HEDLEY_RESTRICT
1620#if defined(JSON_HEDLEY_INLINE)
1621#undef JSON_HEDLEY_INLINE
1623#if (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)) || (defined(__cplusplus) && (__cplusplus >= 199711L))
1624#define JSON_HEDLEY_INLINE inline
1625#elif defined(JSON_HEDLEY_GCC_VERSION) || JSON_HEDLEY_ARM_VERSION_CHECK(6, 2, 0)
1626#define JSON_HEDLEY_INLINE __inline__
1627#elif JSON_HEDLEY_MSVC_VERSION_CHECK(12, 0, 0) || JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021, 1, 0) \
1628 || JSON_HEDLEY_ARM_VERSION_CHECK(4, 1, 0) || JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5, 1, 0) \
1629 || JSON_HEDLEY_TI_CL430_VERSION_CHECK(3, 1, 0) || JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6, 2, 0) \
1630 || JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8, 0, 0) || JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1, 2, 0) \
1631 || JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2, 1, 0) || JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1, 25, 10)
1632#define JSON_HEDLEY_INLINE __inline
1634#define JSON_HEDLEY_INLINE
1637#if defined(JSON_HEDLEY_ALWAYS_INLINE)
1638#undef JSON_HEDLEY_ALWAYS_INLINE
1640#if JSON_HEDLEY_HAS_ATTRIBUTE(always_inline) || JSON_HEDLEY_GCC_VERSION_CHECK(4, 0, 0) \
1641 || JSON_HEDLEY_INTEL_VERSION_CHECK(13, 0, 0) || JSON_HEDLEY_SUNPRO_VERSION_CHECK(5, 11, 0) \
1642 || JSON_HEDLEY_ARM_VERSION_CHECK(4, 1, 0) || JSON_HEDLEY_IBM_VERSION_CHECK(10, 1, 0) \
1643 || JSON_HEDLEY_TI_VERSION_CHECK(15, 12, 0) \
1644 || (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4, 8, 0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) \
1645 || JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5, 2, 0) \
1646 || (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6, 0, 0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) \
1647 || JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6, 4, 0) \
1648 || (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4, 0, 0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) \
1649 || JSON_HEDLEY_TI_CL430_VERSION_CHECK(4, 3, 0) \
1650 || (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7, 2, 0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) \
1651 || JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7, 5, 0) || JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1, 2, 0) \
1652 || JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2, 1, 0) || JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1, 25, 10) \
1653 || JSON_HEDLEY_IAR_VERSION_CHECK(8, 10, 0)
1654#define JSON_HEDLEY_ALWAYS_INLINE __attribute__((__always_inline__)) JSON_HEDLEY_INLINE
1655#elif JSON_HEDLEY_MSVC_VERSION_CHECK(12, 0, 0) || JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021, 1, 0)
1656#define JSON_HEDLEY_ALWAYS_INLINE __forceinline
1657#elif defined(__cplusplus) \
1658 && (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5, 2, 0) || JSON_HEDLEY_TI_CL430_VERSION_CHECK(4, 3, 0) \
1659 || JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6, 4, 0) || JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6, 1, 0) \
1660 || JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1, 2, 0) || JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2, 1, 0))
1661#define JSON_HEDLEY_ALWAYS_INLINE _Pragma("FUNC_ALWAYS_INLINE;")
1662#elif JSON_HEDLEY_IAR_VERSION_CHECK(8, 0, 0)
1663#define JSON_HEDLEY_ALWAYS_INLINE _Pragma("inline=forced")
1665#define JSON_HEDLEY_ALWAYS_INLINE JSON_HEDLEY_INLINE
1668#if defined(JSON_HEDLEY_NEVER_INLINE)
1669#undef JSON_HEDLEY_NEVER_INLINE
1671#if JSON_HEDLEY_HAS_ATTRIBUTE(noinline) || JSON_HEDLEY_GCC_VERSION_CHECK(4, 0, 0) \
1672 || JSON_HEDLEY_INTEL_VERSION_CHECK(13, 0, 0) || JSON_HEDLEY_SUNPRO_VERSION_CHECK(5, 11, 0) \
1673 || JSON_HEDLEY_ARM_VERSION_CHECK(4, 1, 0) || JSON_HEDLEY_IBM_VERSION_CHECK(10, 1, 0) \
1674 || JSON_HEDLEY_TI_VERSION_CHECK(15, 12, 0) \
1675 || (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4, 8, 0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) \
1676 || JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5, 2, 0) \
1677 || (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6, 0, 0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) \
1678 || JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6, 4, 0) \
1679 || (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4, 0, 0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) \
1680 || JSON_HEDLEY_TI_CL430_VERSION_CHECK(4, 3, 0) \
1681 || (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7, 2, 0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) \
1682 || JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7, 5, 0) || JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1, 2, 0) \
1683 || JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2, 1, 0) || JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1, 25, 10) \
1684 || JSON_HEDLEY_IAR_VERSION_CHECK(8, 10, 0)
1685#define JSON_HEDLEY_NEVER_INLINE __attribute__((__noinline__))
1686#elif JSON_HEDLEY_MSVC_VERSION_CHECK(13, 10, 0) || JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021, 1, 0)
1687#define JSON_HEDLEY_NEVER_INLINE __declspec(noinline)
1688#elif JSON_HEDLEY_PGI_VERSION_CHECK(10, 2, 0)
1689#define JSON_HEDLEY_NEVER_INLINE _Pragma("noinline")
1690#elif JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6, 0, 0) && defined(__cplusplus)
1691#define JSON_HEDLEY_NEVER_INLINE _Pragma("FUNC_CANNOT_INLINE;")
1692#elif JSON_HEDLEY_IAR_VERSION_CHECK(8, 0, 0)
1693#define JSON_HEDLEY_NEVER_INLINE _Pragma("inline=never")
1694#elif JSON_HEDLEY_COMPCERT_VERSION_CHECK(3, 2, 0)
1695#define JSON_HEDLEY_NEVER_INLINE __attribute((noinline))
1696#elif JSON_HEDLEY_PELLES_VERSION_CHECK(9, 0, 0)
1697#define JSON_HEDLEY_NEVER_INLINE __declspec(noinline)
1699#define JSON_HEDLEY_NEVER_INLINE
1702#if defined(JSON_HEDLEY_PRIVATE)
1703#undef JSON_HEDLEY_PRIVATE
1705#if defined(JSON_HEDLEY_PUBLIC)
1706#undef JSON_HEDLEY_PUBLIC
1708#if defined(JSON_HEDLEY_IMPORT)
1709#undef JSON_HEDLEY_IMPORT
1711#if defined(_WIN32) || defined(__CYGWIN__)
1712#define JSON_HEDLEY_PRIVATE
1713#define JSON_HEDLEY_PUBLIC __declspec(dllexport)
1714#define JSON_HEDLEY_IMPORT __declspec(dllimport)
1716#if JSON_HEDLEY_HAS_ATTRIBUTE(visibility) || JSON_HEDLEY_GCC_VERSION_CHECK(3, 3, 0) \
1717 || JSON_HEDLEY_SUNPRO_VERSION_CHECK(5, 11, 0) || JSON_HEDLEY_INTEL_VERSION_CHECK(13, 0, 0) \
1718 || JSON_HEDLEY_ARM_VERSION_CHECK(4, 1, 0) || JSON_HEDLEY_IBM_VERSION_CHECK(13, 1, 0) \
1719 || (defined(__TI_EABI__) \
1720 && ((JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7, 2, 0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) \
1721 || JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7, 5, 0))) \
1722 || JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1, 25, 10)
1723#define JSON_HEDLEY_PRIVATE __attribute__((__visibility__("hidden")))
1724#define JSON_HEDLEY_PUBLIC __attribute__((__visibility__("default")))
1726#define JSON_HEDLEY_PRIVATE
1727#define JSON_HEDLEY_PUBLIC
1729#define JSON_HEDLEY_IMPORT extern
1732#if defined(JSON_HEDLEY_NO_THROW)
1733#undef JSON_HEDLEY_NO_THROW
1735#if JSON_HEDLEY_HAS_ATTRIBUTE(nothrow) || JSON_HEDLEY_GCC_VERSION_CHECK(3, 3, 0) \
1736 || JSON_HEDLEY_INTEL_VERSION_CHECK(13, 0, 0) || JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1, 25, 10)
1737#define JSON_HEDLEY_NO_THROW __attribute__((__nothrow__))
1738#elif JSON_HEDLEY_MSVC_VERSION_CHECK(13, 1, 0) || JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021, 1, 0) \
1739 || JSON_HEDLEY_ARM_VERSION_CHECK(4, 1, 0)
1740#define JSON_HEDLEY_NO_THROW __declspec(nothrow)
1742#define JSON_HEDLEY_NO_THROW
1745#if defined(JSON_HEDLEY_FALL_THROUGH)
1746#undef JSON_HEDLEY_FALL_THROUGH
1748#if JSON_HEDLEY_HAS_ATTRIBUTE(fallthrough) || JSON_HEDLEY_GCC_VERSION_CHECK(7, 0, 0) \
1749 || JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1, 25, 10)
1750#define JSON_HEDLEY_FALL_THROUGH __attribute__((__fallthrough__))
1751#elif JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS(clang, fallthrough)
1752#define JSON_HEDLEY_FALL_THROUGH JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[clang::fallthrough]])
1753#elif JSON_HEDLEY_HAS_CPP_ATTRIBUTE(fallthrough)
1754#define JSON_HEDLEY_FALL_THROUGH JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[fallthrough]])
1755#elif defined(__fallthrough)
1756#define JSON_HEDLEY_FALL_THROUGH __fallthrough
1758#define JSON_HEDLEY_FALL_THROUGH
1761#if defined(JSON_HEDLEY_RETURNS_NON_NULL)
1762#undef JSON_HEDLEY_RETURNS_NON_NULL
1764#if JSON_HEDLEY_HAS_ATTRIBUTE(returns_nonnull) || JSON_HEDLEY_GCC_VERSION_CHECK(4, 9, 0) \
1765 || JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1, 25, 10)
1766#define JSON_HEDLEY_RETURNS_NON_NULL __attribute__((__returns_nonnull__))
1767#elif defined(_Ret_notnull_)
1768#define JSON_HEDLEY_RETURNS_NON_NULL _Ret_notnull_
1770#define JSON_HEDLEY_RETURNS_NON_NULL
1773#if defined(JSON_HEDLEY_ARRAY_PARAM)
1774#undef JSON_HEDLEY_ARRAY_PARAM
1776#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) && !defined(__STDC_NO_VLA__) && !defined(__cplusplus) \
1777 && !defined(JSON_HEDLEY_PGI_VERSION) && !defined(JSON_HEDLEY_TINYC_VERSION)
1778#define JSON_HEDLEY_ARRAY_PARAM(name) (name)
1780#define JSON_HEDLEY_ARRAY_PARAM(name)
1783#if defined(JSON_HEDLEY_IS_CONSTANT)
1784#undef JSON_HEDLEY_IS_CONSTANT
1786#if defined(JSON_HEDLEY_REQUIRE_CONSTEXPR)
1787#undef JSON_HEDLEY_REQUIRE_CONSTEXPR
1791#if defined(JSON_HEDLEY_IS_CONSTEXPR_)
1792#undef JSON_HEDLEY_IS_CONSTEXPR_
1794#if JSON_HEDLEY_HAS_BUILTIN(__builtin_constant_p) || JSON_HEDLEY_GCC_VERSION_CHECK(3, 4, 0) \
1795 || JSON_HEDLEY_INTEL_VERSION_CHECK(13, 0, 0) || JSON_HEDLEY_TINYC_VERSION_CHECK(0, 9, 19) \
1796 || JSON_HEDLEY_ARM_VERSION_CHECK(4, 1, 0) || JSON_HEDLEY_IBM_VERSION_CHECK(13, 1, 0) \
1797 || JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6, 1, 0) \
1798 || (JSON_HEDLEY_SUNPRO_VERSION_CHECK(5, 10, 0) && !defined(__cplusplus)) \
1799 || JSON_HEDLEY_CRAY_VERSION_CHECK(8, 1, 0) || JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1, 25, 10)
1800#define JSON_HEDLEY_IS_CONSTANT(expr) __builtin_constant_p(expr)
1802#if !defined(__cplusplus)
1803#if JSON_HEDLEY_HAS_BUILTIN(__builtin_types_compatible_p) || JSON_HEDLEY_GCC_VERSION_CHECK(3, 4, 0) \
1804 || JSON_HEDLEY_INTEL_VERSION_CHECK(13, 0, 0) || JSON_HEDLEY_IBM_VERSION_CHECK(13, 1, 0) \
1805 || JSON_HEDLEY_CRAY_VERSION_CHECK(8, 1, 0) || JSON_HEDLEY_ARM_VERSION_CHECK(5, 4, 0) \
1806 || JSON_HEDLEY_TINYC_VERSION_CHECK(0, 9, 24)
1807#if defined(__INTPTR_TYPE__)
1808#define JSON_HEDLEY_IS_CONSTEXPR_(expr) \
1809 __builtin_types_compatible_p(__typeof__((1 ? (void*)((__INTPTR_TYPE__)((expr) * 0)) : (int*)0)), int*)
1812#define JSON_HEDLEY_IS_CONSTEXPR_(expr) \
1813 __builtin_types_compatible_p(__typeof__((1 ? (void*)((intptr_t)((expr) * 0)) : (int*)0)), int*)
1815#elif (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L) && !defined(JSON_HEDLEY_SUNPRO_VERSION) \
1816 && !defined(JSON_HEDLEY_PGI_VERSION) && !defined(JSON_HEDLEY_IAR_VERSION)) \
1817 || (JSON_HEDLEY_HAS_EXTENSION(c_generic_selections) && !defined(JSON_HEDLEY_IAR_VERSION)) \
1818 || JSON_HEDLEY_GCC_VERSION_CHECK(4, 9, 0) || JSON_HEDLEY_INTEL_VERSION_CHECK(17, 0, 0) \
1819 || JSON_HEDLEY_IBM_VERSION_CHECK(12, 1, 0) || JSON_HEDLEY_ARM_VERSION_CHECK(5, 3, 0)
1820#if defined(__INTPTR_TYPE__)
1821#define JSON_HEDLEY_IS_CONSTEXPR_(expr) \
1822 _Generic((1 ? (void*)((__INTPTR_TYPE__)((expr) * 0)) : (int*)0), int*: 1, void*: 0)
1825#define JSON_HEDLEY_IS_CONSTEXPR_(expr) _Generic((1 ? (void*)((intptr_t)*0) : (int*)0), int*: 1, void*: 0)
1827#elif defined(JSON_HEDLEY_GCC_VERSION) || defined(JSON_HEDLEY_INTEL_VERSION) || defined(JSON_HEDLEY_TINYC_VERSION) \
1828 || defined(JSON_HEDLEY_TI_ARMCL_VERSION) || JSON_HEDLEY_TI_CL430_VERSION_CHECK(18, 12, 0) \
1829 || defined(JSON_HEDLEY_TI_CL2000_VERSION) || defined(JSON_HEDLEY_TI_CL6X_VERSION) \
1830 || defined(JSON_HEDLEY_TI_CL7X_VERSION) || defined(JSON_HEDLEY_TI_CLPRU_VERSION) || defined(__clang__)
1831#define JSON_HEDLEY_IS_CONSTEXPR_(expr) \
1832 (sizeof(void) != sizeof(*(1 ? ((void*)((expr) * 0L)) : ((struct { char v[sizeof(void) * 2]; }*)1))))
1835#if defined(JSON_HEDLEY_IS_CONSTEXPR_)
1836#if !defined(JSON_HEDLEY_IS_CONSTANT)
1837#define JSON_HEDLEY_IS_CONSTANT(expr) JSON_HEDLEY_IS_CONSTEXPR_(expr)
1839#define JSON_HEDLEY_REQUIRE_CONSTEXPR(expr) (JSON_HEDLEY_IS_CONSTEXPR_(expr) ? (expr) : (-1))
1841#if !defined(JSON_HEDLEY_IS_CONSTANT)
1842#define JSON_HEDLEY_IS_CONSTANT(expr) (0)
1844#define JSON_HEDLEY_REQUIRE_CONSTEXPR(expr) (expr)
1847#if defined(JSON_HEDLEY_BEGIN_C_DECLS)
1848#undef JSON_HEDLEY_BEGIN_C_DECLS
1850#if defined(JSON_HEDLEY_END_C_DECLS)
1851#undef JSON_HEDLEY_END_C_DECLS
1853#if defined(JSON_HEDLEY_C_DECL)
1854#undef JSON_HEDLEY_C_DECL
1856#if defined(__cplusplus)
1857#define JSON_HEDLEY_BEGIN_C_DECLS extern "C" {
1858#define JSON_HEDLEY_END_C_DECLS }
1859#define JSON_HEDLEY_C_DECL extern "C"
1861#define JSON_HEDLEY_BEGIN_C_DECLS
1862#define JSON_HEDLEY_END_C_DECLS
1863#define JSON_HEDLEY_C_DECL
1866#if defined(JSON_HEDLEY_STATIC_ASSERT)
1867#undef JSON_HEDLEY_STATIC_ASSERT
1869#if !defined(__cplusplus) \
1870 && ((defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L)) \
1871 || (JSON_HEDLEY_HAS_FEATURE(c_static_assert) && !defined(JSON_HEDLEY_INTEL_CL_VERSION)) \
1872 || JSON_HEDLEY_GCC_VERSION_CHECK(6, 0, 0) || JSON_HEDLEY_INTEL_VERSION_CHECK(13, 0, 0) \
1873 || defined(_Static_assert))
1874#define JSON_HEDLEY_STATIC_ASSERT(expr, message) _Static_assert(expr, message)
1875#elif (defined(__cplusplus) && (__cplusplus >= 201103L)) || JSON_HEDLEY_MSVC_VERSION_CHECK(16, 0, 0) \
1876 || JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021, 1, 0)
1877#define JSON_HEDLEY_STATIC_ASSERT(expr, message) \
1878 JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(static_assert(expr, message))
1880#define JSON_HEDLEY_STATIC_ASSERT(expr, message)
1883#if defined(JSON_HEDLEY_NULL)
1884#undef JSON_HEDLEY_NULL
1886#if defined(__cplusplus)
1887#if __cplusplus >= 201103L
1888#define JSON_HEDLEY_NULL JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(nullptr)
1890#define JSON_HEDLEY_NULL NULL
1892#define JSON_HEDLEY_NULL JSON_HEDLEY_STATIC_CAST(void*, 0)
1895#define JSON_HEDLEY_NULL NULL
1897#define JSON_HEDLEY_NULL ((void*)0)
1900#if defined(JSON_HEDLEY_MESSAGE)
1901#undef JSON_HEDLEY_MESSAGE
1903#if JSON_HEDLEY_HAS_WARNING("-Wunknown-pragmas")
1904#define JSON_HEDLEY_MESSAGE(msg) \
1905 JSON_HEDLEY_DIAGNOSTIC_PUSH \
1906 JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS \
1907 JSON_HEDLEY_PRAGMA(message msg) \
1908 JSON_HEDLEY_DIAGNOSTIC_POP
1909#elif JSON_HEDLEY_GCC_VERSION_CHECK(4, 4, 0) || JSON_HEDLEY_INTEL_VERSION_CHECK(13, 0, 0)
1910#define JSON_HEDLEY_MESSAGE(msg) JSON_HEDLEY_PRAGMA(message msg)
1911#elif JSON_HEDLEY_CRAY_VERSION_CHECK(5, 0, 0)
1912#define JSON_HEDLEY_MESSAGE(msg) JSON_HEDLEY_PRAGMA(_CRI message msg)
1913#elif JSON_HEDLEY_IAR_VERSION_CHECK(8, 0, 0)
1914#define JSON_HEDLEY_MESSAGE(msg) JSON_HEDLEY_PRAGMA(message(msg))
1915#elif JSON_HEDLEY_PELLES_VERSION_CHECK(2, 0, 0)
1916#define JSON_HEDLEY_MESSAGE(msg) JSON_HEDLEY_PRAGMA(message(msg))
1918#define JSON_HEDLEY_MESSAGE(msg)
1921#if defined(JSON_HEDLEY_WARNING)
1922#undef JSON_HEDLEY_WARNING
1924#if JSON_HEDLEY_HAS_WARNING("-Wunknown-pragmas")
1925#define JSON_HEDLEY_WARNING(msg) \
1926 JSON_HEDLEY_DIAGNOSTIC_PUSH \
1927 JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS \
1928 JSON_HEDLEY_PRAGMA(clang warning msg) \
1929 JSON_HEDLEY_DIAGNOSTIC_POP
1930#elif JSON_HEDLEY_GCC_VERSION_CHECK(4, 8, 0) || JSON_HEDLEY_PGI_VERSION_CHECK(18, 4, 0) \
1931 || JSON_HEDLEY_INTEL_VERSION_CHECK(13, 0, 0)
1932#define JSON_HEDLEY_WARNING(msg) JSON_HEDLEY_PRAGMA(GCC warning msg)
1933#elif JSON_HEDLEY_MSVC_VERSION_CHECK(15, 0, 0) || JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021, 1, 0)
1934#define JSON_HEDLEY_WARNING(msg) JSON_HEDLEY_PRAGMA(message(msg))
1936#define JSON_HEDLEY_WARNING(msg) JSON_HEDLEY_MESSAGE(msg)
1939#if defined(JSON_HEDLEY_REQUIRE)
1940#undef JSON_HEDLEY_REQUIRE
1942#if defined(JSON_HEDLEY_REQUIRE_MSG)
1943#undef JSON_HEDLEY_REQUIRE_MSG
1945#if JSON_HEDLEY_HAS_ATTRIBUTE(diagnose_if)
1946#if JSON_HEDLEY_HAS_WARNING("-Wgcc-compat")
1947#define JSON_HEDLEY_REQUIRE(expr) \
1948 JSON_HEDLEY_DIAGNOSTIC_PUSH \
1949 _Pragma("clang diagnostic ignored \"-Wgcc-compat\"") \
1950 __attribute__((diagnose_if(!(expr), #expr, "error"))) JSON_HEDLEY_DIAGNOSTIC_POP
1951#define JSON_HEDLEY_REQUIRE_MSG(expr, msg) \
1952 JSON_HEDLEY_DIAGNOSTIC_PUSH \
1953 _Pragma("clang diagnostic ignored \"-Wgcc-compat\"") \
1954 __attribute__((diagnose_if(!(expr), msg, "error"))) JSON_HEDLEY_DIAGNOSTIC_POP
1956#define JSON_HEDLEY_REQUIRE(expr) __attribute__((diagnose_if(!(expr), #expr, "error")))
1957#define JSON_HEDLEY_REQUIRE_MSG(expr, msg) __attribute__((diagnose_if(!(expr), msg, "error")))
1960#define JSON_HEDLEY_REQUIRE(expr)
1961#define JSON_HEDLEY_REQUIRE_MSG(expr, msg)
1964#if defined(JSON_HEDLEY_FLAGS)
1965#undef JSON_HEDLEY_FLAGS
1967#if JSON_HEDLEY_HAS_ATTRIBUTE(flag_enum) \
1968 && (!defined(__cplusplus) || JSON_HEDLEY_HAS_WARNING("-Wbitfield-enum-conversion"))
1969#define JSON_HEDLEY_FLAGS __attribute__((__flag_enum__))
1971#define JSON_HEDLEY_FLAGS
1974#if defined(JSON_HEDLEY_FLAGS_CAST)
1975#undef JSON_HEDLEY_FLAGS_CAST
1977#if JSON_HEDLEY_INTEL_VERSION_CHECK(19, 0, 0)
1978#define JSON_HEDLEY_FLAGS_CAST(T, expr) \
1980 JSON_HEDLEY_DIAGNOSTIC_PUSH \
1981 _Pragma("warning(disable:188)")((T)(expr)); \
1982 JSON_HEDLEY_DIAGNOSTIC_POP \
1985#define JSON_HEDLEY_FLAGS_CAST(T, expr) JSON_HEDLEY_STATIC_CAST(T, expr)
1988#if defined(JSON_HEDLEY_EMPTY_BASES)
1989#undef JSON_HEDLEY_EMPTY_BASES
1991#if (JSON_HEDLEY_MSVC_VERSION_CHECK(19, 0, 23918) && !JSON_HEDLEY_MSVC_VERSION_CHECK(20, 0, 0)) \
1992 || JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021, 1, 0)
1993#define JSON_HEDLEY_EMPTY_BASES __declspec(empty_bases)
1995#define JSON_HEDLEY_EMPTY_BASES
2000#if defined(JSON_HEDLEY_GCC_NOT_CLANG_VERSION_CHECK)
2001#undef JSON_HEDLEY_GCC_NOT_CLANG_VERSION_CHECK
2003#if defined(__clang__)
2004#define JSON_HEDLEY_GCC_NOT_CLANG_VERSION_CHECK(major, minor, patch) (0)
2006#define JSON_HEDLEY_GCC_NOT_CLANG_VERSION_CHECK(major, minor, patch) JSON_HEDLEY_GCC_VERSION_CHECK(major, minor, patch)
2009#if defined(JSON_HEDLEY_CLANG_HAS_ATTRIBUTE)
2010#undef JSON_HEDLEY_CLANG_HAS_ATTRIBUTE
2012#define JSON_HEDLEY_CLANG_HAS_ATTRIBUTE(attribute) JSON_HEDLEY_HAS_ATTRIBUTE(attribute)
2014#if defined(JSON_HEDLEY_CLANG_HAS_CPP_ATTRIBUTE)
2015#undef JSON_HEDLEY_CLANG_HAS_CPP_ATTRIBUTE
2017#define JSON_HEDLEY_CLANG_HAS_CPP_ATTRIBUTE(attribute) JSON_HEDLEY_HAS_CPP_ATTRIBUTE(attribute)
2019#if defined(JSON_HEDLEY_CLANG_HAS_BUILTIN)
2020#undef JSON_HEDLEY_CLANG_HAS_BUILTIN
2022#define JSON_HEDLEY_CLANG_HAS_BUILTIN(builtin) JSON_HEDLEY_HAS_BUILTIN(builtin)
2024#if defined(JSON_HEDLEY_CLANG_HAS_FEATURE)
2025#undef JSON_HEDLEY_CLANG_HAS_FEATURE
2027#define JSON_HEDLEY_CLANG_HAS_FEATURE(feature) JSON_HEDLEY_HAS_FEATURE(feature)
2029#if defined(JSON_HEDLEY_CLANG_HAS_EXTENSION)
2030#undef JSON_HEDLEY_CLANG_HAS_EXTENSION
2032#define JSON_HEDLEY_CLANG_HAS_EXTENSION(extension) JSON_HEDLEY_HAS_EXTENSION(extension)
2034#if defined(JSON_HEDLEY_CLANG_HAS_DECLSPEC_DECLSPEC_ATTRIBUTE)
2035#undef JSON_HEDLEY_CLANG_HAS_DECLSPEC_DECLSPEC_ATTRIBUTE
2037#define JSON_HEDLEY_CLANG_HAS_DECLSPEC_ATTRIBUTE(attribute) JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE(attribute)
2039#if defined(JSON_HEDLEY_CLANG_HAS_WARNING)
2040#undef JSON_HEDLEY_CLANG_HAS_WARNING
2042#define JSON_HEDLEY_CLANG_HAS_WARNING(warning) JSON_HEDLEY_HAS_WARNING(warning)
2048#include <type_traits>
2056template<
typename... Ts>
2061template<
typename... Ts>
2081template<
class Default,
class AlwaysVoid,
template<
class...>
class Op,
class... Args>
2088template<
class Default,
template<
class...>
class Op,
class... Args>
2095template<
template<
class...>
class Op,
class... Args>
2098template<
template<
class...>
class Op,
class... Args>
2102template<
template<
class...>
class Op,
class... Args>
2105template<
class Default,
template<
class...>
class Op,
class... Args>
2108template<
class Default,
template<
class...>
class Op,
class... Args>
2111template<
class Expected,
template<
class...>
class Op,
class... Args>
2114template<
class To,
template<
class...>
class Op,
class... Args>
2123#if !defined(JSON_SKIP_UNSUPPORTED_COMPILER_CHECK)
2124#if defined(__clang__)
2125#if (__clang_major__ * 10000 + __clang_minor__ * 100 + __clang_patchlevel__) < 30400
2126#error "unsupported Clang version - see https://github.com/nlohmann/json#supported-compilers"
2128#elif defined(__GNUC__) && !(defined(__ICC) || defined(__INTEL_COMPILER))
2129#if (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) < 40800
2130#error "unsupported GCC version - see https://github.com/nlohmann/json#supported-compilers"
2137#if !defined(JSON_HAS_CPP_20) && !defined(JSON_HAS_CPP_17) && !defined(JSON_HAS_CPP_14) && !defined(JSON_HAS_CPP_11)
2138#if (defined(__cplusplus) && __cplusplus >= 202002L) || (defined(_MSVC_LANG) && _MSVC_LANG >= 202002L)
2139#define JSON_HAS_CPP_20
2140#define JSON_HAS_CPP_17
2141#define JSON_HAS_CPP_14
2142#elif (defined(__cplusplus) && __cplusplus >= 201703L) \
2143 || (defined(_HAS_CXX17) && _HAS_CXX17 == 1)
2144#define JSON_HAS_CPP_17
2145#define JSON_HAS_CPP_14
2146#elif (defined(__cplusplus) && __cplusplus >= 201402L) || (defined(_HAS_CXX14) && _HAS_CXX14 == 1)
2147#define JSON_HAS_CPP_14
2150#define JSON_HAS_CPP_11
2153#if !defined(JSON_HAS_FILESYSTEM) && !defined(JSON_HAS_EXPERIMENTAL_FILESYSTEM)
2154#ifdef JSON_HAS_CPP_17
2155#if defined(__cpp_lib_filesystem)
2156#define JSON_HAS_FILESYSTEM 1
2157#elif defined(__cpp_lib_experimental_filesystem)
2158#define JSON_HAS_EXPERIMENTAL_FILESYSTEM 1
2159#elif !defined(__has_include)
2160#define JSON_HAS_EXPERIMENTAL_FILESYSTEM 1
2161#elif __has_include(<filesystem>)
2162#define JSON_HAS_FILESYSTEM 1
2163#elif __has_include(<experimental/filesystem>)
2164#define JSON_HAS_EXPERIMENTAL_FILESYSTEM 1
2168#if defined(__MINGW32__) && defined(__GNUC__) && __GNUC__ == 8
2169#undef JSON_HAS_FILESYSTEM
2170#undef JSON_HAS_EXPERIMENTAL_FILESYSTEM
2174#if defined(__GNUC__) && !defined(__clang__) && __GNUC__ < 8
2175#undef JSON_HAS_FILESYSTEM
2176#undef JSON_HAS_EXPERIMENTAL_FILESYSTEM
2180#if defined(__clang_major__) && __clang_major__ < 7
2181#undef JSON_HAS_FILESYSTEM
2182#undef JSON_HAS_EXPERIMENTAL_FILESYSTEM
2186#if defined(_MSC_VER) && _MSC_VER < 1940
2187#undef JSON_HAS_FILESYSTEM
2188#undef JSON_HAS_EXPERIMENTAL_FILESYSTEM
2192#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) && __IPHONE_OS_VERSION_MIN_REQUIRED < 130000
2193#undef JSON_HAS_FILESYSTEM
2194#undef JSON_HAS_EXPERIMENTAL_FILESYSTEM
2198#if defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && __MAC_OS_X_VERSION_MIN_REQUIRED < 101500
2199#undef JSON_HAS_FILESYSTEM
2200#undef JSON_HAS_EXPERIMENTAL_FILESYSTEM
2205#ifndef JSON_HAS_EXPERIMENTAL_FILESYSTEM
2206#define JSON_HAS_EXPERIMENTAL_FILESYSTEM 0
2209#ifndef JSON_HAS_FILESYSTEM
2210#define JSON_HAS_FILESYSTEM 0
2214#if defined(__clang__)
2215#pragma clang diagnostic push
2216#pragma clang diagnostic ignored "-Wdocumentation"
2217#pragma clang diagnostic ignored "-Wdocumentation-unknown-command"
2221#if (defined(__cpp_exceptions) || defined(__EXCEPTIONS) || defined(_CPPUNWIND)) && !defined(JSON_NOEXCEPTION)
2222#define JSON_THROW(exception) throw exception
2224#define JSON_CATCH(exception) catch (exception)
2225#define JSON_INTERNAL_CATCH(exception) catch (exception)
2228#define JSON_THROW(exception) std::abort()
2229#define JSON_TRY if (true)
2230#define JSON_CATCH(exception) if (false)
2231#define JSON_INTERNAL_CATCH(exception) if (false)
2235#if defined(JSON_THROW_USER)
2237#define JSON_THROW JSON_THROW_USER
2239#if defined(JSON_TRY_USER)
2241#define JSON_TRY JSON_TRY_USER
2243#if defined(JSON_CATCH_USER)
2245#define JSON_CATCH JSON_CATCH_USER
2246#undef JSON_INTERNAL_CATCH
2247#define JSON_INTERNAL_CATCH JSON_CATCH_USER
2249#if defined(JSON_INTERNAL_CATCH_USER)
2250#undef JSON_INTERNAL_CATCH
2251#define JSON_INTERNAL_CATCH JSON_INTERNAL_CATCH_USER
2255#if !defined(JSON_ASSERT)
2257#define JSON_ASSERT(x) assert(x)
2261#if defined(JSON_TESTS_PRIVATE)
2262#define JSON_PRIVATE_UNLESS_TESTED public
2264#define JSON_PRIVATE_UNLESS_TESTED private
2272#define NLOHMANN_JSON_SERIALIZE_ENUM(ENUM_TYPE, ...) \
2273 template<typename BasicJsonType> \
2274 inline void to_json(BasicJsonType& j, const ENUM_TYPE& e) \
2276 static_assert(std::is_enum<ENUM_TYPE>::value, #ENUM_TYPE " must be an enum!"); \
2277 static const std::pair<ENUM_TYPE, BasicJsonType> m[] = __VA_ARGS__; \
2279 std::find_if(std::begin(m), std::end(m), [e](const std::pair<ENUM_TYPE, BasicJsonType>& ej_pair) -> bool { \
2280 return ej_pair.first == e; \
2282 j = ((it != std::end(m)) ? it : std::begin(m))->second; \
2284 template<typename BasicJsonType> \
2285 inline void from_json(const BasicJsonType& j, ENUM_TYPE& e) \
2287 static_assert(std::is_enum<ENUM_TYPE>::value, #ENUM_TYPE " must be an enum!"); \
2288 static const std::pair<ENUM_TYPE, BasicJsonType> m[] = __VA_ARGS__; \
2289 auto it = std::find_if( \
2290 std::begin(m), std::end(m), \
2291 [&j](const std::pair<ENUM_TYPE, BasicJsonType>& ej_pair) -> bool { return ej_pair.second == j; }); \
2292 e = ((it != std::end(m)) ? it : std::begin(m))->first; \
2298#define NLOHMANN_BASIC_JSON_TPL_DECLARATION \
2299 template<template<typename, typename, typename...> class ObjectType, \
2300 template<typename, typename...> class ArrayType, class StringType, class BooleanType, \
2301 class NumberIntegerType, class NumberUnsignedType, class NumberFloatType, \
2302 template<typename> class AllocatorType, template<typename, typename = void> class JSONSerializer, \
2305#define NLOHMANN_BASIC_JSON_TPL \
2306 basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, \
2307 AllocatorType, JSONSerializer, BinaryType>
2311#define NLOHMANN_JSON_EXPAND(x) x
2312#define NLOHMANN_JSON_GET_MACRO(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, \
2313 _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, _31, _32, _33, _34, _35, _36, \
2314 _37, _38, _39, _40, _41, _42, _43, _44, _45, _46, _47, _48, _49, _50, _51, _52, _53, \
2315 _54, _55, _56, _57, _58, _59, _60, _61, _62, _63, _64, NAME, ...) \
2317#define NLOHMANN_JSON_PASTE(...) \
2318 NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_GET_MACRO( \
2319 __VA_ARGS__, NLOHMANN_JSON_PASTE64, NLOHMANN_JSON_PASTE63, NLOHMANN_JSON_PASTE62, NLOHMANN_JSON_PASTE61, \
2320 NLOHMANN_JSON_PASTE60, NLOHMANN_JSON_PASTE59, NLOHMANN_JSON_PASTE58, NLOHMANN_JSON_PASTE57, \
2321 NLOHMANN_JSON_PASTE56, NLOHMANN_JSON_PASTE55, NLOHMANN_JSON_PASTE54, NLOHMANN_JSON_PASTE53, \
2322 NLOHMANN_JSON_PASTE52, NLOHMANN_JSON_PASTE51, NLOHMANN_JSON_PASTE50, NLOHMANN_JSON_PASTE49, \
2323 NLOHMANN_JSON_PASTE48, NLOHMANN_JSON_PASTE47, NLOHMANN_JSON_PASTE46, NLOHMANN_JSON_PASTE45, \
2324 NLOHMANN_JSON_PASTE44, NLOHMANN_JSON_PASTE43, NLOHMANN_JSON_PASTE42, NLOHMANN_JSON_PASTE41, \
2325 NLOHMANN_JSON_PASTE40, NLOHMANN_JSON_PASTE39, NLOHMANN_JSON_PASTE38, NLOHMANN_JSON_PASTE37, \
2326 NLOHMANN_JSON_PASTE36, NLOHMANN_JSON_PASTE35, NLOHMANN_JSON_PASTE34, NLOHMANN_JSON_PASTE33, \
2327 NLOHMANN_JSON_PASTE32, NLOHMANN_JSON_PASTE31, NLOHMANN_JSON_PASTE30, NLOHMANN_JSON_PASTE29, \
2328 NLOHMANN_JSON_PASTE28, NLOHMANN_JSON_PASTE27, NLOHMANN_JSON_PASTE26, NLOHMANN_JSON_PASTE25, \
2329 NLOHMANN_JSON_PASTE24, NLOHMANN_JSON_PASTE23, NLOHMANN_JSON_PASTE22, NLOHMANN_JSON_PASTE21, \
2330 NLOHMANN_JSON_PASTE20, NLOHMANN_JSON_PASTE19, NLOHMANN_JSON_PASTE18, NLOHMANN_JSON_PASTE17, \
2331 NLOHMANN_JSON_PASTE16, NLOHMANN_JSON_PASTE15, NLOHMANN_JSON_PASTE14, NLOHMANN_JSON_PASTE13, \
2332 NLOHMANN_JSON_PASTE12, NLOHMANN_JSON_PASTE11, NLOHMANN_JSON_PASTE10, NLOHMANN_JSON_PASTE9, \
2333 NLOHMANN_JSON_PASTE8, NLOHMANN_JSON_PASTE7, NLOHMANN_JSON_PASTE6, NLOHMANN_JSON_PASTE5, NLOHMANN_JSON_PASTE4, \
2334 NLOHMANN_JSON_PASTE3, NLOHMANN_JSON_PASTE2, NLOHMANN_JSON_PASTE1)(__VA_ARGS__))
2335#define NLOHMANN_JSON_PASTE2(func, v1) func(v1)
2336#define NLOHMANN_JSON_PASTE3(func, v1, v2) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE2(func, v2)
2337#define NLOHMANN_JSON_PASTE4(func, v1, v2, v3) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE3(func, v2, v3)
2338#define NLOHMANN_JSON_PASTE5(func, v1, v2, v3, v4) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE4(func, v2, v3, v4)
2339#define NLOHMANN_JSON_PASTE6(func, v1, v2, v3, v4, v5) \
2340 NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE5(func, v2, v3, v4, v5)
2341#define NLOHMANN_JSON_PASTE7(func, v1, v2, v3, v4, v5, v6) \
2342 NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE6(func, v2, v3, v4, v5, v6)
2343#define NLOHMANN_JSON_PASTE8(func, v1, v2, v3, v4, v5, v6, v7) \
2344 NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE7(func, v2, v3, v4, v5, v6, v7)
2345#define NLOHMANN_JSON_PASTE9(func, v1, v2, v3, v4, v5, v6, v7, v8) \
2346 NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE8(func, v2, v3, v4, v5, v6, v7, v8)
2347#define NLOHMANN_JSON_PASTE10(func, v1, v2, v3, v4, v5, v6, v7, v8, v9) \
2348 NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE9(func, v2, v3, v4, v5, v6, v7, v8, v9)
2349#define NLOHMANN_JSON_PASTE11(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10) \
2350 NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE10(func, v2, v3, v4, v5, v6, v7, v8, v9, v10)
2351#define NLOHMANN_JSON_PASTE12(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11) \
2352 NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE11(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11)
2353#define NLOHMANN_JSON_PASTE13(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12) \
2354 NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE12(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12)
2355#define NLOHMANN_JSON_PASTE14(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13) \
2356 NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE13(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13)
2357#define NLOHMANN_JSON_PASTE15(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14) \
2358 NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE14(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14)
2359#define NLOHMANN_JSON_PASTE16(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15) \
2360 NLOHMANN_JSON_PASTE2(func, v1) \
2361 NLOHMANN_JSON_PASTE15(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15)
2362#define NLOHMANN_JSON_PASTE17(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16) \
2363 NLOHMANN_JSON_PASTE2(func, v1) \
2364 NLOHMANN_JSON_PASTE16(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16)
2365#define NLOHMANN_JSON_PASTE18(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17) \
2366 NLOHMANN_JSON_PASTE2(func, v1) \
2367 NLOHMANN_JSON_PASTE17(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17)
2368#define NLOHMANN_JSON_PASTE19(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18) \
2369 NLOHMANN_JSON_PASTE2(func, v1) \
2370 NLOHMANN_JSON_PASTE18(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18)
2371#define NLOHMANN_JSON_PASTE20(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, \
2373 NLOHMANN_JSON_PASTE2(func, v1) \
2374 NLOHMANN_JSON_PASTE19(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19)
2375#define NLOHMANN_JSON_PASTE21(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, \
2377 NLOHMANN_JSON_PASTE2(func, v1) \
2378 NLOHMANN_JSON_PASTE20(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20)
2379#define NLOHMANN_JSON_PASTE22(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, \
2381 NLOHMANN_JSON_PASTE2(func, v1) \
2382 NLOHMANN_JSON_PASTE21(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, \
2384#define NLOHMANN_JSON_PASTE23(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, \
2385 v19, v20, v21, v22) \
2386 NLOHMANN_JSON_PASTE2(func, v1) \
2387 NLOHMANN_JSON_PASTE22(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, \
2389#define NLOHMANN_JSON_PASTE24(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, \
2390 v19, v20, v21, v22, v23) \
2391 NLOHMANN_JSON_PASTE2(func, v1) \
2392 NLOHMANN_JSON_PASTE23(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, \
2394#define NLOHMANN_JSON_PASTE25(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, \
2395 v19, v20, v21, v22, v23, v24) \
2396 NLOHMANN_JSON_PASTE2(func, v1) \
2397 NLOHMANN_JSON_PASTE24(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, \
2399#define NLOHMANN_JSON_PASTE26(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, \
2400 v19, v20, v21, v22, v23, v24, v25) \
2401 NLOHMANN_JSON_PASTE2(func, v1) \
2402 NLOHMANN_JSON_PASTE25(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, \
2403 v21, v22, v23, v24, v25)
2404#define NLOHMANN_JSON_PASTE27(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, \
2405 v19, v20, v21, v22, v23, v24, v25, v26) \
2406 NLOHMANN_JSON_PASTE2(func, v1) \
2407 NLOHMANN_JSON_PASTE26(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, \
2408 v21, v22, v23, v24, v25, v26)
2409#define NLOHMANN_JSON_PASTE28(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, \
2410 v19, v20, v21, v22, v23, v24, v25, v26, v27) \
2411 NLOHMANN_JSON_PASTE2(func, v1) \
2412 NLOHMANN_JSON_PASTE27(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, \
2413 v21, v22, v23, v24, v25, v26, v27)
2414#define NLOHMANN_JSON_PASTE29(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, \
2415 v19, v20, v21, v22, v23, v24, v25, v26, v27, v28) \
2416 NLOHMANN_JSON_PASTE2(func, v1) \
2417 NLOHMANN_JSON_PASTE28(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, \
2418 v21, v22, v23, v24, v25, v26, v27, v28)
2419#define NLOHMANN_JSON_PASTE30(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, \
2420 v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29) \
2421 NLOHMANN_JSON_PASTE2(func, v1) \
2422 NLOHMANN_JSON_PASTE29(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, \
2423 v21, v22, v23, v24, v25, v26, v27, v28, v29)
2424#define NLOHMANN_JSON_PASTE31(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, \
2425 v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30) \
2426 NLOHMANN_JSON_PASTE2(func, v1) \
2427 NLOHMANN_JSON_PASTE30(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, \
2428 v21, v22, v23, v24, v25, v26, v27, v28, v29, v30)
2429#define NLOHMANN_JSON_PASTE32(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, \
2430 v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31) \
2431 NLOHMANN_JSON_PASTE2(func, v1) \
2432 NLOHMANN_JSON_PASTE31(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, \
2433 v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31)
2434#define NLOHMANN_JSON_PASTE33(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, \
2435 v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32) \
2436 NLOHMANN_JSON_PASTE2(func, v1) \
2437 NLOHMANN_JSON_PASTE32(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, \
2438 v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32)
2439#define NLOHMANN_JSON_PASTE34(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, \
2440 v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33) \
2441 NLOHMANN_JSON_PASTE2(func, v1) \
2442 NLOHMANN_JSON_PASTE33(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, \
2443 v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33)
2444#define NLOHMANN_JSON_PASTE35(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, \
2445 v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34) \
2446 NLOHMANN_JSON_PASTE2(func, v1) \
2447 NLOHMANN_JSON_PASTE34(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, \
2448 v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34)
2449#define NLOHMANN_JSON_PASTE36(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, \
2450 v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35) \
2451 NLOHMANN_JSON_PASTE2(func, v1) \
2452 NLOHMANN_JSON_PASTE35(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, \
2453 v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35)
2454#define NLOHMANN_JSON_PASTE37(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, \
2455 v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, \
2457 NLOHMANN_JSON_PASTE2(func, v1) \
2458 NLOHMANN_JSON_PASTE36(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, \
2459 v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36)
2460#define NLOHMANN_JSON_PASTE38(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, \
2461 v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, \
2463 NLOHMANN_JSON_PASTE2(func, v1) \
2464 NLOHMANN_JSON_PASTE37(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, \
2465 v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37)
2466#define NLOHMANN_JSON_PASTE39(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, \
2467 v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, \
2469 NLOHMANN_JSON_PASTE2(func, v1) \
2470 NLOHMANN_JSON_PASTE38(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, \
2471 v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38)
2472#define NLOHMANN_JSON_PASTE40(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, \
2473 v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, \
2474 v36, v37, v38, v39) \
2475 NLOHMANN_JSON_PASTE2(func, v1) \
2476 NLOHMANN_JSON_PASTE39(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, \
2477 v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, \
2479#define NLOHMANN_JSON_PASTE41(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, \
2480 v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, \
2481 v36, v37, v38, v39, v40) \
2482 NLOHMANN_JSON_PASTE2(func, v1) \
2483 NLOHMANN_JSON_PASTE40(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, \
2484 v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, \
2486#define NLOHMANN_JSON_PASTE42(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, \
2487 v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, \
2488 v36, v37, v38, v39, v40, v41) \
2489 NLOHMANN_JSON_PASTE2(func, v1) \
2490 NLOHMANN_JSON_PASTE41(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, \
2491 v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, \
2493#define NLOHMANN_JSON_PASTE43(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, \
2494 v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, \
2495 v36, v37, v38, v39, v40, v41, v42) \
2496 NLOHMANN_JSON_PASTE2(func, v1) \
2497 NLOHMANN_JSON_PASTE42(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, \
2498 v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, \
2500#define NLOHMANN_JSON_PASTE44(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, \
2501 v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, \
2502 v36, v37, v38, v39, v40, v41, v42, v43) \
2503 NLOHMANN_JSON_PASTE2(func, v1) \
2504 NLOHMANN_JSON_PASTE43(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, \
2505 v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, \
2506 v39, v40, v41, v42, v43)
2507#define NLOHMANN_JSON_PASTE45(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, \
2508 v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, \
2509 v36, v37, v38, v39, v40, v41, v42, v43, v44) \
2510 NLOHMANN_JSON_PASTE2(func, v1) \
2511 NLOHMANN_JSON_PASTE44(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, \
2512 v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, \
2513 v39, v40, v41, v42, v43, v44)
2514#define NLOHMANN_JSON_PASTE46(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, \
2515 v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, \
2516 v36, v37, v38, v39, v40, v41, v42, v43, v44, v45) \
2517 NLOHMANN_JSON_PASTE2(func, v1) \
2518 NLOHMANN_JSON_PASTE45(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, \
2519 v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, \
2520 v39, v40, v41, v42, v43, v44, v45)
2521#define NLOHMANN_JSON_PASTE47(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, \
2522 v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, \
2523 v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46) \
2524 NLOHMANN_JSON_PASTE2(func, v1) \
2525 NLOHMANN_JSON_PASTE46(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, \
2526 v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, \
2527 v39, v40, v41, v42, v43, v44, v45, v46)
2528#define NLOHMANN_JSON_PASTE48(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, \
2529 v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, \
2530 v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47) \
2531 NLOHMANN_JSON_PASTE2(func, v1) \
2532 NLOHMANN_JSON_PASTE47(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, \
2533 v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, \
2534 v39, v40, v41, v42, v43, v44, v45, v46, v47)
2535#define NLOHMANN_JSON_PASTE49(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, \
2536 v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, \
2537 v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48) \
2538 NLOHMANN_JSON_PASTE2(func, v1) \
2539 NLOHMANN_JSON_PASTE48(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, \
2540 v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, \
2541 v39, v40, v41, v42, v43, v44, v45, v46, v47, v48)
2542#define NLOHMANN_JSON_PASTE50(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, \
2543 v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, \
2544 v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49) \
2545 NLOHMANN_JSON_PASTE2(func, v1) \
2546 NLOHMANN_JSON_PASTE49(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, \
2547 v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, \
2548 v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49)
2549#define NLOHMANN_JSON_PASTE51(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, \
2550 v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, \
2551 v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50) \
2552 NLOHMANN_JSON_PASTE2(func, v1) \
2553 NLOHMANN_JSON_PASTE50(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, \
2554 v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, \
2555 v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50)
2556#define NLOHMANN_JSON_PASTE52(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, \
2557 v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, \
2558 v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51) \
2559 NLOHMANN_JSON_PASTE2(func, v1) \
2560 NLOHMANN_JSON_PASTE51(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, \
2561 v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, \
2562 v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51)
2563#define NLOHMANN_JSON_PASTE53(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, \
2564 v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, \
2565 v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52) \
2566 NLOHMANN_JSON_PASTE2(func, v1) \
2567 NLOHMANN_JSON_PASTE52(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, \
2568 v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, \
2569 v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52)
2570#define NLOHMANN_JSON_PASTE54(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, \
2571 v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, \
2572 v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, \
2574 NLOHMANN_JSON_PASTE2(func, v1) \
2575 NLOHMANN_JSON_PASTE53(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, \
2576 v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, \
2577 v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53)
2578#define NLOHMANN_JSON_PASTE55(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, \
2579 v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, \
2580 v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, \
2582 NLOHMANN_JSON_PASTE2(func, v1) \
2583 NLOHMANN_JSON_PASTE54(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, \
2584 v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, \
2585 v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54)
2586#define NLOHMANN_JSON_PASTE56(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, \
2587 v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, \
2588 v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, \
2590 NLOHMANN_JSON_PASTE2(func, v1) \
2591 NLOHMANN_JSON_PASTE55(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, \
2592 v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, \
2593 v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55)
2594#define NLOHMANN_JSON_PASTE57(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, \
2595 v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, \
2596 v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, \
2597 v53, v54, v55, v56) \
2598 NLOHMANN_JSON_PASTE2(func, v1) \
2599 NLOHMANN_JSON_PASTE56(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, \
2600 v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, \
2601 v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56)
2602#define NLOHMANN_JSON_PASTE58(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, \
2603 v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, \
2604 v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, \
2605 v53, v54, v55, v56, v57) \
2606 NLOHMANN_JSON_PASTE2(func, v1) \
2607 NLOHMANN_JSON_PASTE57(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, \
2608 v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, \
2609 v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, \
2611#define NLOHMANN_JSON_PASTE59(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, \
2612 v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, \
2613 v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, \
2614 v53, v54, v55, v56, v57, v58) \
2615 NLOHMANN_JSON_PASTE2(func, v1) \
2616 NLOHMANN_JSON_PASTE58(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, \
2617 v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, \
2618 v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, \
2620#define NLOHMANN_JSON_PASTE60(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, \
2621 v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, \
2622 v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, \
2623 v53, v54, v55, v56, v57, v58, v59) \
2624 NLOHMANN_JSON_PASTE2(func, v1) \
2625 NLOHMANN_JSON_PASTE59(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, \
2626 v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, \
2627 v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, \
2629#define NLOHMANN_JSON_PASTE61(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, \
2630 v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, \
2631 v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, \
2632 v53, v54, v55, v56, v57, v58, v59, v60) \
2633 NLOHMANN_JSON_PASTE2(func, v1) \
2634 NLOHMANN_JSON_PASTE60(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, \
2635 v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, \
2636 v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, \
2638#define NLOHMANN_JSON_PASTE62(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, \
2639 v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, \
2640 v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, \
2641 v53, v54, v55, v56, v57, v58, v59, v60, v61) \
2642 NLOHMANN_JSON_PASTE2(func, v1) \
2643 NLOHMANN_JSON_PASTE61(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, \
2644 v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, \
2645 v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, \
2646 v57, v58, v59, v60, v61)
2647#define NLOHMANN_JSON_PASTE63(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, \
2648 v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, \
2649 v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, \
2650 v53, v54, v55, v56, v57, v58, v59, v60, v61, v62) \
2651 NLOHMANN_JSON_PASTE2(func, v1) \
2652 NLOHMANN_JSON_PASTE62(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, \
2653 v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, \
2654 v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, \
2655 v57, v58, v59, v60, v61, v62)
2656#define NLOHMANN_JSON_PASTE64(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, \
2657 v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, \
2658 v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, \
2659 v53, v54, v55, v56, v57, v58, v59, v60, v61, v62, v63) \
2660 NLOHMANN_JSON_PASTE2(func, v1) \
2661 NLOHMANN_JSON_PASTE63(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, \
2662 v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, \
2663 v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, \
2664 v57, v58, v59, v60, v61, v62, v63)
2666#define NLOHMANN_JSON_TO(v1) nlohmann_json_j[#v1] = nlohmann_json_t.v1;
2667#define NLOHMANN_JSON_FROM(v1) nlohmann_json_j.at(#v1).get_to(nlohmann_json_t.v1);
2674#define NLOHMANN_DEFINE_TYPE_INTRUSIVE(Type, ...) \
2675 friend void to_json(nlohmann::json& nlohmann_json_j, const Type& nlohmann_json_t) \
2677 NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) \
2679 friend void from_json(const nlohmann::json& nlohmann_json_j, Type& nlohmann_json_t) \
2681 NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM, __VA_ARGS__)) \
2689#define NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(Type, ...) \
2690 inline void to_json(nlohmann::json& nlohmann_json_j, const Type& nlohmann_json_t) \
2692 NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) \
2694 inline void from_json(const nlohmann::json& nlohmann_json_j, Type& nlohmann_json_t) \
2696 NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM, __VA_ARGS__)) \
2705#define NLOHMANN_CAN_CALL_STD_FUNC_IMPL(std_name) \
2708 using std::std_name; \
2710 template<typename... T> \
2711 using result_of_##std_name = decltype(std_name(std::declval<T>()...)); \
2716 struct std_name##_tag \
2719 template<typename... T> \
2720 std_name##_tag std_name(T&&...); \
2722 template<typename... T> \
2723 using result_of_##std_name = decltype(std_name(std::declval<T>()...)); \
2725 template<typename... T> \
2726 struct would_call_std_##std_name \
2728 static constexpr auto const value = \
2729 ::nlohmann::detail::is_detected_exact<std_name##_tag, result_of_##std_name, T...>::value; \
2733 template<typename... T> \
2734 struct would_call_std_##std_name : detail2::would_call_std_##std_name<T...> \
2737#ifndef JSON_USE_IMPLICIT_CONVERSIONS
2738#define JSON_USE_IMPLICIT_CONVERSIONS 1
2741#if JSON_USE_IMPLICIT_CONVERSIONS
2742#define JSON_EXPLICIT
2744#define JSON_EXPLICIT explicit
2747#ifndef JSON_DIAGNOSTICS
2748#define JSON_DIAGNOSTICS 0
2772 for (
auto pos = s.find(f);
2773 pos != std::string::npos;
2774 s.replace(pos, f.size(), t),
2775 pos = s.find(f, pos + t.size()))
2850 const char*
what() const noexcept
override {
return m.what(); }
2862 static std::string
name(
const std::string& ename,
int id_)
2864 return "[json.exception." + ename +
"." + std::to_string(id_) +
"] ";
2867 template<
typename BasicJsonType>
2871 std::vector<std::string> tokens;
2872 for (
const auto* current = &leaf_element; current->m_parent !=
nullptr; current = current->m_parent) {
2873 switch (current->m_parent->type()) {
2875 for (std::size_t
i = 0;
i < current->m_parent->m_value.array->size(); ++
i) {
2876 if (¤t->m_parent->m_value.array->operator[](
i) == current) {
2877 tokens.emplace_back(std::to_string(
i));
2885 for (
const auto& element : *current->m_parent->m_value.object) {
2886 if (&element.second == current) {
2887 tokens.emplace_back(element.first.c_str());
2907 if (tokens.empty()) {
2912 + std::accumulate(tokens.rbegin(), tokens.rend(), std::string{},
2913 [](
const std::string&
a,
const std::string&
b) { return a +
"/" + detail::escape(b); })
2916 static_cast<void>(leaf_element);
2923 std::runtime_error
m;
2940 template<
typename BasicJsonType>
2948 template<
typename BasicJsonType>
2952 + (byte_ != 0 ? (
" at byte " + std::to_string(byte_)) :
"") +
": "
2954 return {id_, byte_, w.c_str()};
2976 return " at line " + std::to_string(pos.
lines_read + 1) +
", column "
2986 template<
typename BasicJsonType>
2990 return {id_, w.c_str()};
3005 template<
typename BasicJsonType>
3009 return {id_, w.c_str()};
3024 template<
typename BasicJsonType>
3028 return {id_, w.c_str()};
3043 template<
typename BasicJsonType>
3047 return {id_, w.c_str()};
3065#include <type_traits>
3076using uncvref_t =
typename std::remove_cv<typename std::remove_reference<T>::type>::type;
3078#ifdef JSON_HAS_CPP_14
3081using std::enable_if_t;
3082using std::index_sequence;
3083using std::index_sequence_for;
3084using std::make_index_sequence;
3089template<
bool B,
typename T =
void>
3117template<
typename T, T... Ints>
3121 static constexpr std::size_t
size() noexcept {
return sizeof...(Ints); }
3129template<
size_t... Ints>
3135template<
typename Seq,
size_t SeqSize,
size_t Rem>
3139template<
typename T, T... Ints,
size_t SeqSize>
3145template<
typename T, T... Ints,
size_t SeqSize>
3153template<
typename T,
size_t N>
3174template<
typename T, T N>
3190template<
typename... Ts>
3235#include <type_traits>
3252template<
typename It,
typename =
void>
3256template<
typename It>
3259 typename It::value_type,
3260 typename It::pointer,
3261 typename It::reference,
3262 typename It::iterator_category>>
3273template<
typename T,
typename =
void>
3316#ifndef INCLUDE_NLOHMANN_JSON_FWD_HPP_
3317#define INCLUDE_NLOHMANN_JSON_FWD_HPP_
3339template<
typename T =
void,
typename SFINAE =
void>
3340struct adl_serializer;
3344template<
template<
typename U,
typename V,
typename... Args>
class ObjectType = std::map,
3345 template<
typename U,
typename... Args>
class ArrayType = std::vector,
3347 class BooleanType = bool,
3348 class NumberIntegerType = std::int64_t,
3349 class NumberUnsignedType = std::uint64_t,
3350 class NumberFloatType = double,
3351 template<
typename U>
class AllocatorType = std::allocator,
3352 template<
typename T,
typename SFINAE =
void>
class JSONSerializer = adl_serializer,
3353 class BinaryType = std::vector<std::uint8_t>>
3358template<
typename BasicJsonType>
3369template<
class Key,
class T,
class IgnoredLess,
class Allocator>
3453template<
typename T,
typename... Args>
3456template<
typename T,
typename... Args>
3459template<
typename T,
typename U>
3463template<
typename BasicJsonType,
typename T,
typename =
void>
3471template<
typename BasicJsonType,
typename T>
3477template<
typename BasicJsonType,
typename T>
3480 using serializer =
typename BasicJsonType::template json_serializer<T, void>;
3488template<
typename BasicJsonType,
typename T,
typename =
void>
3492template<
typename BasicJsonType,
typename T>
3495 using serializer =
typename BasicJsonType::template json_serializer<T, void>;
3502template<
typename BasicJsonType,
typename T,
typename =
void>
3506template<
typename BasicJsonType,
typename T>
3509 using serializer =
typename BasicJsonType::template json_serializer<T, void>;
3525template<
class B1,
class... Bn>
3526struct conjunction<
B1, Bn...> : std::conditional<bool(B1::value), conjunction<Bn...>, B1>::type
3531struct negation : std::integral_constant<bool, !B::value>
3541template<
typename T1,
typename T2>
3543 :
conjunction<is_default_constructible<T1>, is_default_constructible<T2>>
3546template<
typename T1,
typename T2>
3548 :
conjunction<is_default_constructible<T1>, is_default_constructible<T2>>
3551template<
typename... Ts>
3555template<
typename... Ts>
3559template<
typename T,
typename... Args>
3563template<
typename T1,
typename T2>
3567template<
typename T1,
typename T2>
3571template<
typename... Ts>
3575template<
typename... Ts>
3579template<
typename T,
typename =
void>
3600 using t_ref =
typename std::add_lvalue_reference<T>::type;
3612 !std::is_same<iterator, nonesuch>::value && !std::is_same<sentinel, nonesuch>::value &&
is_iterator_begin;
3625template<
typename T,
typename =
void>
3633template<
typename BasicJsonType,
typename CompatibleObjectType,
typename =
void>
3637template<
typename BasicJsonType,
typename CompatibleObjectType>
3639 CompatibleObjectType,
3651template<
typename BasicJsonType,
typename CompatibleObjectType>
3655template<
typename BasicJsonType,
typename ConstructibleObjectType,
typename =
void>
3659template<
typename BasicJsonType,
typename ConstructibleObjectType>
3661 ConstructibleObjectType,
3669 && (std::is_move_assignable<ConstructibleObjectType>::value
3670 || std::is_copy_assignable<ConstructibleObjectType>::value)
3672 && std::is_same<typename object_t::mapped_type, typename ConstructibleObjectType::mapped_type>::value))
3677template<
typename BasicJsonType,
typename ConstructibleObjectType>
3681template<
typename BasicJsonType,
typename CompatibleStringType>
3687template<
typename BasicJsonType,
typename ConstructibleStringType>
3693template<
typename BasicJsonType,
typename CompatibleArrayType,
typename =
void>
3697template<
typename BasicJsonType,
typename CompatibleArrayType>
3700 CompatibleArrayType,
3705 !std::is_same<CompatibleArrayType, detected_t<range_value_t, CompatibleArrayType>>
::value>>
3710template<
typename BasicJsonType,
typename CompatibleArrayType>
3714template<
typename BasicJsonType,
typename ConstructibleArrayType,
typename =
void>
3718template<
typename BasicJsonType,
typename ConstructibleArrayType>
3721 ConstructibleArrayType,
3722 enable_if_t<
std::is_same<ConstructibleArrayType, typename BasicJsonType::value_type>
::value>> : std::true_type
3725template<
typename BasicJsonType,
typename ConstructibleArrayType>
3728 ConstructibleArrayType,
3732 && (std::is_move_assignable<ConstructibleArrayType>::value
3733 || std::is_copy_assignable<ConstructibleArrayType>::value)
3739 !std::is_same<ConstructibleArrayType, detected_t<range_value_t, ConstructibleArrayType>>
::value
3744 static constexpr bool value = std::is_same<value_type, typename BasicJsonType::array_t::value_type>::value
3749template<
typename BasicJsonType,
typename ConstructibleArrayType>
3753template<
typename RealIntegerType,
typename CompatibleNumberIntegerType,
typename =
void>
3757template<
typename RealIntegerType,
typename CompatibleNumberIntegerType>
3760 CompatibleNumberIntegerType,
3762 && !std::is_same<bool, CompatibleNumberIntegerType>
::value>>
3765 using RealLimits = std::numeric_limits<RealIntegerType>;
3766 using CompatibleLimits = std::numeric_limits<CompatibleNumberIntegerType>;
3769 && CompatibleLimits::is_integer
3770 && RealLimits::is_signed == CompatibleLimits::is_signed;
3773template<
typename RealIntegerType,
typename CompatibleNumberIntegerType>
3777template<
typename BasicJsonType,
typename CompatibleType,
typename =
void>
3781template<
typename BasicJsonType,
typename CompatibleType>
3787template<
typename BasicJsonType,
typename CompatibleType>
3791template<
typename T1,
typename T2>
3795template<
typename T1,
typename... Args>
3811 template<
typename C>
3813 template<
typename C>
3823template<typename T, typename U, enable_if_t<!std::is_same<T, U>::value,
int> = 0>
3826 return static_cast<T
>(
value);
3829template<typename T, typename U, enable_if_t<std::is_same<T, U>::value,
int> = 0>
3840#if JSON_HAS_EXPERIMENTAL_FILESYSTEM
3841#include <experimental/filesystem>
3844namespace std_fs = std::experimental::filesystem;
3846#elif JSON_HAS_FILESYSTEM
3847#include <filesystem>
3850namespace std_fs = std::filesystem;
3858template<
typename BasicJsonType>
3869 typename ArithmeticType,
3870 enable_if_t<std::is_arithmetic<ArithmeticType>::value
3871 && !std::is_same<ArithmeticType, typename BasicJsonType::boolean_t>::value,
3875 switch (
static_cast<value_t>(j)) {
3877 val =
static_cast<ArithmeticType
>(*j.template get_ptr<const typename BasicJsonType::number_unsigned_t*>());
3881 val =
static_cast<ArithmeticType
>(*j.template get_ptr<const typename BasicJsonType::number_integer_t*>());
3885 val =
static_cast<ArithmeticType
>(*j.template get_ptr<const typename BasicJsonType::number_float_t*>());
3901template<
typename BasicJsonType>
3907 b = *j.template get_ptr<const typename BasicJsonType::boolean_t*>();
3910template<
typename BasicJsonType>
3916 s = *j.template get_ptr<const typename BasicJsonType::string_t*>();
3920 typename ConstructibleStringType,
3921 enable_if_t<is_constructible_string_type<BasicJsonType, ConstructibleStringType>::value
3922 && !std::is_same<typename BasicJsonType::string_t, ConstructibleStringType>::value,
3930 s = *j.template get_ptr<const typename BasicJsonType::string_t*>();
3933template<
typename BasicJsonType>
3939template<
typename BasicJsonType>
3945template<
typename BasicJsonType>
3951template<typename BasicJsonType, typename EnumType, enable_if_t<std::is_enum<EnumType>::value,
int> = 0>
3954 typename std::underlying_type<EnumType>::type val;
3956 e =
static_cast<EnumType
>(val);
3963 enable_if_t<is_getable<BasicJsonType, T>::value,
int> = 0>
3970 std::transform(j.rbegin(), j.rend(), std::front_inserter(l),
3975template<typename BasicJsonType, typename T, enable_if_t<is_getable<BasicJsonType, T>::value,
int> = 0>
3982 std::transform(j.begin(), j.end(), std::begin(l), [](
const BasicJsonType& elem) { return elem.template get<T>(); });
3985template<
typename BasicJsonType,
typename T, std::
size_t N>
3988 ->
decltype(j.template
get<T>(), void())
3990 for (std::size_t
i = 0;
i < N; ++
i) {
3991 arr[
i] = j.at(
i).template
get<T>();
3995template<
typename BasicJsonType>
3998 arr = *j.template get_ptr<const typename BasicJsonType::array_t*>();
4001template<
typename BasicJsonType,
typename T, std::
size_t N>
4003 ->
decltype(j.template
get<T>(), void())
4005 for (std::size_t
i = 0;
i < N; ++
i) {
4006 arr[
i] = j.at(
i).template
get<T>();
4011 typename ConstructibleArrayType,
4012 enable_if_t<std::is_assignable<ConstructibleArrayType&, ConstructibleArrayType>::value,
int> = 0>
4014 ->
decltype(arr.reserve(std::declval<typename ConstructibleArrayType::size_type>()),
4020 ConstructibleArrayType ret;
4021 ret.reserve(j.size());
4022 std::transform(j.begin(), j.end(), std::inserter(ret,
end(ret)), [](
const BasicJsonType&
i) {
4027 arr = std::move(ret);
4031 typename ConstructibleArrayType,
4032 enable_if_t<std::is_assignable<ConstructibleArrayType&, ConstructibleArrayType>::value,
int> = 0>
4037 ConstructibleArrayType ret;
4038 std::transform(j.begin(), j.end(), std::inserter(ret,
end(ret)), [](
const BasicJsonType&
i) {
4043 arr = std::move(ret);
4047 typename ConstructibleArrayType,
4048 enable_if_t<is_constructible_array_type<BasicJsonType, ConstructibleArrayType>::value
4049 && !is_constructible_object_type<BasicJsonType, ConstructibleArrayType>::value
4051 && !std::is_same<ConstructibleArrayType, typename BasicJsonType::binary_t>::value
4052 && !is_basic_json<ConstructibleArrayType>::value,
4071 return {{std::forward<BasicJsonType>(j).at(Idx).template
get<T>()...}};
4074template<
typename BasicJsonType,
typename T, std::
size_t N>
4085template<
typename BasicJsonType>
4092 bin = *j.template get_ptr<const typename BasicJsonType::binary_t*>();
4096 typename ConstructibleObjectType,
4097 enable_if_t<is_constructible_object_type<BasicJsonType, ConstructibleObjectType>::value,
int> = 0>
4104 ConstructibleObjectType ret;
4105 const auto* inner_object = j.template get_ptr<const typename BasicJsonType::object_t*>();
4106 using value_type =
typename ConstructibleObjectType::value_type;
4107 std::transform(inner_object->begin(), inner_object->end(), std::inserter(ret, ret.begin()),
4108 [](
typename BasicJsonType::object_t::value_type
const& p) {
4109 return value_type(p.first,
4110 p.second.template get<typename ConstructibleObjectType::mapped_type>());
4112 obj = std::move(ret);
4120 typename ArithmeticType,
4121 enable_if_t<std::is_arithmetic<ArithmeticType>::value
4122 && !std::is_same<ArithmeticType, typename BasicJsonType::number_unsigned_t>::value
4123 && !std::is_same<ArithmeticType, typename BasicJsonType::number_integer_t>::value
4124 && !std::is_same<ArithmeticType, typename BasicJsonType::number_float_t>::value
4125 && !std::is_same<ArithmeticType, typename BasicJsonType::boolean_t>::value,
4129 switch (
static_cast<value_t>(j)) {
4131 val =
static_cast<ArithmeticType
>(*j.template get_ptr<const typename BasicJsonType::number_unsigned_t*>());
4135 val =
static_cast<ArithmeticType
>(*j.template get_ptr<const typename BasicJsonType::number_integer_t*>());
4139 val =
static_cast<ArithmeticType
>(*j.template get_ptr<const typename BasicJsonType::number_float_t*>());
4143 val =
static_cast<ArithmeticType
>(*j.template get_ptr<const typename BasicJsonType::boolean_t*>());
4158template<
typename BasicJsonType,
typename... Args, std::size_t... Idx>
4161 return std::make_tuple(std::forward<BasicJsonType>(j).
at(Idx).
template get<Args>()...);
4164template<
typename BasicJsonType,
class A1,
class A2>
4169 return {std::forward<BasicJsonType>(j).at(0).template
get<A1>(),
4170 std::forward<BasicJsonType>(j).at(1).template
get<A2>()};
4173template<
typename BasicJsonType,
typename A1,
typename A2>
4195template<
typename BasicJsonType,
typename TupleRelated>
4203 return from_json_tuple_impl(std::forward<BasicJsonType>(j), std::forward<TupleRelated>(t), priority_tag<3>{});
4218 for (
const auto& p : j) {
4232 typename = enable_if_t<!std::is_constructible<typename BasicJsonType::string_t, Key>::value>>
4239 for (
const auto& p : j) {
4247#if JSON_HAS_FILESYSTEM || JSON_HAS_EXPERIMENTAL_FILESYSTEM
4248template<
typename BasicJsonType>
4254 p = *j.template get_ptr<const typename BasicJsonType::string_t*>();
4260 template<
typename BasicJsonType,
typename T>
4262 ->
decltype(
from_json(j, std::forward<T>(val)))
4264 return from_json(j, std::forward<T>(val));
4274constexpr const auto& from_json =
4285#include <type_traits>
4308template<
typename string_type>
4312 using std::to_string;
4313 target = to_string(
value);
4315template<
typename IteratorType>
4325 typename std::remove_reference<decltype(std::declval<IteratorType>().key())>::type>::type;
4367 switch (
anchor.m_object->type()) {
4396 typename IteratorType::reference
value()
const {
return anchor.value(); }
4400template<
typename IteratorType>
4425template<std::
size_t N,
typename IteratorType, enable_if_t<N == 0,
int> = 0>
4433template<std::
size_t N,
typename IteratorType, enable_if_t<N == 1,
int> = 0>
4447#if defined(__clang__)
4449#pragma clang diagnostic push
4450#pragma clang diagnostic ignored "-Wmismatched-tags"
4452template<
typename IteratorType>
4454 :
public std::integral_constant<std::size_t, 2>
4457template<std::
size_t N,
typename IteratorType>
4463#if defined(__clang__)
4464#pragma clang diagnostic pop
4474#if JSON_HAS_EXPERIMENTAL_FILESYSTEM
4475#include <experimental/filesystem>
4478namespace std_fs = std::experimental::filesystem;
4480#elif JSON_HAS_FILESYSTEM
4481#include <filesystem>
4484namespace std_fs = std::filesystem;
4509 template<
typename BasicJsonType>
4512 j.m_value.destroy(j.m_type);
4515 j.assert_invariant();
4522 template<
typename BasicJsonType>
4525 j.m_value.destroy(j.m_type);
4528 j.assert_invariant();
4531 template<
typename BasicJsonType>
4534 j.m_value.destroy(j.m_type);
4536 j.m_value = std::move(s);
4537 j.assert_invariant();
4541 typename CompatibleStringType,
4545 j.m_value.destroy(j.m_type);
4547 j.m_value.string = j.template create<typename BasicJsonType::string_t>(str);
4548 j.assert_invariant();
4555 template<
typename BasicJsonType>
4558 j.m_value.destroy(j.m_type);
4560 j.m_value =
typename BasicJsonType::binary_t(
b);
4561 j.assert_invariant();
4564 template<
typename BasicJsonType>
4567 j.m_value.destroy(j.m_type);
4569 j.m_value =
typename BasicJsonType::binary_t(std::move(
b));
4570 j.assert_invariant();
4577 template<
typename BasicJsonType>
4580 j.m_value.destroy(j.m_type);
4583 j.assert_invariant();
4590 template<
typename BasicJsonType>
4593 j.m_value.destroy(j.m_type);
4596 j.assert_invariant();
4603 template<
typename BasicJsonType>
4606 j.m_value.destroy(j.m_type);
4609 j.assert_invariant();
4616 template<
typename BasicJsonType>
4619 j.m_value.destroy(j.m_type);
4623 j.assert_invariant();
4626 template<
typename BasicJsonType>
4629 j.m_value.destroy(j.m_type);
4631 j.m_value = std::move(arr);
4633 j.assert_invariant();
4637 typename CompatibleArrayType,
4644 j.m_value.destroy(j.m_type);
4646 j.m_value.array = j.template create<typename BasicJsonType::array_t>(
begin(arr),
end(arr));
4648 j.assert_invariant();
4651 template<
typename BasicJsonType>
4654 j.m_value.destroy(j.m_type);
4657 j.m_value.array->reserve(arr.size());
4658 for (
const bool x : arr) {
4659 j.m_value.array->push_back(x);
4660 j.set_parent(j.m_value.array->back());
4662 j.assert_invariant();
4665 template<typename BasicJsonType, typename T, enable_if_t<std::is_convertible<T, BasicJsonType>::value,
int> = 0>
4668 j.m_value.destroy(j.m_type);
4671 j.m_value.array->resize(arr.size());
4672 if (arr.size() > 0) {
4673 std::copy(std::begin(arr), std::end(arr), j.m_value.array->begin());
4676 j.assert_invariant();
4683 template<
typename BasicJsonType>
4686 j.m_value.destroy(j.m_type);
4690 j.assert_invariant();
4693 template<
typename BasicJsonType>
4696 j.m_value.destroy(j.m_type);
4698 j.m_value = std::move(obj);
4700 j.assert_invariant();
4704 typename CompatibleObjectType,
4711 j.m_value.destroy(j.m_type);
4713 j.m_value.object = j.template create<typename BasicJsonType::object_t>(
begin(obj),
end(obj));
4715 j.assert_invariant();
4725 enable_if_t<std::is_same<T, typename BasicJsonType::boolean_t>::value,
int> = 0>
4732 typename CompatibleString,
4733 enable_if_t<std::is_constructible<typename BasicJsonType::string_t, CompatibleString>::value,
int> = 0>
4739template<
typename BasicJsonType>
4745template<typename BasicJsonType, typename FloatType, enable_if_t<std::is_floating_point<FloatType>::value,
int> = 0>
4752 typename CompatibleNumberUnsignedType,
4754 is_compatible_integer_type<typename BasicJsonType::number_unsigned_t, CompatibleNumberUnsignedType>::value,
4759 j,
static_cast<typename BasicJsonType::number_unsigned_t
>(val));
4763 typename CompatibleNumberIntegerType,
4765 is_compatible_integer_type<typename BasicJsonType::number_integer_t, CompatibleNumberIntegerType>::value,
4770 j,
static_cast<typename BasicJsonType::number_integer_t
>(val));
4773template<typename BasicJsonType, typename EnumType, enable_if_t<std::is_enum<EnumType>::value,
int> = 0>
4776 using underlying_type =
typename std::underlying_type<EnumType>::type;
4780template<
typename BasicJsonType>
4787 typename CompatibleArrayType,
4788 enable_if_t<is_compatible_array_type<BasicJsonType, CompatibleArrayType>::value
4789 && !is_compatible_object_type<BasicJsonType, CompatibleArrayType>::value
4791 && !std::is_same<typename BasicJsonType::binary_t, CompatibleArrayType>::value
4792 && !is_basic_json<CompatibleArrayType>::value,
4799template<
typename BasicJsonType>
4805template<typename BasicJsonType, typename T, enable_if_t<std::is_convertible<T, BasicJsonType>::value,
int> = 0>
4811template<
typename BasicJsonType>
4818 typename CompatibleObjectType,
4819 enable_if_t<is_compatible_object_type<BasicJsonType, CompatibleObjectType>::value
4820 && !is_basic_json<CompatibleObjectType>::value,
4827template<
typename BasicJsonType>
4837 enable_if_t<!std::is_constructible<
typename BasicJsonType::string_t,
4851 enable_if_t<std::is_constructible<BasicJsonType, T1>::value && std::is_constructible<BasicJsonType, T2>::value,
4855 j = {p.first, p.second};
4864 j = {{
b.key(),
b.value()}};
4867template<
typename BasicJsonType,
typename Tuple, std::size_t... Idx>
4870 j = {std::get<Idx>(t)...};
4873template<typename BasicJsonType, typename T, enable_if_t<is_constructible_tuple<BasicJsonType, T>::value,
int> = 0>
4879#if JSON_HAS_FILESYSTEM || JSON_HAS_EXPERIMENTAL_FILESYSTEM
4880template<
typename BasicJsonType>
4889 template<
typename BasicJsonType,
typename T>
4891 ->
decltype(
to_json(j, std::forward<T>(val)),
void())
4893 return to_json(j, std::forward<T>(val));
4903constexpr const auto& to_json =
4916template<
typename ValueType,
typename>
4921 template<
typename BasicJsonType,
typename TargetType = ValueType>
4923 TargetType& val)
noexcept(
noexcept(::nlohmann::from_json(std::forward<BasicJsonType>(j),
4925 ->
decltype(::nlohmann::from_json(std::forward<BasicJsonType>(j), val),
void())
4927 ::nlohmann::from_json(std::forward<BasicJsonType>(j), val);
4932 template<
typename BasicJsonType,
typename TargetType = ValueType>
4937 return ::nlohmann::from_json(std::forward<BasicJsonType>(j), detail::identity_tag<TargetType>{});
4942 template<
typename BasicJsonType,
typename TargetType = ValueType>
4944 TargetType&& val)
noexcept(
noexcept(::nlohmann::to_json(j, std::forward<TargetType>(val))))
4945 ->
decltype(::nlohmann::to_json(j, std::forward<TargetType>(val)),
void())
4947 ::nlohmann::to_json(j, std::forward<TargetType>(val));
4963template<
typename BinaryType>
5052#include <functional>
5064inline std::size_t
combine(std::size_t seed, std::size_t h)
noexcept
5066 seed ^= h + 0x9e3779b9 + (seed << 6U) + (seed >> 2U);
5081template<
typename BasicJsonType>
5084 using string_t =
typename BasicJsonType::string_t;
5085 using number_integer_t =
typename BasicJsonType::number_integer_t;
5086 using number_unsigned_t =
typename BasicJsonType::number_unsigned_t;
5087 using number_float_t =
typename BasicJsonType::number_float_t;
5089 const auto type =
static_cast<std::size_t
>(j.type());
5091 case BasicJsonType::value_t::null:
5092 case BasicJsonType::value_t::discarded: {
5096 case BasicJsonType::value_t::object: {
5097 auto seed =
combine(type, j.size());
5098 for (
const auto& element : j.items()) {
5099 const auto h = std::hash<string_t>{}(element.key());
5106 case BasicJsonType::value_t::array: {
5107 auto seed =
combine(type, j.size());
5108 for (
const auto& element : j) {
5114 case BasicJsonType::value_t::string: {
5115 const auto h = std::hash<string_t>{}(j.template get_ref<const string_t&>());
5119 case BasicJsonType::value_t::boolean: {
5120 const auto h = std::hash<bool>{}(j.template
get<bool>());
5124 case BasicJsonType::value_t::number_integer: {
5129 case BasicJsonType::value_t::number_unsigned: {
5134 case BasicJsonType::value_t::number_float: {
5139 case BasicJsonType::value_t::binary: {
5140 auto seed =
combine(type, j.get_binary().size());
5141 const auto h = std::hash<bool>{}(j.get_binary().has_subtype());
5143 seed =
combine(seed,
static_cast<std::size_t
>(j.get_binary().subtype()));
5144 for (
const auto byte : j.get_binary()) {
5145 seed =
combine(seed, std::hash<std::uint8_t>{}(byte));
5185#include <type_traits>
5262 if (
is !=
nullptr) {
5263 is->clear(
is->rdstate() & std::ios::eofbit);
5290 auto res =
sb->sbumpc();
5293 is->clear(
is->rdstate() | std::ios::eofbit);
5300 std::istream*
is =
nullptr;
5301 std::streambuf*
sb =
nullptr;
5307template<
typename IteratorType>
5311 using char_type =
typename std::iterator_traits<IteratorType>::value_type;
5321 auto result = std::char_traits<char_type>::to_int_type(*
current);
5326 return std::char_traits<char_type>::eof();
5333 template<
typename BaseInputAdapter,
size_t T>
5339template<
typename BaseInputAdapter,
size_t T>
5342template<
typename BaseInputAdapter>
5347 std::array<std::char_traits<char>::int_type, 4>& utf8_bytes,
5348 size_t& utf8_bytes_index,
5349 size_t& utf8_bytes_filled)
5351 utf8_bytes_index = 0;
5354 utf8_bytes[0] = std::char_traits<char>::eof();
5355 utf8_bytes_filled = 1;
5358 const auto wc = input.get_character();
5362 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(wc);
5363 utf8_bytes_filled = 1;
5364 }
else if (wc <= 0x7FF) {
5365 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(
5366 0xC0u | ((
static_cast<unsigned int>(wc) >> 6u) & 0x1Fu));
5368 static_cast<std::char_traits<char>::int_type
>(0x80u | (
static_cast<unsigned int>(wc) & 0x3Fu));
5369 utf8_bytes_filled = 2;
5370 }
else if (wc <= 0xFFFF) {
5371 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(
5372 0xE0u | ((
static_cast<unsigned int>(wc) >> 12u) & 0x0Fu));
5373 utf8_bytes[1] =
static_cast<std::char_traits<char>::int_type
>(
5374 0x80u | ((
static_cast<unsigned int>(wc) >> 6u) & 0x3Fu));
5376 static_cast<std::char_traits<char>::int_type
>(0x80u | (
static_cast<unsigned int>(wc) & 0x3Fu));
5377 utf8_bytes_filled = 3;
5378 }
else if (wc <= 0x10FFFF) {
5379 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(
5380 0xF0u | ((
static_cast<unsigned int>(wc) >> 18u) & 0x07u));
5381 utf8_bytes[1] =
static_cast<std::char_traits<char>::int_type
>(
5382 0x80u | ((
static_cast<unsigned int>(wc) >> 12u) & 0x3Fu));
5383 utf8_bytes[2] =
static_cast<std::char_traits<char>::int_type
>(
5384 0x80u | ((
static_cast<unsigned int>(wc) >> 6u) & 0x3Fu));
5386 static_cast<std::char_traits<char>::int_type
>(0x80u | (
static_cast<unsigned int>(wc) & 0x3Fu));
5387 utf8_bytes_filled = 4;
5390 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(wc);
5391 utf8_bytes_filled = 1;
5397template<
typename BaseInputAdapter>
5402 std::array<std::char_traits<char>::int_type, 4>& utf8_bytes,
5403 size_t& utf8_bytes_index,
5404 size_t& utf8_bytes_filled)
5406 utf8_bytes_index = 0;
5409 utf8_bytes[0] = std::char_traits<char>::eof();
5410 utf8_bytes_filled = 1;
5413 const auto wc = input.get_character();
5417 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(wc);
5418 utf8_bytes_filled = 1;
5419 }
else if (wc <= 0x7FF) {
5421 static_cast<std::char_traits<char>::int_type
>(0xC0u | ((
static_cast<unsigned int>(wc) >> 6u)));
5423 static_cast<std::char_traits<char>::int_type
>(0x80u | (
static_cast<unsigned int>(wc) & 0x3Fu));
5424 utf8_bytes_filled = 2;
5425 }
else if (0xD800 > wc || wc >= 0xE000) {
5427 static_cast<std::char_traits<char>::int_type
>(0xE0u | ((
static_cast<unsigned int>(wc) >> 12u)));
5428 utf8_bytes[1] =
static_cast<std::char_traits<char>::int_type
>(
5429 0x80u | ((
static_cast<unsigned int>(wc) >> 6u) & 0x3Fu));
5431 static_cast<std::char_traits<char>::int_type
>(0x80u | (
static_cast<unsigned int>(wc) & 0x3Fu));
5432 utf8_bytes_filled = 3;
5435 const auto wc2 =
static_cast<unsigned int>(input.get_character());
5436 const auto charcode =
5437 0x10000u + (((
static_cast<unsigned int>(wc) & 0x3FFu) << 10u) | (wc2 & 0x3FFu));
5438 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(0xF0u | (charcode >> 18u));
5439 utf8_bytes[1] =
static_cast<std::char_traits<char>::int_type
>(0x80u | ((charcode >> 12u) & 0x3Fu));
5440 utf8_bytes[2] =
static_cast<std::char_traits<char>::int_type
>(0x80u | ((charcode >> 6u) & 0x3Fu));
5441 utf8_bytes[3] =
static_cast<std::char_traits<char>::int_type
>(0x80u | (charcode & 0x3Fu));
5442 utf8_bytes_filled = 4;
5444 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(wc);
5445 utf8_bytes_filled = 1;
5453template<
typename BaseInputAdapter,
typename W
ideCharType>
5490 std::array<std::char_traits<char>::int_type, 4>
utf8_bytes = {{0, 0, 0, 0}};
5498template<
typename IteratorType,
typename Enable =
void>
5502 using char_type =
typename std::iterator_traits<iterator_type>::value_type;
5507 return adapter_type(std::move(first), std::move(last));
5521template<
typename IteratorType>
5525 using char_type =
typename std::iterator_traits<iterator_type>::value_type;
5536template<
typename IteratorType>
5540 return factory_type::create(first, last);
5553template<
typename ContainerType,
typename Enable =
void>
5557template<
typename ContainerType>
5560 void_t<decltype(
begin(
std::declval<ContainerType>()),
end(std::declval<ContainerType>()))>>
5573template<
typename ContainerType>
5574typename container_input_adapter_factory_impl::container_input_adapter_factory<ContainerType>::adapter_type
5599 decltype(
input_adapter(std::declval<const char*>(), std::declval<const char*>()));
5602template<
typename CharT,
5603 typename std::enable_if<std::is_pointer<CharT>::value && !std::is_array<CharT>::value
5604 && std::is_integral<typename std::remove_pointer<CharT>::type>
::value
5605 &&
sizeof(
typename std::remove_pointer<CharT>::type) == 1,
5609 auto length = std::strlen(
reinterpret_cast<const char*
>(
b));
5610 const auto* ptr =
reinterpret_cast<const char*
>(
b);
5614template<
typename T, std::
size_t N>
5628 template<
typename CharT,
5629 typename std::enable_if<std::is_pointer<CharT>::value
5630 && std::is_integral<typename std::remove_pointer<CharT>::type>
::value
5631 &&
sizeof(
typename std::remove_pointer<CharT>::type) == 1,
5634 :
ia(
reinterpret_cast<const char*
>(
b),
reinterpret_cast<const char*
>(
b) + l)
5637 template<
class IteratorType,
5638 typename std::enable_if<std::is_same<typename iterator_traits<IteratorType>::iterator_category,
5639 std::random_access_iterator_tag>
::value,
5647 return std::move(
ia);
5678template<
typename BasicJsonType>
5806template<
typename BasicJsonType>
5920 template<
class Exception>
5921 bool parse_error(std::size_t ,
const std::string& ,
const Exception& ex)
5924 static_cast<void>(ex);
5940 template<
typename Value>
5951 ref_stack.back()->m_value.array->emplace_back(std::forward<Value>(
v));
5952 return &(
ref_stack.back()->m_value.array->back());
5973template<
typename BasicJsonType>
6050 auto val =
handle_value(BasicJsonType::value_t::object,
true);
6098 if (it->is_discarded()) {
6113 auto val =
handle_value(BasicJsonType::value_t::array,
true);
6147 ref_stack.back()->m_value.array->pop_back();
6153 template<
class Exception>
6154 bool parse_error(std::size_t ,
const std::string& ,
const Exception& ex)
6157 static_cast<void>(ex);
6182 template<
typename Value>
6183 std::pair<bool, BasicJsonType*>
handle_value(Value&&
v,
const bool skip_callback =
false)
6190 return {
false,
nullptr};
6201 return {
false,
nullptr};
6206 return {
true, &
root};
6212 return {
false,
nullptr};
6221 return {
true, &(
ref_stack.back()->m_value.array->back())};
6231 if (!store_element) {
6232 return {
false,
nullptr};
6260template<
typename BasicJsonType>
6284 bool start_object(std::size_t =
static_cast<std::size_t
>(-1)) {
return true; }
6290 bool start_array(std::size_t =
static_cast<std::size_t
>(-1)) {
return true; }
6310#include <initializer_list>
6329template<
typename BasicJsonType>
6362 return "<uninitialized>";
6364 return "true literal";
6366 return "false literal";
6368 return "null literal";
6370 return "string literal";
6374 return "number literal";
6388 return "<parse error>";
6390 return "end of input";
6392 return "'[', '{', or a literal";
6395 return "unknown token";
6405template<
typename BasicJsonType,
typename InputAdapterType>
6418 explicit lexer(InputAdapterType&& adapter,
bool ignore_comments_ =
false) noexcept
6419 :
ia(
std::move(adapter))
6440 const auto* loc = localeconv();
6442 return (loc->decimal_point ==
nullptr) ?
'.' : *(loc->decimal_point);
6470 const auto factors = {12u, 8u, 4u, 0u};
6471 for (
const auto factor : factors) {
6475 codepoint +=
static_cast<int>((
static_cast<unsigned int>(
current) - 0x30u) << factor);
6477 codepoint +=
static_cast<int>((
static_cast<unsigned int>(
current) - 0x37u) << factor);
6479 codepoint +=
static_cast<int>((
static_cast<unsigned int>(
current) - 0x57u) << factor);
6485 JSON_ASSERT(0x0000 <= codepoint && codepoint <= 0xFFFF);
6506 JSON_ASSERT(ranges.size() == 2 || ranges.size() == 4 || ranges.size() == 6);
6509 for (
auto range = ranges.begin(); range != ranges.end(); ++range) {
6549 case std::char_traits<char_type>::eof(): {
6551 return token_type::parse_error;
6556 return token_type::value_string;
6598 int codepoint = codepoint1;
6601 error_message =
"invalid string: '\\u' must be followed by 4 hex digits";
6602 return token_type::parse_error;
6606 if (0xD800 <= codepoint1 && codepoint1 <= 0xDBFF) {
6612 error_message =
"invalid string: '\\u' must be followed by 4 hex digits";
6613 return token_type::parse_error;
6619 codepoint =
static_cast<int>(
6621 (
static_cast<unsigned int>(codepoint1) << 10u)
6623 +
static_cast<unsigned int>(codepoint2)
6629 error_message =
"invalid string: surrogate U+D800..U+DBFF must be followed by "
6631 return token_type::parse_error;
6635 "invalid string: surrogate U+D800..U+DBFF must be followed by U+DC00..U+DFFF";
6636 return token_type::parse_error;
6641 "invalid string: surrogate U+DC00..U+DFFF must follow U+D800..U+DBFF";
6642 return token_type::parse_error;
6647 JSON_ASSERT(0x00 <= codepoint && codepoint <= 0x10FFFF);
6650 if (codepoint < 0x80) {
6653 }
else if (codepoint <= 0x7FF) {
6655 add(
static_cast<char_int_type>(0xC0u | (
static_cast<unsigned int>(codepoint) >> 6u)));
6656 add(
static_cast<char_int_type>(0x80u | (
static_cast<unsigned int>(codepoint) & 0x3Fu)));
6657 }
else if (codepoint <= 0xFFFF) {
6659 add(
static_cast<char_int_type>(0xE0u | (
static_cast<unsigned int>(codepoint) >> 12u)));
6661 0x80u | ((
static_cast<unsigned int>(codepoint) >> 6u) & 0x3Fu)));
6662 add(
static_cast<char_int_type>(0x80u | (
static_cast<unsigned int>(codepoint) & 0x3Fu)));
6665 add(
static_cast<char_int_type>(0xF0u | (
static_cast<unsigned int>(codepoint) >> 18u)));
6667 0x80u | ((
static_cast<unsigned int>(codepoint) >> 12u) & 0x3Fu)));
6669 0x80u | ((
static_cast<unsigned int>(codepoint) >> 6u) & 0x3Fu)));
6670 add(
static_cast<char_int_type>(0x80u | (
static_cast<unsigned int>(codepoint) & 0x3Fu)));
6678 error_message =
"invalid string: forbidden character after backslash";
6679 return token_type::parse_error;
6687 error_message =
"invalid string: control character U+0000 (NUL) must be escaped to \\u0000";
6688 return token_type::parse_error;
6692 error_message =
"invalid string: control character U+0001 (SOH) must be escaped to \\u0001";
6693 return token_type::parse_error;
6697 error_message =
"invalid string: control character U+0002 (STX) must be escaped to \\u0002";
6698 return token_type::parse_error;
6702 error_message =
"invalid string: control character U+0003 (ETX) must be escaped to \\u0003";
6703 return token_type::parse_error;
6707 error_message =
"invalid string: control character U+0004 (EOT) must be escaped to \\u0004";
6708 return token_type::parse_error;
6712 error_message =
"invalid string: control character U+0005 (ENQ) must be escaped to \\u0005";
6713 return token_type::parse_error;
6717 error_message =
"invalid string: control character U+0006 (ACK) must be escaped to \\u0006";
6718 return token_type::parse_error;
6722 error_message =
"invalid string: control character U+0007 (BEL) must be escaped to \\u0007";
6723 return token_type::parse_error;
6727 error_message =
"invalid string: control character U+0008 (BS) must be escaped to \\u0008 or \\b";
6728 return token_type::parse_error;
6732 error_message =
"invalid string: control character U+0009 (HT) must be escaped to \\u0009 or \\t";
6733 return token_type::parse_error;
6737 error_message =
"invalid string: control character U+000A (LF) must be escaped to \\u000A or \\n";
6738 return token_type::parse_error;
6742 error_message =
"invalid string: control character U+000B (VT) must be escaped to \\u000B";
6743 return token_type::parse_error;
6747 error_message =
"invalid string: control character U+000C (FF) must be escaped to \\u000C or \\f";
6748 return token_type::parse_error;
6752 error_message =
"invalid string: control character U+000D (CR) must be escaped to \\u000D or \\r";
6753 return token_type::parse_error;
6757 error_message =
"invalid string: control character U+000E (SO) must be escaped to \\u000E";
6758 return token_type::parse_error;
6762 error_message =
"invalid string: control character U+000F (SI) must be escaped to \\u000F";
6763 return token_type::parse_error;
6767 error_message =
"invalid string: control character U+0010 (DLE) must be escaped to \\u0010";
6768 return token_type::parse_error;
6772 error_message =
"invalid string: control character U+0011 (DC1) must be escaped to \\u0011";
6773 return token_type::parse_error;
6777 error_message =
"invalid string: control character U+0012 (DC2) must be escaped to \\u0012";
6778 return token_type::parse_error;
6782 error_message =
"invalid string: control character U+0013 (DC3) must be escaped to \\u0013";
6783 return token_type::parse_error;
6787 error_message =
"invalid string: control character U+0014 (DC4) must be escaped to \\u0014";
6788 return token_type::parse_error;
6792 error_message =
"invalid string: control character U+0015 (NAK) must be escaped to \\u0015";
6793 return token_type::parse_error;
6797 error_message =
"invalid string: control character U+0016 (SYN) must be escaped to \\u0016";
6798 return token_type::parse_error;
6802 error_message =
"invalid string: control character U+0017 (ETB) must be escaped to \\u0017";
6803 return token_type::parse_error;
6807 error_message =
"invalid string: control character U+0018 (CAN) must be escaped to \\u0018";
6808 return token_type::parse_error;
6812 error_message =
"invalid string: control character U+0019 (EM) must be escaped to \\u0019";
6813 return token_type::parse_error;
6817 error_message =
"invalid string: control character U+001A (SUB) must be escaped to \\u001A";
6818 return token_type::parse_error;
6822 error_message =
"invalid string: control character U+001B (ESC) must be escaped to \\u001B";
6823 return token_type::parse_error;
6827 error_message =
"invalid string: control character U+001C (FS) must be escaped to \\u001C";
6828 return token_type::parse_error;
6832 error_message =
"invalid string: control character U+001D (GS) must be escaped to \\u001D";
6833 return token_type::parse_error;
6837 error_message =
"invalid string: control character U+001E (RS) must be escaped to \\u001E";
6838 return token_type::parse_error;
6842 error_message =
"invalid string: control character U+001F (US) must be escaped to \\u001F";
6843 return token_type::parse_error;
6977 return token_type::parse_error;
6985 return token_type::parse_error;
7007 return token_type::parse_error;
7015 return token_type::parse_error;
7023 return token_type::parse_error;
7033 return token_type::parse_error;
7041 return token_type::parse_error;
7049 return token_type::parse_error;
7068 case std::char_traits<char_type>::eof():
7082 case std::char_traits<char_type>::eof():
7108 error_message =
"invalid comment; expecting '/' or '*' after '/'";
7115 static
void strtof(
float& f, const
char* str,
char** endptr) noexcept { f = std::strtof(str, endptr); }
7118 static
void strtof(
double& f, const
char* str,
char** endptr) noexcept { f = std::strtod(str, endptr); }
7121 static
void strtof(
long double& f, const
char* str,
char** endptr) noexcept { f = std::strtold(str, endptr); }
7170 token_type number_type = token_type::value_unsigned;
7176 goto scan_number_minus;
7181 goto scan_number_zero;
7194 goto scan_number_any1;
7204 number_type = token_type::value_integer;
7208 goto scan_number_zero;
7221 goto scan_number_any1;
7226 return token_type::parse_error;
7235 goto scan_number_decimal1;
7241 goto scan_number_exponent;
7245 goto scan_number_done;
7262 goto scan_number_any1;
7267 goto scan_number_decimal1;
7273 goto scan_number_exponent;
7277 goto scan_number_done;
7280 scan_number_decimal1:
7282 number_type = token_type::value_float;
7295 goto scan_number_decimal2;
7300 return token_type::parse_error;
7304 scan_number_decimal2:
7318 goto scan_number_decimal2;
7324 goto scan_number_exponent;
7328 goto scan_number_done;
7331 scan_number_exponent:
7333 number_type = token_type::value_float;
7338 goto scan_number_sign;
7352 goto scan_number_any2;
7356 error_message =
"invalid number; expected '+', '-', or digit after exponent";
7357 return token_type::parse_error;
7375 goto scan_number_any2;
7379 error_message =
"invalid number; expected digit after exponent sign";
7380 return token_type::parse_error;
7398 goto scan_number_any2;
7402 goto scan_number_done;
7410 char* endptr =
nullptr;
7414 if (number_type == token_type::value_unsigned) {
7415 const auto x = std::strtoull(
token_buffer.data(), &endptr, 10);
7423 return token_type::value_unsigned;
7426 }
else if (number_type == token_type::value_integer) {
7427 const auto x = std::strtoll(
token_buffer.data(), &endptr, 10);
7435 return token_type::value_integer;
7447 return token_type::value_float;
7459 for (std::size_t
i = 1;
i < length; ++
i) {
7462 return token_type::parse_error;
7493 ++
position.chars_read_current_line;
7508 position.chars_read_current_line = 0;
7529 if (
position.chars_read_current_line == 0) {
7534 --
position.chars_read_current_line;
7578 if (
static_cast<unsigned char>(c) <=
'\x1F') {
7580 std::array<char, 9> cs{{}};
7581 static_cast<void>((std::snprintf)(
7582 cs.data(), cs.size(),
"<U+%.4X>",
7583 static_cast<unsigned char>(c)));
7587 result.push_back(
static_cast<std::string::value_type
>(c));
7608 if (
get() == 0xEF) {
7610 return get() == 0xBB &&
get() == 0xBF;
7630 error_message =
"invalid BOM; must be 0xEF 0xBB 0xBF if given";
7631 return token_type::parse_error;
7640 return token_type::parse_error;
7650 return token_type::begin_array;
7652 return token_type::end_array;
7654 return token_type::begin_object;
7656 return token_type::end_object;
7658 return token_type::name_separator;
7660 return token_type::value_separator;
7664 std::array<char_type, 4> true_literal = {{
static_cast<char_type>(
't'),
static_cast<char_type>(
'r'),
7666 return scan_literal(true_literal.data(), true_literal.size(), token_type::literal_true);
7669 std::array<char_type, 5> false_literal = {{
static_cast<char_type>(
'f'),
static_cast<char_type>(
'a'),
7672 return scan_literal(false_literal.data(), false_literal.size(), token_type::literal_false);
7675 std::array<char_type, 4> null_literal = {{
static_cast<char_type>(
'n'),
static_cast<char_type>(
'u'),
7677 return scan_literal(null_literal.data(), null_literal.size(), token_type::literal_null);
7701 case std::char_traits<char_type>::eof():
7702 return token_type::end_of_input;
7707 return token_type::parse_error;
7769template<
typename T,
typename Integer>
7772template<
typename T,
typename Un
signed>
7775template<
typename T,
typename Float,
typename String>
7777 decltype(std::declval<T&>().number_float(std::declval<Float>(), std::declval<const String&>()));
7779template<
typename T,
typename String>
7782template<
typename T,
typename Binary>
7788template<
typename T,
typename String>
7800template<
typename T,
typename Exception>
7802 std::declval<const std::string&>(),
7803 std::declval<const Exception&>()));
7805template<
typename SAX,
typename BasicJsonType>
7834template<
typename SAX,
typename BasicJsonType>
7850 "Missing/invalid function: bool boolean(bool)");
7852 "Missing/invalid function: bool boolean(bool)");
7854 "Missing/invalid function: bool number_integer(number_integer_t)");
7856 "Missing/invalid function: bool number_unsigned(number_unsigned_t)");
7858 "Missing/invalid function: bool number_float(number_float_t, const string_t&)");
7860 "Missing/invalid function: bool string(string_t&)");
7862 "Missing/invalid function: bool binary(binary_t&)");
7864 "Missing/invalid function: bool start_object(std::size_t)");
7866 "Missing/invalid function: bool key(string_t&)");
7868 "Missing/invalid function: bool end_object()");
7870 "Missing/invalid function: bool start_array(std::size_t)");
7872 "Missing/invalid function: bool end_array()");
7874 "Missing/invalid function: bool parse_error(std::size_t, const "
7875 "std::string&, const exception&)");
7906 return *
reinterpret_cast<char*
>(&num) == 1;
7916template<
typename BasicJsonType,
typename InputAdapterType,
typename SAX = json_sax_dom_parser<BasicJsonType>>
7935 :
ia(std::move(adapter))
7959 const
bool strict = true,
7996 return sax->parse_error(
8019 std::int32_t document_size{};
8030 return sax->end_object();
8040 bool get_bson_cstr(string_t&
result)
8042 auto out = std::back_inserter(
result);
8051 *out++ =
static_cast<typename string_t::value_type
>(
current);
8066 template<
typename NumberType>
8071 return sax->parse_error(
8075 "string length must be at least 1, is " + std::to_string(len),
8081 &&
get() != std::char_traits<char_type>::eof();
8093 template<
typename NumberType>
8098 return sax->parse_error(
8102 "byte array length cannot be negative, is " + std::to_string(len),
8108 std::uint8_t subtype{};
8110 result.set_subtype(subtype);
8127 switch (element_type) {
8163 return sax->boolean(
get() != 0);
8173 std::int32_t
value{};
8179 std::int64_t
value{};
8185 std::array<char, 3> cr{{}};
8187 (std::snprintf)(cr.data(), cr.size(),
"%.2hhX",
8188 static_cast<unsigned char>(
8190 return sax->parse_error(element_type_parse_position, std::string(cr.data()),
8192 "Unsupported BSON record type 0x" + std::string(cr.data()),
8214 while (
auto element_type =
get()) {
8219 const std::size_t element_type_parse_position =
chars_read;
8224 if (!is_array && !
sax->key(
key)) {
8245 std::int32_t document_size{};
8256 return sax->end_array();
8275 case std::char_traits<char_type>::eof():
8307 std::uint8_t number{};
8313 std::uint16_t number{};
8319 std::uint32_t number{};
8325 std::uint64_t number{};
8354 return sax->number_integer(
static_cast<std::int8_t
>(0x20 - 1 -
current));
8358 std::uint8_t number{};
8365 std::uint16_t number{};
8372 std::uint32_t number{};
8379 std::uint64_t number{};
8492 std::uint16_t len{};
8499 std::uint32_t len{};
8506 std::uint64_t len{};
8512 return get_cbor_array(
static_cast<std::size_t
>(-1), tag_handler);
8551 std::uint16_t len{};
8558 std::uint32_t len{};
8565 std::uint64_t len{};
8593 switch (tag_handler) {
8596 return sax->parse_error(
8608 std::uint8_t subtype_to_ignore{};
8613 std::uint16_t subtype_to_ignore{};
8618 std::uint32_t subtype_to_ignore{};
8623 std::uint64_t subtype_to_ignore{};
8638 std::uint8_t subtype{};
8645 std::uint16_t subtype{};
8652 std::uint32_t subtype{};
8659 std::uint64_t subtype{};
8680 return sax->boolean(
false);
8683 return sax->boolean(
true);
8690 const auto byte1_raw =
get();
8694 const auto byte2_raw =
get();
8699 const auto byte1 =
static_cast<unsigned char>(byte1_raw);
8700 const auto byte2 =
static_cast<unsigned char>(byte2_raw);
8710 const auto half =
static_cast<unsigned int>((byte1 << 8u) + byte2);
8711 const double val = [&half] {
8712 const int exp = (half >> 10u) & 0x1Fu;
8713 const unsigned int mant = half & 0x3FFu;
8718 return std::ldexp(mant, -24);
8720 return (mant == 0) ? std::numeric_limits<double>::infinity()
8721 : std::numeric_limits<double>::quiet_NaN();
8723 return std::ldexp(mant + 1024,
exp - 25);
8726 return sax->number_float(
8750 "invalid byte: 0x" + last_token,
"value"),
8810 std::uint16_t len{};
8816 std::uint32_t len{};
8822 std::uint64_t len{};
8828 while (
get() != 0xFF) {
8840 return sax->parse_error(
8846 "expected length specification (0x60-0x7B) or indefinite string type (0x7F); last byte: 0x"
8908 std::uint16_t len{};
8914 std::uint32_t len{};
8920 std::uint64_t len{};
8926 while (
get() != 0xFF) {
8931 result.insert(
result.end(), chunk.begin(), chunk.end());
8938 return sax->parse_error(
8942 "expected length specification (0x40-0x5B) or indefinite "
8943 "binary array type (0x5F); last byte: 0x"
8963 if (len !=
static_cast<std::size_t
>(-1)) {
8964 for (std::size_t
i = 0;
i < len; ++
i) {
8970 while (
get() != 0xFF) {
8977 return sax->end_array();
8994 if (len !=
static_cast<std::size_t
>(-1)) {
8995 for (std::size_t
i = 0;
i < len; ++
i) {
9007 while (
get() != 0xFF) {
9020 return sax->end_object();
9034 case std::char_traits<char_type>::eof():
9251 return sax->boolean(
false);
9254 return sax->boolean(
true);
9288 std::uint8_t number{};
9294 std::uint16_t number{};
9300 std::uint32_t number{};
9306 std::uint64_t number{};
9312 std::int8_t number{};
9318 std::int16_t number{};
9324 std::int32_t number{};
9330 std::int64_t number{};
9336 std::uint16_t len{};
9342 std::uint32_t len{};
9348 std::uint16_t len{};
9354 std::uint32_t len{};
9391 return sax->number_integer(
static_cast<std::int8_t
>(
current));
9399 "invalid byte: 0x" + last_token,
"value"),
9466 std::uint16_t len{};
9472 std::uint32_t len{};
9478 return sax->parse_error(
9483 "expected length specification (0xA0-0xBF, 0xD9-0xDB); last byte: 0x"
9504 auto assign_and_return_true = [&
result](std::int8_t subtype) {
9505 result.set_subtype(
static_cast<std::uint8_t
>(subtype));
9518 std::uint16_t len{};
9524 std::uint32_t len{};
9531 std::int8_t subtype{};
9538 std::uint16_t len{};
9539 std::int8_t subtype{};
9546 std::uint32_t len{};
9547 std::int8_t subtype{};
9554 std::int8_t subtype{};
9556 && assign_and_return_true(subtype);
9561 std::int8_t subtype{};
9563 && assign_and_return_true(subtype);
9568 std::int8_t subtype{};
9570 && assign_and_return_true(subtype);
9575 std::int8_t subtype{};
9577 && assign_and_return_true(subtype);
9582 std::int8_t subtype{};
9584 && assign_and_return_true(subtype);
9602 for (std::size_t
i = 0;
i < len; ++
i) {
9608 return sax->end_array();
9622 for (std::size_t
i = 0;
i < len; ++
i) {
9634 return sax->end_object();
9705 return sax->parse_error(
9711 "expected length type specification (U, i, I, l, L); last byte: 0x" + last_token,
"string"),
9724 std::uint8_t number{};
9728 result =
static_cast<std::size_t
>(number);
9733 std::int8_t number{};
9737 result =
static_cast<std::size_t
>(
9743 std::int16_t number{};
9747 result =
static_cast<std::size_t
>(number);
9752 std::int32_t number{};
9756 result =
static_cast<std::size_t
>(number);
9761 std::int64_t number{};
9765 result =
static_cast<std::size_t
>(number);
9771 return sax->parse_error(
9776 "expected length type specification (U, i, I, l, L) after '#'; last byte: 0x"
9796 result.first = string_t::npos;
9813 return sax->parse_error(
9818 "expected '#' after type information; last byte: 0x" + last_token,
"size"),
9839 case std::char_traits<char_type>::eof():
9843 return sax->boolean(
true);
9845 return sax->boolean(
false);
9851 std::uint8_t number{};
9856 std::int8_t number{};
9861 std::int16_t number{};
9866 std::int32_t number{};
9871 std::int64_t number{};
9899 return sax->parse_error(
9904 "byte after 'C' must be in range 0x00..0x7F; last byte: 0x" + last_token,
9909 return sax->string(s);
9930 "invalid byte: 0x" + last_token,
"value"),
9941 std::pair<std::size_t, char_int_type> size_and_type;
9946 if (size_and_type.first != string_t::npos) {
9951 if (size_and_type.second != 0) {
9952 if (size_and_type.second !=
'N') {
9953 for (std::size_t
i = 0;
i < size_and_type.first; ++
i) {
9960 for (std::size_t
i = 0;
i < size_and_type.first; ++
i) {
9979 return sax->end_array();
9987 std::pair<std::size_t, char_int_type> size_and_type;
9993 if (size_and_type.first != string_t::npos) {
9998 if (size_and_type.second != 0) {
9999 for (std::size_t
i = 0;
i < size_and_type.first; ++
i) {
10009 for (std::size_t
i = 0;
i < size_and_type.first; ++
i) {
10036 return sax->end_object();
10045 std::size_t size{};
10052 std::vector<char> number_vector;
10053 for (std::size_t
i = 0;
i < size; ++
i) {
10058 number_vector.push_back(
static_cast<char>(
current));
10064 const auto result_number = number_lexer.scan();
10065 const auto number_string = number_lexer.get_token_string();
10066 const auto result_remainder = number_lexer.scan();
10071 return sax->parse_error(
10075 "invalid number text: " + number_lexer.get_token_string(),
10076 "high-precision number"),
10080 switch (result_number) {
10081 case token_type::value_integer:
10082 return sax->number_integer(number_lexer.get_number_integer());
10083 case token_type::value_unsigned:
10084 return sax->number_unsigned(number_lexer.get_number_unsigned());
10085 case token_type::value_float:
10086 return sax->number_float(number_lexer.get_number_float(), std::move(number_string));
10087 case token_type::uninitialized:
10088 case token_type::literal_true:
10089 case token_type::literal_false:
10090 case token_type::literal_null:
10091 case token_type::value_string:
10092 case token_type::begin_array:
10093 case token_type::begin_object:
10094 case token_type::end_array:
10095 case token_type::end_object:
10096 case token_type::name_separator:
10097 case token_type::value_separator:
10098 case token_type::parse_error:
10099 case token_type::end_of_input:
10100 case token_type::literal_or_value:
10102 return sax->parse_error(
10106 "invalid number text: " + number_lexer.get_token_string(),
10107 "high-precision number"),
10156 template<
typename NumberType,
bool InputIsLittleEndian = false>
10160 std::array<std::uint8_t,
sizeof(NumberType)>
vec{};
10161 for (std::size_t
i = 0;
i <
sizeof(NumberType); ++
i) {
10169 vec[
sizeof(NumberType) -
i - 1] =
static_cast<std::uint8_t
>(
current);
10176 std::memcpy(&
result,
vec.data(),
sizeof(NumberType));
10194 template<
typename NumberType>
10197 bool success =
true;
10198 for (NumberType
i = 0;
i < len;
i++) {
10204 result.push_back(
static_cast<typename string_t::value_type
>(
current));
10223 template<
typename NumberType>
10226 bool success =
true;
10227 for (NumberType
i = 0;
i < len;
i++) {
10260 std::array<char, 3> cr{{}};
10261 static_cast<void>((std::snprintf)(
10262 cr.data(), cr.size(),
"%.2hhX",
10263 static_cast<unsigned char>(
current)));
10264 return std::string{cr.data()};
10274 const std::string&
detail,
10275 const std::string& context)
const
10277 std::string error_msg =
"syntax error while parsing ";
10281 error_msg +=
"CBOR";
10285 error_msg +=
"MessagePack";
10289 error_msg +=
"UBJSON";
10293 error_msg +=
"BSON";
10301 return error_msg +
" " + context +
": " +
detail;
10331#include <functional>
10374template<
typename BasicJsonType>
10382template<
typename BasicJsonType,
typename InputAdapterType>
10396 const bool allow_exceptions_ =
true,
10397 const bool skip_comments =
false)
10399 ,
m_lexer(
std::move(adapter), skip_comments)
10438 if (
result.is_discarded()) {
10460 result.assert_invariant();
10475 template<
typename SAX>
10484 return sax->parse_error(
m_lexer.get_position(),
m_lexer.get_token_string(),
10494 template<
typename SAX>
10500 std::vector<bool> states;
10502 bool skip_to_state_evaluation =
false;
10505 if (!skip_to_state_evaluation) {
10508 case token_type::begin_object: {
10514 if (
get_token() == token_type::end_object) {
10523 return sax->parse_error(
10535 return sax->parse_error(
10543 states.push_back(
false);
10550 case token_type::begin_array: {
10556 if (
get_token() == token_type::end_array) {
10564 states.push_back(
true);
10570 case token_type::value_float: {
10571 const auto res =
m_lexer.get_number_float();
10574 return sax->parse_error(
10577 "number overflow parsing '" +
m_lexer.get_token_string() +
"'",
10588 case token_type::literal_false: {
10595 case token_type::literal_null: {
10602 case token_type::literal_true: {
10609 case token_type::value_integer: {
10616 case token_type::value_string: {
10623 case token_type::value_unsigned: {
10630 case token_type::parse_error: {
10632 return sax->parse_error(
10639 case token_type::uninitialized:
10640 case token_type::end_array:
10641 case token_type::end_object:
10642 case token_type::name_separator:
10643 case token_type::value_separator:
10644 case token_type::end_of_input:
10645 case token_type::literal_or_value:
10648 return sax->parse_error(
10656 skip_to_state_evaluation =
false;
10660 if (states.empty()) {
10668 if (
get_token() == token_type::value_separator) {
10686 skip_to_state_evaluation =
true;
10690 return sax->parse_error(
m_lexer.get_position(),
m_lexer.get_token_string(),
10699 if (
get_token() == token_type::value_separator) {
10702 return sax->parse_error(
10715 return sax->parse_error(
10739 skip_to_state_evaluation =
true;
10743 return sax->parse_error(
m_lexer.get_position(),
m_lexer.get_token_string(),
10755 std::string error_msg =
"syntax error ";
10757 if (!context.empty()) {
10758 error_msg +=
"while parsing " + context +
" ";
10763 if (
last_token == token_type::parse_error) {
10764 error_msg += std::string(
m_lexer.get_error_message()) +
"; last read: '" +
m_lexer.get_token_string() +
"'";
10769 if (expected != token_type::uninitialized) {
10841 return lhs.m_it ==
rhs.m_it;
10846 return lhs.m_it <
rhs.m_it;
10858 return lhs.m_it -
rhs.m_it;
10912template<
typename BasicJsonType>
10928#include <type_traits>
10949template<
typename IteratorType>
10951template<
typename IteratorType>
10970template<
typename BasicJsonType>
10975 typename std::remove_const<BasicJsonType>::type,
10987 "iter_impl only accepts (const) basic_json");
10995 using iterator_category = std::bidirectional_iterator_tag;
11002 using pointer =
typename std::conditional<std::is_const<BasicJsonType>::value,
11003 typename BasicJsonType::const_pointer,
11004 typename BasicJsonType::pointer>::type;
11006 using reference =
typename std::conditional<std::is_const<BasicJsonType>::value,
11007 typename BasicJsonType::const_reference,
11008 typename BasicJsonType::reference>::type;
11026 switch (m_object->m_type) {
11028 m_it.object_iterator =
typename object_t::iterator();
11033 m_it.array_iterator =
typename array_t::iterator();
11069 : m_object(other.m_object)
11081 if (&other !=
this) {
11082 m_object = other.m_object;
11094 : m_object(other.m_object)
11105 const iter_impl<
typename std::remove_const<BasicJsonType>::type>& other)
noexcept
11107 m_object = other.m_object;
11119 set_begin() noexcept
11123 switch (m_object->m_type) {
11125 m_it.object_iterator = m_object->m_value.object->begin();
11130 m_it.array_iterator = m_object->m_value.array->begin();
11136 m_it.primitive_iterator.set_end();
11148 m_it.primitive_iterator.set_begin();
11162 switch (m_object->m_type) {
11164 m_it.object_iterator = m_object->m_value.object->end();
11169 m_it.array_iterator = m_object->m_value.array->end();
11182 m_it.primitive_iterator.set_end();
11197 switch (m_object->m_type) {
11199 JSON_ASSERT(
m_it.object_iterator != m_object->m_value.object->end());
11200 return m_it.object_iterator->second;
11205 return *
m_it.array_iterator;
11236 switch (m_object->m_type) {
11238 JSON_ASSERT(
m_it.object_iterator != m_object->m_value.object->end());
11239 return &(
m_it.object_iterator->second);
11244 return &*
m_it.array_iterator;
11284 switch (m_object->m_type) {
11286 std::advance(
m_it.object_iterator, 1);
11291 std::advance(
m_it.array_iterator, 1);
11304 ++
m_it.primitive_iterator;
11331 switch (m_object->m_type) {
11333 std::advance(
m_it.object_iterator, -1);
11338 std::advance(
m_it.array_iterator, -1);
11351 --
m_it.primitive_iterator;
11363 template<
typename IterImpl,
11365 || std::is_same<IterImpl, other_iter_impl>::value),
11366 std::nullptr_t> =
nullptr>
11367 bool operator==(
const IterImpl& other)
const
11376 switch (m_object->m_type) {
11378 return (
m_it.object_iterator == other.m_it.object_iterator);
11381 return (
m_it.array_iterator == other.m_it.array_iterator);
11392 return (
m_it.primitive_iterator == other.m_it.primitive_iterator);
11400 template<
typename IterImpl,
11402 || std::is_same<IterImpl, other_iter_impl>::value),
11403 std::nullptr_t> =
nullptr>
11404 bool operator!=(
const IterImpl& other)
const
11422 switch (m_object->m_type) {
11427 return (
m_it.array_iterator < other.
m_it.array_iterator);
11438 return (
m_it.primitive_iterator < other.
m_it.primitive_iterator);
11468 switch (m_object->m_type) {
11473 std::advance(
m_it.array_iterator,
i);
11486 m_it.primitive_iterator +=
i;
11541 switch (m_object->m_type) {
11546 return m_it.array_iterator - other.
m_it.array_iterator;
11557 return m_it.primitive_iterator - other.
m_it.primitive_iterator;
11569 switch (m_object->m_type) {
11574 return *std::next(
m_it.array_iterator,
n);
11600 const typename object_t::key_type&
key()
const
11605 return m_it.object_iterator->first;
11620 pointer m_object =
nullptr;
11661template<
typename Base>
11729 auto it = --this->base();
11736 auto it = --this->base();
11737 return it.operator*();
11747#include <algorithm>
11768template<
typename BasicJsonType>
11784 std::string to_string()
const
11787 [](
const std::string&
a,
const std::string&
b) { return a +
"/" + detail::escape(b); });
11792 operator std::string()
const {
return to_string(); }
11806 push_back(std::move(
token));
11820 friend json_pointer
operator/(
const json_pointer& lhs,
11835 json_pointer parent_pointer()
const
11859 const std::string&
back()
const
11891 static typename BasicJsonType::size_type
array_index(
const std::string& s)
11893 using size_type =
typename BasicJsonType::size_type;
11906 std::size_t processed_chars = 0;
11907 unsigned long long res = 0;
11910 res = std::stoull(s, &processed_chars);
11924 if (
res >=
static_cast<unsigned long long>((std::numeric_limits<size_type>::max)()))
11960 switch (
result->type()) {
11962 if (reference_token ==
"0") {
12028 if (ptr->is_null()) {
12030 const bool nums = std::all_of(reference_token.begin(), reference_token.end(),
12031 [](
const unsigned char x) { return std::isdigit(x); });
12037 switch (ptr->type()) {
12040 ptr = &ptr->operator[](reference_token);
12045 if (reference_token ==
"-") {
12047 ptr = &ptr->operator[](ptr->m_value.array->size());
12050 ptr = &ptr->operator[](
array_index(reference_token));
12081 switch (ptr->type()) {
12084 ptr = &ptr->at(reference_token);
12092 402,
"array index '-' (" + std::to_string(ptr->m_value.array->size()) +
") is out of range",
12134 switch (ptr->type()) {
12137 ptr = &ptr->operator[](reference_token);
12145 402,
"array index '-' (" + std::to_string(ptr->m_value.array->size()) +
") is out of range",
12150 ptr = &ptr->operator[](
array_index(reference_token));
12180 switch (ptr->type()) {
12183 ptr = &ptr->at(reference_token);
12191 402,
"array index '-' (" + std::to_string(ptr->m_value.array->size()) +
") is out of range",
12224 switch (ptr->type()) {
12226 if (!ptr->contains(reference_token)) {
12231 ptr = &ptr->operator[](reference_token);
12241 && !(
"0" <= reference_token && reference_token <=
"9")))
12251 for (std::size_t
i = 1;
i < reference_token.size();
i++) {
12260 if (idx >= ptr->size()) {
12265 ptr = &ptr->operator[](idx);
12298 static std::vector<std::string>
split(
const std::string& reference_string)
12300 std::vector<std::string>
result;
12303 if (reference_string.empty()) {
12310 107, 1,
"JSON pointer must be empty or begin with '/' - was: '" + reference_string +
"'",
12319 std::size_t slash = reference_string.find_first_of(
'/', 1),
12326 start = (slash == std::string::npos) ? 0 : slash + 1,
12328 slash = reference_string.find_first_of(
'/', start))
12332 auto reference_token = reference_string.substr(start, slash - start);
12335 for (std::size_t pos = reference_token.find_first_of(
'~'); pos != std::string::npos;
12336 pos = reference_token.find_first_of(
'~', pos + 1))
12342 || (reference_token[pos + 1] !=
'0' && reference_token[pos + 1] !=
'1')))
12345 108, 0,
"escape character '~' must be followed with '0' or '1'",
BasicJsonType()));
12351 result.push_back(reference_token);
12367 switch (value.type()) {
12369 if (value.m_value.array->empty()) {
12371 result[reference_string] =
nullptr;
12374 for (std::size_t
i = 0;
i < value.m_value.array->size(); ++
i) {
12375 flatten(reference_string +
"/" + std::to_string(
i), value.m_value.array->operator[](
i),
result);
12382 if (value.m_value.object->empty()) {
12384 result[reference_string] =
nullptr;
12387 for (
const auto& element : *value.m_value.object) {
12404 result[reference_string] = value;
12429 for (
const auto& element : *value.m_value.object) {
12457 return lhs.reference_tokens ==
rhs.reference_tokens;
12480#include <initializer_list>
12489template<
typename BasicJsonType>
12548#include <algorithm>
12563#include <algorithm>
12582template<
typename CharType>
12597template<typename CharType>
12601template<typename CharType, typename AllocatorType =
std::allocator<CharType>>
12614 std::copy(s, s + length, std::back_inserter(
v));
12618 std::vector<CharType, AllocatorType>&
v;
12623template<
typename CharType>
12636 stream.write(s,
static_cast<std::streamsize
>(length));
12645template<
typename CharType,
typename StringType = std::basic_
string<CharType>>
12662template<
typename CharType,
typename StringType = std::basic_
string<CharType>>
12666 template<
typename AllocatorType = std::allocator<CharType>>
12700template<
typename BasicJsonType,
typename CharType>
12714 :
oa(
std::move(adapter))
12725 switch (j.type()) {
12742 317,
"to serialize to BSON, top-level type must be object, but is " + std::string(j.type_name()),
12753 switch (j.type()) {
12765 if (j.m_value.number_integer >= 0) {
12769 if (j.m_value.number_integer <= 0x17) {
12770 write_number(
static_cast<std::uint8_t
>(j.m_value.number_integer));
12771 }
else if (j.m_value.number_integer <= (std::numeric_limits<std::uint8_t>::max)()) {
12773 write_number(
static_cast<std::uint8_t
>(j.m_value.number_integer));
12774 }
else if (j.m_value.number_integer <= (std::numeric_limits<std::uint16_t>::max)()) {
12776 write_number(
static_cast<std::uint16_t
>(j.m_value.number_integer));
12777 }
else if (j.m_value.number_integer <= (std::numeric_limits<std::uint32_t>::max)()) {
12779 write_number(
static_cast<std::uint32_t
>(j.m_value.number_integer));
12782 write_number(
static_cast<std::uint64_t
>(j.m_value.number_integer));
12787 const auto positive_number = -1 - j.m_value.number_integer;
12788 if (j.m_value.number_integer >= -24) {
12789 write_number(
static_cast<std::uint8_t
>(0x20 + positive_number));
12790 }
else if (positive_number <= (std::numeric_limits<std::uint8_t>::max)()) {
12792 write_number(
static_cast<std::uint8_t
>(positive_number));
12793 }
else if (positive_number <= (std::numeric_limits<std::uint16_t>::max)()) {
12795 write_number(
static_cast<std::uint16_t
>(positive_number));
12796 }
else if (positive_number <= (std::numeric_limits<std::uint32_t>::max)()) {
12798 write_number(
static_cast<std::uint32_t
>(positive_number));
12801 write_number(
static_cast<std::uint64_t
>(positive_number));
12808 if (j.m_value.number_unsigned <= 0x17) {
12809 write_number(
static_cast<std::uint8_t
>(j.m_value.number_unsigned));
12810 }
else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint8_t>::max)()) {
12812 write_number(
static_cast<std::uint8_t
>(j.m_value.number_unsigned));
12813 }
else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint16_t>::max)()) {
12815 write_number(
static_cast<std::uint16_t
>(j.m_value.number_unsigned));
12816 }
else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint32_t>::max)()) {
12818 write_number(
static_cast<std::uint32_t
>(j.m_value.number_unsigned));
12821 write_number(
static_cast<std::uint64_t
>(j.m_value.number_unsigned));
12827 if (std::isnan(j.m_value.number_float)) {
12832 }
else if (std::isinf(j.m_value.number_float)) {
12845 const auto N = j.m_value.string->size();
12848 }
else if (N <= (std::numeric_limits<std::uint8_t>::max)()) {
12851 }
else if (N <= (std::numeric_limits<std::uint16_t>::max)()) {
12854 }
else if (N <= (std::numeric_limits<std::uint32_t>::max)()) {
12859 else if (N <= (std::numeric_limits<std::uint64_t>::max)())
12867 oa->write_characters(
reinterpret_cast<const CharType*
>(j.m_value.string->c_str()),
12868 j.m_value.string->size());
12874 const auto N = j.m_value.array->size();
12877 }
else if (N <= (std::numeric_limits<std::uint8_t>::max)()) {
12880 }
else if (N <= (std::numeric_limits<std::uint16_t>::max)()) {
12883 }
else if (N <= (std::numeric_limits<std::uint32_t>::max)()) {
12888 else if (N <= (std::numeric_limits<std::uint64_t>::max)())
12896 for (
const auto& el : *j.m_value.array) {
12903 if (j.m_value.binary->has_subtype()) {
12904 if (j.m_value.binary->subtype() <= (std::numeric_limits<std::uint8_t>::max)()) {
12906 write_number(
static_cast<std::uint8_t
>(j.m_value.binary->subtype()));
12907 }
else if (j.m_value.binary->subtype() <= (std::numeric_limits<std::uint16_t>::max)()) {
12909 write_number(
static_cast<std::uint16_t
>(j.m_value.binary->subtype()));
12910 }
else if (j.m_value.binary->subtype() <= (std::numeric_limits<std::uint32_t>::max)()) {
12912 write_number(
static_cast<std::uint32_t
>(j.m_value.binary->subtype()));
12913 }
else if (j.m_value.binary->subtype() <= (std::numeric_limits<std::uint64_t>::max)()) {
12915 write_number(
static_cast<std::uint64_t
>(j.m_value.binary->subtype()));
12920 const auto N = j.m_value.binary->size();
12923 }
else if (N <= (std::numeric_limits<std::uint8_t>::max)()) {
12926 }
else if (N <= (std::numeric_limits<std::uint16_t>::max)()) {
12929 }
else if (N <= (std::numeric_limits<std::uint32_t>::max)()) {
12934 else if (N <= (std::numeric_limits<std::uint64_t>::max)())
12942 oa->write_characters(
reinterpret_cast<const CharType*
>(j.m_value.binary->data()), N);
12949 const auto N = j.m_value.object->size();
12952 }
else if (N <= (std::numeric_limits<std::uint8_t>::max)()) {
12955 }
else if (N <= (std::numeric_limits<std::uint16_t>::max)()) {
12958 }
else if (N <= (std::numeric_limits<std::uint32_t>::max)()) {
12963 else if (N <= (std::numeric_limits<std::uint64_t>::max)())
12971 for (
const auto& el : *j.m_value.object) {
12989 switch (j.type()) {
13003 if (j.m_value.number_integer >= 0) {
13007 if (j.m_value.number_unsigned < 128) {
13009 write_number(
static_cast<std::uint8_t
>(j.m_value.number_integer));
13010 }
else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint8_t>::max)()) {
13013 write_number(
static_cast<std::uint8_t
>(j.m_value.number_integer));
13014 }
else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint16_t>::max)()) {
13017 write_number(
static_cast<std::uint16_t
>(j.m_value.number_integer));
13018 }
else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint32_t>::max)()) {
13021 write_number(
static_cast<std::uint32_t
>(j.m_value.number_integer));
13022 }
else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint64_t>::max)()) {
13025 write_number(
static_cast<std::uint64_t
>(j.m_value.number_integer));
13028 if (j.m_value.number_integer >= -32) {
13030 write_number(
static_cast<std::int8_t
>(j.m_value.number_integer));
13031 }
else if (j.m_value.number_integer >= (std::numeric_limits<std::int8_t>::min)()
13032 && j.m_value.number_integer <= (std::numeric_limits<std::int8_t>::max)())
13036 write_number(
static_cast<std::int8_t
>(j.m_value.number_integer));
13037 }
else if (j.m_value.number_integer >= (std::numeric_limits<std::int16_t>::min)()
13038 && j.m_value.number_integer <= (std::numeric_limits<std::int16_t>::max)())
13042 write_number(
static_cast<std::int16_t
>(j.m_value.number_integer));
13043 }
else if (j.m_value.number_integer >= (std::numeric_limits<std::int32_t>::min)()
13044 && j.m_value.number_integer <= (std::numeric_limits<std::int32_t>::max)())
13048 write_number(
static_cast<std::int32_t
>(j.m_value.number_integer));
13049 }
else if (j.m_value.number_integer >= (std::numeric_limits<std::int64_t>::min)()
13050 && j.m_value.number_integer <= (std::numeric_limits<std::int64_t>::max)())
13054 write_number(
static_cast<std::int64_t
>(j.m_value.number_integer));
13061 if (j.m_value.number_unsigned < 128) {
13063 write_number(
static_cast<std::uint8_t
>(j.m_value.number_integer));
13064 }
else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint8_t>::max)()) {
13067 write_number(
static_cast<std::uint8_t
>(j.m_value.number_integer));
13068 }
else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint16_t>::max)()) {
13071 write_number(
static_cast<std::uint16_t
>(j.m_value.number_integer));
13072 }
else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint32_t>::max)()) {
13075 write_number(
static_cast<std::uint32_t
>(j.m_value.number_integer));
13076 }
else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint64_t>::max)()) {
13079 write_number(
static_cast<std::uint64_t
>(j.m_value.number_integer));
13091 const auto N = j.m_value.string->size();
13095 }
else if (N <= (std::numeric_limits<std::uint8_t>::max)()) {
13099 }
else if (N <= (std::numeric_limits<std::uint16_t>::max)()) {
13103 }
else if (N <= (std::numeric_limits<std::uint32_t>::max)()) {
13110 oa->write_characters(
reinterpret_cast<const CharType*
>(j.m_value.string->c_str()),
13111 j.m_value.string->size());
13117 const auto N = j.m_value.array->size();
13121 }
else if (N <= (std::numeric_limits<std::uint16_t>::max)()) {
13125 }
else if (N <= (std::numeric_limits<std::uint32_t>::max)()) {
13132 for (
const auto& el : *j.m_value.array) {
13141 const bool use_ext = j.m_value.binary->has_subtype();
13144 const auto N = j.m_value.binary->size();
13145 if (N <= (std::numeric_limits<std::uint8_t>::max)()) {
13146 std::uint8_t output_type{};
13151 output_type = 0xD4;
13154 output_type = 0xD5;
13157 output_type = 0xD6;
13160 output_type = 0xD7;
13163 output_type = 0xD8;
13166 output_type = 0xC7;
13172 output_type = 0xC4;
13180 }
else if (N <= (std::numeric_limits<std::uint16_t>::max)()) {
13181 std::uint8_t output_type = use_ext ? 0xC8
13186 }
else if (N <= (std::numeric_limits<std::uint32_t>::max)()) {
13187 std::uint8_t output_type = use_ext ? 0xC9
13196 write_number(
static_cast<std::int8_t
>(j.m_value.binary->subtype()));
13200 oa->write_characters(
reinterpret_cast<const CharType*
>(j.m_value.binary->data()), N);
13207 const auto N = j.m_value.object->size();
13210 write_number(
static_cast<std::uint8_t
>(0x80 | (N & 0xF)));
13211 }
else if (N <= (std::numeric_limits<std::uint16_t>::max)()) {
13215 }
else if (N <= (std::numeric_limits<std::uint32_t>::max)()) {
13222 for (
const auto& el : *j.m_value.object) {
13243 switch (j.type()) {
13278 oa->write_characters(
reinterpret_cast<const CharType*
>(j.m_value.string->c_str()),
13279 j.m_value.string->size());
13288 bool prefix_required =
true;
13289 if (use_type && !j.m_value.array->empty()) {
13292 const bool same_prefix =
13293 std::all_of(j.begin() + 1, j.end(), [
this, first_prefix](
const BasicJsonType&
v) {
13294 return ubjson_prefix(v) == first_prefix;
13298 prefix_required =
false;
13300 oa->write_character(first_prefix);
13309 for (
const auto& el : *j.m_value.array) {
13310 write_ubjson(el, use_count, use_type, prefix_required);
13325 if (use_type && !j.m_value.binary->empty()) {
13328 oa->write_character(
'U');
13337 oa->write_characters(
reinterpret_cast<const CharType*
>(j.m_value.binary->data()),
13338 j.m_value.binary->size());
13340 for (
size_t i = 0;
i < j.m_value.binary->size(); ++
i) {
13342 oa->write_character(j.m_value.binary->data()[
i]);
13358 bool prefix_required =
true;
13359 if (use_type && !j.m_value.object->empty()) {
13362 const bool same_prefix =
13363 std::all_of(j.begin(), j.end(), [
this, first_prefix](
const BasicJsonType&
v) {
13364 return ubjson_prefix(v) == first_prefix;
13368 prefix_required =
false;
13370 oa->write_character(first_prefix);
13379 for (
const auto& el : *j.m_value.object) {
13381 oa->write_characters(
reinterpret_cast<const CharType*
>(el.first.c_str()), el.first.size());
13382 write_ubjson(el.second, use_count, use_type, prefix_required);
13409 const auto it = name.find(
static_cast<typename string_t::value_type
>(0));
13412 409,
"BSON key cannot contain code point U+0000 (at byte " + std::to_string(it) +
")", j));
13413 static_cast<void>(j);
13416 return 1ul + name.size() + 1u;
13425 oa->write_characters(
reinterpret_cast<const CharType*
>(name.c_str()), name.size() + 1u);
13451 return sizeof(std::int32_t) +
value.size() + 1ul;
13462 oa->write_characters(
reinterpret_cast<const CharType*
>(
value.c_str()),
value.size() + 1);
13475 return (std::numeric_limits<std::int32_t>::min)() <=
value
13476 &&
value <= (std::numeric_limits<std::int32_t>::max)()
13477 ?
sizeof(std::int32_t)
13478 :
sizeof(std::int64_t);
13486 if ((std::numeric_limits<std::int32_t>::min)() <=
value &&
value <= (std::numeric_limits<std::int32_t>::max)())
13501 return (
value <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int32_t>::max)())) ?
sizeof(std::int32_t)
13502 :
sizeof(std::int64_t);
13510 if (j.m_value.number_unsigned <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int32_t>::max)())) {
13513 }
else if (j.m_value.number_unsigned <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int64_t>::max)()))
13519 "integer number " + std::to_string(j.m_value.number_unsigned)
13520 +
" cannot be represented by BSON as it does not fit int64",
13541 const std::size_t embedded_document_size =
13542 std::accumulate(std::begin(
value), std::end(
value),
static_cast<std::size_t
>(0),
13543 [&
array_index](std::size_t
result,
const typename BasicJsonType::array_t::value_type& el) {
13547 return sizeof(std::int32_t) + embedded_document_size + 1ul;
13555 return sizeof(std::int32_t) +
value.size() + 1ul;
13568 for (
const auto& el :
value) {
13584 :
static_cast<std::uint8_t
>(0x00));
13586 oa->write_characters(
reinterpret_cast<const CharType*
>(
value.data()),
value.size());
13596 switch (j.type()) {
13607 return header_size + 1ul;
13610 return header_size + 8ul;
13622 return header_size + 0ul;
13641 switch (j.type()) {
13686 std::size_t document_size =
13687 std::accumulate(
value.begin(),
value.end(),
static_cast<std::size_t
>(0),
13688 [](
size_t result,
const typename BasicJsonType::object_t::value_type& el) {
13689 return result += calc_bson_element_size(el.first, el.second);
13692 return sizeof(std::int32_t) + document_size + 1ul;
13703 for (
const auto& el :
value) {
13743 template<typename NumberType, typename std::enable_if<std::is_floating_point<NumberType>::value,
int>::type = 0>
13753 template<typename NumberType, typename std::enable_if<std::is_unsigned<NumberType>::value,
int>::type = 0>
13756 if (
n <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int8_t>::max)())) {
13761 }
else if (
n <= (std::numeric_limits<std::uint8_t>::max)()) {
13766 }
else if (
n <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int16_t>::max)())) {
13771 }
else if (
n <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int32_t>::max)())) {
13776 }
else if (
n <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int64_t>::max)())) {
13788 for (std::size_t
i = 0;
i < number.size(); ++
i) {
13789 oa->write_character(
to_char_type(
static_cast<std::uint8_t
>(number[
i])));
13795 template<
typename NumberType,
13796 typename std::enable_if<std::is_signed<NumberType>::value && !std::is_floating_point<NumberType>::value,
13800 if ((std::numeric_limits<std::int8_t>::min)() <=
n &&
n <= (std::numeric_limits<std::int8_t>::max)()) {
13805 }
else if (
static_cast<std::int64_t
>((std::numeric_limits<std::uint8_t>::min)()) <=
n
13806 &&
n <=
static_cast<std::int64_t
>((std::numeric_limits<std::uint8_t>::max)()))
13812 }
else if ((std::numeric_limits<std::int16_t>::min)() <=
n &&
n <= (std::numeric_limits<std::int16_t>::max)()) {
13817 }
else if ((std::numeric_limits<std::int32_t>::min)() <=
n &&
n <= (std::numeric_limits<std::int32_t>::max)()) {
13822 }
else if ((std::numeric_limits<std::int64_t>::min)() <=
n &&
n <= (std::numeric_limits<std::int64_t>::max)()) {
13837 for (std::size_t
i = 0;
i < number.size(); ++
i) {
13838 oa->write_character(
to_char_type(
static_cast<std::uint8_t
>(number[
i])));
13849 switch (j.type()) {
13854 return j.m_value.boolean ?
'T' :
'F';
13857 if ((std::numeric_limits<std::int8_t>::min)() <= j.m_value.number_integer
13858 && j.m_value.number_integer <= (std::numeric_limits<std::int8_t>::max)())
13862 if ((std::numeric_limits<std::uint8_t>::min)() <= j.m_value.number_integer
13863 && j.m_value.number_integer <= (std::numeric_limits<std::uint8_t>::max)())
13867 if ((std::numeric_limits<std::int16_t>::min)() <= j.m_value.number_integer
13868 && j.m_value.number_integer <= (std::numeric_limits<std::int16_t>::max)())
13872 if ((std::numeric_limits<std::int32_t>::min)() <= j.m_value.number_integer
13873 && j.m_value.number_integer <= (std::numeric_limits<std::int32_t>::max)())
13877 if ((std::numeric_limits<std::int64_t>::min)() <= j.m_value.number_integer
13878 && j.m_value.number_integer <= (std::numeric_limits<std::int64_t>::max)())
13887 if (j.m_value.number_unsigned <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int8_t>::max)()))
13891 if (j.m_value.number_unsigned <=
static_cast<std::uint64_t
>((std::numeric_limits<std::uint8_t>::max)()))
13895 if (j.m_value.number_unsigned <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int16_t>::max)()))
13899 if (j.m_value.number_unsigned <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int32_t>::max)()))
13903 if (j.m_value.number_unsigned <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int64_t>::max)()))
13955 template<
typename NumberType,
bool OutputIsLittleEndian = false>
13959 std::array<CharType,
sizeof(NumberType)>
vec{};
13960 std::memcpy(
vec.data(), &
n,
sizeof(NumberType));
13965 std::reverse(
vec.begin(),
vec.end());
13968 oa->write_characters(
vec.data(),
sizeof(NumberType));
13974#pragma GCC diagnostic push
13975#pragma GCC diagnostic ignored "-Wfloat-equal"
13977 if (
static_cast<double>(
n) >=
static_cast<double>(std::numeric_limits<float>::lowest())
13978 &&
static_cast<double>(
n) <=
static_cast<double>((std::numeric_limits<float>::max)())
13979 &&
static_cast<double>(
static_cast<float>(
n)) ==
static_cast<double>(
n))
13991#pragma GCC diagnostic pop
14000 template<typename C = CharType, enable_if_t<std::is_signed<C>::value && std::is_signed<char>::value>* =
nullptr>
14003 return *
reinterpret_cast<char*
>(&x);
14006 template<typename C = CharType, enable_if_t<std::is_signed<C>::value && std::is_unsigned<char>::value>* =
nullptr>
14009 static_assert(
sizeof(std::uint8_t) ==
sizeof(CharType),
"size of CharType must be equal to std::uint8_t");
14010 static_assert(std::is_trivial<CharType>::value,
"CharType must be trivial");
14012 std::memcpy(&
result, &x,
sizeof(x));
14016 template<typename C = CharType, enable_if_t<std::is_unsigned<C>::value>* =
nullptr>
14022 template<
typename InputCharType,
14023 typename C = CharType,
14025 && std::is_same<char, typename std::remove_cv<InputCharType>::type>
::value>* =
nullptr>
14045#include <algorithm>
14056#include <type_traits>
14066#include <type_traits>
14097template<
typename Target,
typename Source>
14100 static_assert(
sizeof(Target) ==
sizeof(Source),
"size mismatch");
14103 std::memcpy(&target, &source,
sizeof(Source));
14114 constexpr diyfp(std::uint64_t f_,
int e_) noexcept
14128 return {x.f - y.f, x.e};
14137 static_assert(
kPrecision == 64,
"internal error");
14162 const std::uint64_t u_lo = x.f & 0xFFFFFFFFu;
14163 const std::uint64_t u_hi = x.f >> 32u;
14164 const std::uint64_t v_lo = y.f & 0xFFFFFFFFu;
14165 const std::uint64_t v_hi = y.f >> 32u;
14167 const std::uint64_t p0 = u_lo * v_lo;
14168 const std::uint64_t p1 = u_lo * v_hi;
14169 const std::uint64_t p2 = u_hi * v_lo;
14170 const std::uint64_t p3 = u_hi * v_hi;
14172 const std::uint64_t p0_hi = p0 >> 32u;
14173 const std::uint64_t p1_lo = p1 & 0xFFFFFFFFu;
14174 const std::uint64_t p1_hi = p1 >> 32u;
14175 const std::uint64_t p2_lo = p2 & 0xFFFFFFFFu;
14176 const std::uint64_t p2_hi = p2 >> 32u;
14178 std::uint64_t Q = p0_hi + p1_lo + p2_lo;
14189 Q += std::uint64_t{1} << (64u - 32u - 1u);
14191 const std::uint64_t h = p3 + p2_hi + p1_hi + (Q >> 32u);
14193 return {h, x.e + y.e + 64};
14204 while ((x.f >> 63u) == 0) {
14218 const int delta = x.e - target_exponent;
14223 return {x.f << delta, target_exponent};
14240template<
typename FloatType>
14253 static_assert(std::numeric_limits<FloatType>::is_iec559,
14254 "internal error: dtoa_short requires an IEEE-754 floating-point implementation");
14256 constexpr int kPrecision = std::numeric_limits<FloatType>::digits;
14257 constexpr int kBias = std::numeric_limits<FloatType>::max_exponent - 1 + (kPrecision - 1);
14258 constexpr int kMinExp = 1 - kBias;
14259 constexpr std::uint64_t kHiddenBit = std::uint64_t{1} << (kPrecision - 1);
14261 using bits_type =
typename std::conditional<kPrecision == 24, std::uint32_t, std::uint64_t>::type;
14264 const std::uint64_t E = bits >> (kPrecision - 1);
14265 const std::uint64_t F = bits & (kHiddenBit - 1);
14267 const bool is_denormal = E == 0;
14268 const diyfp v = is_denormal ?
diyfp(F, kMinExp) :
diyfp(F + kHiddenBit,
static_cast<int>(E) - kBias);
14291 const bool lower_boundary_is_closer = F == 0 && E > 1;
14293 const diyfp m_minus = lower_boundary_is_closer ?
diyfp(4 *
v.f - 1,
v.e - 2)
14294 :
diyfp(2 *
v.f - 1,
v.e - 1);
14429 constexpr int kCachedPowersMinDecExp = -300;
14430 constexpr int kCachedPowersDecStep = 8;
14432 static constexpr std::array<cached_power, 79> kCachedPowers = {{
14433 {0xAB70FE17C79AC6CA, -1060, -300}, {0xFF77B1FCBEBCDC4F, -1034, -292}, {0xBE5691EF416BD60C, -1007, -284},
14434 {0x8DD01FAD907FFC3C, -980, -276}, {0xD3515C2831559A83, -954, -268}, {0x9D71AC8FADA6C9B5, -927, -260},
14435 {0xEA9C227723EE8BCB, -901, -252}, {0xAECC49914078536D, -874, -244}, {0x823C12795DB6CE57, -847, -236},
14436 {0xC21094364DFB5637, -821, -228}, {0x9096EA6F3848984F, -794, -220}, {0xD77485CB25823AC7, -768, -212},
14437 {0xA086CFCD97BF97F4, -741, -204}, {0xEF340A98172AACE5, -715, -196}, {0xB23867FB2A35B28E, -688, -188},
14438 {0x84C8D4DFD2C63F3B, -661, -180}, {0xC5DD44271AD3CDBA, -635, -172}, {0x936B9FCEBB25C996, -608, -164},
14439 {0xDBAC6C247D62A584, -582, -156}, {0xA3AB66580D5FDAF6, -555, -148}, {0xF3E2F893DEC3F126, -529, -140},
14440 {0xB5B5ADA8AAFF80B8, -502, -132}, {0x87625F056C7C4A8B, -475, -124}, {0xC9BCFF6034C13053, -449, -116},
14441 {0x964E858C91BA2655, -422, -108}, {0xDFF9772470297EBD, -396, -100}, {0xA6DFBD9FB8E5B88F, -369, -92},
14442 {0xF8A95FCF88747D94, -343, -84}, {0xB94470938FA89BCF, -316, -76}, {0x8A08F0F8BF0F156B, -289, -68},
14443 {0xCDB02555653131B6, -263, -60}, {0x993FE2C6D07B7FAC, -236, -52}, {0xE45C10C42A2B3B06, -210, -44},
14444 {0xAA242499697392D3, -183, -36}, {0xFD87B5F28300CA0E, -157, -28}, {0xBCE5086492111AEB, -130, -20},
14445 {0x8CBCCC096F5088CC, -103, -12}, {0xD1B71758E219652C, -77, -4}, {0x9C40000000000000, -50, 4},
14446 {0xE8D4A51000000000, -24, 12}, {0xAD78EBC5AC620000, 3, 20}, {0x813F3978F8940984, 30, 28},
14447 {0xC097CE7BC90715B3, 56, 36}, {0x8F7E32CE7BEA5C70, 83, 44}, {0xD5D238A4ABE98068, 109, 52},
14448 {0x9F4F2726179A2245, 136, 60}, {0xED63A231D4C4FB27, 162, 68}, {0xB0DE65388CC8ADA8, 189, 76},
14449 {0x83C7088E1AAB65DB, 216, 84}, {0xC45D1DF942711D9A, 242, 92}, {0x924D692CA61BE758, 269, 100},
14450 {0xDA01EE641A708DEA, 295, 108}, {0xA26DA3999AEF774A, 322, 116}, {0xF209787BB47D6B85, 348, 124},
14451 {0xB454E4A179DD1877, 375, 132}, {0x865B86925B9BC5C2, 402, 140}, {0xC83553C5C8965D3D, 428, 148},
14452 {0x952AB45CFA97A0B3, 455, 156}, {0xDE469FBD99A05FE3, 481, 164}, {0xA59BC234DB398C25, 508, 172},
14453 {0xF6C69A72A3989F5C, 534, 180}, {0xB7DCBF5354E9BECE, 561, 188}, {0x88FCF317F22241E2, 588, 196},
14454 {0xCC20CE9BD35C78A5, 614, 204}, {0x98165AF37B2153DF, 641, 212}, {0xE2A0B5DC971F303A, 667, 220},
14455 {0xA8D9D1535CE3B396, 694, 228}, {0xFB9B7CD9A4A7443C, 720, 236}, {0xBB764C4CA7A44410, 747, 244},
14456 {0x8BAB8EEFB6409C1A, 774, 252}, {0xD01FEF10A657842C, 800, 260}, {0x9B10A4E5E9913129, 827, 268},
14457 {0xE7109BFBA19C0C9D, 853, 276}, {0xAC2820D9623BF429, 880, 284}, {0x80444B5E7AA7CF85, 907, 292},
14458 {0xBF21E44003ACDD2D, 933, 300}, {0x8E679C2F5E44FF8F, 960, 308}, {0xD433179D9C8CB841, 986, 316},
14459 {0x9E19DB92B4E31BA9, 1013, 324},
14468 const int f =
kAlpha - e - 1;
14469 const int k = (f * 78913) / (1 << 18) +
static_cast<int>(f > 0);
14471 const int index = (-kCachedPowersMinDecExp + k + (kCachedPowersDecStep - 1)) / kCachedPowersDecStep;
14473 JSON_ASSERT(
static_cast<std::size_t
>(index) < kCachedPowers.size());
14475 const cached_power cached = kCachedPowers[
static_cast<std::size_t
>(index)];
14489 if (
n >= 1000000000) {
14490 pow10 = 1000000000;
14494 if (
n >= 100000000) {
14498 if (
n >= 10000000) {
14502 if (
n >= 1000000) {
14533 std::uint64_t
dist,
14534 std::uint64_t delta,
14535 std::uint64_t rest,
14536 std::uint64_t ten_k)
14562 while (rest < dist && delta - rest >= ten_k && (rest + ten_k < dist || dist - rest > rest + ten_k -
dist)) {
14575 static_assert(
kAlpha >= -60,
"internal error");
14576 static_assert(
kGamma <= -32,
"internal error");
14593 std::uint64_t delta =
diyfp::sub(M_plus, M_minus).
f;
14603 const diyfp one(std::uint64_t{1} << -M_plus.
e, M_plus.
e);
14605 auto p1 =
static_cast<std::uint32_t
>(M_plus.
f
14607 std::uint64_t p2 = M_plus.
f & (one.f - 1);
14615 std::uint32_t pow10{};
14642 const std::uint32_t d = p1 / pow10;
14643 const std::uint32_t r = p1 % pow10;
14649 buffer[length++] =
static_cast<char>(
'0' + d);
14668 const std::uint64_t rest = (std::uint64_t{p1} << -one.e) + p2;
14669 if (rest <= delta) {
14672 decimal_exponent +=
n;
14683 const std::uint64_t ten_n = std::uint64_t{pow10} << -one.e;
14744 JSON_ASSERT(p2 <= (std::numeric_limits<std::uint64_t>::max)() / 10);
14746 const std::uint64_t d = p2 >> -one.e;
14747 const std::uint64_t r = p2 & (one.f - 1);
14754 buffer[length++] =
static_cast<char>(
'0' + d);
14778 decimal_exponent -=
m;
14786 const std::uint64_t ten_m = one.f;
14826 const diyfp c_minus_k(cached.
f, cached.
e);
14854 const diyfp M_minus(w_minus.
f + 1, w_minus.
e);
14855 const diyfp M_plus(w_plus.
f - 1, w_plus.
e);
14857 decimal_exponent = -cached.
k;
14867template<
typename FloatType>
14872 "internal error: not enough precision");
14921 auto k =
static_cast<std::uint32_t
>(e);
14926 *buf++ =
static_cast<char>(
'0' + k);
14927 }
else if (k < 100) {
14928 *buf++ =
static_cast<char>(
'0' + k / 10);
14930 *buf++ =
static_cast<char>(
'0' + k);
14932 *buf++ =
static_cast<char>(
'0' + k / 100);
14934 *buf++ =
static_cast<char>(
'0' + k / 10);
14936 *buf++ =
static_cast<char>(
'0' + k);
14953inline
char*
format_buffer(
char* buf,
int len,
int decimal_exponent,
int min_exp,
int max_exp)
14959 const int n = len + decimal_exponent;
14965 if (k <=
n &&
n <= max_exp) {
14969 std::memset(buf + k,
'0',
static_cast<size_t>(
n) -
static_cast<size_t>(k));
14973 return buf + (
static_cast<size_t>(
n) + 2);
14976 if (0 <
n &&
n <= max_exp) {
14982 std::memmove(buf + (
static_cast<size_t>(
n) + 1), buf +
n,
static_cast<size_t>(k) -
static_cast<size_t>(
n));
14984 return buf + (
static_cast<size_t>(k) + 1U);
14987 if (min_exp <
n &&
n <= 0) {
14991 std::memmove(buf + (2 +
static_cast<size_t>(-
n)), buf,
static_cast<size_t>(k));
14994 std::memset(buf + 2,
'0',
static_cast<size_t>(-
n));
14995 return buf + (2U +
static_cast<size_t>(-
n) +
static_cast<size_t>(k));
15007 std::memmove(buf + 2, buf + 1,
static_cast<size_t>(k) - 1);
15009 buf += 1 +
static_cast<size_t>(k);
15028template<
typename FloatType>
15032 static_cast<void>(last);
15036 if (std::signbit(
value)) {
15042#pragma GCC diagnostic push
15043#pragma GCC diagnostic ignored "-Wfloat-equal"
15054#pragma GCC diagnostic pop
15057 JSON_ASSERT(last - first >= std::numeric_limits<FloatType>::max_digits10);
15064 int decimal_exponent = 0;
15067 JSON_ASSERT(len <= std::numeric_limits<FloatType>::max_digits10);
15070 constexpr int kMinExp = -4;
15072 constexpr int kMaxExp = std::numeric_limits<FloatType>::digits10;
15075 JSON_ASSERT(last - first >= 2 + (-kMinExp - 1) + std::numeric_limits<FloatType>::max_digits10);
15076 JSON_ASSERT(last - first >= std::numeric_limits<FloatType>::max_digits10 + 6);
15112template<
typename BasicJsonType>
15131 ,
loc(
std::localeconv())
15171 const bool pretty_print,
15173 const unsigned int indent_step,
15174 const unsigned int current_indent = 0)
15176 switch (val.m_type) {
15178 if (val.m_value.object->empty()) {
15179 o->write_characters(
"{}", 2);
15183 if (pretty_print) {
15184 o->write_characters(
"{\n", 2);
15187 const auto new_indent = current_indent + indent_step;
15193 auto i = val.m_value.object->cbegin();
15194 for (std::size_t cnt = 0; cnt < val.m_value.object->size() - 1; ++cnt, ++
i) {
15196 o->write_character(
'\"');
15198 o->write_characters(
"\": ", 3);
15200 o->write_characters(
",\n", 2);
15205 JSON_ASSERT(std::next(
i) == val.m_value.object->cend());
15207 o->write_character(
'\"');
15209 o->write_characters(
"\": ", 3);
15212 o->write_character(
'\n');
15213 o->write_characters(
indent_string.c_str(), current_indent);
15214 o->write_character(
'}');
15216 o->write_character(
'{');
15219 auto i = val.m_value.object->cbegin();
15220 for (std::size_t cnt = 0; cnt < val.m_value.object->size() - 1; ++cnt, ++
i) {
15221 o->write_character(
'\"');
15223 o->write_characters(
"\":", 2);
15225 o->write_character(
',');
15230 JSON_ASSERT(std::next(
i) == val.m_value.object->cend());
15231 o->write_character(
'\"');
15233 o->write_characters(
"\":", 2);
15236 o->write_character(
'}');
15243 if (val.m_value.array->empty()) {
15244 o->write_characters(
"[]", 2);
15248 if (pretty_print) {
15249 o->write_characters(
"[\n", 2);
15252 const auto new_indent = current_indent + indent_step;
15258 for (
auto i = val.m_value.array->cbegin();
i != val.m_value.array->cend() - 1; ++
i) {
15261 o->write_characters(
",\n", 2);
15267 dump(val.m_value.array->back(),
true,
ensure_ascii, indent_step, new_indent);
15269 o->write_character(
'\n');
15270 o->write_characters(
indent_string.c_str(), current_indent);
15271 o->write_character(
']');
15273 o->write_character(
'[');
15276 for (
auto i = val.m_value.array->cbegin();
i != val.m_value.array->cend() - 1; ++
i) {
15278 o->write_character(
',');
15283 dump(val.m_value.array->back(),
false,
ensure_ascii, indent_step, current_indent);
15285 o->write_character(
']');
15292 o->write_character(
'\"');
15294 o->write_character(
'\"');
15299 if (pretty_print) {
15300 o->write_characters(
"{\n", 2);
15303 const auto new_indent = current_indent + indent_step;
15310 o->write_characters(
"\"bytes\": [", 10);
15312 if (!val.m_value.binary->empty()) {
15313 for (
auto i = val.m_value.binary->cbegin();
i != val.m_value.binary->cend() - 1; ++
i) {
15315 o->write_characters(
", ", 2);
15317 dump_integer(val.m_value.binary->back());
15320 o->write_characters(
"],\n", 3);
15323 o->write_characters(
"\"subtype\": ", 11);
15324 if (val.m_value.binary->has_subtype()) {
15325 dump_integer(val.m_value.binary->subtype());
15327 o->write_characters(
"null", 4);
15329 o->write_character(
'\n');
15330 o->write_characters(
indent_string.c_str(), current_indent);
15331 o->write_character(
'}');
15333 o->write_characters(
"{\"bytes\":[", 10);
15335 if (!val.m_value.binary->empty()) {
15336 for (
auto i = val.m_value.binary->cbegin();
i != val.m_value.binary->cend() - 1; ++
i) {
15338 o->write_character(
',');
15340 dump_integer(val.m_value.binary->back());
15343 o->write_characters(
"],\"subtype\":", 12);
15344 if (val.m_value.binary->has_subtype()) {
15345 dump_integer(val.m_value.binary->subtype());
15346 o->write_character(
'}');
15348 o->write_characters(
"null}", 5);
15355 if (val.m_value.boolean) {
15356 o->write_characters(
"true", 4);
15358 o->write_characters(
"false", 5);
15364 dump_integer(val.m_value.number_integer);
15369 dump_integer(val.m_value.number_unsigned);
15374 dump_float(val.m_value.number_float);
15379 o->write_characters(
"<discarded>", 11);
15384 o->write_characters(
"null", 4);
15412 std::uint32_t codepoint{};
15420 for (std::size_t
i = 0;
i < s.size(); ++
i) {
15421 const auto byte =
static_cast<std::uint8_t
>(s[
i]);
15423 switch (decode(
state, codepoint,
byte)) {
15426 switch (codepoint) {
15479 if ((codepoint <= 0x1F) || (
ensure_ascii && (codepoint >= 0x7F))) {
15480 if (codepoint <= 0xFFFF) {
15483 static_cast<std::uint16_t
>(codepoint)));
15489 static_cast<std::uint16_t
>(0xD7C0u + (codepoint >> 10u)),
15490 static_cast<std::uint16_t
>(0xDC00u + (codepoint & 0x3FFu))));
15520 std::stringstream ss;
15521 ss << std::uppercase << std::setfill(
'0') << std::setw(2) << std::hex << (
byte | 0);
15523 316,
"invalid UTF-8 byte at index " + std::to_string(
i) +
": 0x" + ss.str(),
15606 std::stringstream ss;
15607 ss << std::uppercase << std::setfill(
'0') << std::setw(2) << std::hex
15608 << (
static_cast<std::uint8_t
>(s.back()) | 0);
15624 o->write_characters(
"\\ufffd", 6);
15626 o->write_characters(
"\xEF\xBF\xBD", 3);
15648 unsigned int n_digits = 1;
15654 return n_digits + 1;
15657 return n_digits + 2;
15660 return n_digits + 3;
15668 template<typename NumberType, enable_if_t<std::is_signed<NumberType>::value,
int> = 0>
15669 bool is_negative_number(NumberType x)
15674 template<typename NumberType, enable_if_t<std::is_unsigned<NumberType>::value,
int> = 0>
15675 bool is_negative_number(NumberType )
15690 typename NumberType,
15691 detail::enable_if_t<std::is_integral<NumberType>::value || std::is_same<NumberType, number_unsigned_t>::value
15692 || std::is_same<NumberType, number_integer_t>::value
15693 || std::is_same<NumberType, binary_char_t>::value,
15695 void dump_integer(NumberType x)
15697 static constexpr std::array<std::array<char, 2>, 100> digits_to_99{{
15698 {{
'0',
'0'}}, {{
'0',
'1'}}, {{
'0',
'2'}}, {{
'0',
'3'}}, {{
'0',
'4'}}, {{
'0',
'5'}}, {{
'0',
'6'}},
15699 {{
'0',
'7'}}, {{
'0',
'8'}}, {{
'0',
'9'}}, {{
'1',
'0'}}, {{
'1',
'1'}}, {{
'1',
'2'}}, {{
'1',
'3'}},
15700 {{
'1',
'4'}}, {{
'1',
'5'}}, {{
'1',
'6'}}, {{
'1',
'7'}}, {{
'1',
'8'}}, {{
'1',
'9'}}, {{
'2',
'0'}},
15701 {{
'2',
'1'}}, {{
'2',
'2'}}, {{
'2',
'3'}}, {{
'2',
'4'}}, {{
'2',
'5'}}, {{
'2',
'6'}}, {{
'2',
'7'}},
15702 {{
'2',
'8'}}, {{
'2',
'9'}}, {{
'3',
'0'}}, {{
'3',
'1'}}, {{
'3',
'2'}}, {{
'3',
'3'}}, {{
'3',
'4'}},
15703 {{
'3',
'5'}}, {{
'3',
'6'}}, {{
'3',
'7'}}, {{
'3',
'8'}}, {{
'3',
'9'}}, {{
'4',
'0'}}, {{
'4',
'1'}},
15704 {{
'4',
'2'}}, {{
'4',
'3'}}, {{
'4',
'4'}}, {{
'4',
'5'}}, {{
'4',
'6'}}, {{
'4',
'7'}}, {{
'4',
'8'}},
15705 {{
'4',
'9'}}, {{
'5',
'0'}}, {{
'5',
'1'}}, {{
'5',
'2'}}, {{
'5',
'3'}}, {{
'5',
'4'}}, {{
'5',
'5'}},
15706 {{
'5',
'6'}}, {{
'5',
'7'}}, {{
'5',
'8'}}, {{
'5',
'9'}}, {{
'6',
'0'}}, {{
'6',
'1'}}, {{
'6',
'2'}},
15707 {{
'6',
'3'}}, {{
'6',
'4'}}, {{
'6',
'5'}}, {{
'6',
'6'}}, {{
'6',
'7'}}, {{
'6',
'8'}}, {{
'6',
'9'}},
15708 {{
'7',
'0'}}, {{
'7',
'1'}}, {{
'7',
'2'}}, {{
'7',
'3'}}, {{
'7',
'4'}}, {{
'7',
'5'}}, {{
'7',
'6'}},
15709 {{
'7',
'7'}}, {{
'7',
'8'}}, {{
'7',
'9'}}, {{
'8',
'0'}}, {{
'8',
'1'}}, {{
'8',
'2'}}, {{
'8',
'3'}},
15710 {{
'8',
'4'}}, {{
'8',
'5'}}, {{
'8',
'6'}}, {{
'8',
'7'}}, {{
'8',
'8'}}, {{
'8',
'9'}}, {{
'9',
'0'}},
15711 {{
'9',
'1'}}, {{
'9',
'2'}}, {{
'9',
'3'}}, {{
'9',
'4'}}, {{
'9',
'5'}}, {{
'9',
'6'}}, {{
'9',
'7'}},
15712 {{
'9',
'8'}}, {{
'9',
'9'}},
15717 o->write_character(
'0');
15728 unsigned int n_chars{};
15730 if (is_negative_number(x)) {
15735 n_chars = 1 + count_digits(abs_value);
15738 n_chars = count_digits(abs_value);
15746 buffer_ptr += n_chars;
15750 while (abs_value >= 100) {
15751 const auto digits_index =
static_cast<unsigned>((abs_value % 100));
15753 *(--buffer_ptr) = digits_to_99[digits_index][1];
15754 *(--buffer_ptr) = digits_to_99[digits_index][0];
15757 if (abs_value >= 10) {
15758 const auto digits_index =
static_cast<unsigned>(abs_value);
15759 *(--buffer_ptr) = digits_to_99[digits_index][1];
15760 *(--buffer_ptr) = digits_to_99[digits_index][0];
15762 *(--buffer_ptr) =
static_cast<char>(
'0' + abs_value);
15765 o->write_characters(number_buffer.data(), n_chars);
15779 if (!std::isfinite(x)) {
15780 o->write_characters(
"null", 4);
15789 static constexpr bool is_ieee_single_or_double =
15790 (std::numeric_limits<number_float_t>::is_iec559 && std::numeric_limits<number_float_t>::digits == 24
15791 && std::numeric_limits<number_float_t>::max_exponent == 128)
15792 || (std::numeric_limits<number_float_t>::is_iec559 && std::numeric_limits<number_float_t>::digits == 53
15793 && std::numeric_limits<number_float_t>::max_exponent == 1024);
15795 dump_float(x, std::integral_constant<bool, is_ieee_single_or_double>());
15800 auto*
begin = number_buffer.data();
15803 o->write_characters(
begin,
static_cast<size_t>(
end -
begin));
15809 static constexpr auto d = std::numeric_limits<number_float_t>::max_digits10;
15813 std::ptrdiff_t len = (std::snprintf)(number_buffer.data(), number_buffer.size(),
"%.*g", d, x);
15818 JSON_ASSERT(
static_cast<std::size_t
>(len) < number_buffer.size());
15824 const auto end = std::remove(number_buffer.begin(), number_buffer.begin() + len,
thousands_sep);
15825 std::fill(
end, number_buffer.end(),
'\0');
15827 len = (
end - number_buffer.begin());
15834 const auto dec_pos = std::find(number_buffer.begin(), number_buffer.end(),
decimal_point);
15835 if (dec_pos != number_buffer.end()) {
15840 o->write_characters(number_buffer.data(),
static_cast<std::size_t
>(len));
15843 const bool value_is_int_like = std::none_of(number_buffer.begin(), number_buffer.begin() + len + 1,
15844 [](
char c) { return c ==
'.' || c ==
'e'; });
15846 if (value_is_int_like) {
15847 o->write_characters(
".0", 2);
15872 static std::uint8_t decode(std::uint8_t&
state, std::uint32_t& codep,
const std::uint8_t
byte)
noexcept
15874 static const std::array<std::uint8_t, 400> utf8d = {{
15875 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
15876 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
15877 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
15878 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
15879 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
15880 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
15881 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
15882 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
15883 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
15884 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,
15885 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
15886 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
15887 8, 8, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
15888 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
15889 0xA, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x4, 0x3, 0x3,
15890 0xB, 0x6, 0x6, 0x6, 0x5, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8,
15891 0x0, 0x1, 0x2, 0x3, 0x5, 0x8, 0x7, 0x1, 0x1, 0x1, 0x4, 0x6, 0x1, 0x1, 0x1, 0x1,
15892 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
15893 1, 0, 1, 1, 1, 1, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1,
15894 1, 2, 1, 1, 1, 1, 1, 2, 1, 2, 1, 1, 1, 1, 1, 1,
15895 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1,
15896 1, 2, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1,
15897 1, 1, 1, 1, 1, 1, 1, 3, 1, 3, 1, 1, 1, 1, 1, 1,
15898 1, 3, 1, 1, 1, 1, 1, 3, 1, 3, 1, 1, 1, 1, 1, 1,
15899 1, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
15903 const std::uint8_t type = utf8d[byte];
15905 codep = (
state !=
UTF8_ACCEPT) ? (
byte & 0x3fu) | (codep << 6u) : (0xFFu >> type) & (byte);
15907 std::size_t index = 256u +
static_cast<size_t>(
state) * 16u +
static_cast<size_t>(type);
15909 state = utf8d[index];
15935 JSON_ASSERT(x < 0 && x < (std::numeric_limits<number_integer_t>::max)());
15944 std::array<char, 64> number_buffer{{}};
15973#include <functional>
15974#include <initializer_list>
15977#include <stdexcept>
15978#include <type_traits>
15991 class IgnoredLess = std::less<Key>,
15992 class Allocator = std::allocator<std::pair<const Key, T>>>
15993struct ordered_map : std::vector<std::pair<const Key, T>, Allocator>
15995 using key_type = Key;
16016 std::pair<iterator, bool>
emplace(
const key_type& key, T&& t)
16018 for (
auto it = this->
begin(); it != this->
end(); ++it) {
16019 if (it->first == key) {
16020 return {it,
false};
16023 Container::emplace_back(key, t);
16024 return {--this->
end(),
true};
16029 const T&
operator[](
const Key& key)
const {
return at(key); }
16033 for (
auto it = this->
begin(); it != this->
end(); ++it) {
16034 if (it->first == key) {
16039 JSON_THROW(std::out_of_range(
"key not found"));
16042 const T&
at(
const Key& key)
const
16044 for (
auto it = this->
begin(); it != this->
end(); ++it) {
16045 if (it->first == key) {
16050 JSON_THROW(std::out_of_range(
"key not found"));
16055 for (
auto it = this->
begin(); it != this->
end(); ++it) {
16056 if (it->first == key) {
16058 for (
auto next = it; ++next != this->
end(); ++it) {
16062 Container::pop_back();
16073 const auto elements_affected = std::distance(first, last);
16074 const auto offset = std::distance(Container::begin(), first);
16096 for (
auto it = first; std::next(it, elements_affected) != Container::end(); ++it) {
16098 new (&*it)
value_type{std::move(*std::next(it, elements_affected))};
16106 Container::resize(this->size() -
static_cast<size_type>(elements_affected));
16115 return Container::begin() + offset;
16120 for (
auto it = this->
begin(); it != this->
end(); ++it) {
16121 if (it->first == key) {
16130 for (
auto it = this->
begin(); it != this->
end(); ++it) {
16131 if (it->first == key) {
16135 return Container::end();
16138 const_iterator
find(
const Key& key)
const
16140 for (
auto it = this->
begin(); it != this->
end(); ++it) {
16141 if (it->first == key) {
16145 return Container::end();
16152 for (
auto it = this->
begin(); it != this->
end(); ++it) {
16153 if (it->first == value.first) {
16154 return {it,
false};
16157 Container::push_back(value);
16158 return {--this->
end(),
true};
16161 template<
typename InputIt>
16163 typename std::enable_if<std::is_convertible<typename std::iterator_traits<InputIt>::iterator_category,
16164 std::input_iterator_tag>::value>::type;
16166 template<
typename InputIt,
typename = require_input_iter<InputIt>>
16169 for (
auto it = first; it != last; ++it) {
16177#if defined(JSON_HAS_CPP_17)
16178#include <string_view>
16211 template<detail::value_t>
16213 friend ::nlohmann::json_pointer<basic_json>;
16215 template<
typename BasicJsonType,
typename InputType>
16216 friend class ::nlohmann::detail::parser;
16217 friend ::nlohmann::detail::serializer<basic_json>;
16218 template<
typename BasicJsonType>
16219 friend class ::nlohmann::detail::iter_impl;
16220 template<
typename BasicJsonType,
typename CharType>
16221 friend class ::nlohmann::detail::binary_writer;
16222 template<
typename BasicJsonType,
typename InputType,
typename SAX>
16223 friend class ::nlohmann::detail::binary_reader;
16224 template<
typename BasicJsonType>
16225 friend class ::nlohmann::detail::json_sax_dom_parser;
16226 template<
typename BasicJsonType>
16227 friend class ::nlohmann::detail::json_sax_dom_callback_parser;
16228 friend class ::nlohmann::detail::exception;
16238 template<
typename InputAdapterType>
16239 static ::nlohmann::detail::parser<basic_json, InputAdapterType>
parser(
16240 InputAdapterType adapter,
16242 const bool allow_exceptions =
true,
16243 const bool ignore_comments =
false)
16245 return ::nlohmann::detail::parser<basic_json, InputAdapterType>(std::move(adapter), std::move(cb),
16246 allow_exceptions, ignore_comments);
16251 template<
typename BasicJsonType>
16253 template<
typename BasicJsonType>
16255 template<
typename Iterator>
16257 template<
typename Base>
16260 template<
typename CharType>
16263 template<
typename InputType>
16265 template<
typename CharType>
16274 template<
typename T,
typename SFINAE>
16330 using pointer =
typename std::allocator_traits<allocator_type>::pointer;
16332 using const_pointer =
typename std::allocator_traits<allocator_type>::const_pointer;
16356 result[
"copyright"] =
"(C) 2013-2022 Niels Lohmann";
16357 result[
"name"] =
"JSON for Modern C++";
16358 result[
"url"] =
"https://github.com/nlohmann/json";
16367 result[
"platform"] =
"win32";
16368#elif defined __linux__
16369 result[
"platform"] =
"linux";
16370#elif defined __APPLE__
16371 result[
"platform"] =
"apple";
16372#elif defined __unix__
16373 result[
"platform"] =
"unix";
16375 result[
"platform"] =
"unknown";
16378#if defined(__ICC) || defined(__INTEL_COMPILER)
16379 result[
"compiler"] = {{
"family",
"icc"}, {
"version", __INTEL_COMPILER}};
16380#elif defined(__clang__)
16381 result[
"compiler"] = {{
"family",
"clang"}, {
"version", __clang_version__}};
16382#elif defined(__GNUC__) || defined(__GNUG__)
16383 result[
"compiler"] = {{
"family",
"gcc"},
16384 {
"version", std::to_string(__GNUC__) +
"." + std::to_string(__GNUC_MINOR__) +
"."
16385 + std::to_string(__GNUC_PATCHLEVEL__)}};
16386#elif defined(__HP_cc) || defined(__HP_aCC)
16387 result[
"compiler"] =
"hp"
16388#elif defined(__IBMCPP__)
16389 result[
"compiler"] = {{
"family",
"ilecpp"}, {
"version", __IBMCPP__}};
16390#elif defined(_MSC_VER)
16391 result[
"compiler"] = {{
"family",
"msvc"}, {
"version", _MSC_VER}};
16392#elif defined(__PGI)
16393 result[
"compiler"] = {{
"family",
"pgcpp"}, {
"version", __PGI}};
16394#elif defined(__SUNPRO_CC)
16395 result[
"compiler"] = {{
"family",
"sunpro"}, {
"version", __SUNPRO_CC}};
16397 result[
"compiler"] = {{
"family",
"unknown"}, {
"version",
"unknown"}};
16401 result[
"compiler"][
"c++"] = std::to_string(__cplusplus);
16403 result[
"compiler"][
"c++"] =
"unknown";
16419#if defined(JSON_HAS_CPP_14)
16430 ObjectType<StringType, basic_json, object_comparator_t, AllocatorType<std::pair<const StringType, basic_json>>>;
16434 using array_t = ArrayType<basic_json, AllocatorType<basic_json>>;
16442 using boolean_t = BooleanType;
16446 using number_integer_t = NumberIntegerType;
16450 using number_unsigned_t = NumberUnsignedType;
16454 using number_float_t = NumberFloatType;
16464 template<
typename T,
typename... Args>
16467 AllocatorType<T> alloc;
16468 using AllocatorTraits = std::allocator_traits<AllocatorType<T>>;
16470 auto deleter = [&](T* obj) { AllocatorTraits::deallocate(alloc, obj, 1); };
16471 std::unique_ptr<T,
decltype(deleter)> obj(AllocatorTraits::allocate(alloc, 1), deleter);
16472 AllocatorTraits::construct(alloc, obj.get(), std::forward<Args>(args)...);
16474 return obj.release();
16520 number_integer_t number_integer;
16522 number_unsigned_t number_unsigned;
16524 number_float_t number_float;
16534 : number_integer(
v)
16538 : number_unsigned(
v)
16548 case value_t::object: {
16553 case value_t::array: {
16558 case value_t::string: {
16563 case value_t::binary: {
16568 case value_t::boolean: {
16569 boolean =
static_cast<boolean_t
>(
false);
16573 case value_t::number_integer: {
16574 number_integer =
static_cast<number_integer_t
>(0);
16578 case value_t::number_unsigned: {
16579 number_unsigned =
static_cast<number_unsigned_t
>(0);
16583 case value_t::number_float: {
16584 number_float =
static_cast<number_float_t
>(0.0);
16588 case value_t::null: {
16593 case value_t::discarded:
16657 if (t == value_t::array || t == value_t::object) {
16659 std::vector<basic_json> stack;
16662 if (t == value_t::array) {
16663 stack.reserve(
array->size());
16664 std::move(
array->begin(),
array->end(), std::back_inserter(stack));
16666 stack.reserve(
object->size());
16667 for (
auto&& it : *
object) {
16668 stack.push_back(std::move(it.second));
16672 while (!stack.empty()) {
16674 basic_json current_item(std::move(stack.back()));
16679 if (current_item.is_array()) {
16681 std::back_inserter(stack));
16684 }
else if (current_item.is_object()) {
16685 for (
auto&& it : *current_item.
m_value.object) {
16686 stack.push_back(std::move(it.second));
16689 current_item.
m_value.object->clear();
16698 case value_t::object: {
16699 AllocatorType<object_t> alloc;
16700 std::allocator_traits<
decltype(alloc)>
::destroy(alloc,
object);
16701 std::allocator_traits<
decltype(alloc)>::deallocate(alloc,
object, 1);
16705 case value_t::array: {
16706 AllocatorType<array_t> alloc;
16708 std::allocator_traits<
decltype(alloc)>::deallocate(alloc,
array, 1);
16712 case value_t::string: {
16713 AllocatorType<string_t> alloc;
16714 std::allocator_traits<
decltype(alloc)>
::destroy(alloc,
string);
16715 std::allocator_traits<
decltype(alloc)>::deallocate(alloc,
string, 1);
16719 case value_t::binary: {
16720 AllocatorType<binary_t> alloc;
16722 std::allocator_traits<
decltype(alloc)>::deallocate(alloc,
binary, 1);
16726 case value_t::null:
16727 case value_t::boolean:
16728 case value_t::number_integer:
16729 case value_t::number_unsigned:
16730 case value_t::number_float:
16731 case value_t::discarded:
16765#if JSON_DIAGNOSTICS
16770 || std::all_of(
begin(),
end(), [
this](
const basic_json& j) {
return j.m_parent ==
this; }));
16774 static_cast<void>(check_parents);
16779#if JSON_DIAGNOSTICS
16781 case value_t::array: {
16782 for (
auto& element : *
m_value.array) {
16783 element.m_parent =
this;
16788 case value_t::object: {
16789 for (
auto& element : *
m_value.object) {
16790 element.second.m_parent =
this;
16795 case value_t::null:
16796 case value_t::string:
16797 case value_t::boolean:
16798 case value_t::number_integer:
16799 case value_t::number_unsigned:
16800 case value_t::number_float:
16801 case value_t::binary:
16802 case value_t::discarded:
16811#if JSON_DIAGNOSTICS
16813 (it +
i)->m_parent =
this;
16816 static_cast<void>(count_set_parents);
16823#if JSON_DIAGNOSTICS
16824 if (old_capacity !=
static_cast<std::size_t
>(-1)) {
16836#ifdef JSON_HEDLEY_MSVC_VERSION
16837#pragma warning(push)
16838#pragma warning(disable : 4127)
16844#ifdef JSON_HEDLEY_MSVC_VERSION
16845#pragma warning(pop)
16850 static_cast<void>(j);
16851 static_cast<void>(old_capacity);
16889 basic_json(std::nullptr_t =
nullptr) noexcept
16897 template<
typename CompatibleType,
16899 detail::enable_if_t<!detail::is_basic_json<U>::value && detail::is_compatible_type<basic_json_t, U>::value,
16903 JSONSerializer<U>::to_json(std::declval<basic_json_t&>(), std::forward<CompatibleType>(val))))
16905 JSONSerializer<U>::to_json(*
this, std::forward<CompatibleType>(val));
16913 detail::enable_if_t<detail::is_basic_json<BasicJsonType>::value
16914 && !std::is_same<basic_json, BasicJsonType>::value,
16918 using other_boolean_t =
typename BasicJsonType::boolean_t;
16919 using other_number_float_t =
typename BasicJsonType::number_float_t;
16920 using other_number_integer_t =
typename BasicJsonType::number_integer_t;
16921 using other_number_unsigned_t =
typename BasicJsonType::number_unsigned_t;
16922 using other_string_t =
typename BasicJsonType::string_t;
16923 using other_object_t =
typename BasicJsonType::object_t;
16924 using other_array_t =
typename BasicJsonType::array_t;
16925 using other_binary_t =
typename BasicJsonType::binary_t;
16927 switch (val.type()) {
16928 case value_t::boolean:
16929 JSONSerializer<other_boolean_t>::to_json(*
this, val.template get<other_boolean_t>());
16931 case value_t::number_float:
16932 JSONSerializer<other_number_float_t>::to_json(*
this, val.template get<other_number_float_t>());
16934 case value_t::number_integer:
16935 JSONSerializer<other_number_integer_t>::to_json(*
this, val.template get<other_number_integer_t>());
16937 case value_t::number_unsigned:
16938 JSONSerializer<other_number_unsigned_t>::to_json(*
this, val.template get<other_number_unsigned_t>());
16940 case value_t::string:
16941 JSONSerializer<other_string_t>::to_json(*
this, val.template get_ref<const other_string_t&>());
16943 case value_t::object:
16944 JSONSerializer<other_object_t>::to_json(*
this, val.template get_ref<const other_object_t&>());
16946 case value_t::array:
16947 JSONSerializer<other_array_t>::to_json(*
this, val.template get_ref<const other_array_t&>());
16949 case value_t::binary:
16950 JSONSerializer<other_binary_t>::to_json(*
this, val.template get_ref<const other_binary_t&>());
16952 case value_t::null:
16955 case value_t::discarded:
16956 m_type = value_t::discarded;
16971 bool is_an_object = std::all_of(init.begin(), init.end(), [](
const detail::json_ref<basic_json>& element_ref) {
16972 return element_ref->is_array() && element_ref->size() == 2 && (*element_ref)[0].is_string();
16976 if (!type_deduction) {
16978 if (manual_type == value_t::array) {
16979 is_an_object =
false;
16988 if (is_an_object) {
16990 m_type = value_t::object;
16993 for (
auto& element_ref : init) {
16994 auto element = element_ref.moved_or_copied();
16995 m_value.object->emplace(std::move(*((*element.m_value.array)[0].m_value.string)),
16996 std::move((*element.m_value.array)[1]));
17000 m_type = value_t::array;
17014 res.m_type = value_t::binary;
17015 res.m_value = init;
17022 static basic_json binary(
const typename binary_t::container_type& init,
typename binary_t::subtype_type subtype)
17025 res.m_type = value_t::binary;
17026 res.m_value = binary_t(init, subtype);
17036 res.m_type = value_t::binary;
17037 res.m_value = std::move(init);
17044 static basic_json binary(
typename binary_t::container_type&& init,
typename binary_t::subtype_type subtype)
17047 res.m_type = value_t::binary;
17048 res.m_value = binary_t(std::move(init), subtype);
17074 template<
class InputIT,
17075 typename std::enable_if<std::is_same<InputIT, typename basic_json_t::iterator>::value
17076 || std::is_same<InputIT, typename basic_json_t::const_iterator>::value,
17089 m_type = first.m_object->m_type;
17093 case value_t::boolean:
17094 case value_t::number_float:
17095 case value_t::number_integer:
17096 case value_t::number_unsigned:
17097 case value_t::string: {
17099 || !last.m_it.primitive_iterator.is_end()))
17106 case value_t::null:
17107 case value_t::object:
17108 case value_t::array:
17109 case value_t::binary:
17110 case value_t::discarded:
17116 case value_t::number_integer: {
17117 m_value.number_integer = first.m_object->m_value.number_integer;
17121 case value_t::number_unsigned: {
17122 m_value.number_unsigned = first.m_object->m_value.number_unsigned;
17126 case value_t::number_float: {
17127 m_value.number_float = first.m_object->m_value.number_float;
17131 case value_t::boolean: {
17132 m_value.boolean = first.m_object->m_value.boolean;
17136 case value_t::string: {
17137 m_value = *first.m_object->m_value.string;
17141 case value_t::object: {
17146 case value_t::array: {
17151 case value_t::binary: {
17152 m_value = *first.m_object->m_value.binary;
17156 case value_t::null:
17157 case value_t::discarded:
17160 206,
"cannot construct with iterators from " + std::string(first.m_object->type_name()),
17172 template<
typename JsonRef,
17174 std::is_same<typename JsonRef::value_type, basic_json>>::value,
17183 : m_type(other.m_type)
17186 other.assert_invariant();
17189 case value_t::object: {
17190 m_value = *other.m_value.object;
17194 case value_t::array: {
17195 m_value = *other.m_value.array;
17199 case value_t::string: {
17200 m_value = *other.m_value.string;
17204 case value_t::boolean: {
17205 m_value = other.m_value.boolean;
17209 case value_t::number_integer: {
17210 m_value = other.m_value.number_integer;
17214 case value_t::number_unsigned: {
17215 m_value = other.m_value.number_unsigned;
17219 case value_t::number_float: {
17220 m_value = other.m_value.number_float;
17224 case value_t::binary: {
17225 m_value = *other.m_value.binary;
17229 case value_t::null:
17230 case value_t::discarded:
17242 : m_type(std::move(other.m_type))
17243 ,
m_value(std::move(other.m_value))
17249 other.m_type = value_t::null;
17250 other.m_value = {};
17259 && std::is_nothrow_move_assignable<value_t>::value
17260 && std::is_nothrow_move_constructible<json_value>::value
17261 && std::is_nothrow_move_assignable<json_value>::value)
17264 other.assert_invariant();
17267 swap(m_type, other.m_type);
17296 string_t dump(
const int indent = -1,
17297 const char indent_char =
' ',
17298 const bool ensure_ascii =
false,
17302 serializer s(detail::output_adapter<char, string_t>(
result), indent_char, error_handler);
17305 s.dump(*
this,
true, ensure_ascii,
static_cast<unsigned int>(indent));
17307 s.dump(*
this,
false, ensure_ascii, 0);
17315 constexpr value_t type() const noexcept {
return m_type; }
17319 constexpr bool is_primitive() const noexcept
17321 return is_null() || is_string() || is_boolean() || is_number() || is_binary();
17326 constexpr bool is_structured() const noexcept {
return is_array() || is_object(); }
17330 constexpr bool is_null() const noexcept {
return m_type == value_t::null; }
17334 constexpr bool is_boolean() const noexcept {
return m_type == value_t::boolean; }
17338 constexpr bool is_number() const noexcept {
return is_number_integer() || is_number_float(); }
17342 constexpr bool is_number_integer() const noexcept
17344 return m_type == value_t::number_integer || m_type == value_t::number_unsigned;
17349 constexpr bool is_number_unsigned() const noexcept {
return m_type == value_t::number_unsigned; }
17353 constexpr bool is_number_float() const noexcept {
return m_type == value_t::number_float; }
17357 constexpr bool is_object() const noexcept {
return m_type == value_t::object; }
17361 constexpr bool is_array() const noexcept {
return m_type == value_t::array; }
17365 constexpr bool is_string() const noexcept {
return m_type == value_t::string; }
17369 constexpr bool is_binary() const noexcept {
return m_type == value_t::binary; }
17373 constexpr bool is_discarded() const noexcept {
return m_type == value_t::discarded; }
17377 constexpr operator value_t() const noexcept {
return m_type; }
17387 boolean_t get_impl(boolean_t* )
const
17397 object_t* get_impl_ptr(object_t* )
noexcept {
return is_object() ?
m_value.object :
nullptr; }
17400 constexpr const object_t* get_impl_ptr(
const object_t* )
const noexcept
17402 return is_object() ?
m_value.object :
nullptr;
17406 array_t* get_impl_ptr(array_t* )
noexcept {
return is_array() ?
m_value.array :
nullptr; }
17409 constexpr const array_t* get_impl_ptr(
const array_t* )
const noexcept
17411 return is_array() ?
m_value.array :
nullptr;
17415 string_t* get_impl_ptr(string_t* )
noexcept {
return is_string() ?
m_value.string :
nullptr; }
17418 constexpr const string_t* get_impl_ptr(
const string_t* )
const noexcept
17420 return is_string() ?
m_value.string :
nullptr;
17424 boolean_t* get_impl_ptr(boolean_t* )
noexcept {
return is_boolean() ? &
m_value.boolean :
nullptr; }
17427 constexpr const boolean_t* get_impl_ptr(
const boolean_t* )
const noexcept
17429 return is_boolean() ? &
m_value.boolean :
nullptr;
17433 number_integer_t* get_impl_ptr(number_integer_t* )
noexcept
17435 return is_number_integer() ? &
m_value.number_integer :
nullptr;
17439 constexpr const number_integer_t* get_impl_ptr(
const number_integer_t* )
const noexcept
17441 return is_number_integer() ? &
m_value.number_integer :
nullptr;
17445 number_unsigned_t* get_impl_ptr(number_unsigned_t* )
noexcept
17447 return is_number_unsigned() ? &
m_value.number_unsigned :
nullptr;
17451 constexpr const number_unsigned_t* get_impl_ptr(
const number_unsigned_t* )
const noexcept
17453 return is_number_unsigned() ? &
m_value.number_unsigned :
nullptr;
17457 number_float_t* get_impl_ptr(number_float_t* )
noexcept
17459 return is_number_float() ? &
m_value.number_float :
nullptr;
17463 constexpr const number_float_t* get_impl_ptr(
const number_float_t* )
const noexcept
17465 return is_number_float() ? &
m_value.number_float :
nullptr;
17469 binary_t* get_impl_ptr(binary_t* )
noexcept {
return is_binary() ?
m_value.binary :
nullptr; }
17472 constexpr const binary_t* get_impl_ptr(
const binary_t* )
const noexcept
17474 return is_binary() ?
m_value.binary :
nullptr;
17488 template<
typename ReferenceType,
typename ThisType>
17489 static ReferenceType get_ref_impl(ThisType& obj)
17492 auto* ptr = obj.template get_ptr<typename std::add_pointer<ReferenceType>::type>();
17499 303,
"incompatible ReferenceType for get_ref, actual type is " + std::string(obj.type_name()), obj));
17509 template<typename PointerType, typename std::enable_if<std::is_pointer<PointerType>::value,
int>
::type = 0>
17510 auto get_ptr() noexcept -> decltype(std::declval<
basic_json_t&>().get_impl_ptr(std::declval<PointerType>()))
17513 return get_impl_ptr(
static_cast<PointerType
>(
nullptr));
17518 template<
typename PointerType,
17519 typename std::enable_if<std::is_pointer<PointerType>::value
17520 && std::is_const<typename std::remove_pointer<PointerType>::type>::value,
17522 constexpr auto get_ptr() const noexcept
17523 -> decltype(std::declval<const
basic_json_t&>().get_impl_ptr(std::declval<PointerType>()))
17526 return get_impl_ptr(
static_cast<PointerType
>(
nullptr));
17568 template<
typename ValueType,
17569 detail::enable_if_t<detail::is_default_constructible<ValueType>::value
17570 && detail::has_from_json<basic_json_t, ValueType>::value,
17572 ValueType get_impl(detail::priority_tag<0> )
const
17573 noexcept(
noexcept(JSONSerializer<ValueType>::from_json(std::declval<const basic_json_t&>(),
17574 std::declval<ValueType&>())))
17576 auto ret = ValueType();
17577 JSONSerializer<ValueType>::from_json(*
this, ret);
17611 template<
typename ValueType,
17612 detail::enable_if_t<detail::has_non_default_from_json<basic_json_t, ValueType>::value,
int> = 0>
17613 ValueType get_impl(detail::priority_tag<1> )
const
17614 noexcept(
noexcept(JSONSerializer<ValueType>::from_json(std::declval<const basic_json_t&>())))
17616 return JSONSerializer<ValueType>::from_json(*
this);
17634 template<typename BasicJsonType, detail::enable_if_t<detail::is_basic_json<BasicJsonType>::value,
int> = 0>
17654 template<typename BasicJsonType, detail::enable_if_t<std::is_same<BasicJsonType, basic_json_t>::value,
int> = 0>
17655 basic_json get_impl(detail::priority_tag<3> )
const
17664 template<typename PointerType, detail::enable_if_t<std::is_pointer<PointerType>::value,
int> = 0>
17665 constexpr auto get_impl(detail::priority_tag<4> )
const noexcept
17666 ->
decltype(std::declval<const basic_json_t&>().template get_ptr<PointerType>())
17669 return get_ptr<PointerType>();
17696 template<
typename ValueTypeCV,
typename ValueType = detail::uncvref_t<ValueTypeCV>>
17697#if defined(JSON_HAS_CPP_14)
17702 noexcept(noexcept(std::declval<const
basic_json_t&>().template get_impl<ValueType>(detail::priority_tag<4>{})))
17703 ->
decltype(std::declval<const basic_json_t&>().template get_impl<ValueType>(detail::priority_tag<4>{}))
17708 static_assert(!std::is_reference<ValueTypeCV>::value,
17709 "get() cannot be used with reference types, you might want to use get_ref()");
17710 return get_impl<ValueType>(detail::priority_tag<4>{});
17740 template<typename PointerType, typename std::enable_if<std::is_pointer<PointerType>::value,
int>
::type = 0>
17741 auto get() noexcept -> decltype(std::declval<
basic_json_t&>().template get_ptr<PointerType>())
17744 return get_ptr<PointerType>();
17749 template<
typename ValueType,
17750 detail::enable_if_t<!detail::is_basic_json<ValueType>::value
17751 && detail::has_from_json<basic_json_t, ValueType>::value,
17753 ValueType& get_to(ValueType&
v)
const
17754 noexcept(
noexcept(JSONSerializer<ValueType>::from_json(std::declval<const basic_json_t&>(),
v)))
17756 JSONSerializer<ValueType>::from_json(*
this,
v);
17762 template<typename ValueType, detail::enable_if_t<detail::is_basic_json<ValueType>::value,
int> = 0>
17763 ValueType& get_to(ValueType&
v)
const
17769 template<
typename T,
17773 detail::enable_if_t<detail::has_from_json<basic_json_t, Array>::value,
int> = 0>
17776 noexcept(
noexcept(JSONSerializer<Array>::from_json(std::declval<const basic_json_t&>(),
v)))
17778 JSONSerializer<Array>::from_json(*
this,
v);
17784 template<typename ReferenceType, typename std::enable_if<std::is_reference<ReferenceType>::value,
int>
::type = 0>
17785 ReferenceType get_ref()
17788 return get_ref_impl<ReferenceType>(*
this);
17793 template<
typename ReferenceType,
17794 typename std::enable_if<std::is_reference<ReferenceType>::value
17795 && std::is_const<typename std::remove_reference<ReferenceType>::type>::value,
17797 ReferenceType get_ref()
const
17800 return get_ref_impl<ReferenceType>(*
this);
17832 template<
typename ValueType,
17833 typename std::enable_if<
17834 detail::conjunction<
17835 detail::negation<std::is_pointer<ValueType>>,
17836 detail::negation<std::is_same<ValueType, detail::json_ref<basic_json>>>,
17837 detail::negation<std::is_same<ValueType, typename string_t::value_type>>,
17838 detail::negation<detail::is_basic_json<ValueType>>,
17839 detail::negation<std::is_same<ValueType, std::initializer_list<typename string_t::value_type>>>,
17841#if defined(JSON_HAS_CPP_17) && (defined(__GNUC__) || (defined(_MSC_VER) && _MSC_VER >= 1910 && _MSC_VER <= 1914))
17842 detail::negation<std::is_same<ValueType, std::string_view>>,
17844 detail::is_detected_lazy<detail::get_template_function, const basic_json_t&, ValueType>>::value,
17849 return get<ValueType>();
17854 binary_t& get_binary()
17856 if (!is_binary()) {
17860 return *get_ptr<binary_t*>();
17865 const binary_t& get_binary()
const
17867 if (!is_binary()) {
17871 return *get_ptr<const binary_t*>();
17912 return m_value.array->at(idx);
17926 reference at(
const typename object_t::key_type& key)
17952 return m_value.object->at(key);
17970 m_type = value_t::array;
17978 if (idx >=
m_value.array->size()) {
17979#if JSON_DIAGNOSTICS
17981 const auto old_size =
m_value.array->size();
17982 const auto old_capacity =
m_value.array->capacity();
17984 m_value.array->resize(idx + 1);
17986#if JSON_DIAGNOSTICS
17999 return m_value.array->operator[](idx);
18003 305,
"cannot use operator[] with a numeric argument with " + std::string(type_name()), *
this));
18012 return m_value.array->operator[](idx);
18016 305,
"cannot use operator[] with a numeric argument with " + std::string(type_name()), *
this));
18025 m_type = value_t::object;
18036 305,
"cannot use operator[] with a string argument with " + std::string(type_name()), *
this));
18046 return m_value.object->find(key)->second;
18050 305,
"cannot use operator[] with a string argument with " + std::string(type_name()), *
this));
18055 template<
typename T>
18061 m_type = value_t::object;
18072 305,
"cannot use operator[] with a string argument with " + std::string(type_name()), *
this));
18077 template<
typename T>
18084 return m_value.object->find(key)->second;
18088 305,
"cannot use operator[] with a string argument with " + std::string(type_name()), *
this));
18094 template<
class ValueType,
18095 typename std::enable_if<detail::is_getable<basic_json_t, ValueType>::value
18096 && !std::is_same<value_t, ValueType>::value,
18098 ValueType
value(
const typename object_t::key_type& key,
const ValueType& default_value)
const
18103 const auto it =
find(key);
18105 return it->template get<ValueType>();
18108 return default_value;
18117 string_t
value(
const typename object_t::key_type& key,
const char* default_value)
const
18119 return value(key, string_t(default_value));
18124 template<
class ValueType,
18125 typename std::enable_if<detail::is_getable<basic_json_t, ValueType>::value,
int>
::type = 0>
18133 return ptr.get_checked(
this).template get<ValueType>();
18137 return default_value;
18148 string_t value(const
json_pointer& ptr, const
char* default_value)
const
18150 return value(ptr, string_t(default_value));
18181 template<
class IteratorType,
18182 typename std::enable_if<std::is_same<IteratorType, typename basic_json_t::iterator>::value
18183 || std::is_same<IteratorType, typename basic_json_t::const_iterator>::value,
18185 IteratorType
erase(IteratorType pos)
18195 case value_t::boolean:
18196 case value_t::number_float:
18197 case value_t::number_integer:
18198 case value_t::number_unsigned:
18199 case value_t::string:
18200 case value_t::binary: {
18206 AllocatorType<string_t> alloc;
18208 std::allocator_traits<
decltype(alloc)>::deallocate(alloc,
m_value.string, 1);
18210 }
else if (is_binary()) {
18211 AllocatorType<binary_t> alloc;
18213 std::allocator_traits<
decltype(alloc)>::deallocate(alloc,
m_value.binary, 1);
18217 m_type = value_t::null;
18222 case value_t::object: {
18223 result.m_it.object_iterator =
m_value.object->erase(pos.m_it.object_iterator);
18227 case value_t::array: {
18228 result.m_it.array_iterator =
m_value.array->erase(pos.m_it.array_iterator);
18232 case value_t::null:
18233 case value_t::discarded:
18243 template<
class IteratorType,
18244 typename std::enable_if<std::is_same<IteratorType, typename basic_json_t::iterator>::value
18245 || std::is_same<IteratorType, typename basic_json_t::const_iterator>::value,
18247 IteratorType
erase(IteratorType first, IteratorType last)
18257 case value_t::boolean:
18258 case value_t::number_float:
18259 case value_t::number_integer:
18260 case value_t::number_unsigned:
18261 case value_t::string:
18262 case value_t::binary: {
18264 || !last.m_it.primitive_iterator.is_end()))
18270 AllocatorType<string_t> alloc;
18272 std::allocator_traits<
decltype(alloc)>::deallocate(alloc,
m_value.string, 1);
18274 }
else if (is_binary()) {
18275 AllocatorType<binary_t> alloc;
18277 std::allocator_traits<
decltype(alloc)>::deallocate(alloc,
m_value.binary, 1);
18281 m_type = value_t::null;
18286 case value_t::object: {
18287 result.m_it.object_iterator =
18288 m_value.object->erase(first.m_it.object_iterator, last.m_it.object_iterator);
18292 case value_t::array: {
18293 result.m_it.array_iterator =
m_value.array->erase(first.m_it.array_iterator, last.m_it.array_iterator);
18297 case value_t::null:
18298 case value_t::discarded:
18312 return m_value.object->erase(key);
18345 template<
typename KeyT>
18351 result.m_it.object_iterator =
m_value.object->find(std::forward<KeyT>(key));
18359 template<
typename KeyT>
18365 result.m_it.object_iterator =
m_value.object->find(std::forward<KeyT>(key));
18373 template<
typename KeyT>
18377 return is_object() ?
m_value.object->count(std::forward<KeyT>(key)) : 0;
18384 typename std::enable_if<!std::is_same<typename std::decay<KeyT>::type,
json_pointer>::value,
int>
::type = 0>
18387 return is_object() &&
m_value.object->find(std::forward<KeyT>(key)) !=
m_value.object->end();
18507 bool empty() const noexcept
18510 case value_t::null: {
18515 case value_t::array: {
18517 return m_value.array->empty();
18520 case value_t::object: {
18522 return m_value.object->empty();
18525 case value_t::string:
18526 case value_t::boolean:
18527 case value_t::number_integer:
18528 case value_t::number_unsigned:
18529 case value_t::number_float:
18530 case value_t::binary:
18531 case value_t::discarded:
18544 case value_t::null: {
18549 case value_t::array: {
18551 return m_value.array->size();
18554 case value_t::object: {
18556 return m_value.object->size();
18559 case value_t::string:
18560 case value_t::boolean:
18561 case value_t::number_integer:
18562 case value_t::number_unsigned:
18563 case value_t::number_float:
18564 case value_t::binary:
18565 case value_t::discarded:
18578 case value_t::array: {
18580 return m_value.array->max_size();
18583 case value_t::object: {
18585 return m_value.object->max_size();
18588 case value_t::null:
18589 case value_t::string:
18590 case value_t::boolean:
18591 case value_t::number_integer:
18592 case value_t::number_unsigned:
18593 case value_t::number_float:
18594 case value_t::binary:
18595 case value_t::discarded:
18614 void clear() noexcept
18617 case value_t::number_integer: {
18622 case value_t::number_unsigned: {
18627 case value_t::number_float: {
18632 case value_t::boolean: {
18637 case value_t::string: {
18642 case value_t::binary: {
18647 case value_t::array: {
18652 case value_t::object: {
18657 case value_t::null:
18658 case value_t::discarded:
18675 m_type = value_t::array;
18681 const auto old_capacity =
m_value.array->capacity();
18682 m_value.array->push_back(std::move(val));
18691 push_back(std::move(val));
18706 m_type = value_t::array;
18712 const auto old_capacity =
m_value.array->capacity();
18713 m_value.array->push_back(val);
18727 void push_back(
const typename object_t::value_type& val)
18736 m_type = value_t::object;
18758 if (is_object() && init.size() == 2 && (*init.begin())->is_string()) {
18760 push_back(
typename object_t::value_type(std::move(
key.get_ref<string_t&>()),
18761 (init.begin() + 1)->moved_or_copied()));
18777 template<
class... Args>
18787 m_type = value_t::array;
18793 const auto old_capacity =
m_value.array->capacity();
18794 m_value.array->emplace_back(std::forward<Args>(args)...);
18800 template<
class... Args>
18801 std::pair<iterator, bool>
emplace(Args&&... args)
18810 m_type = value_t::object;
18816 auto res =
m_value.object->emplace(std::forward<Args>(args)...);
18821 it.m_it.object_iterator =
res.first;
18824 return {it,
res.second};
18830 template<
typename... Args>
18836 auto insert_pos = std::distance(
m_value.array->begin(), pos.m_it.array_iterator);
18837 m_value.array->insert(pos.m_it.array_iterator, std::forward<Args>(args)...);
18838 result.m_it.array_iterator =
m_value.array->begin() + insert_pos;
18860 return insert_iterator(pos, val);
18882 return insert_iterator(pos, cnt, val);
18912 return insert_iterator(pos, first.m_it.array_iterator, last.m_it.array_iterator);
18930 return insert_iterator(pos, ilist.begin(), ilist.end());
18952 m_value.object->insert(first.m_it.object_iterator, last.m_it.object_iterator);
18965 m_type = value_t::object;
18985 for (
auto it = first; it != last; ++it) {
18986 if (merge_objects && it.value().is_object()) {
18987 auto it2 =
m_value.object->find(it.key());
18988 if (it2 !=
m_value.object->end()) {
18989 it2->second.update(it.value(),
true);
18993 m_value.object->operator[](it.key()) = it.value();
18994#if JSON_DIAGNOSTICS
18995 m_value.object->operator[](it.key()).m_parent =
this;
19002 void swap(
reference other)
noexcept(std::is_nothrow_move_constructible<value_t>::value
19003 && std::is_nothrow_move_assignable<value_t>::value
19004 && std::is_nothrow_move_constructible<json_value>::value
19005 && std::is_nothrow_move_assignable<json_value>::value)
19007 std::swap(m_type, other.m_type);
19008 std::swap(
m_value, other.m_value);
19011 other.set_parents();
19017 friend void swap(
reference left,
reference right)
noexcept(std::is_nothrow_move_constructible<value_t>::value
19018 && std::is_nothrow_move_assignable<value_t>::value
19019 && std::is_nothrow_move_constructible<json_value>::value
19020 && std::is_nothrow_move_assignable<json_value>::value)
19027 void swap(array_t& other)
19031 std::swap(*(
m_value.array), other);
19039 void swap(object_t& other)
19043 std::swap(*(
m_value.object), other);
19051 void swap(string_t& other)
19055 std::swap(*(
m_value.string), other);
19063 void swap(binary_t& other)
19067 std::swap(*(
m_value.binary), other);
19075 void swap(
typename binary_t::container_type& other)
19079 std::swap(*(
m_value.binary), other);
19100#pragma GCC diagnostic push
19101#pragma GCC diagnostic ignored "-Wfloat-equal"
19103 const auto lhs_type = lhs.type();
19104 const auto rhs_type =
rhs.type();
19106 if (lhs_type == rhs_type) {
19107 switch (lhs_type) {
19108 case value_t::array:
19109 return *lhs.m_value.array == *
rhs.m_value.array;
19111 case value_t::object:
19112 return *lhs.m_value.object == *
rhs.m_value.object;
19114 case value_t::null:
19117 case value_t::string:
19118 return *lhs.m_value.string == *
rhs.m_value.string;
19120 case value_t::boolean:
19121 return lhs.m_value.boolean ==
rhs.m_value.boolean;
19123 case value_t::number_integer:
19124 return lhs.m_value.number_integer ==
rhs.m_value.number_integer;
19126 case value_t::number_unsigned:
19127 return lhs.m_value.number_unsigned ==
rhs.m_value.number_unsigned;
19129 case value_t::number_float:
19130 return lhs.m_value.number_float ==
rhs.m_value.number_float;
19132 case value_t::binary:
19133 return *lhs.m_value.binary == *
rhs.m_value.binary;
19135 case value_t::discarded:
19139 }
else if (lhs_type == value_t::number_integer && rhs_type == value_t::number_float) {
19140 return static_cast<number_float_t
>(lhs.m_value.number_integer) ==
rhs.m_value.number_float;
19141 }
else if (lhs_type == value_t::number_float && rhs_type == value_t::number_integer) {
19142 return lhs.m_value.number_float ==
static_cast<number_float_t
>(
rhs.m_value.number_integer);
19143 }
else if (lhs_type == value_t::number_unsigned && rhs_type == value_t::number_float) {
19144 return static_cast<number_float_t
>(lhs.m_value.number_unsigned) ==
rhs.m_value.number_float;
19145 }
else if (lhs_type == value_t::number_float && rhs_type == value_t::number_unsigned) {
19146 return lhs.m_value.number_float ==
static_cast<number_float_t
>(
rhs.m_value.number_unsigned);
19147 }
else if (lhs_type == value_t::number_unsigned && rhs_type == value_t::number_integer) {
19148 return static_cast<number_integer_t
>(lhs.m_value.number_unsigned) ==
rhs.m_value.number_integer;
19149 }
else if (lhs_type == value_t::number_integer && rhs_type == value_t::number_unsigned) {
19150 return lhs.m_value.number_integer ==
static_cast<number_integer_t
>(
rhs.m_value.number_unsigned);
19155#pragma GCC diagnostic pop
19161 template<typename ScalarType, typename std::enable_if<std::is_scalar<ScalarType>::value,
int>
::type = 0>
19169 template<typename ScalarType, typename std::enable_if<std::is_scalar<ScalarType>::value,
int>
::type = 0>
19181 template<typename ScalarType, typename std::enable_if<std::is_scalar<ScalarType>::value,
int>
::type = 0>
19189 template<typename ScalarType, typename std::enable_if<std::is_scalar<ScalarType>::value,
int>
::type = 0>
19199 const auto lhs_type = lhs.type();
19200 const auto rhs_type =
rhs.type();
19202 if (lhs_type == rhs_type) {
19203 switch (lhs_type) {
19204 case value_t::array:
19207 return (*lhs.m_value.array) < (*
rhs.m_value.array);
19209 case value_t::object:
19210 return (*lhs.m_value.object) < (*
rhs.m_value.object);
19212 case value_t::null:
19215 case value_t::string:
19216 return (*lhs.m_value.string) < (*
rhs.m_value.string);
19218 case value_t::boolean:
19219 return (lhs.m_value.boolean) < (
rhs.m_value.boolean);
19221 case value_t::number_integer:
19222 return (lhs.m_value.number_integer) < (
rhs.m_value.number_integer);
19224 case value_t::number_unsigned:
19225 return (lhs.m_value.number_unsigned) < (
rhs.m_value.number_unsigned);
19227 case value_t::number_float:
19228 return (lhs.m_value.number_float) < (
rhs.m_value.number_float);
19230 case value_t::binary:
19231 return (*lhs.m_value.binary) < (*
rhs.m_value.binary);
19233 case value_t::discarded:
19237 }
else if (lhs_type == value_t::number_integer && rhs_type == value_t::number_float) {
19238 return static_cast<number_float_t
>(lhs.m_value.number_integer) <
rhs.m_value.number_float;
19239 }
else if (lhs_type == value_t::number_float && rhs_type == value_t::number_integer) {
19240 return lhs.m_value.number_float <
static_cast<number_float_t
>(
rhs.m_value.number_integer);
19241 }
else if (lhs_type == value_t::number_unsigned && rhs_type == value_t::number_float) {
19242 return static_cast<number_float_t
>(lhs.m_value.number_unsigned) <
rhs.m_value.number_float;
19243 }
else if (lhs_type == value_t::number_float && rhs_type == value_t::number_unsigned) {
19244 return lhs.m_value.number_float <
static_cast<number_float_t
>(
rhs.m_value.number_unsigned);
19245 }
else if (lhs_type == value_t::number_integer && rhs_type == value_t::number_unsigned) {
19246 return lhs.m_value.number_integer <
static_cast<number_integer_t
>(
rhs.m_value.number_unsigned);
19247 }
else if (lhs_type == value_t::number_unsigned && rhs_type == value_t::number_integer) {
19248 return static_cast<number_integer_t
>(lhs.m_value.number_unsigned) <
rhs.m_value.number_integer;
19259 template<typename ScalarType, typename std::enable_if<std::is_scalar<ScalarType>::value,
int>
::type = 0>
19267 template<typename ScalarType, typename std::enable_if<std::is_scalar<ScalarType>::value,
int>
::type = 0>
19279 template<typename ScalarType, typename std::enable_if<std::is_scalar<ScalarType>::value,
int>
::type = 0>
19287 template<typename ScalarType, typename std::enable_if<std::is_scalar<ScalarType>::value,
int>
::type = 0>
19299 template<typename ScalarType, typename std::enable_if<std::is_scalar<ScalarType>::value,
int>
::type = 0>
19307 template<typename ScalarType, typename std::enable_if<std::is_scalar<ScalarType>::value,
int>
::type = 0>
19319 template<typename ScalarType, typename std::enable_if<std::is_scalar<ScalarType>::value,
int>
::type = 0>
19327 template<typename ScalarType, typename std::enable_if<std::is_scalar<ScalarType>::value,
int>
::type = 0>
19347 const bool pretty_print = o.width() > 0;
19348 const auto indentation = pretty_print ? o.width() : 0;
19354 serializer s(detail::output_adapter<char>(o), o.fill());
19355 s.dump(j, pretty_print,
false,
static_cast<unsigned int>(indentation));
19379 template<
typename InputType>
19381 const parser_callback_t cb =
nullptr,
19382 const bool allow_exceptions =
true,
19383 const bool ignore_comments =
false)
19393 template<
typename IteratorType>
19396 const parser_callback_t cb =
nullptr,
19397 const bool allow_exceptions =
true,
19398 const bool ignore_comments =
false)
19408 static basic_json parse(detail::span_input_adapter&&
i,
19409 const parser_callback_t cb =
nullptr,
19410 const bool allow_exceptions =
true,
19411 const bool ignore_comments =
false)
19414 parser(
i.get(), cb, allow_exceptions, ignore_comments).parse(
true,
result);
19420 template<
typename InputType>
19421 static bool accept(InputType&&
i,
const bool ignore_comments =
false)
19428 template<
typename IteratorType>
19429 static bool accept(IteratorType first, IteratorType last,
const bool ignore_comments =
false)
19437 static bool accept(detail::span_input_adapter&&
i,
const bool ignore_comments =
false)
19439 return parser(
i.get(),
nullptr,
false, ignore_comments).accept(
true);
19444 template<
typename InputType,
typename SAX>
19446 static
bool sax_parse(InputType&&
i,
19449 const
bool strict = true,
19450 const
bool ignore_comments = false)
19453 return format == input_format_t::json
19454 ?
parser(std::move(ia),
nullptr,
true, ignore_comments).sax_parse(sax, strict)
19455 : detail::binary_reader<basic_json, decltype(ia), SAX>(std::move(ia)).sax_parse(format, sax, strict);
19460 template<
class IteratorType,
class SAX>
19462 static
bool sax_parse(IteratorType first,
19466 const
bool strict = true,
19467 const
bool ignore_comments = false)
19470 return format == input_format_t::json
19471 ?
parser(std::move(ia),
nullptr,
true, ignore_comments).sax_parse(sax, strict)
19472 : detail::binary_reader<basic_json, decltype(ia), SAX>(std::move(ia)).sax_parse(format, sax, strict);
19480 template<
typename SAX>
19485 const
bool strict = true,
19486 const
bool ignore_comments = false)
19489 return format == input_format_t::json
19491 ?
parser(std::move(ia),
nullptr,
true, ignore_comments).sax_parse(sax, strict)
19493 : detail::binary_reader<basic_json, decltype(ia), SAX>(std::move(ia)).sax_parse(format, sax, strict);
19522 const char* type_name() const noexcept
19525 case value_t::null:
19527 case value_t::object:
19529 case value_t::array:
19531 case value_t::string:
19533 case value_t::boolean:
19535 case value_t::binary:
19537 case value_t::discarded:
19538 return "discarded";
19539 case value_t::number_integer:
19540 case value_t::number_unsigned:
19541 case value_t::number_float:
19554 value_t m_type = value_t::null;
19559#if JSON_DIAGNOSTICS
19574 static std::vector<std::uint8_t> to_cbor(
const basic_json& j)
19576 std::vector<std::uint8_t>
result;
19583 static void to_cbor(
const basic_json& j, detail::output_adapter<std::uint8_t> o)
19594 static std::vector<std::uint8_t> to_msgpack(
const basic_json& j)
19596 std::vector<std::uint8_t>
result;
19603 static void to_msgpack(
const basic_json& j, detail::output_adapter<std::uint8_t> o)
19610 static void to_msgpack(
const basic_json& j, detail::output_adapter<char> o)
19617 static std::vector<std::uint8_t> to_ubjson(
const basic_json& j,
19618 const bool use_size =
false,
19619 const bool use_type =
false)
19621 std::vector<std::uint8_t>
result;
19622 to_ubjson(j,
result, use_size, use_type);
19629 detail::output_adapter<std::uint8_t> o,
19630 const bool use_size =
false,
19631 const bool use_type =
false)
19639 detail::output_adapter<char> o,
19640 const bool use_size =
false,
19641 const bool use_type =
false)
19648 static std::vector<std::uint8_t> to_bson(
const basic_json& j)
19650 std::vector<std::uint8_t>
result;
19657 static void to_bson(
const basic_json& j, detail::output_adapter<std::uint8_t> o)
19668 template<
typename InputType>
19671 const bool strict =
true,
19672 const bool allow_exceptions =
true,
19676 detail::json_sax_dom_parser<basic_json> sdp(
result, allow_exceptions);
19685 template<
typename IteratorType>
19687 IteratorType first,
19689 const bool strict =
true,
19690 const bool allow_exceptions =
true,
19694 detail::json_sax_dom_parser<basic_json> sdp(
result, allow_exceptions);
19701 template<
typename T>
19703 from_cbor(
const T* ptr,
19705 const bool strict =
true,
19706 const bool allow_exceptions =
true,
19709 return from_cbor(ptr, ptr + len, strict, allow_exceptions, tag_handler);
19714 static basic_json from_cbor(detail::span_input_adapter&&
i,
19715 const bool strict =
true,
19716 const bool allow_exceptions =
true,
19720 detail::json_sax_dom_parser<basic_json> sdp(
result, allow_exceptions);
19730 template<
typename InputType>
19732 const bool strict =
true,
19733 const bool allow_exceptions =
true)
19736 detail::json_sax_dom_parser<basic_json> sdp(
result, allow_exceptions);
19744 template<
typename IteratorType>
19747 const bool strict =
true,
19748 const bool allow_exceptions =
true)
19751 detail::json_sax_dom_parser<basic_json> sdp(
result, allow_exceptions);
19757 template<
typename T>
19759 from_msgpack(
const T* ptr, std::size_t len,
const bool strict =
true,
const bool allow_exceptions =
true)
19761 return from_msgpack(ptr, ptr + len, strict, allow_exceptions);
19766 static basic_json from_msgpack(detail::span_input_adapter&&
i,
19767 const bool strict =
true,
19768 const bool allow_exceptions =
true)
19771 detail::json_sax_dom_parser<basic_json> sdp(
result, allow_exceptions);
19780 template<
typename InputType>
19782 const bool strict =
true,
19783 const bool allow_exceptions =
true)
19786 detail::json_sax_dom_parser<basic_json> sdp(
result, allow_exceptions);
19794 template<
typename IteratorType>
19797 const bool strict =
true,
19798 const bool allow_exceptions =
true)
19801 detail::json_sax_dom_parser<basic_json> sdp(
result, allow_exceptions);
19807 template<
typename T>
19809 from_ubjson(
const T* ptr, std::size_t len,
const bool strict =
true,
const bool allow_exceptions =
true)
19811 return from_ubjson(ptr, ptr + len, strict, allow_exceptions);
19816 static basic_json from_ubjson(detail::span_input_adapter&&
i,
19817 const bool strict =
true,
19818 const bool allow_exceptions =
true)
19821 detail::json_sax_dom_parser<basic_json> sdp(
result, allow_exceptions);
19830 template<
typename InputType>
19832 const bool strict =
true,
19833 const bool allow_exceptions =
true)
19836 detail::json_sax_dom_parser<basic_json> sdp(
result, allow_exceptions);
19844 template<
typename IteratorType>
19847 const bool strict =
true,
19848 const bool allow_exceptions =
true)
19851 detail::json_sax_dom_parser<basic_json> sdp(
result, allow_exceptions);
19857 template<
typename T>
19859 from_bson(
const T* ptr, std::size_t len,
const bool strict =
true,
const bool allow_exceptions =
true)
19861 return from_bson(ptr, ptr + len, strict, allow_exceptions);
19866 static basic_json from_bson(detail::span_input_adapter&&
i,
19867 const bool strict =
true,
19868 const bool allow_exceptions =
true)
19871 detail::json_sax_dom_parser<basic_json> sdp(
result, allow_exceptions);
19907 json_pointer::flatten(
"", *
this,
result);
19932 enum class patch_operations
19943 const auto get_op = [](
const std::string& op) {
19945 return patch_operations::add;
19947 if (op ==
"remove") {
19948 return patch_operations::remove;
19950 if (op ==
"replace") {
19951 return patch_operations::replace;
19953 if (op ==
"move") {
19954 return patch_operations::move;
19956 if (op ==
"copy") {
19957 return patch_operations::copy;
19959 if (op ==
"test") {
19960 return patch_operations::test;
19963 return patch_operations::invalid;
19976 if (top_pointer != ptr) {
19981 const auto last_path = ptr.back();
19985 switch (
parent.m_type) {
19986 case value_t::null:
19987 case value_t::object: {
19989 parent[last_path] = val;
19993 case value_t::array: {
19994 if (last_path ==
"-") {
19998 const auto idx = json_pointer::array_index(last_path);
20002 401,
"array index " + std::to_string(idx) +
" is out of range",
parent));
20012 case value_t::string:
20013 case value_t::boolean:
20014 case value_t::number_integer:
20015 case value_t::number_unsigned:
20016 case value_t::number_float:
20017 case value_t::binary:
20018 case value_t::discarded:
20027 const auto last_path = ptr.back();
20032 if (
parent.is_object()) {
20034 auto it =
parent.find(last_path);
20040 }
else if (
parent.is_array()) {
20042 parent.erase(json_pointer::array_index(last_path));
20048 JSON_THROW(parse_error::create(104, 0,
"JSON patch must be an array of objects", json_patch));
20052 for (
const auto& val : json_patch) {
20054 const auto get_value = [&val](
const std::string& op,
const std::string& member,
20057 auto it = val.m_value.object->find(member);
20060 const auto error_msg = (op ==
"op") ?
"operation" :
"operation '" + op +
"'";
20065 JSON_THROW(parse_error::create(105, 0, error_msg +
" must have member '" + member +
"'", val));
20072 parse_error::create(105, 0, error_msg +
" must have string member '" + member +
"'", val));
20081 JSON_THROW(parse_error::create(104, 0,
"JSON patch must be an array of objects", val));
20085 const auto op = get_value(
"op",
"op",
true).template get<std::string>();
20086 const auto path = get_value(op,
"path",
true).template get<std::string>();
20089 switch (get_op(op)) {
20090 case patch_operations::add: {
20091 operation_add(ptr, get_value(
"add",
"value",
false));
20095 case patch_operations::remove: {
20096 operation_remove(ptr);
20100 case patch_operations::replace: {
20102 result.at(ptr) = get_value(
"replace",
"value",
false);
20106 case patch_operations::move: {
20107 const auto from_path = get_value(
"move",
"from",
true).template get<std::string>();
20117 operation_remove(from_ptr);
20118 operation_add(ptr,
v);
20122 case patch_operations::copy: {
20123 const auto from_path = get_value(
"copy",
"from",
true).template get<std::string>();
20132 operation_add(ptr,
v);
20136 case patch_operations::test: {
20137 bool success =
false;
20142 success = (
result.at(ptr) == get_value(
"test",
"value",
false));
20157 case patch_operations::invalid:
20161 JSON_THROW(parse_error::create(105, 0,
"operation value '" + op +
"' is invalid", val));
20178 if (source == target) {
20182 if (source.type() != target.type()) {
20184 result.push_back({{
"op",
"replace"}, {
"path", path}, {
"value", target}});
20188 switch (source.type()) {
20189 case value_t::array: {
20192 while (
i < source.size() &&
i < target.size()) {
20194 auto temp_diff = diff(source[
i], target[
i], path +
"/" + std::to_string(
i));
20195 result.insert(
result.end(), temp_diff.begin(), temp_diff.end());
20204 while (
i < source.size()) {
20208 object({{
"op",
"remove"}, {
"path", path +
"/" + std::to_string(i)}}));
20213 while (
i < target.size()) {
20214 result.push_back({{
"op",
"add"}, {
"path", path +
"/-"}, {
"value", target[
i]}});
20221 case value_t::object: {
20223 for (
auto it = source.cbegin(); it != source.cend(); ++it) {
20227 if (target.find(it.key()) != target.end()) {
20229 auto temp_diff = diff(it.value(), target[it.key()], path_key);
20230 result.insert(
result.end(), temp_diff.begin(), temp_diff.end());
20233 result.push_back(
object({{
"op",
"remove"}, {
"path", path_key}}));
20238 for (
auto it = target.cbegin(); it != target.cend(); ++it) {
20239 if (source.find(it.key()) == source.end()) {
20242 result.push_back({{
"op",
"add"}, {
"path", path_key}, {
"value", it.value()}});
20249 case value_t::null:
20250 case value_t::string:
20251 case value_t::boolean:
20252 case value_t::number_integer:
20253 case value_t::number_unsigned:
20254 case value_t::number_float:
20255 case value_t::binary:
20256 case value_t::discarded:
20259 result.push_back({{
"op",
"replace"}, {
"path", path}, {
"value", target}});
20278 void merge_patch(
const basic_json& apply_patch)
20280 if (apply_patch.is_object()) {
20281 if (!is_object()) {
20284 for (
auto it = apply_patch.begin(); it != apply_patch.end(); ++it) {
20285 if (it.value().is_null()) {
20288 operator[](it.key()).merge_patch(it.value());
20292 *
this = apply_patch;
20340#ifndef JSON_HAS_CPP_20
20346 nlohmann::NLOHMANN_BASIC_JSON_TPL& j1,
20347 nlohmann::NLOHMANN_BASIC_JSON_TPL& j2)
noexcept(
20348 is_nothrow_move_constructible<nlohmann::NLOHMANN_BASIC_JSON_TPL>::value &&
20349 is_nothrow_move_assignable<nlohmann::NLOHMANN_BASIC_JSON_TPL>::value)
20363 return nlohmann::json::parse(s, s +
n);
20369inline nlohmann::
json::
json_pointer operator
"" _json_pointer(const
char* s, std::
size_t n)
20371 return nlohmann::json::json_pointer(std::string(s,
n));
20377#if defined(__clang__)
20378#pragma clang diagnostic pop
20383#undef JSON_INTERNAL_CATCH
20387#undef JSON_PRIVATE_UNLESS_TESTED
20388#undef JSON_HAS_CPP_11
20389#undef JSON_HAS_CPP_14
20390#undef JSON_HAS_CPP_17
20391#undef JSON_HAS_CPP_20
20392#undef JSON_HAS_FILESYSTEM
20393#undef JSON_HAS_EXPERIMENTAL_FILESYSTEM
20394#undef NLOHMANN_BASIC_JSON_TPL_DECLARATION
20395#undef NLOHMANN_BASIC_JSON_TPL
20396#undef JSON_EXPLICIT
20397#undef NLOHMANN_CAN_CALL_STD_FUNC_IMPL
20401#undef JSON_HEDLEY_ALWAYS_INLINE
20402#undef JSON_HEDLEY_ARM_VERSION
20403#undef JSON_HEDLEY_ARM_VERSION_CHECK
20404#undef JSON_HEDLEY_ARRAY_PARAM
20405#undef JSON_HEDLEY_ASSUME
20406#undef JSON_HEDLEY_BEGIN_C_DECLS
20407#undef JSON_HEDLEY_CLANG_HAS_ATTRIBUTE
20408#undef JSON_HEDLEY_CLANG_HAS_BUILTIN
20409#undef JSON_HEDLEY_CLANG_HAS_CPP_ATTRIBUTE
20410#undef JSON_HEDLEY_CLANG_HAS_DECLSPEC_DECLSPEC_ATTRIBUTE
20411#undef JSON_HEDLEY_CLANG_HAS_EXTENSION
20412#undef JSON_HEDLEY_CLANG_HAS_FEATURE
20413#undef JSON_HEDLEY_CLANG_HAS_WARNING
20414#undef JSON_HEDLEY_COMPCERT_VERSION
20415#undef JSON_HEDLEY_COMPCERT_VERSION_CHECK
20416#undef JSON_HEDLEY_CONCAT
20417#undef JSON_HEDLEY_CONCAT3
20418#undef JSON_HEDLEY_CONCAT3_EX
20419#undef JSON_HEDLEY_CONCAT_EX
20420#undef JSON_HEDLEY_CONST
20421#undef JSON_HEDLEY_CONSTEXPR
20422#undef JSON_HEDLEY_CONST_CAST
20423#undef JSON_HEDLEY_CPP_CAST
20424#undef JSON_HEDLEY_CRAY_VERSION
20425#undef JSON_HEDLEY_CRAY_VERSION_CHECK
20426#undef JSON_HEDLEY_C_DECL
20427#undef JSON_HEDLEY_DEPRECATED
20428#undef JSON_HEDLEY_DEPRECATED_FOR
20429#undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL
20430#undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_
20431#undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED
20432#undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES
20433#undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS
20434#undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION
20435#undef JSON_HEDLEY_DIAGNOSTIC_POP
20436#undef JSON_HEDLEY_DIAGNOSTIC_PUSH
20437#undef JSON_HEDLEY_DMC_VERSION
20438#undef JSON_HEDLEY_DMC_VERSION_CHECK
20439#undef JSON_HEDLEY_EMPTY_BASES
20440#undef JSON_HEDLEY_EMSCRIPTEN_VERSION
20441#undef JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK
20442#undef JSON_HEDLEY_END_C_DECLS
20443#undef JSON_HEDLEY_FLAGS
20444#undef JSON_HEDLEY_FLAGS_CAST
20445#undef JSON_HEDLEY_GCC_HAS_ATTRIBUTE
20446#undef JSON_HEDLEY_GCC_HAS_BUILTIN
20447#undef JSON_HEDLEY_GCC_HAS_CPP_ATTRIBUTE
20448#undef JSON_HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE
20449#undef JSON_HEDLEY_GCC_HAS_EXTENSION
20450#undef JSON_HEDLEY_GCC_HAS_FEATURE
20451#undef JSON_HEDLEY_GCC_HAS_WARNING
20452#undef JSON_HEDLEY_GCC_NOT_CLANG_VERSION_CHECK
20453#undef JSON_HEDLEY_GCC_VERSION
20454#undef JSON_HEDLEY_GCC_VERSION_CHECK
20455#undef JSON_HEDLEY_GNUC_HAS_ATTRIBUTE
20456#undef JSON_HEDLEY_GNUC_HAS_BUILTIN
20457#undef JSON_HEDLEY_GNUC_HAS_CPP_ATTRIBUTE
20458#undef JSON_HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE
20459#undef JSON_HEDLEY_GNUC_HAS_EXTENSION
20460#undef JSON_HEDLEY_GNUC_HAS_FEATURE
20461#undef JSON_HEDLEY_GNUC_HAS_WARNING
20462#undef JSON_HEDLEY_GNUC_VERSION
20463#undef JSON_HEDLEY_GNUC_VERSION_CHECK
20464#undef JSON_HEDLEY_HAS_ATTRIBUTE
20465#undef JSON_HEDLEY_HAS_BUILTIN
20466#undef JSON_HEDLEY_HAS_CPP_ATTRIBUTE
20467#undef JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS
20468#undef JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE
20469#undef JSON_HEDLEY_HAS_EXTENSION
20470#undef JSON_HEDLEY_HAS_FEATURE
20471#undef JSON_HEDLEY_HAS_WARNING
20472#undef JSON_HEDLEY_IAR_VERSION
20473#undef JSON_HEDLEY_IAR_VERSION_CHECK
20474#undef JSON_HEDLEY_IBM_VERSION
20475#undef JSON_HEDLEY_IBM_VERSION_CHECK
20476#undef JSON_HEDLEY_IMPORT
20477#undef JSON_HEDLEY_INLINE
20478#undef JSON_HEDLEY_INTEL_CL_VERSION
20479#undef JSON_HEDLEY_INTEL_CL_VERSION_CHECK
20480#undef JSON_HEDLEY_INTEL_VERSION
20481#undef JSON_HEDLEY_INTEL_VERSION_CHECK
20482#undef JSON_HEDLEY_IS_CONSTANT
20483#undef JSON_HEDLEY_IS_CONSTEXPR_
20484#undef JSON_HEDLEY_LIKELY
20485#undef JSON_HEDLEY_MALLOC
20486#undef JSON_HEDLEY_MCST_LCC_VERSION
20487#undef JSON_HEDLEY_MCST_LCC_VERSION_CHECK
20488#undef JSON_HEDLEY_MESSAGE
20489#undef JSON_HEDLEY_MSVC_VERSION
20490#undef JSON_HEDLEY_MSVC_VERSION_CHECK
20491#undef JSON_HEDLEY_NEVER_INLINE
20492#undef JSON_HEDLEY_NON_NULL
20493#undef JSON_HEDLEY_NO_ESCAPE
20494#undef JSON_HEDLEY_NO_RETURN
20495#undef JSON_HEDLEY_NO_THROW
20496#undef JSON_HEDLEY_NULL
20497#undef JSON_HEDLEY_PELLES_VERSION
20498#undef JSON_HEDLEY_PELLES_VERSION_CHECK
20499#undef JSON_HEDLEY_PGI_VERSION
20500#undef JSON_HEDLEY_PGI_VERSION_CHECK
20501#undef JSON_HEDLEY_PREDICT
20502#undef JSON_HEDLEY_PRINTF_FORMAT
20503#undef JSON_HEDLEY_PRIVATE
20504#undef JSON_HEDLEY_PUBLIC
20505#undef JSON_HEDLEY_PURE
20506#undef JSON_HEDLEY_REINTERPRET_CAST
20507#undef JSON_HEDLEY_REQUIRE
20508#undef JSON_HEDLEY_REQUIRE_CONSTEXPR
20509#undef JSON_HEDLEY_REQUIRE_MSG
20510#undef JSON_HEDLEY_RESTRICT
20511#undef JSON_HEDLEY_RETURNS_NON_NULL
20512#undef JSON_HEDLEY_SENTINEL
20513#undef JSON_HEDLEY_STATIC_ASSERT
20514#undef JSON_HEDLEY_STATIC_CAST
20515#undef JSON_HEDLEY_STRINGIFY
20516#undef JSON_HEDLEY_STRINGIFY_EX
20517#undef JSON_HEDLEY_SUNPRO_VERSION
20518#undef JSON_HEDLEY_SUNPRO_VERSION_CHECK
20519#undef JSON_HEDLEY_TINYC_VERSION
20520#undef JSON_HEDLEY_TINYC_VERSION_CHECK
20521#undef JSON_HEDLEY_TI_ARMCL_VERSION
20522#undef JSON_HEDLEY_TI_ARMCL_VERSION_CHECK
20523#undef JSON_HEDLEY_TI_CL2000_VERSION
20524#undef JSON_HEDLEY_TI_CL2000_VERSION_CHECK
20525#undef JSON_HEDLEY_TI_CL430_VERSION
20526#undef JSON_HEDLEY_TI_CL430_VERSION_CHECK
20527#undef JSON_HEDLEY_TI_CL6X_VERSION
20528#undef JSON_HEDLEY_TI_CL6X_VERSION_CHECK
20529#undef JSON_HEDLEY_TI_CL7X_VERSION
20530#undef JSON_HEDLEY_TI_CL7X_VERSION_CHECK
20531#undef JSON_HEDLEY_TI_CLPRU_VERSION
20532#undef JSON_HEDLEY_TI_CLPRU_VERSION_CHECK
20533#undef JSON_HEDLEY_TI_VERSION
20534#undef JSON_HEDLEY_TI_VERSION_CHECK
20535#undef JSON_HEDLEY_UNAVAILABLE
20536#undef JSON_HEDLEY_UNLIKELY
20537#undef JSON_HEDLEY_UNPREDICTABLE
20538#undef JSON_HEDLEY_UNREACHABLE
20539#undef JSON_HEDLEY_UNREACHABLE_RETURN
20540#undef JSON_HEDLEY_VERSION
20541#undef JSON_HEDLEY_VERSION_DECODE_MAJOR
20542#undef JSON_HEDLEY_VERSION_DECODE_MINOR
20543#undef JSON_HEDLEY_VERSION_DECODE_REVISION
20544#undef JSON_HEDLEY_VERSION_ENCODE
20545#undef JSON_HEDLEY_WARNING
20546#undef JSON_HEDLEY_WARN_UNUSED_RESULT
20547#undef JSON_HEDLEY_WARN_UNUSED_RESULT_MSG
20548#undef JSON_HEDLEY_FALL_THROUGH
vector< Double_t > dist(vector< Double_t > qp, Double_t mu)
TBuffer & operator>>(TBuffer &buf, Tmpl *&obj)
Bool_t operator<=(const TDatime &d1, const TDatime &d2)
Bool_t operator>(const TDatime &d1, const TDatime &d2)
Bool_t operator>=(const TDatime &d1, const TDatime &d2)
Bool_t operator<(const TDatime &d1, const TDatime &d2)
TRObject operator()(const T1 &t1) const
ROOT::R::TRInterface & operator<<(ROOT::R::TRInterface &r, TString code)
Binding & operator=(OUT(*fun)(U0 u0))
UInt_t Hash(const char *s)
std::string & operator+=(std::string &left, const TString &right)
TTime operator/(const TTime &t1, const TTime &t2)
a class to store JSON values
*constructor for rvalue objects json_value(object_t &&value)
{ *the type of elements in a basic_json container using value_type=basic_json value_type & reference
NLOHMANN_BASIC_JSON_TPL basic_json_t
*brief a type for an array *sa AllocatorType< basic_json >
json_sax< basic_json > json_sax_t
*constructor for rvalue binary arrays json_value(typename binary_t::container_type &&value)
* binary(stored with pointer to save storage) binary_t *binary
detail::error_handler_t error_handler_t
detail::input_format_t input_format_t
detail::out_of_range out_of_range
* array(stored with pointer to save storage) array_t *array
void assert_invariant(bool check_parents=true) const noexcept
checks the class invariants
std::ptrdiff_t difference_type
typename std::allocator_traits< allocator_type >::const_pointer const_pointer
typename std::allocator_traits< allocator_type >::pointer pointer
*constructor for rvalue strings json_value(string_t &&value)
iterator set_parents(iterator it, typename iterator::difference_type count_set_parents)
std::initializer_list< detail::json_ref< basic_json > > initializer_list_t
detail::cbor_tag_handler_t cbor_tag_handler_t
::nlohmann::detail::json_reverse_iterator< Base > json_reverse_iterator
json_reverse_iterator< typename basic_json::iterator > reverse_iterator
reference set_parent(reference j, std::size_t old_capacity=static_cast< std::size_t >(-1))
::nlohmann::detail::binary_reader< basic_json, InputType > binary_reader
detail::invalid_iterator invalid_iterator
*constructor for rvalue arrays json_value(array_t &&value)
***name constructors and destructors *Constructors of class ref basic_json copy move constructor copy static functions creating and the destructor **the value of the current element json_value m_value
detail::other_error other_error
*constructor for binary arrays json_value(const typename binary_t::container_type &value)
::nlohmann::detail::iter_impl< BasicJsonType > iter_impl
*boolean boolean_t boolean
* string(stored with pointer to save storage) string_t *string
*constructor for strings json_value(const string_t &value)
iter_impl< basic_json > iterator
*constructor for booleans json_value(boolean_t v) noexcept
json_reverse_iterator< typename basic_json::const_iterator > const_reverse_iterator
::nlohmann::json_pointer< basic_json > json_pointer
::nlohmann::detail::binary_writer< basic_json, CharType > binary_writer
const value_type & const_reference
*constructor for objects json_value(const object_t &value)
friend class ::nlohmann::detail::exception
::nlohmann::detail::internal_iterator< BasicJsonType > internal_iterator
::nlohmann::detail::output_adapter_t< CharType > output_adapter_t
*constructor for empty values of a given type json_value(value_t t)
friend class ::nlohmann::detail::parser
detail::type_error type_error
***name JSON value data types *The data types to store a JSON value These types are derived from *the template arguments passed to class ref basic_json **brief a type for an object *sa object_comparator_t
std::allocator< basic_json > allocator_type
adl_serializer< T, SFINAE > json_serializer
{ using exception=detail::exception detail::parse_error parse_error
*helper for exception safe object creation static JSON_HEDLEY_RETURNS_NON_NULL T * create(Args &&... args)
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)
::nlohmann::detail::primitive_iterator_t primitive_iterator_t
::nlohmann::detail::iteration_proxy< Iterator > iteration_proxy
***name JSON value data types *The data types to store a JSON value These types are derived from *the template arguments passed to class ref basic_json **brief a type for an object *sa basic_json
iter_impl< const basic_json > const_iterator
*constructor for arrays json_value(const array_t &value)
** JSON_PRIVATE_UNLESS_TESTED
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
**char_int_type get()
get next character from the input
bool get_msgpack_array(const std::size_t len)
**bool parse_cbor_internal(const bool get_char, const cbor_tag_handler_t tag_handler)
binary_reader & operator=(const binary_reader &)=delete
bool get_bson_string(const NumberType len, string_t &result)
Parses a C-style string 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_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
*whether we can assume little endianness const bool is_little_endian
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 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
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 unexpect_eof(const input_format_t format, const char *context) const
*the number of characters read std::size_t chars_read
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
*the json_sax_dom_parser< basic_json > parser json_sax_t * sax
bool get_msgpack_object(const std::size_t len)
**bool parse_msgpack_internal()
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
typename std::char_traits< char_type >::int_type char_int_type
**bool parse_ubjson_internal(const bool get_char=true)
binary_reader(const binary_reader &)=delete
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)
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.
*the current character char_int_type current
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
bool get_msgpack_string(string_t &result)
reads a MessagePack string
typename BasicJsonType::number_float_t number_float_t
*input adapter InputAdapterType ia
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 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 basic_json &j)
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 basic_json::object_t &value)
typename BasicJsonType::string_t string_t
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 basic_json &j) const noexcept
void write_bson_integer(const string_t &name, const std::int64_t value)
Writes a BSON element with key name and integer value.
**void write_number_with_ubjson_prefix(const NumberType n, const bool add_prefix)
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_bson_element(const string_t &name, const basic_json &j)
**static std::size_t calc_bson_entry_header_size(const string_t &name, const BasicJsonType &j)
*whether we can assume little endianness const bool is_little_endian
**void write_number(const NumberType n)
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 constexpr CharType get_cbor_float_prefix(float)
static std::size_t calc_bson_object_size(const typename basic_json::object_t &value)
**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.
*the output output_adapter_t< CharType > oa
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(int id_, const char *what_arg)
exception indicating errors with iterators
static invalid_iterator create(int id_, const std::string &what_arg, const BasicJsonType &context)
invalid_iterator(int id_, const char *what_arg)
bool operator<(const iter_impl &other) const
comparison: smaller
iter_impl operator-(difference_type i) const
subtract from iterator
iter_impl const operator--(int)
post-decrement (it–)
void set_end() noexcept
set the iterator past the last value
*the actual iterator of the associated instance internal_iterator< typename std::remove_const< BasicJsonType >::type > m_it
typename BasicJsonType::difference_type difference_type
iter_impl & operator--()
pre-decrement (–it)
difference_type operator-(const iter_impl &other) const
return difference
iter_impl< typename std::conditional< std::is_const< BasicJsonType >::value, typename std::remove_const< BasicJsonType >::type, const BasicJsonType >::type > other_iter_impl
iter_impl & operator=(const iter_impl< const BasicJsonType > &other) noexcept
converting assignment
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
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
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
typename BasicJsonType::object_t object_t
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
members friend other_iter_impl
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
const string_type empty_str
an empty string (to return a reference for primitive values)
iteration_proxy_value(IteratorType it) noexcept
iteration_proxy_value value_type
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)
typename std::remove_cv< typename std::remove_reference< decltype(std::declval< IteratorType >().key())>::type >::type string_type
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)
Iterator::reference container
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
*access to successor reference operator[](difference_type n) const
*return the value of an iterator reference value() const
typename Base::reference reference
std::reverse_iterator< Base > base_iterator
*create reverse iterator from base class explicit json_reverse_iterator(const base_iterator &it) noexcept
std::ptrdiff_t difference_type
*return difference difference_type operator-(const json_reverse_iterator &other) const
*subtract from iterator json_reverse_iterator operator-(difference_type i) const
*add to iterator json_reverse_iterator & operator+=(difference_type i)
*create reverse iterator from iterator json_reverse_iterator(const typename base_iterator::iterator_type &it) noexcept
*return the key of an object iterator auto key() const -> decltype(std::declval< Base >().key())
*add to iterator json_reverse_iterator operator+(difference_type i) const
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)
const bool allow_exceptions
whether to throw exceptions in case of errors
constexpr bool is_errored() const
typename BasicJsonType::number_unsigned_t number_unsigned_t
BasicJsonType * object_element
helper to hold the reference for the next object element
typename BasicJsonType::number_integer_t number_integer_t
std::pair< bool, BasicJsonType * > handle_value(Value &&v, const bool skip_callback=false)
const parser_callback_t callback
callback function
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
std::vector< BasicJsonType * > ref_stack
stack to model hierarchy of values
BasicJsonType discarded
a discarded value for the callback
std::vector< bool > key_keep_stack
stack to manage which object keys to keep
typename BasicJsonType::number_float_t number_float_t
typename BasicJsonType::parse_event_t parse_event_t
bool errored
whether a syntax error occurred
std::vector< bool > keep_stack
stack to manage which values to keep
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)
bool errored
whether a syntax error occurred
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)
BasicJsonType * object_element
helper to hold the reference for the next object element
std::vector< BasicJsonType * > ref_stack
stack to model hierarchy of values
bool binary(binary_t &val)
const bool allow_exceptions
whether to throw exceptions in case of errors
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
return the last read token (for errors only).
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)
other_error(int id_, const char *what_arg)
exception indicating access out of the defined range
static out_of_range create(int id_, const std::string &what_arg, const BasicJsonType &context)
out_of_range(int id_, const char *what_arg)
output_adapter_t< CharType > oa
output_adapter(std::basic_ostream< CharType > &s)
output_adapter(std::vector< CharType, AllocatorType > &vec)
output_adapter(StringType &s)
void write_character(CharType c) override
std::basic_ostream< CharType > & stream
void write_characters(const CharType *s, std::size_t length) override
output_stream_adapter(std::basic_ostream< CharType > &s) noexcept
void write_character(CharType c) override
void write_characters(const CharType *s, std::size_t length) override
output_string_adapter(StringType &s) noexcept
void write_characters(const CharType *s, std::size_t length) override
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)
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
lexer< BasicJsonType, InputAdapterType > lexer_t
bool sax_parse_internal(SAX *sax)
*get next token from lexer token_type get_token()
void parse(const bool strict, BasicJsonType &result)
public parser interface
*a parser reading from an input adapter parser(InputAdapterType &&adapter, const parser_callback_t< BasicJsonType > cb=nullptr, const bool allow_exceptions_=true, const bool skip_comments=false)
*callback function const parser_callback_t< BasicJsonType > callback
std::string exception_message(const token_type expected, const std::string &context)
*the type of the last read token token_type last_token
typename BasicJsonType::number_float_t number_float_t
typename BasicJsonType::number_integer_t number_integer_t
*the lexer lexer_t m_lexer
*whether to throw exceptions in case of errors const bool allow_exceptions
primitive_iterator_t operator+(difference_type n) noexcept
primitive_iterator_t & operator++() noexcept
*return whether the iterator can be dereferenced constexpr bool is_begin() const noexcept
primitive_iterator_t & operator-=(difference_type n) noexcept
*set iterator to a defined beginning void set_begin() noexcept
friend constexpr bool operator<(primitive_iterator_t lhs, primitive_iterator_t rhs) noexcept
*set iterator to a defined past the end void set_end() noexcept
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
constexpr difference_type get_value() const noexcept
primitive_iterator_t const operator--(int) noexcept
std::ptrdiff_t difference_type
*return whether the iterator is at end constexpr bool is_end() const noexcept
primitive_iterator_t & operator+=(difference_type n) noexcept
static constexpr difference_type begin_value
*the indentation string string_t indent_string
*error_handler how to react on decoding errors const error_handler_t error_handler
*the locale s thousand separator character const char thousands_sep
typename BasicJsonType::number_unsigned_t number_unsigned_t
static constexpr std::uint8_t UTF8_ACCEPT
serializer(serializer &&)=delete
serializer & operator=(serializer &&)=delete
*string buffer std::array< char, 512 > string_buffer
typename BasicJsonType::number_float_t number_float_t
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
std::size_t bytes_after_last_accept
*a *(hopefully) large enough character buffer std the locale const std::lconv * loc
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)
*the indentation character const char indent_char
typename BasicJsonType::string_t string_t
*the locale s decimal point character const char decimal_point
serializer(const serializer &)=delete
typename BasicJsonType::number_integer_t number_integer_t
exception indicating executing a member function with a wrong type
static type_error create(int id_, const std::string &what_arg, const BasicJsonType &context)
type_error(int id_, const char *what_arg)
JSON Pointer defines a string syntax for identifying a specific value within a JSON document.
decltype(get< N >(std::declval<::nlohmann::detail::iteration_proxy_value< IteratorType > >())) type
void swap(RVec< T > &lhs, RVec< T > &rhs)
RVec< T0 > & operator/=(RVec< T0 > &v, const T1 &y)
RVec< PromoteType< T > > exp(const RVec< T > &v)
#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
*brief user defined string literal for JSON values *sa std::size_t n
#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 update(const LAYERDATA &prevLayerData, LAYERDATA &currLayerData, double factorWeightDecay, EnumRegularization regularization)
void Compare(const TMatrixTBase< Element > &m1, const TMatrixTBase< Element > &m2)
implements the Grisu2 algorithm for binary to decimal floating-point conversion.
void grisu2(char *buf, int &len, int &decimal_exponent, diyfp m_minus, diyfp v, diyfp m_plus)
v = buf * 10^decimal_exponent len is the length of the buffer (number of decimal digits) The buffer m...
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)
Compute the (normalized) diyfp representing the input number 'value' and its boundaries.
int find_largest_pow10(const std::uint32_t n, std::uint32_t &pow10)
For n != 0, returns k, such that pow10 := 10^(k-1) <= n < 10^k.
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)
Generates V = buffer * 10^decimal_exponent, such that M- <= V <= M+.
cached_power get_cached_power_for_binary_exponent(int e)
For a normalized diyfp w = f * 2^e, this function returns a (normalized) cached power-of-ten c = f_c ...
detail namespace with internal helper functions
typename detector< nonesuch, void, Op, Args... >::value_t is_detected
bool operator<(const value_t lhs, const value_t rhs) noexcept
comparison operator for JSON types
std::is_same< Expected, detected_t< Op, Args... > > is_detected_exact
static void unescape(std::string &s)
string unescaping as described in RFC 6901 (Sect.
void to_json(BasicJsonType &j, T b) noexcept
make_integer_sequence< size_t, N > make_index_sequence
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)
std::is_convertible< detected_t< Op, Args... >, To > is_detected_convertible
decltype(std::declval< T & >().string(std::declval< String & >())) string_function_t
decltype(std::declval< T & >().number_float(std::declval< Float >(), std::declval< const String & >())) number_float_function_t
value_type_t< iterator_traits< iterator_t< T > > > range_value_t
constexpr T static_const< T >::value
decltype(input_adapter(std::declval< const char * >(), std::declval< const char * >())) contiguous_bytes_input_adapter
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 & >().parse_error(std::declval< std::size_t >(), std::declval< const std::string & >(), std::declval< const Exception & >())) parse_error_function_t
decltype(std::declval< T & >().key(std::declval< String & >())) key_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).
typename T::iterator_category iterator_category_t
typename T::difference_type difference_type_t
void to_json_tuple_impl(BasicJsonType &j, const Tuple &t, index_sequence< Idx... >)
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
@ 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
typename T::value_type value_type_t
typename std::remove_cv< typename std::remove_reference< T >::type >::type uncvref_t
iterator_input_adapter_factory< IteratorType >::adapter_type input_adapter(IteratorType first, IteratorType last)
typename make_void< Ts... >::type void_t
make_index_sequence< sizeof...(Ts)> index_sequence_for
std::size_t combine(std::size_t seed, std::size_t h) noexcept
decltype(T::from_json(std::declval< Args >()...)) from_json_function
std::size_t hash(const BasicJsonType &j)
hash a JSON value
static bool little_endianness(int num=1) noexcept
determine system byte order
decltype(std::declval< T & >().start_array(std::declval< std::size_t >())) start_array_function_t
typename T::pointer pointer_t
typename T::mapped_type mapped_type_t
decltype(std::declval< T & >().boolean(std::declval< bool >())) boolean_function_t
std::pair< A1, A2 > from_json_tuple_impl(BasicJsonType &&j, identity_tag< std::pair< A1, A2 > >, priority_tag< 0 >)
std::function< bool(int, parse_event_t, BasicJsonType &)> parser_callback_t
void get_arithmetic_value(const BasicJsonType &j, ArithmeticType &val)
typename T::reference reference_t
typename utility_internal::Gen< T, N >::type make_integer_sequence
decltype(std::declval< T >().template get< U >()) get_template_function
std::string escape(std::string s)
string escaping as described in RFC 6901 (Sect.
decltype(std::declval< T & >().number_unsigned(std::declval< Unsigned >())) number_unsigned_function_t
decltype(T::to_json(std::declval< Args >()...)) to_json_function
input_format_t
the supported input formats
decltype(std::declval< T & >().start_object(std::declval< std::size_t >())) start_object_function_t
std::tuple< Args... > from_json_tuple_impl_base(BasicJsonType &&j, index_sequence< Idx... >)
typename detector< nonesuch, void, Op, Args... >::type detected_t
std::array< T, sizeof...(Idx)> from_json_inplace_array_impl(BasicJsonType &&j, identity_tag< std::array< T, sizeof...(Idx)> >, index_sequence< Idx... >)
integer_sequence< size_t, Ints... > index_sequence
decltype(std::declval< T & >().end_object()) end_object_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 std::enable_if< B, T >::type enable_if_t
decltype(std::declval< T & >().end_array()) end_array_function_t
decltype(std::declval< T & >().null()) null_function_t
decltype(std::declval< T & >().binary(std::declval< Binary & >())) binary_function_t
typename T::key_type key_type_t
decltype(std::declval< T & >().number_integer(std::declval< Integer >())) number_integer_function_t
std::shared_ptr< output_adapter_protocol< CharType > > output_adapter_t
typename detected_or< Default, Op, Args... >::type detected_or_t
enable_if_t< is_range< R >::value, result_of_begin< decltype(std::declval< R & >())> > iterator_t
detector< Default, void, Op, Args... > detected_or
T conditional_static_cast(U value)
namespace for Niels Lohmann
typename Container::size_type size_type
typename std::enable_if< std::is_convertible< typename std::iterator_traits< InputIt >::iterator_category, std::input_iterator_tag >::value >::type require_input_iter
*brief create a new JSON pointer by appending the unescaped token at the end of the JSON pointer *sa std::string token
bool contains(const BasicJsonType *ptr) const
basic_json< nlohmann::ordered_map > ordered_json
specialization that maintains the insertion order of object keys
*brief create JSON pointer *sa reference_tokens const std::string & a
iterator find(const Key &key)
static BasicJsonType unflatten(const BasicJsonType &value)
*brief remove last reference token *sa JSON pointer has no parent
*brief create JSON pointer *sa reference_tokens end()
std::vector< std::pair< const Key, T >, Allocator > Container
static BasicJsonType::size_type array_index(const std::string &s)
typename Container::value_type value_type
typename Container::iterator iterator
size_type count(const Key &key) const
static void flatten(const std::string &reference_string, const BasicJsonType &value, BasicJsonType &result)
*brief append another JSON pointer at the end of this JSON pointer *sa ptr reference_tokens begin()
*brief create JSON pointer *sa reference_tokens const std::string const std::string & b
*brief create a new JSON pointer by appending the right JSON pointer at the end of the left JSON pointer *sa const json_pointer & rhs
BasicJsonType & get_checked(BasicJsonType *ptr) const
basic_json<> json
default specialization
friend bool operator!=(json_pointer const &lhs, json_pointer const &rhs) noexcept
compares two JSON pointers for inequality
typename Container::const_iterator const_iterator
size_type erase(const Key &key)
std::pair< iterator, bool > emplace(const key_type &key, T &&t)
BasicJsonType & get_and_create(BasicJsonType &j) const
create and return a reference to the pointed to value
*brief remove last reference token *sa JSON pointer has no BasicJsonType()))
return reference_tokens back()
*brief create a new JSON pointer by appending the array index token at the end of the JSON pointer *sa std::size_t array_idx
static std::vector< std::string > split(const std::string &reference_string)
split the string input to reference tokens
friend bool operator==(json_pointer const &lhs, json_pointer const &rhs) noexcept
compares two JSON pointers for equality
std::pair< iterator, bool > insert(value_type &&value)
BasicJsonType & get_unchecked(BasicJsonType *ptr) const
return a reference to the pointed to value
T & operator[](const Key &key)
*brief exchanges the values of two JSON objects *sa nlohmann::NLOHMANN_BASIC_JSON_TPL &j2 noexcept(is_nothrow_move_constructible< nlohmann::NLOHMANN_BASIC_JSON_TPL >::value &&is_nothrow_move_assignable< nlohmann::NLOHMANN_BASIC_JSON_TPL >::value)
default JSONSerializer template argument
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 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 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)))
static constexpr bool value
typename BasicJsonType::template json_serializer< T, void > serializer
typename BasicJsonType::template json_serializer< T, void > serializer
static constexpr bool value
static constexpr bool value
typename BasicJsonType::template json_serializer< T, void > serializer
static constexpr std::size_t size() noexcept
*iterator for JSON objects BasicJsonType::object_t::iterator object_iterator
*iterator for JSON arrays BasicJsonType::array_t::iterator array_iterator
*generic iterator for all other types primitive_iterator_t primitive_iterator
static constexpr bool value
static constexpr bool value
typename BasicJsonType::object_t object_t
static constexpr auto value
static constexpr bool 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 static constexpr bool 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
static constexpr bool value
typename BasicJsonType::object_t object_t
static constexpr auto value
static constexpr bool value
typename std::iterator_traits< T >::value_type value_type
iterator_traits< T > traits
static constexpr auto value
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
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())
integer_sequence< T, Ints...,(Ints+SeqSize)..., 2 *SeqSize > type
integer_sequence< T, Ints...,(Ints+SeqSize)... > type
integer_sequence< T > type
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
bool operator()(nlohmann::detail::value_t lhs, nlohmann::detail::value_t rhs) const noexcept
compare two value_t enum values