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>
63 #include <type_traits>
71 #include <forward_list>
76 #include <type_traits>
77 #include <unordered_map>
158 static constexpr std::array<std::uint8_t, 9> order = {{
165 const auto l_index =
static_cast<std::size_t>(lhs);
166 const auto r_index =
static_cast<std::size_t>(rhs);
167 return l_index < order.size() && r_index < order.size() && order[l_index] < order[r_index];
195 #if !defined(JSON_HEDLEY_VERSION) || (JSON_HEDLEY_VERSION < 15)
196 #if defined(JSON_HEDLEY_VERSION)
197 #undef JSON_HEDLEY_VERSION
199 #define JSON_HEDLEY_VERSION 15
201 #if defined(JSON_HEDLEY_STRINGIFY_EX)
202 #undef JSON_HEDLEY_STRINGIFY_EX
204 #define JSON_HEDLEY_STRINGIFY_EX(x) #x
206 #if defined(JSON_HEDLEY_STRINGIFY)
207 #undef JSON_HEDLEY_STRINGIFY
209 #define JSON_HEDLEY_STRINGIFY(x) JSON_HEDLEY_STRINGIFY_EX(x)
211 #if defined(JSON_HEDLEY_CONCAT_EX)
212 #undef JSON_HEDLEY_CONCAT_EX
214 #define JSON_HEDLEY_CONCAT_EX(a,b) a##b
216 #if defined(JSON_HEDLEY_CONCAT)
217 #undef JSON_HEDLEY_CONCAT
219 #define JSON_HEDLEY_CONCAT(a,b) JSON_HEDLEY_CONCAT_EX(a,b)
221 #if defined(JSON_HEDLEY_CONCAT3_EX)
222 #undef JSON_HEDLEY_CONCAT3_EX
224 #define JSON_HEDLEY_CONCAT3_EX(a,b,c) a##b##c
226 #if defined(JSON_HEDLEY_CONCAT3)
227 #undef JSON_HEDLEY_CONCAT3
229 #define JSON_HEDLEY_CONCAT3(a,b,c) JSON_HEDLEY_CONCAT3_EX(a,b,c)
231 #if defined(JSON_HEDLEY_VERSION_ENCODE)
232 #undef JSON_HEDLEY_VERSION_ENCODE
234 #define JSON_HEDLEY_VERSION_ENCODE(major,minor,revision) (((major) * 1000000) + ((minor) * 1000) + (revision))
236 #if defined(JSON_HEDLEY_VERSION_DECODE_MAJOR)
237 #undef JSON_HEDLEY_VERSION_DECODE_MAJOR
239 #define JSON_HEDLEY_VERSION_DECODE_MAJOR(version) ((version) / 1000000)
241 #if defined(JSON_HEDLEY_VERSION_DECODE_MINOR)
242 #undef JSON_HEDLEY_VERSION_DECODE_MINOR
244 #define JSON_HEDLEY_VERSION_DECODE_MINOR(version) (((version) % 1000000) / 1000)
246 #if defined(JSON_HEDLEY_VERSION_DECODE_REVISION)
247 #undef JSON_HEDLEY_VERSION_DECODE_REVISION
249 #define JSON_HEDLEY_VERSION_DECODE_REVISION(version) ((version) % 1000)
251 #if defined(JSON_HEDLEY_GNUC_VERSION)
252 #undef JSON_HEDLEY_GNUC_VERSION
254 #if defined(__GNUC__) && defined(__GNUC_PATCHLEVEL__)
255 #define JSON_HEDLEY_GNUC_VERSION JSON_HEDLEY_VERSION_ENCODE(__GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__)
256 #elif defined(__GNUC__)
257 #define JSON_HEDLEY_GNUC_VERSION JSON_HEDLEY_VERSION_ENCODE(__GNUC__, __GNUC_MINOR__, 0)
260 #if defined(JSON_HEDLEY_GNUC_VERSION_CHECK)
261 #undef JSON_HEDLEY_GNUC_VERSION_CHECK
263 #if defined(JSON_HEDLEY_GNUC_VERSION)
264 #define JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_GNUC_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
266 #define JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) (0)
269 #if defined(JSON_HEDLEY_MSVC_VERSION)
270 #undef JSON_HEDLEY_MSVC_VERSION
272 #if defined(_MSC_FULL_VER) && (_MSC_FULL_VER >= 140000000) && !defined(__ICL)
273 #define JSON_HEDLEY_MSVC_VERSION JSON_HEDLEY_VERSION_ENCODE(_MSC_FULL_VER / 10000000, (_MSC_FULL_VER % 10000000) / 100000, (_MSC_FULL_VER % 100000) / 100)
274 #elif defined(_MSC_FULL_VER) && !defined(__ICL)
275 #define JSON_HEDLEY_MSVC_VERSION JSON_HEDLEY_VERSION_ENCODE(_MSC_FULL_VER / 1000000, (_MSC_FULL_VER % 1000000) / 10000, (_MSC_FULL_VER % 10000) / 10)
276 #elif defined(_MSC_VER) && !defined(__ICL)
277 #define JSON_HEDLEY_MSVC_VERSION JSON_HEDLEY_VERSION_ENCODE(_MSC_VER / 100, _MSC_VER % 100, 0)
280 #if defined(JSON_HEDLEY_MSVC_VERSION_CHECK)
281 #undef JSON_HEDLEY_MSVC_VERSION_CHECK
283 #if !defined(JSON_HEDLEY_MSVC_VERSION)
284 #define JSON_HEDLEY_MSVC_VERSION_CHECK(major,minor,patch) (0)
285 #elif defined(_MSC_VER) && (_MSC_VER >= 1400)
286 #define JSON_HEDLEY_MSVC_VERSION_CHECK(major,minor,patch) (_MSC_FULL_VER >= ((major * 10000000) + (minor * 100000) + (patch)))
287 #elif defined(_MSC_VER) && (_MSC_VER >= 1200)
288 #define JSON_HEDLEY_MSVC_VERSION_CHECK(major,minor,patch) (_MSC_FULL_VER >= ((major * 1000000) + (minor * 10000) + (patch)))
290 #define JSON_HEDLEY_MSVC_VERSION_CHECK(major,minor,patch) (_MSC_VER >= ((major * 100) + (minor)))
293 #if defined(JSON_HEDLEY_INTEL_VERSION)
294 #undef JSON_HEDLEY_INTEL_VERSION
296 #if defined(__INTEL_COMPILER) && defined(__INTEL_COMPILER_UPDATE) && !defined(__ICL)
297 #define JSON_HEDLEY_INTEL_VERSION JSON_HEDLEY_VERSION_ENCODE(__INTEL_COMPILER / 100, __INTEL_COMPILER % 100, __INTEL_COMPILER_UPDATE)
298 #elif defined(__INTEL_COMPILER) && !defined(__ICL)
299 #define JSON_HEDLEY_INTEL_VERSION JSON_HEDLEY_VERSION_ENCODE(__INTEL_COMPILER / 100, __INTEL_COMPILER % 100, 0)
302 #if defined(JSON_HEDLEY_INTEL_VERSION_CHECK)
303 #undef JSON_HEDLEY_INTEL_VERSION_CHECK
305 #if defined(JSON_HEDLEY_INTEL_VERSION)
306 #define JSON_HEDLEY_INTEL_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_INTEL_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
308 #define JSON_HEDLEY_INTEL_VERSION_CHECK(major,minor,patch) (0)
311 #if defined(JSON_HEDLEY_INTEL_CL_VERSION)
312 #undef JSON_HEDLEY_INTEL_CL_VERSION
314 #if defined(__INTEL_COMPILER) && defined(__INTEL_COMPILER_UPDATE) && defined(__ICL)
315 #define JSON_HEDLEY_INTEL_CL_VERSION JSON_HEDLEY_VERSION_ENCODE(__INTEL_COMPILER, __INTEL_COMPILER_UPDATE, 0)
318 #if defined(JSON_HEDLEY_INTEL_CL_VERSION_CHECK)
319 #undef JSON_HEDLEY_INTEL_CL_VERSION_CHECK
321 #if defined(JSON_HEDLEY_INTEL_CL_VERSION)
322 #define JSON_HEDLEY_INTEL_CL_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_INTEL_CL_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
324 #define JSON_HEDLEY_INTEL_CL_VERSION_CHECK(major,minor,patch) (0)
327 #if defined(JSON_HEDLEY_PGI_VERSION)
328 #undef JSON_HEDLEY_PGI_VERSION
330 #if defined(__PGI) && defined(__PGIC__) && defined(__PGIC_MINOR__) && defined(__PGIC_PATCHLEVEL__)
331 #define JSON_HEDLEY_PGI_VERSION JSON_HEDLEY_VERSION_ENCODE(__PGIC__, __PGIC_MINOR__, __PGIC_PATCHLEVEL__)
334 #if defined(JSON_HEDLEY_PGI_VERSION_CHECK)
335 #undef JSON_HEDLEY_PGI_VERSION_CHECK
337 #if defined(JSON_HEDLEY_PGI_VERSION)
338 #define JSON_HEDLEY_PGI_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_PGI_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
340 #define JSON_HEDLEY_PGI_VERSION_CHECK(major,minor,patch) (0)
343 #if defined(JSON_HEDLEY_SUNPRO_VERSION)
344 #undef JSON_HEDLEY_SUNPRO_VERSION
346 #if defined(__SUNPRO_C) && (__SUNPRO_C > 0x1000)
347 #define JSON_HEDLEY_SUNPRO_VERSION JSON_HEDLEY_VERSION_ENCODE((((__SUNPRO_C >> 16) & 0xf) * 10) + ((__SUNPRO_C >> 12) & 0xf), (((__SUNPRO_C >> 8) & 0xf) * 10) + ((__SUNPRO_C >> 4) & 0xf), (__SUNPRO_C & 0xf) * 10)
348 #elif defined(__SUNPRO_C)
349 #define JSON_HEDLEY_SUNPRO_VERSION JSON_HEDLEY_VERSION_ENCODE((__SUNPRO_C >> 8) & 0xf, (__SUNPRO_C >> 4) & 0xf, (__SUNPRO_C) & 0xf)
350 #elif defined(__SUNPRO_CC) && (__SUNPRO_CC > 0x1000)
351 #define JSON_HEDLEY_SUNPRO_VERSION JSON_HEDLEY_VERSION_ENCODE((((__SUNPRO_CC >> 16) & 0xf) * 10) + ((__SUNPRO_CC >> 12) & 0xf), (((__SUNPRO_CC >> 8) & 0xf) * 10) + ((__SUNPRO_CC >> 4) & 0xf), (__SUNPRO_CC & 0xf) * 10)
352 #elif defined(__SUNPRO_CC)
353 #define JSON_HEDLEY_SUNPRO_VERSION JSON_HEDLEY_VERSION_ENCODE((__SUNPRO_CC >> 8) & 0xf, (__SUNPRO_CC >> 4) & 0xf, (__SUNPRO_CC) & 0xf)
356 #if defined(JSON_HEDLEY_SUNPRO_VERSION_CHECK)
357 #undef JSON_HEDLEY_SUNPRO_VERSION_CHECK
359 #if defined(JSON_HEDLEY_SUNPRO_VERSION)
360 #define JSON_HEDLEY_SUNPRO_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_SUNPRO_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
362 #define JSON_HEDLEY_SUNPRO_VERSION_CHECK(major,minor,patch) (0)
365 #if defined(JSON_HEDLEY_EMSCRIPTEN_VERSION)
366 #undef JSON_HEDLEY_EMSCRIPTEN_VERSION
368 #if defined(__EMSCRIPTEN__)
369 #define JSON_HEDLEY_EMSCRIPTEN_VERSION JSON_HEDLEY_VERSION_ENCODE(__EMSCRIPTEN_major__, __EMSCRIPTEN_minor__, __EMSCRIPTEN_tiny__)
372 #if defined(JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK)
373 #undef JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK
375 #if defined(JSON_HEDLEY_EMSCRIPTEN_VERSION)
376 #define JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_EMSCRIPTEN_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
378 #define JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK(major,minor,patch) (0)
381 #if defined(JSON_HEDLEY_ARM_VERSION)
382 #undef JSON_HEDLEY_ARM_VERSION
384 #if defined(__CC_ARM) && defined(__ARMCOMPILER_VERSION)
385 #define JSON_HEDLEY_ARM_VERSION JSON_HEDLEY_VERSION_ENCODE(__ARMCOMPILER_VERSION / 1000000, (__ARMCOMPILER_VERSION % 1000000) / 10000, (__ARMCOMPILER_VERSION % 10000) / 100)
386 #elif defined(__CC_ARM) && defined(__ARMCC_VERSION)
387 #define JSON_HEDLEY_ARM_VERSION JSON_HEDLEY_VERSION_ENCODE(__ARMCC_VERSION / 1000000, (__ARMCC_VERSION % 1000000) / 10000, (__ARMCC_VERSION % 10000) / 100)
390 #if defined(JSON_HEDLEY_ARM_VERSION_CHECK)
391 #undef JSON_HEDLEY_ARM_VERSION_CHECK
393 #if defined(JSON_HEDLEY_ARM_VERSION)
394 #define JSON_HEDLEY_ARM_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_ARM_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
396 #define JSON_HEDLEY_ARM_VERSION_CHECK(major,minor,patch) (0)
399 #if defined(JSON_HEDLEY_IBM_VERSION)
400 #undef JSON_HEDLEY_IBM_VERSION
402 #if defined(__ibmxl__)
403 #define JSON_HEDLEY_IBM_VERSION JSON_HEDLEY_VERSION_ENCODE(__ibmxl_version__, __ibmxl_release__, __ibmxl_modification__)
404 #elif defined(__xlC__) && defined(__xlC_ver__)
405 #define JSON_HEDLEY_IBM_VERSION JSON_HEDLEY_VERSION_ENCODE(__xlC__ >> 8, __xlC__ & 0xff, (__xlC_ver__ >> 8) & 0xff)
406 #elif defined(__xlC__)
407 #define JSON_HEDLEY_IBM_VERSION JSON_HEDLEY_VERSION_ENCODE(__xlC__ >> 8, __xlC__ & 0xff, 0)
410 #if defined(JSON_HEDLEY_IBM_VERSION_CHECK)
411 #undef JSON_HEDLEY_IBM_VERSION_CHECK
413 #if defined(JSON_HEDLEY_IBM_VERSION)
414 #define JSON_HEDLEY_IBM_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_IBM_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
416 #define JSON_HEDLEY_IBM_VERSION_CHECK(major,minor,patch) (0)
419 #if defined(JSON_HEDLEY_TI_VERSION)
420 #undef JSON_HEDLEY_TI_VERSION
423 defined(__TI_COMPILER_VERSION__) && \
425 defined(__TMS470__) || defined(__TI_ARM__) || \
426 defined(__MSP430__) || \
427 defined(__TMS320C2000__) \
429 #if (__TI_COMPILER_VERSION__ >= 16000000)
430 #define JSON_HEDLEY_TI_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000))
434 #if defined(JSON_HEDLEY_TI_VERSION_CHECK)
435 #undef JSON_HEDLEY_TI_VERSION_CHECK
437 #if defined(JSON_HEDLEY_TI_VERSION)
438 #define JSON_HEDLEY_TI_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
440 #define JSON_HEDLEY_TI_VERSION_CHECK(major,minor,patch) (0)
443 #if defined(JSON_HEDLEY_TI_CL2000_VERSION)
444 #undef JSON_HEDLEY_TI_CL2000_VERSION
446 #if defined(__TI_COMPILER_VERSION__) && defined(__TMS320C2000__)
447 #define JSON_HEDLEY_TI_CL2000_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000))
450 #if defined(JSON_HEDLEY_TI_CL2000_VERSION_CHECK)
451 #undef JSON_HEDLEY_TI_CL2000_VERSION_CHECK
453 #if defined(JSON_HEDLEY_TI_CL2000_VERSION)
454 #define JSON_HEDLEY_TI_CL2000_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_CL2000_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
456 #define JSON_HEDLEY_TI_CL2000_VERSION_CHECK(major,minor,patch) (0)
459 #if defined(JSON_HEDLEY_TI_CL430_VERSION)
460 #undef JSON_HEDLEY_TI_CL430_VERSION
462 #if defined(__TI_COMPILER_VERSION__) && defined(__MSP430__)
463 #define JSON_HEDLEY_TI_CL430_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000))
466 #if defined(JSON_HEDLEY_TI_CL430_VERSION_CHECK)
467 #undef JSON_HEDLEY_TI_CL430_VERSION_CHECK
469 #if defined(JSON_HEDLEY_TI_CL430_VERSION)
470 #define JSON_HEDLEY_TI_CL430_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_CL430_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
472 #define JSON_HEDLEY_TI_CL430_VERSION_CHECK(major,minor,patch) (0)
475 #if defined(JSON_HEDLEY_TI_ARMCL_VERSION)
476 #undef JSON_HEDLEY_TI_ARMCL_VERSION
478 #if defined(__TI_COMPILER_VERSION__) && (defined(__TMS470__) || defined(__TI_ARM__))
479 #define JSON_HEDLEY_TI_ARMCL_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000))
482 #if defined(JSON_HEDLEY_TI_ARMCL_VERSION_CHECK)
483 #undef JSON_HEDLEY_TI_ARMCL_VERSION_CHECK
485 #if defined(JSON_HEDLEY_TI_ARMCL_VERSION)
486 #define JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_ARMCL_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
488 #define JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(major,minor,patch) (0)
491 #if defined(JSON_HEDLEY_TI_CL6X_VERSION)
492 #undef JSON_HEDLEY_TI_CL6X_VERSION
494 #if defined(__TI_COMPILER_VERSION__) && defined(__TMS320C6X__)
495 #define JSON_HEDLEY_TI_CL6X_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000))
498 #if defined(JSON_HEDLEY_TI_CL6X_VERSION_CHECK)
499 #undef JSON_HEDLEY_TI_CL6X_VERSION_CHECK
501 #if defined(JSON_HEDLEY_TI_CL6X_VERSION)
502 #define JSON_HEDLEY_TI_CL6X_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_CL6X_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
504 #define JSON_HEDLEY_TI_CL6X_VERSION_CHECK(major,minor,patch) (0)
507 #if defined(JSON_HEDLEY_TI_CL7X_VERSION)
508 #undef JSON_HEDLEY_TI_CL7X_VERSION
510 #if defined(__TI_COMPILER_VERSION__) && defined(__C7000__)
511 #define JSON_HEDLEY_TI_CL7X_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000))
514 #if defined(JSON_HEDLEY_TI_CL7X_VERSION_CHECK)
515 #undef JSON_HEDLEY_TI_CL7X_VERSION_CHECK
517 #if defined(JSON_HEDLEY_TI_CL7X_VERSION)
518 #define JSON_HEDLEY_TI_CL7X_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_CL7X_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
520 #define JSON_HEDLEY_TI_CL7X_VERSION_CHECK(major,minor,patch) (0)
523 #if defined(JSON_HEDLEY_TI_CLPRU_VERSION)
524 #undef JSON_HEDLEY_TI_CLPRU_VERSION
526 #if defined(__TI_COMPILER_VERSION__) && defined(__PRU__)
527 #define JSON_HEDLEY_TI_CLPRU_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000))
530 #if defined(JSON_HEDLEY_TI_CLPRU_VERSION_CHECK)
531 #undef JSON_HEDLEY_TI_CLPRU_VERSION_CHECK
533 #if defined(JSON_HEDLEY_TI_CLPRU_VERSION)
534 #define JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_CLPRU_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
536 #define JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(major,minor,patch) (0)
539 #if defined(JSON_HEDLEY_CRAY_VERSION)
540 #undef JSON_HEDLEY_CRAY_VERSION
543 #if defined(_RELEASE_PATCHLEVEL)
544 #define JSON_HEDLEY_CRAY_VERSION JSON_HEDLEY_VERSION_ENCODE(_RELEASE_MAJOR, _RELEASE_MINOR, _RELEASE_PATCHLEVEL)
546 #define JSON_HEDLEY_CRAY_VERSION JSON_HEDLEY_VERSION_ENCODE(_RELEASE_MAJOR, _RELEASE_MINOR, 0)
550 #if defined(JSON_HEDLEY_CRAY_VERSION_CHECK)
551 #undef JSON_HEDLEY_CRAY_VERSION_CHECK
553 #if defined(JSON_HEDLEY_CRAY_VERSION)
554 #define JSON_HEDLEY_CRAY_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_CRAY_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
556 #define JSON_HEDLEY_CRAY_VERSION_CHECK(major,minor,patch) (0)
559 #if defined(JSON_HEDLEY_IAR_VERSION)
560 #undef JSON_HEDLEY_IAR_VERSION
562 #if defined(__IAR_SYSTEMS_ICC__)
564 #define JSON_HEDLEY_IAR_VERSION JSON_HEDLEY_VERSION_ENCODE((__VER__ / 1000000), ((__VER__ / 1000) % 1000), (__VER__ % 1000))
566 #define JSON_HEDLEY_IAR_VERSION JSON_HEDLEY_VERSION_ENCODE(__VER__ / 100, __VER__ % 100, 0)
570 #if defined(JSON_HEDLEY_IAR_VERSION_CHECK)
571 #undef JSON_HEDLEY_IAR_VERSION_CHECK
573 #if defined(JSON_HEDLEY_IAR_VERSION)
574 #define JSON_HEDLEY_IAR_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_IAR_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
576 #define JSON_HEDLEY_IAR_VERSION_CHECK(major,minor,patch) (0)
579 #if defined(JSON_HEDLEY_TINYC_VERSION)
580 #undef JSON_HEDLEY_TINYC_VERSION
582 #if defined(__TINYC__)
583 #define JSON_HEDLEY_TINYC_VERSION JSON_HEDLEY_VERSION_ENCODE(__TINYC__ / 1000, (__TINYC__ / 100) % 10, __TINYC__ % 100)
586 #if defined(JSON_HEDLEY_TINYC_VERSION_CHECK)
587 #undef JSON_HEDLEY_TINYC_VERSION_CHECK
589 #if defined(JSON_HEDLEY_TINYC_VERSION)
590 #define JSON_HEDLEY_TINYC_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TINYC_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
592 #define JSON_HEDLEY_TINYC_VERSION_CHECK(major,minor,patch) (0)
595 #if defined(JSON_HEDLEY_DMC_VERSION)
596 #undef JSON_HEDLEY_DMC_VERSION
599 #define JSON_HEDLEY_DMC_VERSION JSON_HEDLEY_VERSION_ENCODE(__DMC__ >> 8, (__DMC__ >> 4) & 0xf, __DMC__ & 0xf)
602 #if defined(JSON_HEDLEY_DMC_VERSION_CHECK)
603 #undef JSON_HEDLEY_DMC_VERSION_CHECK
605 #if defined(JSON_HEDLEY_DMC_VERSION)
606 #define JSON_HEDLEY_DMC_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_DMC_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
608 #define JSON_HEDLEY_DMC_VERSION_CHECK(major,minor,patch) (0)
611 #if defined(JSON_HEDLEY_COMPCERT_VERSION)
612 #undef JSON_HEDLEY_COMPCERT_VERSION
614 #if defined(__COMPCERT_VERSION__)
615 #define JSON_HEDLEY_COMPCERT_VERSION JSON_HEDLEY_VERSION_ENCODE(__COMPCERT_VERSION__ / 10000, (__COMPCERT_VERSION__ / 100) % 100, __COMPCERT_VERSION__ % 100)
618 #if defined(JSON_HEDLEY_COMPCERT_VERSION_CHECK)
619 #undef JSON_HEDLEY_COMPCERT_VERSION_CHECK
621 #if defined(JSON_HEDLEY_COMPCERT_VERSION)
622 #define JSON_HEDLEY_COMPCERT_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_COMPCERT_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
624 #define JSON_HEDLEY_COMPCERT_VERSION_CHECK(major,minor,patch) (0)
627 #if defined(JSON_HEDLEY_PELLES_VERSION)
628 #undef JSON_HEDLEY_PELLES_VERSION
630 #if defined(__POCC__)
631 #define JSON_HEDLEY_PELLES_VERSION JSON_HEDLEY_VERSION_ENCODE(__POCC__ / 100, __POCC__ % 100, 0)
634 #if defined(JSON_HEDLEY_PELLES_VERSION_CHECK)
635 #undef JSON_HEDLEY_PELLES_VERSION_CHECK
637 #if defined(JSON_HEDLEY_PELLES_VERSION)
638 #define JSON_HEDLEY_PELLES_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_PELLES_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
640 #define JSON_HEDLEY_PELLES_VERSION_CHECK(major,minor,patch) (0)
643 #if defined(JSON_HEDLEY_MCST_LCC_VERSION)
644 #undef JSON_HEDLEY_MCST_LCC_VERSION
646 #if defined(__LCC__) && defined(__LCC_MINOR__)
647 #define JSON_HEDLEY_MCST_LCC_VERSION JSON_HEDLEY_VERSION_ENCODE(__LCC__ / 100, __LCC__ % 100, __LCC_MINOR__)
650 #if defined(JSON_HEDLEY_MCST_LCC_VERSION_CHECK)
651 #undef JSON_HEDLEY_MCST_LCC_VERSION_CHECK
653 #if defined(JSON_HEDLEY_MCST_LCC_VERSION)
654 #define JSON_HEDLEY_MCST_LCC_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_MCST_LCC_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
656 #define JSON_HEDLEY_MCST_LCC_VERSION_CHECK(major,minor,patch) (0)
659 #if defined(JSON_HEDLEY_GCC_VERSION)
660 #undef JSON_HEDLEY_GCC_VERSION
663 defined(JSON_HEDLEY_GNUC_VERSION) && \
664 !defined(__clang__) && \
665 !defined(JSON_HEDLEY_INTEL_VERSION) && \
666 !defined(JSON_HEDLEY_PGI_VERSION) && \
667 !defined(JSON_HEDLEY_ARM_VERSION) && \
668 !defined(JSON_HEDLEY_CRAY_VERSION) && \
669 !defined(JSON_HEDLEY_TI_VERSION) && \
670 !defined(JSON_HEDLEY_TI_ARMCL_VERSION) && \
671 !defined(JSON_HEDLEY_TI_CL430_VERSION) && \
672 !defined(JSON_HEDLEY_TI_CL2000_VERSION) && \
673 !defined(JSON_HEDLEY_TI_CL6X_VERSION) && \
674 !defined(JSON_HEDLEY_TI_CL7X_VERSION) && \
675 !defined(JSON_HEDLEY_TI_CLPRU_VERSION) && \
676 !defined(__COMPCERT__) && \
677 !defined(JSON_HEDLEY_MCST_LCC_VERSION)
678 #define JSON_HEDLEY_GCC_VERSION JSON_HEDLEY_GNUC_VERSION
681 #if defined(JSON_HEDLEY_GCC_VERSION_CHECK)
682 #undef JSON_HEDLEY_GCC_VERSION_CHECK
684 #if defined(JSON_HEDLEY_GCC_VERSION)
685 #define JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_GCC_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
687 #define JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) (0)
690 #if defined(JSON_HEDLEY_HAS_ATTRIBUTE)
691 #undef JSON_HEDLEY_HAS_ATTRIBUTE
694 defined(__has_attribute) && \
696 (!defined(JSON_HEDLEY_IAR_VERSION) || JSON_HEDLEY_IAR_VERSION_CHECK(8,5,9)) \
698 # define JSON_HEDLEY_HAS_ATTRIBUTE(attribute) __has_attribute(attribute)
700 # define JSON_HEDLEY_HAS_ATTRIBUTE(attribute) (0)
703 #if defined(JSON_HEDLEY_GNUC_HAS_ATTRIBUTE)
704 #undef JSON_HEDLEY_GNUC_HAS_ATTRIBUTE
706 #if defined(__has_attribute)
707 #define JSON_HEDLEY_GNUC_HAS_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_HAS_ATTRIBUTE(attribute)
709 #define JSON_HEDLEY_GNUC_HAS_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch)
712 #if defined(JSON_HEDLEY_GCC_HAS_ATTRIBUTE)
713 #undef JSON_HEDLEY_GCC_HAS_ATTRIBUTE
715 #if defined(__has_attribute)
716 #define JSON_HEDLEY_GCC_HAS_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_HAS_ATTRIBUTE(attribute)
718 #define JSON_HEDLEY_GCC_HAS_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch)
721 #if defined(JSON_HEDLEY_HAS_CPP_ATTRIBUTE)
722 #undef JSON_HEDLEY_HAS_CPP_ATTRIBUTE
725 defined(__has_cpp_attribute) && \
726 defined(__cplusplus) && \
727 (!defined(JSON_HEDLEY_SUNPRO_VERSION) || JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,15,0))
728 #define JSON_HEDLEY_HAS_CPP_ATTRIBUTE(attribute) __has_cpp_attribute(attribute)
730 #define JSON_HEDLEY_HAS_CPP_ATTRIBUTE(attribute) (0)
733 #if defined(JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS)
734 #undef JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS
736 #if !defined(__cplusplus) || !defined(__has_cpp_attribute)
737 #define JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS(ns,attribute) (0)
739 !defined(JSON_HEDLEY_PGI_VERSION) && \
740 !defined(JSON_HEDLEY_IAR_VERSION) && \
741 (!defined(JSON_HEDLEY_SUNPRO_VERSION) || JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,15,0)) && \
742 (!defined(JSON_HEDLEY_MSVC_VERSION) || JSON_HEDLEY_MSVC_VERSION_CHECK(19,20,0))
743 #define JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS(ns,attribute) JSON_HEDLEY_HAS_CPP_ATTRIBUTE(ns::attribute)
745 #define JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS(ns,attribute) (0)
748 #if defined(JSON_HEDLEY_GNUC_HAS_CPP_ATTRIBUTE)
749 #undef JSON_HEDLEY_GNUC_HAS_CPP_ATTRIBUTE
751 #if defined(__has_cpp_attribute) && defined(__cplusplus)
752 #define JSON_HEDLEY_GNUC_HAS_CPP_ATTRIBUTE(attribute,major,minor,patch) __has_cpp_attribute(attribute)
754 #define JSON_HEDLEY_GNUC_HAS_CPP_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch)
757 #if defined(JSON_HEDLEY_GCC_HAS_CPP_ATTRIBUTE)
758 #undef JSON_HEDLEY_GCC_HAS_CPP_ATTRIBUTE
760 #if defined(__has_cpp_attribute) && defined(__cplusplus)
761 #define JSON_HEDLEY_GCC_HAS_CPP_ATTRIBUTE(attribute,major,minor,patch) __has_cpp_attribute(attribute)
763 #define JSON_HEDLEY_GCC_HAS_CPP_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch)
766 #if defined(JSON_HEDLEY_HAS_BUILTIN)
767 #undef JSON_HEDLEY_HAS_BUILTIN
769 #if defined(__has_builtin)
770 #define JSON_HEDLEY_HAS_BUILTIN(builtin) __has_builtin(builtin)
772 #define JSON_HEDLEY_HAS_BUILTIN(builtin) (0)
775 #if defined(JSON_HEDLEY_GNUC_HAS_BUILTIN)
776 #undef JSON_HEDLEY_GNUC_HAS_BUILTIN
778 #if defined(__has_builtin)
779 #define JSON_HEDLEY_GNUC_HAS_BUILTIN(builtin,major,minor,patch) __has_builtin(builtin)
781 #define JSON_HEDLEY_GNUC_HAS_BUILTIN(builtin,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch)
784 #if defined(JSON_HEDLEY_GCC_HAS_BUILTIN)
785 #undef JSON_HEDLEY_GCC_HAS_BUILTIN
787 #if defined(__has_builtin)
788 #define JSON_HEDLEY_GCC_HAS_BUILTIN(builtin,major,minor,patch) __has_builtin(builtin)
790 #define JSON_HEDLEY_GCC_HAS_BUILTIN(builtin,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch)
793 #if defined(JSON_HEDLEY_HAS_FEATURE)
794 #undef JSON_HEDLEY_HAS_FEATURE
796 #if defined(__has_feature)
797 #define JSON_HEDLEY_HAS_FEATURE(feature) __has_feature(feature)
799 #define JSON_HEDLEY_HAS_FEATURE(feature) (0)
802 #if defined(JSON_HEDLEY_GNUC_HAS_FEATURE)
803 #undef JSON_HEDLEY_GNUC_HAS_FEATURE
805 #if defined(__has_feature)
806 #define JSON_HEDLEY_GNUC_HAS_FEATURE(feature,major,minor,patch) __has_feature(feature)
808 #define JSON_HEDLEY_GNUC_HAS_FEATURE(feature,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch)
811 #if defined(JSON_HEDLEY_GCC_HAS_FEATURE)
812 #undef JSON_HEDLEY_GCC_HAS_FEATURE
814 #if defined(__has_feature)
815 #define JSON_HEDLEY_GCC_HAS_FEATURE(feature,major,minor,patch) __has_feature(feature)
817 #define JSON_HEDLEY_GCC_HAS_FEATURE(feature,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch)
820 #if defined(JSON_HEDLEY_HAS_EXTENSION)
821 #undef JSON_HEDLEY_HAS_EXTENSION
823 #if defined(__has_extension)
824 #define JSON_HEDLEY_HAS_EXTENSION(extension) __has_extension(extension)
826 #define JSON_HEDLEY_HAS_EXTENSION(extension) (0)
829 #if defined(JSON_HEDLEY_GNUC_HAS_EXTENSION)
830 #undef JSON_HEDLEY_GNUC_HAS_EXTENSION
832 #if defined(__has_extension)
833 #define JSON_HEDLEY_GNUC_HAS_EXTENSION(extension,major,minor,patch) __has_extension(extension)
835 #define JSON_HEDLEY_GNUC_HAS_EXTENSION(extension,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch)
838 #if defined(JSON_HEDLEY_GCC_HAS_EXTENSION)
839 #undef JSON_HEDLEY_GCC_HAS_EXTENSION
841 #if defined(__has_extension)
842 #define JSON_HEDLEY_GCC_HAS_EXTENSION(extension,major,minor,patch) __has_extension(extension)
844 #define JSON_HEDLEY_GCC_HAS_EXTENSION(extension,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch)
847 #if defined(JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE)
848 #undef JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE
850 #if defined(__has_declspec_attribute)
851 #define JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE(attribute) __has_declspec_attribute(attribute)
853 #define JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE(attribute) (0)
856 #if defined(JSON_HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE)
857 #undef JSON_HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE
859 #if defined(__has_declspec_attribute)
860 #define JSON_HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE(attribute,major,minor,patch) __has_declspec_attribute(attribute)
862 #define JSON_HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch)
865 #if defined(JSON_HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE)
866 #undef JSON_HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE
868 #if defined(__has_declspec_attribute)
869 #define JSON_HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE(attribute,major,minor,patch) __has_declspec_attribute(attribute)
871 #define JSON_HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch)
874 #if defined(JSON_HEDLEY_HAS_WARNING)
875 #undef JSON_HEDLEY_HAS_WARNING
877 #if defined(__has_warning)
878 #define JSON_HEDLEY_HAS_WARNING(warning) __has_warning(warning)
880 #define JSON_HEDLEY_HAS_WARNING(warning) (0)
883 #if defined(JSON_HEDLEY_GNUC_HAS_WARNING)
884 #undef JSON_HEDLEY_GNUC_HAS_WARNING
886 #if defined(__has_warning)
887 #define JSON_HEDLEY_GNUC_HAS_WARNING(warning,major,minor,patch) __has_warning(warning)
889 #define JSON_HEDLEY_GNUC_HAS_WARNING(warning,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch)
892 #if defined(JSON_HEDLEY_GCC_HAS_WARNING)
893 #undef JSON_HEDLEY_GCC_HAS_WARNING
895 #if defined(__has_warning)
896 #define JSON_HEDLEY_GCC_HAS_WARNING(warning,major,minor,patch) __has_warning(warning)
898 #define JSON_HEDLEY_GCC_HAS_WARNING(warning,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch)
902 (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)) || \
903 defined(__clang__) || \
904 JSON_HEDLEY_GCC_VERSION_CHECK(3,0,0) || \
905 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
906 JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) || \
907 JSON_HEDLEY_PGI_VERSION_CHECK(18,4,0) || \
908 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
909 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
910 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,7,0) || \
911 JSON_HEDLEY_TI_CL430_VERSION_CHECK(2,0,1) || \
912 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,1,0) || \
913 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,0,0) || \
914 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
915 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
916 JSON_HEDLEY_CRAY_VERSION_CHECK(5,0,0) || \
917 JSON_HEDLEY_TINYC_VERSION_CHECK(0,9,17) || \
918 JSON_HEDLEY_SUNPRO_VERSION_CHECK(8,0,0) || \
919 (JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) && defined(__C99_PRAGMA_OPERATOR))
920 #define JSON_HEDLEY_PRAGMA(value) _Pragma(#value)
921 #elif JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0)
922 #define JSON_HEDLEY_PRAGMA(value) __pragma(value)
924 #define JSON_HEDLEY_PRAGMA(value)
927 #if defined(JSON_HEDLEY_DIAGNOSTIC_PUSH)
928 #undef JSON_HEDLEY_DIAGNOSTIC_PUSH
930 #if defined(JSON_HEDLEY_DIAGNOSTIC_POP)
931 #undef JSON_HEDLEY_DIAGNOSTIC_POP
933 #if defined(__clang__)
934 #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("clang diagnostic push")
935 #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("clang diagnostic pop")
936 #elif JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0)
937 #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("warning(push)")
938 #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("warning(pop)")
939 #elif JSON_HEDLEY_GCC_VERSION_CHECK(4,6,0)
940 #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("GCC diagnostic push")
941 #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("GCC diagnostic pop")
943 JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0) || \
944 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
945 #define JSON_HEDLEY_DIAGNOSTIC_PUSH __pragma(warning(push))
946 #define JSON_HEDLEY_DIAGNOSTIC_POP __pragma(warning(pop))
947 #elif JSON_HEDLEY_ARM_VERSION_CHECK(5,6,0)
948 #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("push")
949 #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("pop")
951 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
952 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
953 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,4,0) || \
954 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,1,0) || \
955 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
956 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0)
957 #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("diag_push")
958 #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("diag_pop")
959 #elif JSON_HEDLEY_PELLES_VERSION_CHECK(2,90,0)
960 #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("warning(push)")
961 #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("warning(pop)")
963 #define JSON_HEDLEY_DIAGNOSTIC_PUSH
964 #define JSON_HEDLEY_DIAGNOSTIC_POP
969 #if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_)
970 #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_
972 #if defined(__cplusplus)
973 # if JSON_HEDLEY_HAS_WARNING("-Wc++98-compat")
974 # if JSON_HEDLEY_HAS_WARNING("-Wc++17-extensions")
975 # if JSON_HEDLEY_HAS_WARNING("-Wc++1z-extensions")
976 # define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(xpr) \
977 JSON_HEDLEY_DIAGNOSTIC_PUSH \
978 _Pragma("clang diagnostic ignored \"-Wc++98-compat\"") \
979 _Pragma("clang diagnostic ignored \"-Wc++17-extensions\"") \
980 _Pragma("clang diagnostic ignored \"-Wc++1z-extensions\"") \
982 JSON_HEDLEY_DIAGNOSTIC_POP
984 # define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(xpr) \
985 JSON_HEDLEY_DIAGNOSTIC_PUSH \
986 _Pragma("clang diagnostic ignored \"-Wc++98-compat\"") \
987 _Pragma("clang diagnostic ignored \"-Wc++17-extensions\"") \
989 JSON_HEDLEY_DIAGNOSTIC_POP
992 # define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(xpr) \
993 JSON_HEDLEY_DIAGNOSTIC_PUSH \
994 _Pragma("clang diagnostic ignored \"-Wc++98-compat\"") \
996 JSON_HEDLEY_DIAGNOSTIC_POP
1000 #if !defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_)
1001 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(x) x
1004 #if defined(JSON_HEDLEY_CONST_CAST)
1005 #undef JSON_HEDLEY_CONST_CAST
1007 #if defined(__cplusplus)
1008 # define JSON_HEDLEY_CONST_CAST(T, expr) (const_cast<T>(expr))
1010 JSON_HEDLEY_HAS_WARNING("-Wcast-qual") || \
1011 JSON_HEDLEY_GCC_VERSION_CHECK(4,6,0) || \
1012 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0)
1013 # define JSON_HEDLEY_CONST_CAST(T, expr) (__extension__ ({ \
1014 JSON_HEDLEY_DIAGNOSTIC_PUSH \
1015 JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL \
1017 JSON_HEDLEY_DIAGNOSTIC_POP \
1020 # define JSON_HEDLEY_CONST_CAST(T, expr) ((T) (expr))
1023 #if defined(JSON_HEDLEY_REINTERPRET_CAST)
1024 #undef JSON_HEDLEY_REINTERPRET_CAST
1026 #if defined(__cplusplus)
1027 #define JSON_HEDLEY_REINTERPRET_CAST(T, expr) (reinterpret_cast<T>(expr))
1029 #define JSON_HEDLEY_REINTERPRET_CAST(T, expr) ((T) (expr))
1032 #if defined(JSON_HEDLEY_STATIC_CAST)
1033 #undef JSON_HEDLEY_STATIC_CAST
1035 #if defined(__cplusplus)
1036 #define JSON_HEDLEY_STATIC_CAST(T, expr) (static_cast<T>(expr))
1038 #define JSON_HEDLEY_STATIC_CAST(T, expr) ((T) (expr))
1041 #if defined(JSON_HEDLEY_CPP_CAST)
1042 #undef JSON_HEDLEY_CPP_CAST
1044 #if defined(__cplusplus)
1045 # if JSON_HEDLEY_HAS_WARNING("-Wold-style-cast")
1046 # define JSON_HEDLEY_CPP_CAST(T, expr) \
1047 JSON_HEDLEY_DIAGNOSTIC_PUSH \
1048 _Pragma("clang diagnostic ignored \"-Wold-style-cast\"") \
1050 JSON_HEDLEY_DIAGNOSTIC_POP
1051 # elif JSON_HEDLEY_IAR_VERSION_CHECK(8,3,0)
1052 # define JSON_HEDLEY_CPP_CAST(T, expr) \
1053 JSON_HEDLEY_DIAGNOSTIC_PUSH \
1054 _Pragma("diag_suppress=Pe137") \
1055 JSON_HEDLEY_DIAGNOSTIC_POP
1057 # define JSON_HEDLEY_CPP_CAST(T, expr) ((T) (expr))
1060 # define JSON_HEDLEY_CPP_CAST(T, expr) (expr)
1063 #if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED)
1064 #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED
1066 #if JSON_HEDLEY_HAS_WARNING("-Wdeprecated-declarations")
1067 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("clang diagnostic ignored \"-Wdeprecated-declarations\"")
1068 #elif JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0)
1069 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("warning(disable:1478 1786)")
1070 #elif JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1071 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED __pragma(warning(disable:1478 1786))
1072 #elif JSON_HEDLEY_PGI_VERSION_CHECK(20,7,0)
1073 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress 1215,1216,1444,1445")
1074 #elif JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0)
1075 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress 1215,1444")
1076 #elif JSON_HEDLEY_GCC_VERSION_CHECK(4,3,0)
1077 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"")
1078 #elif JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0)
1079 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED __pragma(warning(disable:4996))
1080 #elif JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1081 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress 1215,1444")
1083 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1084 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1085 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1086 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1087 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1088 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1089 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1090 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1091 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1092 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1093 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0)
1094 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress 1291,1718")
1095 #elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,13,0) && !defined(__cplusplus)
1096 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("error_messages(off,E_DEPRECATED_ATT,E_DEPRECATED_ATT_MESS)")
1097 #elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,13,0) && defined(__cplusplus)
1098 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("error_messages(off,symdeprecated,symdeprecated2)")
1099 #elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
1100 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress=Pe1444,Pe1215")
1101 #elif JSON_HEDLEY_PELLES_VERSION_CHECK(2,90,0)
1102 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("warn(disable:2241)")
1104 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED
1107 #if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS)
1108 #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS
1110 #if JSON_HEDLEY_HAS_WARNING("-Wunknown-pragmas")
1111 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("clang diagnostic ignored \"-Wunknown-pragmas\"")
1112 #elif JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0)
1113 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("warning(disable:161)")
1114 #elif JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1115 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS __pragma(warning(disable:161))
1116 #elif JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0)
1117 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress 1675")
1118 #elif JSON_HEDLEY_GCC_VERSION_CHECK(4,3,0)
1119 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("GCC diagnostic ignored \"-Wunknown-pragmas\"")
1120 #elif JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0)
1121 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS __pragma(warning(disable:4068))
1123 JSON_HEDLEY_TI_VERSION_CHECK(16,9,0) || \
1124 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,0,0) || \
1125 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1126 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,3,0)
1127 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress 163")
1128 #elif JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,0,0)
1129 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress 163")
1130 #elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
1131 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress=Pe161")
1132 #elif JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1133 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress 161")
1135 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS
1138 #if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES)
1139 #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES
1141 #if JSON_HEDLEY_HAS_WARNING("-Wunknown-attributes")
1142 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("clang diagnostic ignored \"-Wunknown-attributes\"")
1143 #elif JSON_HEDLEY_GCC_VERSION_CHECK(4,6,0)
1144 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"")
1145 #elif JSON_HEDLEY_INTEL_VERSION_CHECK(17,0,0)
1146 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("warning(disable:1292)")
1147 #elif JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1148 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES __pragma(warning(disable:1292))
1149 #elif JSON_HEDLEY_MSVC_VERSION_CHECK(19,0,0)
1150 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES __pragma(warning(disable:5030))
1151 #elif JSON_HEDLEY_PGI_VERSION_CHECK(20,7,0)
1152 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress 1097,1098")
1153 #elif JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0)
1154 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress 1097")
1155 #elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,14,0) && defined(__cplusplus)
1156 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("error_messages(off,attrskipunsup)")
1158 JSON_HEDLEY_TI_VERSION_CHECK(18,1,0) || \
1159 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,3,0) || \
1160 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0)
1161 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress 1173")
1162 #elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
1163 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress=Pe1097")
1164 #elif JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1165 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress 1097")
1167 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES
1170 #if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL)
1171 #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL
1173 #if JSON_HEDLEY_HAS_WARNING("-Wcast-qual")
1174 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL _Pragma("clang diagnostic ignored \"-Wcast-qual\"")
1175 #elif JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0)
1176 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL _Pragma("warning(disable:2203 2331)")
1177 #elif JSON_HEDLEY_GCC_VERSION_CHECK(3,0,0)
1178 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL _Pragma("GCC diagnostic ignored \"-Wcast-qual\"")
1180 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL
1183 #if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION)
1184 #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION
1186 #if JSON_HEDLEY_HAS_WARNING("-Wunused-function")
1187 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION _Pragma("clang diagnostic ignored \"-Wunused-function\"")
1188 #elif JSON_HEDLEY_GCC_VERSION_CHECK(3,4,0)
1189 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION _Pragma("GCC diagnostic ignored \"-Wunused-function\"")
1190 #elif JSON_HEDLEY_MSVC_VERSION_CHECK(1,0,0)
1191 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION __pragma(warning(disable:4505))
1192 #elif JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1193 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION _Pragma("diag_suppress 3142")
1195 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION
1198 #if defined(JSON_HEDLEY_DEPRECATED)
1199 #undef JSON_HEDLEY_DEPRECATED
1201 #if defined(JSON_HEDLEY_DEPRECATED_FOR)
1202 #undef JSON_HEDLEY_DEPRECATED_FOR
1205 JSON_HEDLEY_MSVC_VERSION_CHECK(14,0,0) || \
1206 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1207 #define JSON_HEDLEY_DEPRECATED(since) __declspec(deprecated("Since " # since))
1208 #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) __declspec(deprecated("Since " #since "; use " #replacement))
1210 (JSON_HEDLEY_HAS_EXTENSION(attribute_deprecated_with_message) && !defined(JSON_HEDLEY_IAR_VERSION)) || \
1211 JSON_HEDLEY_GCC_VERSION_CHECK(4,5,0) || \
1212 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1213 JSON_HEDLEY_ARM_VERSION_CHECK(5,6,0) || \
1214 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,13,0) || \
1215 JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) || \
1216 JSON_HEDLEY_TI_VERSION_CHECK(18,1,0) || \
1217 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(18,1,0) || \
1218 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,3,0) || \
1219 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1220 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,3,0) || \
1221 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1222 #define JSON_HEDLEY_DEPRECATED(since) __attribute__((__deprecated__("Since " #since)))
1223 #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) __attribute__((__deprecated__("Since " #since "; use " #replacement)))
1224 #elif defined(__cplusplus) && (__cplusplus >= 201402L)
1225 #define JSON_HEDLEY_DEPRECATED(since) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[deprecated("Since " #since)]])
1226 #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[deprecated("Since " #since "; use " #replacement)]])
1228 JSON_HEDLEY_HAS_ATTRIBUTE(deprecated) || \
1229 JSON_HEDLEY_GCC_VERSION_CHECK(3,1,0) || \
1230 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1231 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1232 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1233 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1234 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1235 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1236 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1237 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1238 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1239 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1240 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1241 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1242 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) || \
1243 JSON_HEDLEY_IAR_VERSION_CHECK(8,10,0)
1244 #define JSON_HEDLEY_DEPRECATED(since) __attribute__((__deprecated__))
1245 #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) __attribute__((__deprecated__))
1247 JSON_HEDLEY_MSVC_VERSION_CHECK(13,10,0) || \
1248 JSON_HEDLEY_PELLES_VERSION_CHECK(6,50,0) || \
1249 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1250 #define JSON_HEDLEY_DEPRECATED(since) __declspec(deprecated)
1251 #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) __declspec(deprecated)
1252 #elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
1253 #define JSON_HEDLEY_DEPRECATED(since) _Pragma("deprecated")
1254 #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) _Pragma("deprecated")
1256 #define JSON_HEDLEY_DEPRECATED(since)
1257 #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement)
1260 #if defined(JSON_HEDLEY_UNAVAILABLE)
1261 #undef JSON_HEDLEY_UNAVAILABLE
1264 JSON_HEDLEY_HAS_ATTRIBUTE(warning) || \
1265 JSON_HEDLEY_GCC_VERSION_CHECK(4,3,0) || \
1266 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1267 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1268 #define JSON_HEDLEY_UNAVAILABLE(available_since) __attribute__((__warning__("Not available until " #available_since)))
1270 #define JSON_HEDLEY_UNAVAILABLE(available_since)
1273 #if defined(JSON_HEDLEY_WARN_UNUSED_RESULT)
1274 #undef JSON_HEDLEY_WARN_UNUSED_RESULT
1276 #if defined(JSON_HEDLEY_WARN_UNUSED_RESULT_MSG)
1277 #undef JSON_HEDLEY_WARN_UNUSED_RESULT_MSG
1280 JSON_HEDLEY_HAS_ATTRIBUTE(warn_unused_result) || \
1281 JSON_HEDLEY_GCC_VERSION_CHECK(3,4,0) || \
1282 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1283 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1284 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1285 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1286 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1287 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1288 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1289 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1290 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1291 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1292 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1293 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1294 (JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,15,0) && defined(__cplusplus)) || \
1295 JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) || \
1296 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1297 #define JSON_HEDLEY_WARN_UNUSED_RESULT __attribute__((__warn_unused_result__))
1298 #define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg) __attribute__((__warn_unused_result__))
1299 #elif (JSON_HEDLEY_HAS_CPP_ATTRIBUTE(nodiscard) >= 201907L)
1300 #define JSON_HEDLEY_WARN_UNUSED_RESULT JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[nodiscard]])
1301 #define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[nodiscard(msg)]])
1302 #elif JSON_HEDLEY_HAS_CPP_ATTRIBUTE(nodiscard)
1303 #define JSON_HEDLEY_WARN_UNUSED_RESULT JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[nodiscard]])
1304 #define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[nodiscard]])
1305 #elif defined(_Check_return_)
1306 #define JSON_HEDLEY_WARN_UNUSED_RESULT _Check_return_
1307 #define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg) _Check_return_
1309 #define JSON_HEDLEY_WARN_UNUSED_RESULT
1310 #define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg)
1313 #if defined(JSON_HEDLEY_SENTINEL)
1314 #undef JSON_HEDLEY_SENTINEL
1317 JSON_HEDLEY_HAS_ATTRIBUTE(sentinel) || \
1318 JSON_HEDLEY_GCC_VERSION_CHECK(4,0,0) || \
1319 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1320 JSON_HEDLEY_ARM_VERSION_CHECK(5,4,0) || \
1321 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1322 #define JSON_HEDLEY_SENTINEL(position) __attribute__((__sentinel__(position)))
1324 #define JSON_HEDLEY_SENTINEL(position)
1327 #if defined(JSON_HEDLEY_NO_RETURN)
1328 #undef JSON_HEDLEY_NO_RETURN
1330 #if JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
1331 #define JSON_HEDLEY_NO_RETURN __noreturn
1333 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1334 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1335 #define JSON_HEDLEY_NO_RETURN __attribute__((__noreturn__))
1336 #elif defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L
1337 #define JSON_HEDLEY_NO_RETURN _Noreturn
1338 #elif defined(__cplusplus) && (__cplusplus >= 201103L)
1339 #define JSON_HEDLEY_NO_RETURN JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[noreturn]])
1341 JSON_HEDLEY_HAS_ATTRIBUTE(noreturn) || \
1342 JSON_HEDLEY_GCC_VERSION_CHECK(3,2,0) || \
1343 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \
1344 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1345 JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
1346 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1347 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1348 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1349 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1350 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1351 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1352 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1353 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1354 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1355 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1356 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1357 JSON_HEDLEY_IAR_VERSION_CHECK(8,10,0)
1358 #define JSON_HEDLEY_NO_RETURN __attribute__((__noreturn__))
1359 #elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0)
1360 #define JSON_HEDLEY_NO_RETURN _Pragma("does_not_return")
1362 JSON_HEDLEY_MSVC_VERSION_CHECK(13,10,0) || \
1363 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1364 #define JSON_HEDLEY_NO_RETURN __declspec(noreturn)
1365 #elif JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6,0,0) && defined(__cplusplus)
1366 #define JSON_HEDLEY_NO_RETURN _Pragma("FUNC_NEVER_RETURNS;")
1367 #elif JSON_HEDLEY_COMPCERT_VERSION_CHECK(3,2,0)
1368 #define JSON_HEDLEY_NO_RETURN __attribute((noreturn))
1369 #elif JSON_HEDLEY_PELLES_VERSION_CHECK(9,0,0)
1370 #define JSON_HEDLEY_NO_RETURN __declspec(noreturn)
1372 #define JSON_HEDLEY_NO_RETURN
1375 #if defined(JSON_HEDLEY_NO_ESCAPE)
1376 #undef JSON_HEDLEY_NO_ESCAPE
1378 #if JSON_HEDLEY_HAS_ATTRIBUTE(noescape)
1379 #define JSON_HEDLEY_NO_ESCAPE __attribute__((__noescape__))
1381 #define JSON_HEDLEY_NO_ESCAPE
1384 #if defined(JSON_HEDLEY_UNREACHABLE)
1385 #undef JSON_HEDLEY_UNREACHABLE
1387 #if defined(JSON_HEDLEY_UNREACHABLE_RETURN)
1388 #undef JSON_HEDLEY_UNREACHABLE_RETURN
1390 #if defined(JSON_HEDLEY_ASSUME)
1391 #undef JSON_HEDLEY_ASSUME
1394 JSON_HEDLEY_MSVC_VERSION_CHECK(13,10,0) || \
1395 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1396 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1397 #define JSON_HEDLEY_ASSUME(expr) __assume(expr)
1398 #elif JSON_HEDLEY_HAS_BUILTIN(__builtin_assume)
1399 #define JSON_HEDLEY_ASSUME(expr) __builtin_assume(expr)
1401 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,2,0) || \
1402 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(4,0,0)
1403 #if defined(__cplusplus)
1404 #define JSON_HEDLEY_ASSUME(expr) std::_nassert(expr)
1406 #define JSON_HEDLEY_ASSUME(expr) _nassert(expr)
1410 (JSON_HEDLEY_HAS_BUILTIN(__builtin_unreachable) && (!defined(JSON_HEDLEY_ARM_VERSION))) || \
1411 JSON_HEDLEY_GCC_VERSION_CHECK(4,5,0) || \
1412 JSON_HEDLEY_PGI_VERSION_CHECK(18,10,0) || \
1413 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1414 JSON_HEDLEY_IBM_VERSION_CHECK(13,1,5) || \
1415 JSON_HEDLEY_CRAY_VERSION_CHECK(10,0,0) || \
1416 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1417 #define JSON_HEDLEY_UNREACHABLE() __builtin_unreachable()
1418 #elif defined(JSON_HEDLEY_ASSUME)
1419 #define JSON_HEDLEY_UNREACHABLE() JSON_HEDLEY_ASSUME(0)
1421 #if !defined(JSON_HEDLEY_ASSUME)
1422 #if defined(JSON_HEDLEY_UNREACHABLE)
1423 #define JSON_HEDLEY_ASSUME(expr) JSON_HEDLEY_STATIC_CAST(void, ((expr) ? 1 : (JSON_HEDLEY_UNREACHABLE(), 1)))
1425 #define JSON_HEDLEY_ASSUME(expr) JSON_HEDLEY_STATIC_CAST(void, expr)
1428 #if defined(JSON_HEDLEY_UNREACHABLE)
1430 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,2,0) || \
1431 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(4,0,0)
1432 #define JSON_HEDLEY_UNREACHABLE_RETURN(value) return (JSON_HEDLEY_STATIC_CAST(void, JSON_HEDLEY_ASSUME(0)), (value))
1434 #define JSON_HEDLEY_UNREACHABLE_RETURN(value) JSON_HEDLEY_UNREACHABLE()
1437 #define JSON_HEDLEY_UNREACHABLE_RETURN(value) return (value)
1439 #if !defined(JSON_HEDLEY_UNREACHABLE)
1440 #define JSON_HEDLEY_UNREACHABLE() JSON_HEDLEY_ASSUME(0)
1444 #if JSON_HEDLEY_HAS_WARNING("-Wpedantic")
1445 #pragma clang diagnostic ignored "-Wpedantic"
1447 #if JSON_HEDLEY_HAS_WARNING("-Wc++98-compat-pedantic") && defined(__cplusplus)
1448 #pragma clang diagnostic ignored "-Wc++98-compat-pedantic"
1450 #if JSON_HEDLEY_GCC_HAS_WARNING("-Wvariadic-macros",4,0,0)
1451 #if defined(__clang__)
1452 #pragma clang diagnostic ignored "-Wvariadic-macros"
1453 #elif defined(JSON_HEDLEY_GCC_VERSION)
1454 #pragma GCC diagnostic ignored "-Wvariadic-macros"
1457 #if defined(JSON_HEDLEY_NON_NULL)
1458 #undef JSON_HEDLEY_NON_NULL
1461 JSON_HEDLEY_HAS_ATTRIBUTE(nonnull) || \
1462 JSON_HEDLEY_GCC_VERSION_CHECK(3,3,0) || \
1463 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1464 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0)
1465 #define JSON_HEDLEY_NON_NULL(...) __attribute__((__nonnull__(__VA_ARGS__)))
1467 #define JSON_HEDLEY_NON_NULL(...)
1471 #if defined(JSON_HEDLEY_PRINTF_FORMAT)
1472 #undef JSON_HEDLEY_PRINTF_FORMAT
1474 #if defined(__MINGW32__) && JSON_HEDLEY_GCC_HAS_ATTRIBUTE(format,4,4,0) && !defined(__USE_MINGW_ANSI_STDIO)
1475 #define JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) __attribute__((__format__(ms_printf, string_idx, first_to_check)))
1476 #elif defined(__MINGW32__) && JSON_HEDLEY_GCC_HAS_ATTRIBUTE(format,4,4,0) && defined(__USE_MINGW_ANSI_STDIO)
1477 #define JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) __attribute__((__format__(gnu_printf, string_idx, first_to_check)))
1479 JSON_HEDLEY_HAS_ATTRIBUTE(format) || \
1480 JSON_HEDLEY_GCC_VERSION_CHECK(3,1,0) || \
1481 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1482 JSON_HEDLEY_ARM_VERSION_CHECK(5,6,0) || \
1483 JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
1484 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1485 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1486 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1487 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1488 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1489 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1490 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1491 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1492 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1493 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1494 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1495 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1496 #define JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) __attribute__((__format__(__printf__, string_idx, first_to_check)))
1497 #elif JSON_HEDLEY_PELLES_VERSION_CHECK(6,0,0)
1498 #define JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) __declspec(vaformat(printf,string_idx,first_to_check))
1500 #define JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check)
1503 #if defined(JSON_HEDLEY_CONSTEXPR)
1504 #undef JSON_HEDLEY_CONSTEXPR
1506 #if defined(__cplusplus)
1507 #if __cplusplus >= 201103L
1508 #define JSON_HEDLEY_CONSTEXPR JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(constexpr)
1511 #if !defined(JSON_HEDLEY_CONSTEXPR)
1512 #define JSON_HEDLEY_CONSTEXPR
1515 #if defined(JSON_HEDLEY_PREDICT)
1516 #undef JSON_HEDLEY_PREDICT
1518 #if defined(JSON_HEDLEY_LIKELY)
1519 #undef JSON_HEDLEY_LIKELY
1521 #if defined(JSON_HEDLEY_UNLIKELY)
1522 #undef JSON_HEDLEY_UNLIKELY
1524 #if defined(JSON_HEDLEY_UNPREDICTABLE)
1525 #undef JSON_HEDLEY_UNPREDICTABLE
1527 #if JSON_HEDLEY_HAS_BUILTIN(__builtin_unpredictable)
1528 #define JSON_HEDLEY_UNPREDICTABLE(expr) __builtin_unpredictable((expr))
1531 (JSON_HEDLEY_HAS_BUILTIN(__builtin_expect_with_probability) && !defined(JSON_HEDLEY_PGI_VERSION)) || \
1532 JSON_HEDLEY_GCC_VERSION_CHECK(9,0,0) || \
1533 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1534 # define JSON_HEDLEY_PREDICT(expr, value, probability) __builtin_expect_with_probability( (expr), (value), (probability))
1535 # define JSON_HEDLEY_PREDICT_TRUE(expr, probability) __builtin_expect_with_probability(!!(expr), 1 , (probability))
1536 # define JSON_HEDLEY_PREDICT_FALSE(expr, probability) __builtin_expect_with_probability(!!(expr), 0 , (probability))
1537 # define JSON_HEDLEY_LIKELY(expr) __builtin_expect (!!(expr), 1 )
1538 # define JSON_HEDLEY_UNLIKELY(expr) __builtin_expect (!!(expr), 0 )
1540 (JSON_HEDLEY_HAS_BUILTIN(__builtin_expect) && !defined(JSON_HEDLEY_INTEL_CL_VERSION)) || \
1541 JSON_HEDLEY_GCC_VERSION_CHECK(3,0,0) || \
1542 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1543 (JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,15,0) && defined(__cplusplus)) || \
1544 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1545 JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
1546 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1547 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,7,0) || \
1548 JSON_HEDLEY_TI_CL430_VERSION_CHECK(3,1,0) || \
1549 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,1,0) || \
1550 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6,1,0) || \
1551 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1552 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1553 JSON_HEDLEY_TINYC_VERSION_CHECK(0,9,27) || \
1554 JSON_HEDLEY_CRAY_VERSION_CHECK(8,1,0) || \
1555 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1556 # define JSON_HEDLEY_PREDICT(expr, expected, probability) \
1557 (((probability) >= 0.9) ? __builtin_expect((expr), (expected)) : (JSON_HEDLEY_STATIC_CAST(void, expected), (expr)))
1558 # define JSON_HEDLEY_PREDICT_TRUE(expr, probability) \
1560 double hedley_probability_ = (probability); \
1561 ((hedley_probability_ >= 0.9) ? __builtin_expect(!!(expr), 1) : ((hedley_probability_ <= 0.1) ? __builtin_expect(!!(expr), 0) : !!(expr))); \
1563 # define JSON_HEDLEY_PREDICT_FALSE(expr, probability) \
1565 double hedley_probability_ = (probability); \
1566 ((hedley_probability_ >= 0.9) ? __builtin_expect(!!(expr), 0) : ((hedley_probability_ <= 0.1) ? __builtin_expect(!!(expr), 1) : !!(expr))); \
1568 # define JSON_HEDLEY_LIKELY(expr) __builtin_expect(!!(expr), 1)
1569 # define JSON_HEDLEY_UNLIKELY(expr) __builtin_expect(!!(expr), 0)
1571 # define JSON_HEDLEY_PREDICT(expr, expected, probability) (JSON_HEDLEY_STATIC_CAST(void, expected), (expr))
1572 # define JSON_HEDLEY_PREDICT_TRUE(expr, probability) (!!(expr))
1573 # define JSON_HEDLEY_PREDICT_FALSE(expr, probability) (!!(expr))
1574 # define JSON_HEDLEY_LIKELY(expr) (!!(expr))
1575 # define JSON_HEDLEY_UNLIKELY(expr) (!!(expr))
1577 #if !defined(JSON_HEDLEY_UNPREDICTABLE)
1578 #define JSON_HEDLEY_UNPREDICTABLE(expr) JSON_HEDLEY_PREDICT(expr, 1, 0.5)
1581 #if defined(JSON_HEDLEY_MALLOC)
1582 #undef JSON_HEDLEY_MALLOC
1585 JSON_HEDLEY_HAS_ATTRIBUTE(malloc) || \
1586 JSON_HEDLEY_GCC_VERSION_CHECK(3,1,0) || \
1587 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1588 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \
1589 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1590 JSON_HEDLEY_IBM_VERSION_CHECK(12,1,0) || \
1591 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1592 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1593 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1594 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1595 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1596 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1597 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1598 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1599 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1600 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1601 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1602 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1603 #define JSON_HEDLEY_MALLOC __attribute__((__malloc__))
1604 #elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0)
1605 #define JSON_HEDLEY_MALLOC _Pragma("returns_new_memory")
1607 JSON_HEDLEY_MSVC_VERSION_CHECK(14,0,0) || \
1608 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1609 #define JSON_HEDLEY_MALLOC __declspec(restrict)
1611 #define JSON_HEDLEY_MALLOC
1614 #if defined(JSON_HEDLEY_PURE)
1615 #undef JSON_HEDLEY_PURE
1618 JSON_HEDLEY_HAS_ATTRIBUTE(pure) || \
1619 JSON_HEDLEY_GCC_VERSION_CHECK(2,96,0) || \
1620 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1621 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \
1622 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1623 JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
1624 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1625 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1626 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1627 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1628 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1629 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1630 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1631 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1632 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1633 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1634 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1635 JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) || \
1636 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1637 # define JSON_HEDLEY_PURE __attribute__((__pure__))
1638 #elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0)
1639 # define JSON_HEDLEY_PURE _Pragma("does_not_write_global_data")
1640 #elif defined(__cplusplus) && \
1642 JSON_HEDLEY_TI_CL430_VERSION_CHECK(2,0,1) || \
1643 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(4,0,0) || \
1644 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) \
1646 # define JSON_HEDLEY_PURE _Pragma("FUNC_IS_PURE;")
1648 # define JSON_HEDLEY_PURE
1651 #if defined(JSON_HEDLEY_CONST)
1652 #undef JSON_HEDLEY_CONST
1655 JSON_HEDLEY_HAS_ATTRIBUTE(const) || \
1656 JSON_HEDLEY_GCC_VERSION_CHECK(2,5,0) || \
1657 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1658 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \
1659 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1660 JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
1661 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1662 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1663 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1664 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1665 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1666 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1667 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1668 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1669 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1670 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1671 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1672 JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) || \
1673 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1674 #define JSON_HEDLEY_CONST __attribute__((__const__))
1676 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0)
1677 #define JSON_HEDLEY_CONST _Pragma("no_side_effect")
1679 #define JSON_HEDLEY_CONST JSON_HEDLEY_PURE
1682 #if defined(JSON_HEDLEY_RESTRICT)
1683 #undef JSON_HEDLEY_RESTRICT
1685 #if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) && !defined(__cplusplus)
1686 #define JSON_HEDLEY_RESTRICT restrict
1688 JSON_HEDLEY_GCC_VERSION_CHECK(3,1,0) || \
1689 JSON_HEDLEY_MSVC_VERSION_CHECK(14,0,0) || \
1690 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1691 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) || \
1692 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1693 JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
1694 JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) || \
1695 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1696 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,2,4) || \
1697 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,1,0) || \
1698 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1699 (JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,14,0) && defined(__cplusplus)) || \
1700 JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) || \
1701 defined(__clang__) || \
1702 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1703 #define JSON_HEDLEY_RESTRICT __restrict
1704 #elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,3,0) && !defined(__cplusplus)
1705 #define JSON_HEDLEY_RESTRICT _Restrict
1707 #define JSON_HEDLEY_RESTRICT
1710 #if defined(JSON_HEDLEY_INLINE)
1711 #undef JSON_HEDLEY_INLINE
1714 (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)) || \
1715 (defined(__cplusplus) && (__cplusplus >= 199711L))
1716 #define JSON_HEDLEY_INLINE inline
1718 defined(JSON_HEDLEY_GCC_VERSION) || \
1719 JSON_HEDLEY_ARM_VERSION_CHECK(6,2,0)
1720 #define JSON_HEDLEY_INLINE __inline__
1722 JSON_HEDLEY_MSVC_VERSION_CHECK(12,0,0) || \
1723 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) || \
1724 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1725 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,1,0) || \
1726 JSON_HEDLEY_TI_CL430_VERSION_CHECK(3,1,0) || \
1727 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,2,0) || \
1728 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,0,0) || \
1729 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1730 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1731 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1732 #define JSON_HEDLEY_INLINE __inline
1734 #define JSON_HEDLEY_INLINE
1737 #if defined(JSON_HEDLEY_ALWAYS_INLINE)
1738 #undef JSON_HEDLEY_ALWAYS_INLINE
1741 JSON_HEDLEY_HAS_ATTRIBUTE(always_inline) || \
1742 JSON_HEDLEY_GCC_VERSION_CHECK(4,0,0) || \
1743 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1744 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \
1745 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1746 JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
1747 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1748 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1749 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1750 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1751 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1752 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1753 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1754 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1755 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1756 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1757 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1758 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) || \
1759 JSON_HEDLEY_IAR_VERSION_CHECK(8,10,0)
1760 # define JSON_HEDLEY_ALWAYS_INLINE __attribute__((__always_inline__)) JSON_HEDLEY_INLINE
1762 JSON_HEDLEY_MSVC_VERSION_CHECK(12,0,0) || \
1763 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1764 # define JSON_HEDLEY_ALWAYS_INLINE __forceinline
1765 #elif defined(__cplusplus) && \
1767 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1768 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1769 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1770 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6,1,0) || \
1771 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1772 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) \
1774 # define JSON_HEDLEY_ALWAYS_INLINE _Pragma("FUNC_ALWAYS_INLINE;")
1775 #elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
1776 # define JSON_HEDLEY_ALWAYS_INLINE _Pragma("inline=forced")
1778 # define JSON_HEDLEY_ALWAYS_INLINE JSON_HEDLEY_INLINE
1781 #if defined(JSON_HEDLEY_NEVER_INLINE)
1782 #undef JSON_HEDLEY_NEVER_INLINE
1785 JSON_HEDLEY_HAS_ATTRIBUTE(noinline) || \
1786 JSON_HEDLEY_GCC_VERSION_CHECK(4,0,0) || \
1787 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1788 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \
1789 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1790 JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
1791 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1792 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1793 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1794 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1795 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1796 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1797 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1798 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1799 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1800 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1801 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1802 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) || \
1803 JSON_HEDLEY_IAR_VERSION_CHECK(8,10,0)
1804 #define JSON_HEDLEY_NEVER_INLINE __attribute__((__noinline__))
1806 JSON_HEDLEY_MSVC_VERSION_CHECK(13,10,0) || \
1807 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1808 #define JSON_HEDLEY_NEVER_INLINE __declspec(noinline)
1809 #elif JSON_HEDLEY_PGI_VERSION_CHECK(10,2,0)
1810 #define JSON_HEDLEY_NEVER_INLINE _Pragma("noinline")
1811 #elif JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6,0,0) && defined(__cplusplus)
1812 #define JSON_HEDLEY_NEVER_INLINE _Pragma("FUNC_CANNOT_INLINE;")
1813 #elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
1814 #define JSON_HEDLEY_NEVER_INLINE _Pragma("inline=never")
1815 #elif JSON_HEDLEY_COMPCERT_VERSION_CHECK(3,2,0)
1816 #define JSON_HEDLEY_NEVER_INLINE __attribute((noinline))
1817 #elif JSON_HEDLEY_PELLES_VERSION_CHECK(9,0,0)
1818 #define JSON_HEDLEY_NEVER_INLINE __declspec(noinline)
1820 #define JSON_HEDLEY_NEVER_INLINE
1823 #if defined(JSON_HEDLEY_PRIVATE)
1824 #undef JSON_HEDLEY_PRIVATE
1826 #if defined(JSON_HEDLEY_PUBLIC)
1827 #undef JSON_HEDLEY_PUBLIC
1829 #if defined(JSON_HEDLEY_IMPORT)
1830 #undef JSON_HEDLEY_IMPORT
1832 #if defined(_WIN32) || defined(__CYGWIN__)
1833 # define JSON_HEDLEY_PRIVATE
1834 # define JSON_HEDLEY_PUBLIC __declspec(dllexport)
1835 # define JSON_HEDLEY_IMPORT __declspec(dllimport)
1838 JSON_HEDLEY_HAS_ATTRIBUTE(visibility) || \
1839 JSON_HEDLEY_GCC_VERSION_CHECK(3,3,0) || \
1840 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \
1841 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1842 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1843 JSON_HEDLEY_IBM_VERSION_CHECK(13,1,0) || \
1845 defined(__TI_EABI__) && \
1847 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1848 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) \
1851 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1852 # define JSON_HEDLEY_PRIVATE __attribute__((__visibility__("hidden")))
1853 # define JSON_HEDLEY_PUBLIC __attribute__((__visibility__("default")))
1855 # define JSON_HEDLEY_PRIVATE
1856 # define JSON_HEDLEY_PUBLIC
1858 # define JSON_HEDLEY_IMPORT extern
1861 #if defined(JSON_HEDLEY_NO_THROW)
1862 #undef JSON_HEDLEY_NO_THROW
1865 JSON_HEDLEY_HAS_ATTRIBUTE(nothrow) || \
1866 JSON_HEDLEY_GCC_VERSION_CHECK(3,3,0) || \
1867 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1868 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1869 #define JSON_HEDLEY_NO_THROW __attribute__((__nothrow__))
1871 JSON_HEDLEY_MSVC_VERSION_CHECK(13,1,0) || \
1872 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) || \
1873 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0)
1874 #define JSON_HEDLEY_NO_THROW __declspec(nothrow)
1876 #define JSON_HEDLEY_NO_THROW
1879 #if defined(JSON_HEDLEY_FALL_THROUGH)
1880 #undef JSON_HEDLEY_FALL_THROUGH
1883 JSON_HEDLEY_HAS_ATTRIBUTE(fallthrough) || \
1884 JSON_HEDLEY_GCC_VERSION_CHECK(7,0,0) || \
1885 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1886 #define JSON_HEDLEY_FALL_THROUGH __attribute__((__fallthrough__))
1887 #elif JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS(clang,fallthrough)
1888 #define JSON_HEDLEY_FALL_THROUGH JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[clang::fallthrough]])
1889 #elif JSON_HEDLEY_HAS_CPP_ATTRIBUTE(fallthrough)
1890 #define JSON_HEDLEY_FALL_THROUGH JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[fallthrough]])
1891 #elif defined(__fallthrough)
1892 #define JSON_HEDLEY_FALL_THROUGH __fallthrough
1894 #define JSON_HEDLEY_FALL_THROUGH
1897 #if defined(JSON_HEDLEY_RETURNS_NON_NULL)
1898 #undef JSON_HEDLEY_RETURNS_NON_NULL
1901 JSON_HEDLEY_HAS_ATTRIBUTE(returns_nonnull) || \
1902 JSON_HEDLEY_GCC_VERSION_CHECK(4,9,0) || \
1903 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1904 #define JSON_HEDLEY_RETURNS_NON_NULL __attribute__((__returns_nonnull__))
1905 #elif defined(_Ret_notnull_)
1906 #define JSON_HEDLEY_RETURNS_NON_NULL _Ret_notnull_
1908 #define JSON_HEDLEY_RETURNS_NON_NULL
1911 #if defined(JSON_HEDLEY_ARRAY_PARAM)
1912 #undef JSON_HEDLEY_ARRAY_PARAM
1915 defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) && \
1916 !defined(__STDC_NO_VLA__) && \
1917 !defined(__cplusplus) && \
1918 !defined(JSON_HEDLEY_PGI_VERSION) && \
1919 !defined(JSON_HEDLEY_TINYC_VERSION)
1920 #define JSON_HEDLEY_ARRAY_PARAM(name) (name)
1922 #define JSON_HEDLEY_ARRAY_PARAM(name)
1925 #if defined(JSON_HEDLEY_IS_CONSTANT)
1926 #undef JSON_HEDLEY_IS_CONSTANT
1928 #if defined(JSON_HEDLEY_REQUIRE_CONSTEXPR)
1929 #undef JSON_HEDLEY_REQUIRE_CONSTEXPR
1933 #if defined(JSON_HEDLEY_IS_CONSTEXPR_)
1934 #undef JSON_HEDLEY_IS_CONSTEXPR_
1937 JSON_HEDLEY_HAS_BUILTIN(__builtin_constant_p) || \
1938 JSON_HEDLEY_GCC_VERSION_CHECK(3,4,0) || \
1939 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1940 JSON_HEDLEY_TINYC_VERSION_CHECK(0,9,19) || \
1941 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1942 JSON_HEDLEY_IBM_VERSION_CHECK(13,1,0) || \
1943 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6,1,0) || \
1944 (JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0) && !defined(__cplusplus)) || \
1945 JSON_HEDLEY_CRAY_VERSION_CHECK(8,1,0) || \
1946 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1947 #define JSON_HEDLEY_IS_CONSTANT(expr) __builtin_constant_p(expr)
1949 #if !defined(__cplusplus)
1951 JSON_HEDLEY_HAS_BUILTIN(__builtin_types_compatible_p) || \
1952 JSON_HEDLEY_GCC_VERSION_CHECK(3,4,0) || \
1953 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1954 JSON_HEDLEY_IBM_VERSION_CHECK(13,1,0) || \
1955 JSON_HEDLEY_CRAY_VERSION_CHECK(8,1,0) || \
1956 JSON_HEDLEY_ARM_VERSION_CHECK(5,4,0) || \
1957 JSON_HEDLEY_TINYC_VERSION_CHECK(0,9,24)
1958 #if defined(__INTPTR_TYPE__)
1959 #define JSON_HEDLEY_IS_CONSTEXPR_(expr) __builtin_types_compatible_p(__typeof__((1 ? (void*) ((__INTPTR_TYPE__) ((expr) * 0)) : (int*) 0)), int*)
1962 #define JSON_HEDLEY_IS_CONSTEXPR_(expr) __builtin_types_compatible_p(__typeof__((1 ? (void*) ((intptr_t) ((expr) * 0)) : (int*) 0)), int*)
1966 defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L) && \
1967 !defined(JSON_HEDLEY_SUNPRO_VERSION) && \
1968 !defined(JSON_HEDLEY_PGI_VERSION) && \
1969 !defined(JSON_HEDLEY_IAR_VERSION)) || \
1970 (JSON_HEDLEY_HAS_EXTENSION(c_generic_selections) && !defined(JSON_HEDLEY_IAR_VERSION)) || \
1971 JSON_HEDLEY_GCC_VERSION_CHECK(4,9,0) || \
1972 JSON_HEDLEY_INTEL_VERSION_CHECK(17,0,0) || \
1973 JSON_HEDLEY_IBM_VERSION_CHECK(12,1,0) || \
1974 JSON_HEDLEY_ARM_VERSION_CHECK(5,3,0)
1975 #if defined(__INTPTR_TYPE__)
1976 #define JSON_HEDLEY_IS_CONSTEXPR_(expr) _Generic((1 ? (void*) ((__INTPTR_TYPE__) ((expr) * 0)) : (int*) 0), int*: 1, void*: 0)
1979 #define JSON_HEDLEY_IS_CONSTEXPR_(expr) _Generic((1 ? (void*) ((intptr_t) * 0) : (int*) 0), int*: 1, void*: 0)
1982 defined(JSON_HEDLEY_GCC_VERSION) || \
1983 defined(JSON_HEDLEY_INTEL_VERSION) || \
1984 defined(JSON_HEDLEY_TINYC_VERSION) || \
1985 defined(JSON_HEDLEY_TI_ARMCL_VERSION) || \
1986 JSON_HEDLEY_TI_CL430_VERSION_CHECK(18,12,0) || \
1987 defined(JSON_HEDLEY_TI_CL2000_VERSION) || \
1988 defined(JSON_HEDLEY_TI_CL6X_VERSION) || \
1989 defined(JSON_HEDLEY_TI_CL7X_VERSION) || \
1990 defined(JSON_HEDLEY_TI_CLPRU_VERSION) || \
1992 # define JSON_HEDLEY_IS_CONSTEXPR_(expr) ( \
1996 ((void*) ((expr) * 0L) ) : \
1997 ((struct { char v[sizeof(void) * 2]; } *) 1) \
2003 #if defined(JSON_HEDLEY_IS_CONSTEXPR_)
2004 #if !defined(JSON_HEDLEY_IS_CONSTANT)
2005 #define JSON_HEDLEY_IS_CONSTANT(expr) JSON_HEDLEY_IS_CONSTEXPR_(expr)
2007 #define JSON_HEDLEY_REQUIRE_CONSTEXPR(expr) (JSON_HEDLEY_IS_CONSTEXPR_(expr) ? (expr) : (-1))
2009 #if !defined(JSON_HEDLEY_IS_CONSTANT)
2010 #define JSON_HEDLEY_IS_CONSTANT(expr) (0)
2012 #define JSON_HEDLEY_REQUIRE_CONSTEXPR(expr) (expr)
2015 #if defined(JSON_HEDLEY_BEGIN_C_DECLS)
2016 #undef JSON_HEDLEY_BEGIN_C_DECLS
2018 #if defined(JSON_HEDLEY_END_C_DECLS)
2019 #undef JSON_HEDLEY_END_C_DECLS
2021 #if defined(JSON_HEDLEY_C_DECL)
2022 #undef JSON_HEDLEY_C_DECL
2024 #if defined(__cplusplus)
2025 #define JSON_HEDLEY_BEGIN_C_DECLS extern "C" {
2026 #define JSON_HEDLEY_END_C_DECLS }
2027 #define JSON_HEDLEY_C_DECL extern "C"
2029 #define JSON_HEDLEY_BEGIN_C_DECLS
2030 #define JSON_HEDLEY_END_C_DECLS
2031 #define JSON_HEDLEY_C_DECL
2034 #if defined(JSON_HEDLEY_STATIC_ASSERT)
2035 #undef JSON_HEDLEY_STATIC_ASSERT
2038 !defined(__cplusplus) && ( \
2039 (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L)) || \
2040 (JSON_HEDLEY_HAS_FEATURE(c_static_assert) && !defined(JSON_HEDLEY_INTEL_CL_VERSION)) || \
2041 JSON_HEDLEY_GCC_VERSION_CHECK(6,0,0) || \
2042 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
2043 defined(_Static_assert) \
2045 # define JSON_HEDLEY_STATIC_ASSERT(expr, message) _Static_assert(expr, message)
2047 (defined(__cplusplus) && (__cplusplus >= 201103L)) || \
2048 JSON_HEDLEY_MSVC_VERSION_CHECK(16,0,0) || \
2049 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
2050 # define JSON_HEDLEY_STATIC_ASSERT(expr, message) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(static_assert(expr, message))
2052 # define JSON_HEDLEY_STATIC_ASSERT(expr, message)
2055 #if defined(JSON_HEDLEY_NULL)
2056 #undef JSON_HEDLEY_NULL
2058 #if defined(__cplusplus)
2059 #if __cplusplus >= 201103L
2060 #define JSON_HEDLEY_NULL JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(nullptr)
2062 #define JSON_HEDLEY_NULL NULL
2064 #define JSON_HEDLEY_NULL JSON_HEDLEY_STATIC_CAST(void*, 0)
2067 #define JSON_HEDLEY_NULL NULL
2069 #define JSON_HEDLEY_NULL ((void*) 0)
2072 #if defined(JSON_HEDLEY_MESSAGE)
2073 #undef JSON_HEDLEY_MESSAGE
2075 #if JSON_HEDLEY_HAS_WARNING("-Wunknown-pragmas")
2076 # define JSON_HEDLEY_MESSAGE(msg) \
2077 JSON_HEDLEY_DIAGNOSTIC_PUSH \
2078 JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS \
2079 JSON_HEDLEY_PRAGMA(message msg) \
2080 JSON_HEDLEY_DIAGNOSTIC_POP
2082 JSON_HEDLEY_GCC_VERSION_CHECK(4,4,0) || \
2083 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0)
2084 # define JSON_HEDLEY_MESSAGE(msg) JSON_HEDLEY_PRAGMA(message msg)
2085 #elif JSON_HEDLEY_CRAY_VERSION_CHECK(5,0,0)
2086 # define JSON_HEDLEY_MESSAGE(msg) JSON_HEDLEY_PRAGMA(_CRI message msg)
2087 #elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
2088 # define JSON_HEDLEY_MESSAGE(msg) JSON_HEDLEY_PRAGMA(message(msg))
2089 #elif JSON_HEDLEY_PELLES_VERSION_CHECK(2,0,0)
2090 # define JSON_HEDLEY_MESSAGE(msg) JSON_HEDLEY_PRAGMA(message(msg))
2092 # define JSON_HEDLEY_MESSAGE(msg)
2095 #if defined(JSON_HEDLEY_WARNING)
2096 #undef JSON_HEDLEY_WARNING
2098 #if JSON_HEDLEY_HAS_WARNING("-Wunknown-pragmas")
2099 # define JSON_HEDLEY_WARNING(msg) \
2100 JSON_HEDLEY_DIAGNOSTIC_PUSH \
2101 JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS \
2102 JSON_HEDLEY_PRAGMA(clang warning msg) \
2103 JSON_HEDLEY_DIAGNOSTIC_POP
2105 JSON_HEDLEY_GCC_VERSION_CHECK(4,8,0) || \
2106 JSON_HEDLEY_PGI_VERSION_CHECK(18,4,0) || \
2107 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0)
2108 # define JSON_HEDLEY_WARNING(msg) JSON_HEDLEY_PRAGMA(GCC warning msg)
2110 JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0) || \
2111 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
2112 # define JSON_HEDLEY_WARNING(msg) JSON_HEDLEY_PRAGMA(message(msg))
2114 # define JSON_HEDLEY_WARNING(msg) JSON_HEDLEY_MESSAGE(msg)
2117 #if defined(JSON_HEDLEY_REQUIRE)
2118 #undef JSON_HEDLEY_REQUIRE
2120 #if defined(JSON_HEDLEY_REQUIRE_MSG)
2121 #undef JSON_HEDLEY_REQUIRE_MSG
2123 #if JSON_HEDLEY_HAS_ATTRIBUTE(diagnose_if)
2124 # if JSON_HEDLEY_HAS_WARNING("-Wgcc-compat")
2125 # define JSON_HEDLEY_REQUIRE(expr) \
2126 JSON_HEDLEY_DIAGNOSTIC_PUSH \
2127 _Pragma("clang diagnostic ignored \"-Wgcc-compat\"") \
2128 __attribute__((diagnose_if(!(expr), #expr, "error"))) \
2129 JSON_HEDLEY_DIAGNOSTIC_POP
2130 # define JSON_HEDLEY_REQUIRE_MSG(expr,msg) \
2131 JSON_HEDLEY_DIAGNOSTIC_PUSH \
2132 _Pragma("clang diagnostic ignored \"-Wgcc-compat\"") \
2133 __attribute__((diagnose_if(!(expr), msg, "error"))) \
2134 JSON_HEDLEY_DIAGNOSTIC_POP
2136 # define JSON_HEDLEY_REQUIRE(expr) __attribute__((diagnose_if(!(expr), #expr, "error")))
2137 # define JSON_HEDLEY_REQUIRE_MSG(expr,msg) __attribute__((diagnose_if(!(expr), msg, "error")))
2140 # define JSON_HEDLEY_REQUIRE(expr)
2141 # define JSON_HEDLEY_REQUIRE_MSG(expr,msg)
2144 #if defined(JSON_HEDLEY_FLAGS)
2145 #undef JSON_HEDLEY_FLAGS
2147 #if JSON_HEDLEY_HAS_ATTRIBUTE(flag_enum) && (!defined(__cplusplus) || JSON_HEDLEY_HAS_WARNING("-Wbitfield-enum-conversion"))
2148 #define JSON_HEDLEY_FLAGS __attribute__((__flag_enum__))
2150 #define JSON_HEDLEY_FLAGS
2153 #if defined(JSON_HEDLEY_FLAGS_CAST)
2154 #undef JSON_HEDLEY_FLAGS_CAST
2156 #if JSON_HEDLEY_INTEL_VERSION_CHECK(19,0,0)
2157 # define JSON_HEDLEY_FLAGS_CAST(T, expr) (__extension__ ({ \
2158 JSON_HEDLEY_DIAGNOSTIC_PUSH \
2159 _Pragma("warning(disable:188)") \
2161 JSON_HEDLEY_DIAGNOSTIC_POP \
2164 # define JSON_HEDLEY_FLAGS_CAST(T, expr) JSON_HEDLEY_STATIC_CAST(T, expr)
2167 #if defined(JSON_HEDLEY_EMPTY_BASES)
2168 #undef JSON_HEDLEY_EMPTY_BASES
2171 (JSON_HEDLEY_MSVC_VERSION_CHECK(19,0,23918) && !JSON_HEDLEY_MSVC_VERSION_CHECK(20,0,0)) || \
2172 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
2173 #define JSON_HEDLEY_EMPTY_BASES __declspec(empty_bases)
2175 #define JSON_HEDLEY_EMPTY_BASES
2180 #if defined(JSON_HEDLEY_GCC_NOT_CLANG_VERSION_CHECK)
2181 #undef JSON_HEDLEY_GCC_NOT_CLANG_VERSION_CHECK
2183 #if defined(__clang__)
2184 #define JSON_HEDLEY_GCC_NOT_CLANG_VERSION_CHECK(major,minor,patch) (0)
2186 #define JSON_HEDLEY_GCC_NOT_CLANG_VERSION_CHECK(major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch)
2189 #if defined(JSON_HEDLEY_CLANG_HAS_ATTRIBUTE)
2190 #undef JSON_HEDLEY_CLANG_HAS_ATTRIBUTE
2192 #define JSON_HEDLEY_CLANG_HAS_ATTRIBUTE(attribute) JSON_HEDLEY_HAS_ATTRIBUTE(attribute)
2194 #if defined(JSON_HEDLEY_CLANG_HAS_CPP_ATTRIBUTE)
2195 #undef JSON_HEDLEY_CLANG_HAS_CPP_ATTRIBUTE
2197 #define JSON_HEDLEY_CLANG_HAS_CPP_ATTRIBUTE(attribute) JSON_HEDLEY_HAS_CPP_ATTRIBUTE(attribute)
2199 #if defined(JSON_HEDLEY_CLANG_HAS_BUILTIN)
2200 #undef JSON_HEDLEY_CLANG_HAS_BUILTIN
2202 #define JSON_HEDLEY_CLANG_HAS_BUILTIN(builtin) JSON_HEDLEY_HAS_BUILTIN(builtin)
2204 #if defined(JSON_HEDLEY_CLANG_HAS_FEATURE)
2205 #undef JSON_HEDLEY_CLANG_HAS_FEATURE
2207 #define JSON_HEDLEY_CLANG_HAS_FEATURE(feature) JSON_HEDLEY_HAS_FEATURE(feature)
2209 #if defined(JSON_HEDLEY_CLANG_HAS_EXTENSION)
2210 #undef JSON_HEDLEY_CLANG_HAS_EXTENSION
2212 #define JSON_HEDLEY_CLANG_HAS_EXTENSION(extension) JSON_HEDLEY_HAS_EXTENSION(extension)
2214 #if defined(JSON_HEDLEY_CLANG_HAS_DECLSPEC_DECLSPEC_ATTRIBUTE)
2215 #undef JSON_HEDLEY_CLANG_HAS_DECLSPEC_DECLSPEC_ATTRIBUTE
2217 #define JSON_HEDLEY_CLANG_HAS_DECLSPEC_ATTRIBUTE(attribute) JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE(attribute)
2219 #if defined(JSON_HEDLEY_CLANG_HAS_WARNING)
2220 #undef JSON_HEDLEY_CLANG_HAS_WARNING
2222 #define JSON_HEDLEY_CLANG_HAS_WARNING(warning) JSON_HEDLEY_HAS_WARNING(warning)
2229 #include <type_traits>
2262 template<
class Default,
2264 template<
class...>
class Op,
2272 template<
class Default,
template<
class...>
class Op,
class... Args>
2279 template<
template<
class...>
class Op,
class... Args>
2282 template<
template<
class...>
class Op,
class... Args>
2285 template<
template<
class...>
class Op,
class... Args>
2288 template<
class Default,
template<
class...>
class Op,
class... Args>
2291 template<
class Default,
template<
class...>
class Op,
class... Args>
2294 template<
class Expected,
template<
class...>
class Op,
class... Args>
2297 template<
class To,
template<
class...>
class Op,
class... Args>
2308 #if !defined(JSON_SKIP_UNSUPPORTED_COMPILER_CHECK)
2309 #if defined(__clang__)
2310 #if (__clang_major__ * 10000 + __clang_minor__ * 100 + __clang_patchlevel__) < 30400
2311 #error "unsupported Clang version - see https://github.com/nlohmann/json#supported-compilers"
2313 #elif defined(__GNUC__) && !(defined(__ICC) || defined(__INTEL_COMPILER))
2314 #if (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) < 40800
2315 #error "unsupported GCC version - see https://github.com/nlohmann/json#supported-compilers"
2322 #if !defined(JSON_HAS_CPP_20) && !defined(JSON_HAS_CPP_17) && !defined(JSON_HAS_CPP_14) && !defined(JSON_HAS_CPP_11)
2323 #if (defined(__cplusplus) && __cplusplus >= 202002L) || (defined(_MSVC_LANG) && _MSVC_LANG >= 202002L)
2324 #define JSON_HAS_CPP_20
2325 #define JSON_HAS_CPP_17
2326 #define JSON_HAS_CPP_14
2327 #elif (defined(__cplusplus) && __cplusplus >= 201703L) || (defined(_HAS_CXX17) && _HAS_CXX17 == 1) // fix for issue #464
2328 #define JSON_HAS_CPP_17
2329 #define JSON_HAS_CPP_14
2330 #elif (defined(__cplusplus) && __cplusplus >= 201402L) || (defined(_HAS_CXX14) && _HAS_CXX14 == 1)
2331 #define JSON_HAS_CPP_14
2334 #define JSON_HAS_CPP_11
2337 #if !defined(JSON_HAS_FILESYSTEM) && !defined(JSON_HAS_EXPERIMENTAL_FILESYSTEM)
2338 #ifdef JSON_HAS_CPP_17
2339 #if defined(__cpp_lib_filesystem)
2340 #define JSON_HAS_FILESYSTEM 1
2341 #elif defined(__cpp_lib_experimental_filesystem)
2342 #define JSON_HAS_EXPERIMENTAL_FILESYSTEM 1
2343 #elif !defined(__has_include)
2344 #define JSON_HAS_EXPERIMENTAL_FILESYSTEM 1
2345 #elif __has_include(<filesystem>)
2346 #define JSON_HAS_FILESYSTEM 1
2347 #elif __has_include(<experimental/filesystem>)
2348 #define JSON_HAS_EXPERIMENTAL_FILESYSTEM 1
2352 #if defined(__MINGW32__) && defined(__GNUC__) && __GNUC__ == 8
2353 #undef JSON_HAS_FILESYSTEM
2354 #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM
2358 #if defined(__GNUC__) && !defined(__clang__) && __GNUC__ < 8
2359 #undef JSON_HAS_FILESYSTEM
2360 #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM
2364 #if defined(__clang_major__) && __clang_major__ < 7
2365 #undef JSON_HAS_FILESYSTEM
2366 #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM
2370 #if defined(_MSC_VER) && _MSC_VER < 1940
2371 #undef JSON_HAS_FILESYSTEM
2372 #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM
2376 #if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) && __IPHONE_OS_VERSION_MIN_REQUIRED < 130000
2377 #undef JSON_HAS_FILESYSTEM
2378 #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM
2382 #if defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && __MAC_OS_X_VERSION_MIN_REQUIRED < 101500
2383 #undef JSON_HAS_FILESYSTEM
2384 #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM
2389 #ifndef JSON_HAS_EXPERIMENTAL_FILESYSTEM
2390 #define JSON_HAS_EXPERIMENTAL_FILESYSTEM 0
2393 #ifndef JSON_HAS_FILESYSTEM
2394 #define JSON_HAS_FILESYSTEM 0
2398 #if defined(__clang__)
2399 #pragma clang diagnostic push
2400 #pragma clang diagnostic ignored "-Wdocumentation"
2401 #pragma clang diagnostic ignored "-Wdocumentation-unknown-command"
2405 #if (defined(__cpp_exceptions) || defined(__EXCEPTIONS) || defined(_CPPUNWIND)) && !defined(JSON_NOEXCEPTION)
2406 #define JSON_THROW(exception) throw exception
2407 #define JSON_TRY try
2408 #define JSON_CATCH(exception) catch(exception)
2409 #define JSON_INTERNAL_CATCH(exception) catch(exception)
2412 #define JSON_THROW(exception) std::abort()
2413 #define JSON_TRY if(true)
2414 #define JSON_CATCH(exception) if(false)
2415 #define JSON_INTERNAL_CATCH(exception) if(false)
2419 #if defined(JSON_THROW_USER)
2421 #define JSON_THROW JSON_THROW_USER
2423 #if defined(JSON_TRY_USER)
2425 #define JSON_TRY JSON_TRY_USER
2427 #if defined(JSON_CATCH_USER)
2429 #define JSON_CATCH JSON_CATCH_USER
2430 #undef JSON_INTERNAL_CATCH
2431 #define JSON_INTERNAL_CATCH JSON_CATCH_USER
2433 #if defined(JSON_INTERNAL_CATCH_USER)
2434 #undef JSON_INTERNAL_CATCH
2435 #define JSON_INTERNAL_CATCH JSON_INTERNAL_CATCH_USER
2439 #if !defined(JSON_ASSERT)
2441 #define JSON_ASSERT(x) assert(x)
2445 #if defined(JSON_TESTS_PRIVATE)
2446 #define JSON_PRIVATE_UNLESS_TESTED public
2448 #define JSON_PRIVATE_UNLESS_TESTED private
2456 #define NLOHMANN_JSON_SERIALIZE_ENUM(ENUM_TYPE, ...) \
2457 template<typename BasicJsonType> \
2458 inline void to_json(BasicJsonType& j, const ENUM_TYPE& e) \
2460 static_assert(std::is_enum<ENUM_TYPE>::value, #ENUM_TYPE " must be an enum!"); \
2461 static const std::pair<ENUM_TYPE, BasicJsonType> m[] = __VA_ARGS__; \
2462 auto it = std::find_if(std::begin(m), std::end(m), \
2463 [e](const std::pair<ENUM_TYPE, BasicJsonType>& ej_pair) -> bool \
2465 return ej_pair.first == e; \
2467 j = ((it != std::end(m)) ? it : std::begin(m))->second; \
2469 template<typename BasicJsonType> \
2470 inline void from_json(const BasicJsonType& j, ENUM_TYPE& e) \
2472 static_assert(std::is_enum<ENUM_TYPE>::value, #ENUM_TYPE " must be an enum!"); \
2473 static const std::pair<ENUM_TYPE, BasicJsonType> m[] = __VA_ARGS__; \
2474 auto it = std::find_if(std::begin(m), std::end(m), \
2475 [&j](const std::pair<ENUM_TYPE, BasicJsonType>& ej_pair) -> bool \
2477 return ej_pair.second == j; \
2479 e = ((it != std::end(m)) ? it : std::begin(m))->first; \
2485 #define NLOHMANN_BASIC_JSON_TPL_DECLARATION \
2486 template<template<typename, typename, typename...> class ObjectType, \
2487 template<typename, typename...> class ArrayType, \
2488 class StringType, class BooleanType, class NumberIntegerType, \
2489 class NumberUnsignedType, class NumberFloatType, \
2490 template<typename> class AllocatorType, \
2491 template<typename, typename = void> class JSONSerializer, \
2494 #define NLOHMANN_BASIC_JSON_TPL \
2495 basic_json<ObjectType, ArrayType, StringType, BooleanType, \
2496 NumberIntegerType, NumberUnsignedType, NumberFloatType, \
2497 AllocatorType, JSONSerializer, BinaryType>
2501 #define NLOHMANN_JSON_EXPAND( x ) x
2502 #define NLOHMANN_JSON_GET_MACRO(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, _31, _32, _33, _34, _35, _36, _37, _38, _39, _40, _41, _42, _43, _44, _45, _46, _47, _48, _49, _50, _51, _52, _53, _54, _55, _56, _57, _58, _59, _60, _61, _62, _63, _64, NAME,...) NAME
2503 #define NLOHMANN_JSON_PASTE(...) NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_GET_MACRO(__VA_ARGS__, \
2504 NLOHMANN_JSON_PASTE64, \
2505 NLOHMANN_JSON_PASTE63, \
2506 NLOHMANN_JSON_PASTE62, \
2507 NLOHMANN_JSON_PASTE61, \
2508 NLOHMANN_JSON_PASTE60, \
2509 NLOHMANN_JSON_PASTE59, \
2510 NLOHMANN_JSON_PASTE58, \
2511 NLOHMANN_JSON_PASTE57, \
2512 NLOHMANN_JSON_PASTE56, \
2513 NLOHMANN_JSON_PASTE55, \
2514 NLOHMANN_JSON_PASTE54, \
2515 NLOHMANN_JSON_PASTE53, \
2516 NLOHMANN_JSON_PASTE52, \
2517 NLOHMANN_JSON_PASTE51, \
2518 NLOHMANN_JSON_PASTE50, \
2519 NLOHMANN_JSON_PASTE49, \
2520 NLOHMANN_JSON_PASTE48, \
2521 NLOHMANN_JSON_PASTE47, \
2522 NLOHMANN_JSON_PASTE46, \
2523 NLOHMANN_JSON_PASTE45, \
2524 NLOHMANN_JSON_PASTE44, \
2525 NLOHMANN_JSON_PASTE43, \
2526 NLOHMANN_JSON_PASTE42, \
2527 NLOHMANN_JSON_PASTE41, \
2528 NLOHMANN_JSON_PASTE40, \
2529 NLOHMANN_JSON_PASTE39, \
2530 NLOHMANN_JSON_PASTE38, \
2531 NLOHMANN_JSON_PASTE37, \
2532 NLOHMANN_JSON_PASTE36, \
2533 NLOHMANN_JSON_PASTE35, \
2534 NLOHMANN_JSON_PASTE34, \
2535 NLOHMANN_JSON_PASTE33, \
2536 NLOHMANN_JSON_PASTE32, \
2537 NLOHMANN_JSON_PASTE31, \
2538 NLOHMANN_JSON_PASTE30, \
2539 NLOHMANN_JSON_PASTE29, \
2540 NLOHMANN_JSON_PASTE28, \
2541 NLOHMANN_JSON_PASTE27, \
2542 NLOHMANN_JSON_PASTE26, \
2543 NLOHMANN_JSON_PASTE25, \
2544 NLOHMANN_JSON_PASTE24, \
2545 NLOHMANN_JSON_PASTE23, \
2546 NLOHMANN_JSON_PASTE22, \
2547 NLOHMANN_JSON_PASTE21, \
2548 NLOHMANN_JSON_PASTE20, \
2549 NLOHMANN_JSON_PASTE19, \
2550 NLOHMANN_JSON_PASTE18, \
2551 NLOHMANN_JSON_PASTE17, \
2552 NLOHMANN_JSON_PASTE16, \
2553 NLOHMANN_JSON_PASTE15, \
2554 NLOHMANN_JSON_PASTE14, \
2555 NLOHMANN_JSON_PASTE13, \
2556 NLOHMANN_JSON_PASTE12, \
2557 NLOHMANN_JSON_PASTE11, \
2558 NLOHMANN_JSON_PASTE10, \
2559 NLOHMANN_JSON_PASTE9, \
2560 NLOHMANN_JSON_PASTE8, \
2561 NLOHMANN_JSON_PASTE7, \
2562 NLOHMANN_JSON_PASTE6, \
2563 NLOHMANN_JSON_PASTE5, \
2564 NLOHMANN_JSON_PASTE4, \
2565 NLOHMANN_JSON_PASTE3, \
2566 NLOHMANN_JSON_PASTE2, \
2567 NLOHMANN_JSON_PASTE1)(__VA_ARGS__))
2568 #define NLOHMANN_JSON_PASTE2(func, v1) func(v1)
2569 #define NLOHMANN_JSON_PASTE3(func, v1, v2) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE2(func, v2)
2570 #define NLOHMANN_JSON_PASTE4(func, v1, v2, v3) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE3(func, v2, v3)
2571 #define NLOHMANN_JSON_PASTE5(func, v1, v2, v3, v4) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE4(func, v2, v3, v4)
2572 #define NLOHMANN_JSON_PASTE6(func, v1, v2, v3, v4, v5) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE5(func, v2, v3, v4, v5)
2573 #define NLOHMANN_JSON_PASTE7(func, v1, v2, v3, v4, v5, v6) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE6(func, v2, v3, v4, v5, v6)
2574 #define NLOHMANN_JSON_PASTE8(func, v1, v2, v3, v4, v5, v6, v7) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE7(func, v2, v3, v4, v5, v6, v7)
2575 #define NLOHMANN_JSON_PASTE9(func, v1, v2, v3, v4, v5, v6, v7, v8) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE8(func, v2, v3, v4, v5, v6, v7, v8)
2576 #define NLOHMANN_JSON_PASTE10(func, v1, v2, v3, v4, v5, v6, v7, v8, v9) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE9(func, v2, v3, v4, v5, v6, v7, v8, v9)
2577 #define NLOHMANN_JSON_PASTE11(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE10(func, v2, v3, v4, v5, v6, v7, v8, v9, v10)
2578 #define NLOHMANN_JSON_PASTE12(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE11(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11)
2579 #define NLOHMANN_JSON_PASTE13(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE12(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12)
2580 #define NLOHMANN_JSON_PASTE14(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE13(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13)
2581 #define NLOHMANN_JSON_PASTE15(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE14(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14)
2582 #define NLOHMANN_JSON_PASTE16(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE15(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15)
2583 #define NLOHMANN_JSON_PASTE17(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE16(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16)
2584 #define NLOHMANN_JSON_PASTE18(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE17(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17)
2585 #define NLOHMANN_JSON_PASTE19(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE18(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18)
2586 #define NLOHMANN_JSON_PASTE20(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE19(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19)
2587 #define NLOHMANN_JSON_PASTE21(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE20(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20)
2588 #define NLOHMANN_JSON_PASTE22(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE21(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21)
2589 #define NLOHMANN_JSON_PASTE23(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE22(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22)
2590 #define NLOHMANN_JSON_PASTE24(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE23(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23)
2591 #define NLOHMANN_JSON_PASTE25(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE24(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24)
2592 #define NLOHMANN_JSON_PASTE26(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE25(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25)
2593 #define NLOHMANN_JSON_PASTE27(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE26(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26)
2594 #define NLOHMANN_JSON_PASTE28(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE27(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27)
2595 #define NLOHMANN_JSON_PASTE29(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE28(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28)
2596 #define NLOHMANN_JSON_PASTE30(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE29(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29)
2597 #define NLOHMANN_JSON_PASTE31(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE30(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30)
2598 #define NLOHMANN_JSON_PASTE32(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE31(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31)
2599 #define NLOHMANN_JSON_PASTE33(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE32(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32)
2600 #define NLOHMANN_JSON_PASTE34(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE33(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33)
2601 #define NLOHMANN_JSON_PASTE35(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE34(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34)
2602 #define NLOHMANN_JSON_PASTE36(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE35(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35)
2603 #define NLOHMANN_JSON_PASTE37(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE36(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36)
2604 #define NLOHMANN_JSON_PASTE38(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE37(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37)
2605 #define NLOHMANN_JSON_PASTE39(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE38(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38)
2606 #define NLOHMANN_JSON_PASTE40(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE39(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39)
2607 #define NLOHMANN_JSON_PASTE41(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE40(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40)
2608 #define NLOHMANN_JSON_PASTE42(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE41(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41)
2609 #define NLOHMANN_JSON_PASTE43(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE42(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42)
2610 #define NLOHMANN_JSON_PASTE44(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE43(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43)
2611 #define NLOHMANN_JSON_PASTE45(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE44(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44)
2612 #define NLOHMANN_JSON_PASTE46(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE45(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45)
2613 #define NLOHMANN_JSON_PASTE47(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE46(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46)
2614 #define NLOHMANN_JSON_PASTE48(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE47(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47)
2615 #define NLOHMANN_JSON_PASTE49(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE48(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48)
2616 #define NLOHMANN_JSON_PASTE50(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE49(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49)
2617 #define NLOHMANN_JSON_PASTE51(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE50(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50)
2618 #define NLOHMANN_JSON_PASTE52(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE51(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51)
2619 #define NLOHMANN_JSON_PASTE53(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE52(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52)
2620 #define NLOHMANN_JSON_PASTE54(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE53(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53)
2621 #define NLOHMANN_JSON_PASTE55(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE54(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54)
2622 #define NLOHMANN_JSON_PASTE56(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE55(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55)
2623 #define NLOHMANN_JSON_PASTE57(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE56(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56)
2624 #define NLOHMANN_JSON_PASTE58(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE57(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57)
2625 #define NLOHMANN_JSON_PASTE59(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE58(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58)
2626 #define NLOHMANN_JSON_PASTE60(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE59(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59)
2627 #define NLOHMANN_JSON_PASTE61(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE60(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60)
2628 #define NLOHMANN_JSON_PASTE62(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60, v61) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE61(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60, v61)
2629 #define NLOHMANN_JSON_PASTE63(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60, v61, v62) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE62(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60, v61, v62)
2630 #define NLOHMANN_JSON_PASTE64(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60, v61, v62, v63) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE63(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60, v61, v62, v63)
2632 #define NLOHMANN_JSON_TO(v1) nlohmann_json_j[#v1] = nlohmann_json_t.v1;
2633 #define NLOHMANN_JSON_FROM(v1) nlohmann_json_j.at(#v1).get_to(nlohmann_json_t.v1);
2640 #define NLOHMANN_DEFINE_TYPE_INTRUSIVE(Type, ...) \
2641 friend void to_json(nlohmann::json& nlohmann_json_j, const Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) } \
2642 friend void from_json(const nlohmann::json& nlohmann_json_j, Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM, __VA_ARGS__)) }
2649 #define NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(Type, ...) \
2650 inline void to_json(nlohmann::json& nlohmann_json_j, const Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) } \
2651 inline void from_json(const nlohmann::json& nlohmann_json_j, Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM, __VA_ARGS__)) }
2660 #define NLOHMANN_CAN_CALL_STD_FUNC_IMPL(std_name) \
2661 namespace detail { \
2662 using std::std_name; \
2664 template<typename... T> \
2665 using result_of_##std_name = decltype(std_name(std::declval<T>()...)); \
2668 namespace detail2 { \
2669 struct std_name##_tag \
2673 template<typename... T> \
2674 std_name##_tag std_name(T&&...); \
2676 template<typename... T> \
2677 using result_of_##std_name = decltype(std_name(std::declval<T>()...)); \
2679 template<typename... T> \
2680 struct would_call_std_##std_name \
2682 static constexpr auto const value = ::nlohmann::detail:: \
2683 is_detected_exact<std_name##_tag, result_of_##std_name, T...>::value; \
2687 template<typename... T> \
2688 struct would_call_std_##std_name : detail2::would_call_std_##std_name<T...> \
2692 #ifndef JSON_USE_IMPLICIT_CONVERSIONS
2693 #define JSON_USE_IMPLICIT_CONVERSIONS 1
2696 #if JSON_USE_IMPLICIT_CONVERSIONS
2697 #define JSON_EXPLICIT
2699 #define JSON_EXPLICIT explicit
2702 #ifndef JSON_DIAGNOSTICS
2703 #define JSON_DIAGNOSTICS 0
2726 const std::string& t)
2729 for (
auto pos =
s.find(
f);
2730 pos != std::string::npos;
2731 s.replace(pos,
f.size(), t),
2732 pos =
s.find(
f, pos + t.size()))
2812 const char*
what() const noexcept
override
2822 exception(
int id_, const
char* what_arg) :
id(id_),
m(what_arg) {}
2824 static std::string
name(
const std::string& ename,
int id_)
2826 return "[json.exception." + ename +
"." + std::to_string(id_) +
"] ";
2829 template<
typename BasicJsonType>
2832 #if JSON_DIAGNOSTICS
2833 std::vector<std::string> tokens;
2834 for (
const auto* current = &leaf_element; current->m_parent !=
nullptr; current = current->m_parent)
2836 switch (current->m_parent->type())
2840 for (
std::size_t i = 0; i < current->m_parent->m_value.array->size(); ++i)
2842 if (¤t->m_parent->m_value.array->operator[](i) == current)
2844 tokens.emplace_back(std::to_string(i));
2853 for (
const auto& element : *current->m_parent->m_value.object)
2855 if (&element.second == current)
2857 tokens.emplace_back(element.first.c_str());
2882 return "(" + std::accumulate(tokens.rbegin(), tokens.rend(), std::string{},
2883 [](
const std::string & a,
const std::string & b)
2885 return a +
"/" + detail::escape(b);
2888 static_cast<void>(leaf_element);
2895 std::runtime_error
m;
2912 template<
typename BasicJsonType>
2920 template<
typename BasicJsonType>
2924 (byte_ != 0 ? (
" at byte " + std::to_string(byte_)) :
"") +
2926 return {id_, byte_, w.c_str()};
2946 return " at line " + std::to_string(pos.
lines_read + 1) +
2956 template<
typename BasicJsonType>
2960 return {id_, w.c_str()};
2974 template<
typename BasicJsonType>
2978 return {id_, w.c_str()};
2991 template<
typename BasicJsonType>
2995 return {id_, w.c_str()};
3008 template<
typename BasicJsonType>
3012 return {id_, w.c_str()};
3029 #include <type_traits>
3040 template<
typename T>
3043 #ifdef JSON_HAS_CPP_14
3054 template<
bool B,
typename T =
void>
3081 template <
typename T, T... Ints>
3087 return sizeof...(Ints);
3096 template <
size_t... Ints>
3099 namespace utility_internal
3102 template <
typename Seq,
size_t SeqSize,
size_t Rem>
3106 template <
typename T, T... Ints,
size_t SeqSize>
3112 template <
typename T, T... Ints,
size_t SeqSize>
3120 template <
typename T,
size_t N>
3127 template <
typename T>
3142 template <
typename T, T N>
3158 template <
typename... Ts>
3170 template<
typename T>
3176 template<
typename T>
3198 #include <type_traits>
3219 template<
typename It,
typename =
void>
3222 template<
typename It>
3237 template<
typename T,
typename =
void>
3242 template<
typename T>
3248 template<
typename T>
3287 #ifndef INCLUDE_NLOHMANN_JSON_FWD_HPP_
3288 #define INCLUDE_NLOHMANN_JSON_FWD_HPP_
3310 template<
typename T =
void,
typename SFINAE =
void>
3315 template<
template<
typename U,
typename V,
typename... Args>
class ObjectType =
3317 template<
typename U,
typename... Args>
class ArrayType = std::vector,
3318 class StringType = std::string,
class BooleanType = bool,
3319 class NumberIntegerType = std::int64_t,
3320 class NumberUnsignedType = std::uint64_t,
3321 class NumberFloatType = double,
3323 template<
typename T,
typename SFINAE =
void>
class JSONSerializer =
3325 class BinaryType = std::vector<std::uint8_t>>
3330 template<
typename BasicJsonType>
3341 template<
class Key,
class T,
class IgnoredLess,
class Allocator>
3350 #endif // INCLUDE_NLOHMANN_JSON_FWD_HPP_
3393 template<
typename T>
3400 template<
typename T>
3403 template<
typename T>
3406 template<
typename T>
3409 template<
typename T>
3412 template<
typename T>
3415 template<
typename T>
3418 template<
typename T>
3421 template<
typename T,
typename... Args>
3424 template<
typename T,
typename... Args>
3427 template<
typename T,
typename U>
3431 template<
typename BasicJsonType,
typename T,
typename =
void>
3438 template <
typename BasicJsonType,
typename T>
3444 template<
typename BasicJsonType,
typename T>
3447 using serializer =
typename BasicJsonType::template json_serializer<T, void>;
3451 const BasicJsonType&, T&>::value;
3456 template<
typename BasicJsonType,
typename T,
typename =
void>
3459 template<
typename BasicJsonType,
typename T>
3462 using serializer =
typename BasicJsonType::template json_serializer<T, void>;
3466 const BasicJsonType&>::value;
3471 template<
typename BasicJsonType,
typename T,
typename =
void>
3474 template<
typename BasicJsonType,
typename T>
3477 using serializer =
typename BasicJsonType::template json_serializer<T, void>;
3492 template<
class B1,
class... Bn>
3494 : std::conditional<bool(B1::value), conjunction<Bn...>, B1>
::type {};
3497 template<
class B>
struct negation : std::integral_constant < bool, !B::value > { };
3502 template <
typename T>
3505 template <
typename T1,
typename T2>
3507 :
conjunction<is_default_constructible<T1>, is_default_constructible<T2>> {};
3509 template <
typename T1,
typename T2>
3511 :
conjunction<is_default_constructible<T1>, is_default_constructible<T2>> {};
3513 template <
typename... Ts>
3515 :
conjunction<is_default_constructible<Ts>...> {};
3517 template <
typename... Ts>
3519 :
conjunction<is_default_constructible<Ts>...> {};
3522 template <
typename T,
typename... Args>
3525 template <
typename T1,
typename T2>
3528 template <
typename T1,
typename T2>
3531 template <
typename... Ts>
3534 template <
typename... Ts>
3538 template<
typename T,
typename =
void>
3541 template<
typename T>
3556 template<
typename T>
3572 static constexpr
bool value = !std::is_same<iterator, nonesuch>::value && !std::is_same<sentinel, nonesuch>::value &&
is_iterator_begin;
3575 template<
typename R>
3578 template<
typename T>
3585 template<
typename T,
typename =
void>
3588 template<
typename T>
3591 template<
typename BasicJsonType,
typename CompatibleObjectType,
3595 template<
typename BasicJsonType,
typename CompatibleObjectType>
3597 BasicJsonType, CompatibleObjectType,
3599 is_detected<key_type_t, CompatibleObjectType>::value >>
3606 typename CompatibleObjectType::key_type>::value &&
3608 typename CompatibleObjectType::mapped_type>::value;
3611 template<
typename BasicJsonType,
typename CompatibleObjectType>
3615 template<
typename BasicJsonType,
typename ConstructibleObjectType,
3619 template<
typename BasicJsonType,
typename ConstructibleObjectType>
3621 BasicJsonType, ConstructibleObjectType,
3623 is_detected<key_type_t, ConstructibleObjectType>::value >>
3629 (std::is_move_assignable<ConstructibleObjectType>::value ||
3630 std::is_copy_assignable<ConstructibleObjectType>::value) &&
3632 typename object_t::key_type>::value &&
3634 typename object_t::mapped_type,
3635 typename ConstructibleObjectType::mapped_type >::value)) ||
3637 typename ConstructibleObjectType::mapped_type>::value ||
3640 typename ConstructibleObjectType::mapped_type >::value);
3643 template<
typename BasicJsonType,
typename ConstructibleObjectType>
3646 ConstructibleObjectType> {};
3648 template<
typename BasicJsonType,
typename CompatibleStringType>
3655 template<
typename BasicJsonType,
typename ConstructibleStringType>
3660 typename BasicJsonType::string_t>
::value;
3663 template<
typename BasicJsonType,
typename CompatibleArrayType,
typename =
void>
3666 template<
typename BasicJsonType,
typename CompatibleArrayType>
3668 BasicJsonType, CompatibleArrayType,
3671 is_iterator_traits<iterator_traits<detected_t<iterator_t, CompatibleArrayType>>>::value&&
3674 !std::is_same<CompatibleArrayType, detected_t<range_value_t, CompatibleArrayType>>::value >>
3681 template<
typename BasicJsonType,
typename CompatibleArrayType>
3685 template<
typename BasicJsonType,
typename ConstructibleArrayType,
typename =
void>
3688 template<
typename BasicJsonType,
typename ConstructibleArrayType>
3690 BasicJsonType, ConstructibleArrayType,
3692 typename BasicJsonType::value_type>::value >>
3695 template<
typename BasicJsonType,
typename ConstructibleArrayType>
3697 BasicJsonType, ConstructibleArrayType,
3699 typename BasicJsonType::value_type>::value&&
3702 (std::is_move_assignable<ConstructibleArrayType>::value ||
3703 std::is_copy_assignable<ConstructibleArrayType>::value)&&
3704 is_detected<iterator_t, ConstructibleArrayType>::value&&
3705 is_iterator_traits<iterator_traits<detected_t<iterator_t, ConstructibleArrayType>>>::value&&
3706 is_detected<range_value_t, ConstructibleArrayType>::value&&
3709 !std::is_same<ConstructibleArrayType, detected_t<range_value_t, ConstructibleArrayType>>::value&&
3711 detected_t<range_value_t, ConstructibleArrayType >>::value >>
3717 typename BasicJsonType::array_t::value_type>::value ||
3725 template<
typename BasicJsonType,
typename ConstructibleArrayType>
3729 template<
typename RealIntegerType,
typename CompatibleNumberIntegerType,
3733 template<
typename RealIntegerType,
typename CompatibleNumberIntegerType>
3735 RealIntegerType, CompatibleNumberIntegerType,
3737 std::is_integral<CompatibleNumberIntegerType>::value&&
3738 !std::is_same<bool, CompatibleNumberIntegerType>::value >>
3746 CompatibleNumberIntegerType>::value &&
3751 template<
typename RealIntegerType,
typename CompatibleNumberIntegerType>
3754 CompatibleNumberIntegerType> {};
3756 template<
typename BasicJsonType,
typename CompatibleType,
typename =
void>
3759 template<
typename BasicJsonType,
typename CompatibleType>
3761 BasicJsonType, CompatibleType,
3768 template<
typename BasicJsonType,
typename CompatibleType>
3772 template<
typename T1,
typename T2>
3775 template<
typename T1,
typename... Args>
3780 template <
typename T>
3790 template <
typename C>
static one test( decltype(&C::capacity) ) ;
3791 template <
typename C>
static two test(...);
3793 enum {
value =
sizeof(test<T>(
nullptr)) ==
sizeof(
char) };
3797 template < typename T, typename U, enable_if_t < !std::is_same<T, U>::value,
int > = 0 >
3800 return static_cast<T
>(
value);
3803 template<typename T, typename U, enable_if_t<std::is_same<T, U>::value,
int> = 0>
3815 #if JSON_HAS_EXPERIMENTAL_FILESYSTEM
3816 #include <experimental/filesystem>
3819 namespace std_fs = std::experimental::filesystem;
3821 #elif JSON_HAS_FILESYSTEM
3822 #include <filesystem>
3825 namespace std_fs = std::filesystem;
3833 template<
typename BasicJsonType>
3834 void from_json(
const BasicJsonType& j,
typename std::nullptr_t& n)
3844 template <
typename BasicJsonType,
typename ArithmeticType,
3846 !std::is_same<ArithmeticType, typename BasicJsonType::boolean_t>::value,
3850 switch (
static_cast<value_t>(j))
3854 val =
static_cast<ArithmeticType
>(*j.template get_ptr<const typename BasicJsonType::number_unsigned_t*>());
3859 val =
static_cast<ArithmeticType
>(*j.template get_ptr<const typename BasicJsonType::number_integer_t*>());
3864 val =
static_cast<ArithmeticType
>(*j.template get_ptr<const typename BasicJsonType::number_float_t*>());
3880 template<
typename BasicJsonType>
3881 void from_json(
const BasicJsonType& j,
typename BasicJsonType::boolean_t& b)
3887 b = *j.template get_ptr<const typename BasicJsonType::boolean_t*>();
3890 template<
typename BasicJsonType>
3891 void from_json(
const BasicJsonType& j,
typename BasicJsonType::string_t& s)
3897 s = *j.template get_ptr<const typename BasicJsonType::string_t*>();
3901 typename BasicJsonType,
typename ConstructibleStringType,
3904 !std::is_same<
typename BasicJsonType::string_t,
3905 ConstructibleStringType>::value,
3907 void from_json(
const BasicJsonType& j, ConstructibleStringType& s)
3914 s = *j.template get_ptr<const typename BasicJsonType::string_t*>();
3917 template<
typename BasicJsonType>
3918 void from_json(
const BasicJsonType& j,
typename BasicJsonType::number_float_t& val)
3923 template<
typename BasicJsonType>
3924 void from_json(
const BasicJsonType& j,
typename BasicJsonType::number_unsigned_t& val)
3929 template<
typename BasicJsonType>
3930 void from_json(
const BasicJsonType& j,
typename BasicJsonType::number_integer_t& val)
3935 template<
typename BasicJsonType,
typename EnumType,
3941 e =
static_cast<EnumType
>(val);
3945 template<
typename BasicJsonType,
typename T,
typename Allocator,
3947 void from_json(
const BasicJsonType& j, std::forward_list<T, Allocator>& l)
3954 std::transform(j.rbegin(), j.rend(),
3955 std::front_inserter(l), [](
const BasicJsonType & i)
3957 return i.template get<T>();
3962 template<
typename BasicJsonType,
typename T,
3971 std::transform(j.begin(), j.end(), std::begin(l),
3972 [](
const BasicJsonType & elem)
3974 return elem.template get<T>();
3978 template<
typename BasicJsonType,
typename T, std::
size_t N>
3980 -> decltype(j.template get<T>(),
void())
3984 arr[i] = j.at(i).template get<T>();
3988 template<
typename BasicJsonType>
3991 arr = *j.template get_ptr<const typename BasicJsonType::array_t*>();
3994 template<
typename BasicJsonType,
typename T, std::
size_t N>
3997 -> decltype(j.template get<T>(),
void())
4001 arr[i] = j.at(i).template get<T>();
4005 template<
typename BasicJsonType,
typename ConstructibleArrayType,
4007 std::is_assignable<ConstructibleArrayType&, ConstructibleArrayType>::value,
4011 arr.reserve(std::declval<typename ConstructibleArrayType::size_type>()),
4012 j.template get<typename ConstructibleArrayType::value_type>(),
4017 ConstructibleArrayType
ret;
4018 ret.reserve(j.size());
4019 std::transform(j.begin(), j.end(),
4020 std::inserter(
ret, end(
ret)), [](
const BasicJsonType & i)
4024 return i.template get<typename ConstructibleArrayType::value_type>();
4029 template<
typename BasicJsonType,
typename ConstructibleArrayType,
4031 std::is_assignable<ConstructibleArrayType&, ConstructibleArrayType>::value,
4038 ConstructibleArrayType
ret;
4040 j.begin(), j.end(), std::inserter(
ret, end(
ret)),
4041 [](
const BasicJsonType & i)
4045 return i.template get<typename ConstructibleArrayType::value_type>();
4050 template <
typename BasicJsonType,
typename ConstructibleArrayType,
4052 is_constructible_array_type<BasicJsonType, ConstructibleArrayType>::value&&
4053 !is_constructible_object_type<BasicJsonType, ConstructibleArrayType>::value&&
4055 !std::is_same<ConstructibleArrayType, typename BasicJsonType::binary_t>::value&&
4056 !is_basic_json<ConstructibleArrayType>::value,
4058 auto from_json(
const BasicJsonType& j, ConstructibleArrayType& arr)
4060 j.template get<typename ConstructibleArrayType::value_type>(),
4071 template <
typename BasicJsonType,
typename T,
std::size_t... Idx >
4075 return { { std::forward<BasicJsonType>(j).at(Idx).template get<T>()... } };
4078 template <
typename BasicJsonType,
typename T, std::
size_t N >
4090 template<
typename BasicJsonType>
4091 void from_json(
const BasicJsonType& j,
typename BasicJsonType::binary_t& bin)
4098 bin = *j.template get_ptr<const typename BasicJsonType::binary_t*>();
4101 template<
typename BasicJsonType,
typename ConstructibleObjectType,
4103 void from_json(
const BasicJsonType& j, ConstructibleObjectType& obj)
4110 ConstructibleObjectType
ret;
4111 const auto* inner_object = j.template get_ptr<const typename BasicJsonType::object_t*>();
4112 using value_type =
typename ConstructibleObjectType::value_type;
4114 inner_object->begin(), inner_object->end(),
4115 std::inserter(
ret,
ret.begin()),
4116 [](
typename BasicJsonType::object_t::value_type
const & p)
4118 return value_type(p.first, p.second.template get<typename ConstructibleObjectType::mapped_type>());
4127 template <
typename BasicJsonType,
typename ArithmeticType,
4129 std::is_arithmetic<ArithmeticType>::value&&
4130 !std::is_same<ArithmeticType, typename BasicJsonType::number_unsigned_t>::value&&
4131 !std::is_same<ArithmeticType, typename BasicJsonType::number_integer_t>::value&&
4132 !std::is_same<ArithmeticType, typename BasicJsonType::number_float_t>::value&&
4133 !std::is_same<ArithmeticType, typename BasicJsonType::boolean_t>::value,
4137 switch (
static_cast<value_t>(j))
4141 val =
static_cast<ArithmeticType
>(*j.template get_ptr<const typename BasicJsonType::number_unsigned_t*>());
4146 val =
static_cast<ArithmeticType
>(*j.template get_ptr<const typename BasicJsonType::number_integer_t*>());
4151 val =
static_cast<ArithmeticType
>(*j.template get_ptr<const typename BasicJsonType::number_float_t*>());
4156 val =
static_cast<ArithmeticType
>(*j.template get_ptr<const typename BasicJsonType::boolean_t*>());
4171 template<
typename BasicJsonType,
typename... Args,
std::size_t... Idx>
4174 return std::make_tuple(std::forward<BasicJsonType>(j).at(Idx).
template get<Args>()...);
4177 template <
typename BasicJsonType,
class A1,
class A2 >
4180 return {std::forward<BasicJsonType>(j).at(0).template get<A1>(),
4181 std::forward<BasicJsonType>(j).at(1).template get<A2>()};
4184 template<
typename BasicJsonType,
typename A1,
typename A2>
4190 template<
typename BasicJsonType,
typename... Args>
4196 template<
typename BasicJsonType,
typename... Args>
4202 template<
typename BasicJsonType,
typename TupleRelated>
4211 return from_json_tuple_impl(std::forward<BasicJsonType>(j), std::forward<TupleRelated>(t), priority_tag<3> {});
4214 template <
typename BasicJsonType,
typename Key,
typename Value,
typename Compare,
typename Allocator,
4216 typename BasicJsonType::string_t, Key >::value >>
4217 void from_json(
const BasicJsonType& j, std::map<Key, Value, Compare, Allocator>& m)
4224 for (
const auto& p : j)
4230 m.emplace(p.at(0).template get<Key>(), p.at(1).template get<Value>());
4234 template <
typename BasicJsonType,
typename Key,
typename Value,
typename Hash,
typename KeyEqual,
typename Allocator,
4236 typename BasicJsonType::string_t, Key >::value >>
4237 void from_json(
const BasicJsonType& j, std::unordered_map<Key, Value, Hash, KeyEqual, Allocator>& m)
4244 for (
const auto& p : j)
4250 m.emplace(p.at(0).template get<Key>(), p.at(1).template get<Value>());
4254 #if JSON_HAS_FILESYSTEM || JSON_HAS_EXPERIMENTAL_FILESYSTEM
4255 template<
typename BasicJsonType>
4256 void from_json(
const BasicJsonType& j, std_fs::path& p)
4262 p = *j.template get_ptr<const typename BasicJsonType::string_t*>();
4268 template<
typename BasicJsonType,
typename T>
4270 noexcept(noexcept(
from_json(j, std::forward<T>(val))))
4271 -> decltype(
from_json(j, std::forward<T>(val)))
4273 return from_json(j, std::forward<T>(val));
4290 #include <algorithm>
4294 #include <type_traits>
4319 template<
typename string_type>
4323 using std::to_string;
4324 target = to_string(
value);
4334 using string_type =
typename std::remove_cv< typename std::remove_reference<decltype( std::declval<IteratorType>().
key() ) >::type >::type;
4385 switch (
anchor.m_object->type())
4450 template<std::
size_t N,
typename IteratorType, enable_if_t<N == 0,
int> = 0>
4458 template<std::
size_t N,
typename IteratorType, enable_if_t<N == 1,
int> = 0>
4472 #if defined(__clang__)
4474 #pragma clang diagnostic push
4475 #pragma clang diagnostic ignored "-Wmismatched-tags"
4477 template<
typename IteratorType>
4479 :
public std::integral_constant<std::size_t, 2> {};
4481 template<std::
size_t N,
typename IteratorType>
4485 using type = decltype(
4486 get<N>(std::declval <
4489 #if defined(__clang__)
4490 #pragma clang diagnostic pop
4501 #if JSON_HAS_EXPERIMENTAL_FILESYSTEM
4502 #include <experimental/filesystem>
4505 namespace std_fs = std::experimental::filesystem;
4507 #elif JSON_HAS_FILESYSTEM
4508 #include <filesystem>
4511 namespace std_fs = std::filesystem;
4535 template<
typename BasicJsonType>
4536 static void construct(BasicJsonType& j,
typename BasicJsonType::boolean_t b) noexcept
4538 j.m_value.destroy(j.m_type);
4541 j.assert_invariant();
4548 template<
typename BasicJsonType>
4549 static void construct(BasicJsonType& j,
const typename BasicJsonType::string_t& s)
4551 j.m_value.destroy(j.m_type);
4554 j.assert_invariant();
4557 template<
typename BasicJsonType>
4558 static void construct(BasicJsonType& j,
typename BasicJsonType::string_t&& s)
4560 j.m_value.destroy(j.m_type);
4563 j.assert_invariant();
4566 template <
typename BasicJsonType,
typename CompatibleStringType,
4569 static void construct(BasicJsonType& j,
const CompatibleStringType& str)
4571 j.m_value.destroy(j.m_type);
4573 j.m_value.string = j.template create<typename BasicJsonType::string_t>(str);
4574 j.assert_invariant();
4581 template<
typename BasicJsonType>
4582 static void construct(BasicJsonType& j,
const typename BasicJsonType::binary_t& b)
4584 j.m_value.destroy(j.m_type);
4586 j.m_value =
typename BasicJsonType::binary_t(b);
4587 j.assert_invariant();
4590 template<
typename BasicJsonType>
4591 static void construct(BasicJsonType& j,
typename BasicJsonType::binary_t&& b)
4593 j.m_value.destroy(j.m_type);
4595 j.m_value =
typename BasicJsonType::binary_t(
std::move(b));
4596 j.assert_invariant();
4603 template<
typename BasicJsonType>
4604 static void construct(BasicJsonType& j,
typename BasicJsonType::number_float_t val) noexcept
4606 j.m_value.destroy(j.m_type);
4609 j.assert_invariant();
4616 template<
typename BasicJsonType>
4617 static void construct(BasicJsonType& j,
typename BasicJsonType::number_unsigned_t val) noexcept
4619 j.m_value.destroy(j.m_type);
4622 j.assert_invariant();
4629 template<
typename BasicJsonType>
4630 static void construct(BasicJsonType& j,
typename BasicJsonType::number_integer_t val) noexcept
4632 j.m_value.destroy(j.m_type);
4635 j.assert_invariant();
4642 template<
typename BasicJsonType>
4643 static void construct(BasicJsonType& j,
const typename BasicJsonType::array_t& arr)
4645 j.m_value.destroy(j.m_type);
4649 j.assert_invariant();
4652 template<
typename BasicJsonType>
4653 static void construct(BasicJsonType& j,
typename BasicJsonType::array_t&& arr)
4655 j.m_value.destroy(j.m_type);
4659 j.assert_invariant();
4662 template <
typename BasicJsonType,
typename CompatibleArrayType,
4665 static void construct(BasicJsonType& j,
const CompatibleArrayType& arr)
4670 j.m_value.destroy(j.m_type);
4672 j.m_value.array = j.template create<typename BasicJsonType::array_t>(begin(arr), end(arr));
4674 j.assert_invariant();
4677 template<
typename BasicJsonType>
4678 static void construct(BasicJsonType& j,
const std::vector<bool>& arr)
4680 j.m_value.destroy(j.m_type);
4683 j.m_value.array->reserve(arr.size());
4684 for (
const bool x : arr)
4686 j.m_value.array->push_back(
x);
4687 j.set_parent(j.m_value.array->back());
4689 j.assert_invariant();
4692 template<
typename BasicJsonType,
typename T,
4694 static void construct(BasicJsonType& j,
const std::valarray<T>& arr)
4696 j.m_value.destroy(j.m_type);
4699 j.m_value.array->resize(arr.size());
4702 std::copy(std::begin(arr), std::end(arr), j.m_value.array->begin());
4705 j.assert_invariant();
4712 template<
typename BasicJsonType>
4713 static void construct(BasicJsonType& j,
const typename BasicJsonType::object_t& obj)
4715 j.m_value.destroy(j.m_type);
4719 j.assert_invariant();
4722 template<
typename BasicJsonType>
4723 static void construct(BasicJsonType& j,
typename BasicJsonType::object_t&& obj)
4725 j.m_value.destroy(j.m_type);
4729 j.assert_invariant();
4732 template <
typename BasicJsonType,
typename CompatibleObjectType,
4734 static void construct(BasicJsonType& j,
const CompatibleObjectType& obj)
4739 j.m_value.destroy(j.m_type);
4741 j.m_value.object = j.template create<typename BasicJsonType::object_t>(begin(obj), end(obj));
4743 j.assert_invariant();
4751 template<
typename BasicJsonType,
typename T,
4758 template<
typename BasicJsonType,
typename CompatibleString,
4760 void to_json(BasicJsonType& j,
const CompatibleString& s)
4765 template<
typename BasicJsonType>
4766 void to_json(BasicJsonType& j,
typename BasicJsonType::string_t&& s)
4771 template<
typename BasicJsonType,
typename FloatType,
4773 void to_json(BasicJsonType& j, FloatType val) noexcept
4778 template<
typename BasicJsonType,
typename CompatibleNumberUnsignedType,
4780 void to_json(BasicJsonType& j, CompatibleNumberUnsignedType val) noexcept
4785 template<
typename BasicJsonType,
typename CompatibleNumberIntegerType,
4787 void to_json(BasicJsonType& j, CompatibleNumberIntegerType val) noexcept
4792 template<
typename BasicJsonType,
typename EnumType,
4794 void to_json(BasicJsonType& j, EnumType e) noexcept
4800 template<
typename BasicJsonType>
4801 void to_json(BasicJsonType& j,
const std::vector<bool>& e)
4806 template <
typename BasicJsonType,
typename CompatibleArrayType,
4807 enable_if_t < is_compatible_array_type<BasicJsonType,
4808 CompatibleArrayType>::value&&
4809 !is_compatible_object_type<BasicJsonType, CompatibleArrayType>::value&&
4811 !std::is_same<typename BasicJsonType::binary_t, CompatibleArrayType>::value&&
4812 !is_basic_json<CompatibleArrayType>::value,
4814 void to_json(BasicJsonType& j,
const CompatibleArrayType& arr)
4819 template<
typename BasicJsonType>
4820 void to_json(BasicJsonType& j,
const typename BasicJsonType::binary_t& bin)
4825 template<
typename BasicJsonType,
typename T,
4827 void to_json(BasicJsonType& j,
const std::valarray<T>& arr)
4832 template<
typename BasicJsonType>
4833 void to_json(BasicJsonType& j,
typename BasicJsonType::array_t&& arr)
4838 template <
typename BasicJsonType,
typename CompatibleObjectType,
4840 void to_json(BasicJsonType& j,
const CompatibleObjectType& obj)
4845 template<
typename BasicJsonType>
4846 void to_json(BasicJsonType& j,
typename BasicJsonType::object_t&& obj)
4852 typename BasicJsonType,
typename T,
std::size_t N,
4853 enable_if_t < !std::is_constructible<
typename BasicJsonType::string_t,
4854 const T(&)[N]>::value,
4861 template < typename BasicJsonType, typename T1, typename T2, enable_if_t < std::is_constructible<BasicJsonType, T1>::value&& std::is_constructible<BasicJsonType, T2>::value,
int > = 0 >
4862 void to_json(BasicJsonType& j,
const std::pair<T1, T2>& p)
4864 j = { p.first, p.second };
4868 template<
typename BasicJsonType,
typename T,
4872 j = { {b.key(), b.value()} };
4875 template<
typename BasicJsonType,
typename Tuple,
std::size_t... Idx>
4878 j = { std::get<Idx>(t)... };
4881 template<typename BasicJsonType, typename T, enable_if_t<is_constructible_tuple<BasicJsonType, T>::value,
int > = 0>
4882 void to_json(BasicJsonType& j,
const T& t)
4887 #if JSON_HAS_FILESYSTEM || JSON_HAS_EXPERIMENTAL_FILESYSTEM
4888 template<
typename BasicJsonType>
4889 void to_json(BasicJsonType& j,
const std_fs::path& p)
4897 template<
typename BasicJsonType,
typename T>
4898 auto operator()(BasicJsonType& j, T&& val)
const noexcept(noexcept(
to_json(j, std::forward<T>(val))))
4899 -> decltype(
to_json(j, std::forward<T>(val)),
void())
4901 return to_json(j, std::forward<T>(val));
4924 template<
typename ValueType,
typename>
4925 struct adl_serializer
4929 template<
typename BasicJsonType,
typename TargetType = ValueType>
4930 static auto from_json(BasicJsonType && j, TargetType& val) noexcept(
4939 template<
typename BasicJsonType,
typename TargetType = ValueType>
4949 template<
typename BasicJsonType,
typename TargetType = ValueType>
4950 static auto to_json(BasicJsonType& j, TargetType && val) noexcept(
4971 template<
typename BinaryType>
5015 return !(rhs == *
this);
5066 #include <functional>
5081 seed ^= h + 0x9e3779b9 + (seed << 6U) + (seed >> 2U);
5096 template<
typename BasicJsonType>
5099 using string_t =
typename BasicJsonType::string_t;
5100 using number_integer_t =
typename BasicJsonType::number_integer_t;
5101 using number_unsigned_t =
typename BasicJsonType::number_unsigned_t;
5102 using number_float_t =
typename BasicJsonType::number_float_t;
5104 const auto type =
static_cast<std::size_t>(j.type());
5107 case BasicJsonType::value_t::null:
5108 case BasicJsonType::value_t::discarded:
5115 auto seed =
combine(type, j.size());
5116 for (
const auto& element : j.items())
5118 const auto h = std::hash<string_t> {}(element.key());
5125 case BasicJsonType::value_t::array:
5127 auto seed =
combine(type, j.size());
5128 for (
const auto& element : j)
5135 case BasicJsonType::value_t::string:
5137 const auto h = std::hash<string_t> {}(j.template get_ref<const string_t&>());
5143 const auto h = std::hash<bool> {}(j.template get<bool>());
5147 case BasicJsonType::value_t::number_integer:
5149 const auto h = std::hash<number_integer_t> {}(j.template get<number_integer_t>());
5153 case BasicJsonType::value_t::number_unsigned:
5155 const auto h = std::hash<number_unsigned_t> {}(j.template get<number_unsigned_t>());
5159 case BasicJsonType::value_t::number_float:
5161 const auto h = std::hash<number_float_t> {}(j.template get<number_float_t>());
5165 case BasicJsonType::value_t::binary:
5167 auto seed =
combine(type, j.get_binary().size());
5168 const auto h = std::hash<bool> {}(j.get_binary().has_subtype());
5171 for (
const auto byte : j.get_binary())
5173 seed =
combine(seed, std::hash<std::uint8_t> {}(byte));
5190 #include <algorithm>
5215 #include <type_traits>
5221 #endif // JSON_NO_IO
5263 return std::fgetc(
m_file);
5292 is->clear(
is->rdstate() & std::ios::eofbit);
5297 :
is(&i),
sb(i.rdbuf())
5306 :
is(rhs.is),
sb(rhs.sb)
5317 auto res =
sb->sbumpc();
5321 is->clear(
is->rdstate() | std::ios::eofbit);
5328 std::istream*
is =
nullptr;
5329 std::streambuf*
sb =
nullptr;
5331 #endif // JSON_NO_IO
5335 template<
typename IteratorType>
5339 using char_type =
typename std::iterator_traits<IteratorType>::value_type;
5349 auto result = std::char_traits<char_type>::to_int_type(*
current);
5354 return std::char_traits<char_type>::eof();
5361 template<
typename BaseInputAdapter,
size_t T>
5371 template<
typename BaseInputAdapter,
size_t T>
5374 template<
typename BaseInputAdapter>
5379 std::array<std::char_traits<char>::int_type, 4>& utf8_bytes,
5380 size_t& utf8_bytes_index,
5381 size_t& utf8_bytes_filled)
5383 utf8_bytes_index = 0;
5387 utf8_bytes[0] = std::char_traits<char>::eof();
5388 utf8_bytes_filled = 1;
5393 const auto wc = input.get_character();
5398 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(wc);
5399 utf8_bytes_filled = 1;
5401 else if (wc <= 0x7FF)
5403 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(0xC0u | ((
static_cast<unsigned int>(wc) >> 6u) & 0x1Fu));
5404 utf8_bytes[1] =
static_cast<std::char_traits<char>::int_type
>(0x80u | (
static_cast<unsigned int>(wc) & 0x3Fu));
5405 utf8_bytes_filled = 2;
5407 else if (wc <= 0xFFFF)
5409 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(0xE0u | ((
static_cast<unsigned int>(wc) >> 12u) & 0x0Fu));
5410 utf8_bytes[1] =
static_cast<std::char_traits<char>::int_type
>(0x80u | ((
static_cast<unsigned int>(wc) >> 6u) & 0x3Fu));
5411 utf8_bytes[2] =
static_cast<std::char_traits<char>::int_type
>(0x80u | (
static_cast<unsigned int>(wc) & 0x3Fu));
5412 utf8_bytes_filled = 3;
5414 else if (wc <= 0x10FFFF)
5416 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(0xF0u | ((
static_cast<unsigned int>(wc) >> 18u) & 0x07u));
5417 utf8_bytes[1] =
static_cast<std::char_traits<char>::int_type
>(0x80u | ((
static_cast<unsigned int>(wc) >> 12u) & 0x3Fu));
5418 utf8_bytes[2] =
static_cast<std::char_traits<char>::int_type
>(0x80u | ((
static_cast<unsigned int>(wc) >> 6u) & 0x3Fu));
5419 utf8_bytes[3] =
static_cast<std::char_traits<char>::int_type
>(0x80u | (
static_cast<unsigned int>(wc) & 0x3Fu));
5420 utf8_bytes_filled = 4;
5425 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(wc);
5426 utf8_bytes_filled = 1;
5432 template<
typename BaseInputAdapter>
5437 std::array<std::char_traits<char>::int_type, 4>& utf8_bytes,
5438 size_t& utf8_bytes_index,
5439 size_t& utf8_bytes_filled)
5441 utf8_bytes_index = 0;
5445 utf8_bytes[0] = std::char_traits<char>::eof();
5446 utf8_bytes_filled = 1;
5451 const auto wc = input.get_character();
5456 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(wc);
5457 utf8_bytes_filled = 1;
5459 else if (wc <= 0x7FF)
5461 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(0xC0u | ((
static_cast<unsigned int>(wc) >> 6u)));
5462 utf8_bytes[1] =
static_cast<std::char_traits<char>::int_type
>(0x80u | (
static_cast<unsigned int>(wc) & 0x3Fu));
5463 utf8_bytes_filled = 2;
5465 else if (0xD800 > wc || wc >= 0xE000)
5467 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(0xE0u | ((
static_cast<unsigned int>(wc) >> 12u)));
5468 utf8_bytes[1] =
static_cast<std::char_traits<char>::int_type
>(0x80u | ((
static_cast<unsigned int>(wc) >> 6u) & 0x3Fu));
5469 utf8_bytes[2] =
static_cast<std::char_traits<char>::int_type
>(0x80u | (
static_cast<unsigned int>(wc) & 0x3Fu));
5470 utf8_bytes_filled = 3;
5476 const auto wc2 =
static_cast<unsigned int>(input.get_character());
5477 const auto charcode = 0x10000u + (((
static_cast<unsigned int>(wc) & 0x3FFu) << 10u) | (wc2 & 0x3FFu));
5478 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(0xF0u | (charcode >> 18u));
5479 utf8_bytes[1] =
static_cast<std::char_traits<char>::int_type
>(0x80u | ((charcode >> 12u) & 0x3Fu));
5480 utf8_bytes[2] =
static_cast<std::char_traits<char>::int_type
>(0x80u | ((charcode >> 6u) & 0x3Fu));
5481 utf8_bytes[3] =
static_cast<std::char_traits<char>::int_type
>(0x80u | (charcode & 0x3Fu));
5482 utf8_bytes_filled = 4;
5486 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(wc);
5487 utf8_bytes_filled = 1;
5495 template<
typename BaseInputAdapter,
typename W
ideCharType>
5509 fill_buffer<sizeof(WideCharType)>();
5531 std::array<std::char_traits<char>::int_type, 4>
utf8_bytes = {{0, 0, 0, 0}};
5540 template<
typename IteratorType,
typename Enable =
void>
5544 using char_type =
typename std::iterator_traits<iterator_type>::value_type;
5553 template<
typename T>
5563 template<
typename IteratorType>
5567 using char_type =
typename std::iterator_traits<iterator_type>::value_type;
5578 template<
typename IteratorType>
5589 namespace container_input_adapter_factory_impl
5595 template<
typename ContainerType,
typename Enable =
void>
5598 template<
typename ContainerType>
5600 void_t<decltype(begin(
std::declval<ContainerType>()), end(std::declval<ContainerType>()))>>
5612 template<
typename ContainerType>
5634 #endif // JSON_NO_IO
5639 template <
typename CharT,
5640 typename std::enable_if <
5641 std::is_pointer<CharT>::value&&
5642 !std::is_array<CharT>::value&&
5648 auto length = std::strlen(
reinterpret_cast<const char*
>(b));
5649 const auto*
ptr =
reinterpret_cast<const char*
>(b);
5653 template<
typename T, std::
size_t N>
5665 template <
typename CharT,
5666 typename std::enable_if <
5667 std::is_pointer<CharT>::value&&
5672 : ia(
reinterpret_cast<const char*
>(b),
reinterpret_cast<const char*
>(b) + l) {}
5674 template<
class IteratorType,
5675 typename std::enable_if<
5676 std::is_same<typename iterator_traits<IteratorType>::iterator_category, std::random_access_iterator_tag>::value,
5716 template<
typename BasicJsonType>
5729 virtual bool null() = 0;
5736 virtual bool boolean(
bool val) = 0;
5820 const std::string& last_token,
5847 template<
typename BasicJsonType>
5863 : root(r), allow_exceptions(allow_exceptions_)
5875 handle_value(
nullptr);
5930 object_element = &(ref_stack.back()->m_value.object->operator[](val));
5936 ref_stack.back()->set_parents();
5937 ref_stack.pop_back();
5943 ref_stack.push_back(handle_value(BasicJsonType::value_t::array));
5955 ref_stack.back()->set_parents();
5956 ref_stack.pop_back();
5960 template<
class Exception>
5962 const Exception& ex)
5965 static_cast<void>(ex);
5966 if (allow_exceptions)
5985 template<
typename Value>
5989 if (ref_stack.empty())
5991 root = BasicJsonType(std::forward<Value>(v));
5995 JSON_ASSERT(ref_stack.back()->is_array() || ref_stack.back()->is_object());
5997 if (ref_stack.back()->is_array())
5999 ref_stack.back()->m_value.array->emplace_back(std::forward<Value>(v));
6000 return &(ref_stack.back()->m_value.array->back());
6005 *object_element = BasicJsonType(std::forward<Value>(v));
6006 return object_element;
6012 std::vector<BasicJsonType*> ref_stack {};
6014 BasicJsonType* object_element =
nullptr;
6016 bool errored =
false;
6018 const bool allow_exceptions =
true;
6021 template<
typename BasicJsonType>
6035 const bool allow_exceptions_ =
true)
6036 : root(r), callback(cb), allow_exceptions(allow_exceptions_)
6038 keep_stack.push_back(
true);
6050 handle_value(
nullptr);
6093 const bool keep = callback(
static_cast<int>(ref_stack.size()), parse_event_t::object_start,
discarded);
6094 keep_stack.push_back(keep);
6097 ref_stack.push_back(val.second);
6110 BasicJsonType k = BasicJsonType(val);
6113 const bool keep = callback(
static_cast<int>(ref_stack.size()), parse_event_t::key, k);
6114 key_keep_stack.push_back(keep);
6117 if (keep && ref_stack.back())
6119 object_element = &(ref_stack.back()->m_value.object->operator[](val) =
discarded);
6127 if (ref_stack.back())
6129 if (!callback(
static_cast<int>(ref_stack.size()) - 1, parse_event_t::object_end, *ref_stack.back()))
6136 ref_stack.back()->set_parents();
6142 ref_stack.pop_back();
6143 keep_stack.pop_back();
6145 if (!ref_stack.empty() && ref_stack.back() && ref_stack.back()->is_structured())
6148 for (
auto it = ref_stack.back()->begin(); it != ref_stack.back()->end(); ++it)
6150 if (it->is_discarded())
6152 ref_stack.back()->erase(it);
6163 const bool keep = callback(
static_cast<int>(ref_stack.size()), parse_event_t::array_start,
discarded);
6164 keep_stack.push_back(keep);
6166 auto val = handle_value(BasicJsonType::value_t::array,
true);
6167 ref_stack.push_back(val.second);
6182 if (ref_stack.back())
6184 keep = callback(
static_cast<int>(ref_stack.size()) - 1, parse_event_t::array_end, *ref_stack.back());
6187 ref_stack.back()->set_parents();
6198 ref_stack.pop_back();
6199 keep_stack.pop_back();
6202 if (!keep && !ref_stack.empty() && ref_stack.back()->is_array())
6204 ref_stack.back()->m_value.array->pop_back();
6210 template<
class Exception>
6212 const Exception& ex)
6215 static_cast<void>(ex);
6216 if (allow_exceptions)
6244 template<
typename Value>
6251 if (!keep_stack.back())
6253 return {
false,
nullptr};
6257 auto value = BasicJsonType(std::forward<Value>(v));
6260 const bool keep = skip_callback || callback(
static_cast<int>(ref_stack.size()), parse_event_t::value,
value);
6265 return {
false,
nullptr};
6268 if (ref_stack.empty())
6271 return {
true, &root};
6276 if (!ref_stack.back())
6278 return {
false,
nullptr};
6282 JSON_ASSERT(ref_stack.back()->is_array() || ref_stack.back()->is_object());
6285 if (ref_stack.back()->is_array())
6288 return {
true, &(ref_stack.back()->m_value.array->back())};
6295 const bool store_element = key_keep_stack.back();
6296 key_keep_stack.pop_back();
6300 return {
false,
nullptr};
6305 return {
true, object_element};
6311 std::vector<BasicJsonType*> ref_stack {};
6313 std::vector<bool> keep_stack {};
6315 std::vector<bool> key_keep_stack {};
6317 BasicJsonType* object_element =
nullptr;
6319 bool errored =
false;
6323 const bool allow_exceptions =
true;
6325 BasicJsonType
discarded = BasicJsonType::value_t::discarded;
6328 template<
typename BasicJsonType>
6415 #include <initializer_list>
6435 template<
typename BasicJsonType>
6469 return "<uninitialized>";
6471 return "true literal";
6473 return "false literal";
6475 return "null literal";
6477 return "string literal";
6481 return "number literal";
6495 return "<parse error>";
6497 return "end of input";
6499 return "'[', '{', or a literal";
6502 return "unknown token";
6512 template<
typename BasicJsonType,
typename InputAdapterType>
6525 explicit lexer(InputAdapterType&& adapter,
bool ignore_comments_ =
false) noexcept
6547 const auto* loc = localeconv();
6549 return (loc->decimal_point ==
nullptr) ?
'.' : *(loc->decimal_point);
6577 const auto factors = { 12u, 8u, 4u, 0u };
6578 for (
const auto factor : factors)
6584 codepoint +=
static_cast<int>((
static_cast<unsigned int>(
current) - 0x30u) << factor);
6588 codepoint +=
static_cast<int>((
static_cast<unsigned int>(
current) - 0x37u) << factor);
6592 codepoint +=
static_cast<int>((
static_cast<unsigned int>(
current) - 0x57u) << factor);
6621 JSON_ASSERT(ranges.size() == 2 || ranges.size() == 4 || ranges.size() == 6);
6624 for (
auto range = ranges.begin(); range != ranges.end(); ++range)
6670 case std::char_traits<char_type>::eof():
6673 return token_type::parse_error;
6679 return token_type::value_string;
6728 error_message =
"invalid string: '\\u' must be followed by 4 hex digits";
6729 return token_type::parse_error;
6733 if (0xD800 <= codepoint1 && codepoint1 <= 0xDBFF)
6742 error_message =
"invalid string: '\\u' must be followed by 4 hex digits";
6743 return token_type::parse_error;
6752 (
static_cast<unsigned int>(codepoint1) << 10u)
6754 +
static_cast<unsigned int>(codepoint2)
6762 error_message =
"invalid string: surrogate U+D800..U+DBFF must be followed by U+DC00..U+DFFF";
6763 return token_type::parse_error;
6768 error_message =
"invalid string: surrogate U+D800..U+DBFF must be followed by U+DC00..U+DFFF";
6769 return token_type::parse_error;
6776 error_message =
"invalid string: surrogate U+DC00..U+DFFF must follow U+D800..U+DBFF";
6777 return token_type::parse_error;
6817 error_message =
"invalid string: forbidden character after backslash";
6818 return token_type::parse_error;
6827 error_message =
"invalid string: control character U+0000 (NUL) must be escaped to \\u0000";
6828 return token_type::parse_error;
6833 error_message =
"invalid string: control character U+0001 (SOH) must be escaped to \\u0001";
6834 return token_type::parse_error;
6839 error_message =
"invalid string: control character U+0002 (STX) must be escaped to \\u0002";
6840 return token_type::parse_error;
6845 error_message =
"invalid string: control character U+0003 (ETX) must be escaped to \\u0003";
6846 return token_type::parse_error;
6851 error_message =
"invalid string: control character U+0004 (EOT) must be escaped to \\u0004";
6852 return token_type::parse_error;
6857 error_message =
"invalid string: control character U+0005 (ENQ) must be escaped to \\u0005";
6858 return token_type::parse_error;
6863 error_message =
"invalid string: control character U+0006 (ACK) must be escaped to \\u0006";
6864 return token_type::parse_error;
6869 error_message =
"invalid string: control character U+0007 (BEL) must be escaped to \\u0007";
6870 return token_type::parse_error;
6875 error_message =
"invalid string: control character U+0008 (BS) must be escaped to \\u0008 or \\b";
6876 return token_type::parse_error;
6881 error_message =
"invalid string: control character U+0009 (HT) must be escaped to \\u0009 or \\t";
6882 return token_type::parse_error;
6887 error_message =
"invalid string: control character U+000A (LF) must be escaped to \\u000A or \\n";
6888 return token_type::parse_error;
6893 error_message =
"invalid string: control character U+000B (VT) must be escaped to \\u000B";
6894 return token_type::parse_error;
6899 error_message =
"invalid string: control character U+000C (FF) must be escaped to \\u000C or \\f";
6900 return token_type::parse_error;
6905 error_message =
"invalid string: control character U+000D (CR) must be escaped to \\u000D or \\r";
6906 return token_type::parse_error;
6911 error_message =
"invalid string: control character U+000E (SO) must be escaped to \\u000E";
6912 return token_type::parse_error;
6917 error_message =
"invalid string: control character U+000F (SI) must be escaped to \\u000F";
6918 return token_type::parse_error;
6923 error_message =
"invalid string: control character U+0010 (DLE) must be escaped to \\u0010";
6924 return token_type::parse_error;
6929 error_message =
"invalid string: control character U+0011 (DC1) must be escaped to \\u0011";
6930 return token_type::parse_error;
6935 error_message =
"invalid string: control character U+0012 (DC2) must be escaped to \\u0012";
6936 return token_type::parse_error;
6941 error_message =
"invalid string: control character U+0013 (DC3) must be escaped to \\u0013";
6942 return token_type::parse_error;
6947 error_message =
"invalid string: control character U+0014 (DC4) must be escaped to \\u0014";
6948 return token_type::parse_error;
6953 error_message =
"invalid string: control character U+0015 (NAK) must be escaped to \\u0015";
6954 return token_type::parse_error;
6959 error_message =
"invalid string: control character U+0016 (SYN) must be escaped to \\u0016";
6960 return token_type::parse_error;
6965 error_message =
"invalid string: control character U+0017 (ETB) must be escaped to \\u0017";
6966 return token_type::parse_error;
6971 error_message =
"invalid string: control character U+0018 (CAN) must be escaped to \\u0018";
6972 return token_type::parse_error;
6977 error_message =
"invalid string: control character U+0019 (EM) must be escaped to \\u0019";
6978 return token_type::parse_error;
6983 error_message =
"invalid string: control character U+001A (SUB) must be escaped to \\u001A";
6984 return token_type::parse_error;
6989 error_message =
"invalid string: control character U+001B (ESC) must be escaped to \\u001B";
6990 return token_type::parse_error;
6995 error_message =
"invalid string: control character U+001C (FS) must be escaped to \\u001C";
6996 return token_type::parse_error;
7001 error_message =
"invalid string: control character U+001D (GS) must be escaped to \\u001D";
7002 return token_type::parse_error;
7007 error_message =
"invalid string: control character U+001E (RS) must be escaped to \\u001E";
7008 return token_type::parse_error;
7013 error_message =
"invalid string: control character U+001F (US) must be escaped to \\u001F";
7014 return token_type::parse_error;
7151 return token_type::parse_error;
7161 return token_type::parse_error;
7185 return token_type::parse_error;
7195 return token_type::parse_error;
7205 return token_type::parse_error;
7217 return token_type::parse_error;
7227 return token_type::parse_error;
7236 return token_type::parse_error;
7259 case std::char_traits<char_type>::eof():
7276 case std::char_traits<char_type>::eof():
7307 error_message =
"invalid comment; expecting '/' or '*' after '/'";
7314 static
void strtof(
float& f, const
char* str,
char** endptr) noexcept
7316 f = std::strtof(str, endptr);
7320 static
void strtof(
double& f, const
char* str,
char** endptr) noexcept
7322 f = std::strtod(str, endptr);
7326 static
void strtof(
long double& f, const
char* str,
char** endptr) noexcept
7328 f = std::strtold(str, endptr);
7378 token_type number_type = token_type::value_unsigned;
7386 goto scan_number_minus;
7392 goto scan_number_zero;
7406 goto scan_number_any1;
7416 number_type = token_type::value_integer;
7422 goto scan_number_zero;
7436 goto scan_number_any1;
7442 return token_type::parse_error;
7453 goto scan_number_decimal1;
7460 goto scan_number_exponent;
7464 goto scan_number_done;
7483 goto scan_number_any1;
7489 goto scan_number_decimal1;
7496 goto scan_number_exponent;
7500 goto scan_number_done;
7503 scan_number_decimal1:
7505 number_type = token_type::value_float;
7520 goto scan_number_decimal2;
7526 return token_type::parse_error;
7530 scan_number_decimal2:
7546 goto scan_number_decimal2;
7553 goto scan_number_exponent;
7557 goto scan_number_done;
7560 scan_number_exponent:
7562 number_type = token_type::value_float;
7569 goto scan_number_sign;
7584 goto scan_number_any2;
7590 "invalid number; expected '+', '-', or digit after exponent";
7591 return token_type::parse_error;
7611 goto scan_number_any2;
7616 error_message =
"invalid number; expected digit after exponent sign";
7617 return token_type::parse_error;
7637 goto scan_number_any2;
7641 goto scan_number_done;
7649 char* endptr =
nullptr;
7653 if (number_type == token_type::value_unsigned)
7655 const auto x = std::strtoull(
token_buffer.data(), &endptr, 10);
7665 return token_type::value_unsigned;
7669 else if (number_type == token_type::value_integer)
7671 const auto x = std::strtoll(
token_buffer.data(), &endptr, 10);
7681 return token_type::value_integer;
7693 return token_type::value_float;
7711 return token_type::parse_error;
7805 token_buffer.push_back(
static_cast<typename string_t::value_type
>(c));
7856 if (
static_cast<unsigned char>(c) <=
'\x1F')
7859 std::array<char, 9> cs{{}};
7860 static_cast<void>((std::snprintf)(cs.data(), cs.size(),
"<U+%.4X>",
static_cast<unsigned char>(c)));
7861 result += cs.data();
7866 result.push_back(
static_cast<std::string::value_type
>(c));
7893 return get() == 0xBB &&
get() == 0xBF;
7916 error_message =
"invalid BOM; must be 0xEF 0xBB 0xBF if given";
7917 return token_type::parse_error;
7928 return token_type::parse_error;
7939 return token_type::begin_array;
7941 return token_type::end_array;
7943 return token_type::begin_object;
7945 return token_type::end_object;
7947 return token_type::name_separator;
7949 return token_type::value_separator;
7955 return scan_literal(true_literal.data(), true_literal.size(), token_type::literal_true);
7960 return scan_literal(false_literal.data(), false_literal.size(), token_type::literal_false);
7965 return scan_literal(null_literal.data(), null_literal.size(), token_type::literal_null);
7989 case std::char_traits<char_type>::eof():
7990 return token_type::end_of_input;
7995 return token_type::parse_error;
8053 template<
typename T>
8056 template<
typename T>
8058 decltype(std::declval<T&>().
boolean(std::declval<bool>()));
8060 template<
typename T,
typename Integer>
8064 template<
typename T,
typename Un
signed>
8068 template<
typename T,
typename Float,
typename String>
8070 std::declval<Float>(), std::declval<const String&>()));
8072 template<
typename T,
typename String>
8074 decltype(std::declval<T&>().
string(std::declval<String&>()));
8076 template<
typename T,
typename Binary>
8078 decltype(std::declval<T&>().
binary(std::declval<Binary&>()));
8080 template<
typename T>
8082 decltype(std::declval<T&>().start_object(std::declval<std::size_t>()));
8084 template<
typename T,
typename String>
8086 decltype(std::declval<T&>().
key(std::declval<String&>()));
8088 template<
typename T>
8091 template<
typename T>
8093 decltype(std::declval<T&>().start_array(std::declval<std::size_t>()));
8095 template<
typename T>
8098 template<
typename T,
typename Exception>
8100 std::declval<std::size_t>(), std::declval<const std::string&>(),
8101 std::declval<const Exception&>()));
8103 template<
typename SAX,
typename BasicJsonType>
8108 "BasicJsonType must be of type basic_json<...>");
8134 template<
typename SAX,
typename BasicJsonType>
8139 "BasicJsonType must be of type basic_json<...>");
8150 "Missing/invalid function: bool null()");
8152 "Missing/invalid function: bool boolean(bool)");
8154 "Missing/invalid function: bool boolean(bool)");
8158 "Missing/invalid function: bool number_integer(number_integer_t)");
8162 "Missing/invalid function: bool number_unsigned(number_unsigned_t)");
8165 "Missing/invalid function: bool number_float(number_float_t, const string_t&)");
8168 "Missing/invalid function: bool string(string_t&)");
8171 "Missing/invalid function: bool binary(binary_t&)");
8173 "Missing/invalid function: bool start_object(std::size_t)");
8175 "Missing/invalid function: bool key(string_t&)");
8177 "Missing/invalid function: bool end_object()");
8179 "Missing/invalid function: bool start_array(std::size_t)");
8181 "Missing/invalid function: bool end_array()");
8184 "Missing/invalid function: bool parse_error(std::size_t, const "
8185 "std::string&, const exception&)");
8217 return *
reinterpret_cast<char*
>(&num) == 1;
8228 template<
typename BasicJsonType,
typename InputAdapterType,
typename SAX = json_sax_dom_parser<BasicJsonType>>
8269 const
bool strict = true,
8273 bool result =
false;
8331 std::int32_t document_size{};
8344 return sax->end_object();
8356 auto out = std::back_inserter(result);
8368 *out++ =
static_cast<typename string_t::value_type
>(
current);
8383 template<
typename NumberType>
8404 template<
typename NumberType>
8414 std::uint8_t subtype{};
8416 result.set_subtype(subtype);
8434 switch (element_type)
8468 return sax->boolean(
get() != 0);
8478 std::int32_t
value{};
8484 std::int64_t
value{};
8490 std::array<char, 3> cr{{}};
8491 static_cast<void>((std::snprintf)(cr.data(), cr.size(),
"%.2hhX",
static_cast<unsigned char>(element_type)));
8492 return sax->parse_error(element_type_parse_position, std::string(cr.data()),
parse_error::create(114, element_type_parse_position,
"Unsupported BSON record type 0x" + std::string(cr.data()), BasicJsonType()));
8513 while (
auto element_type =
get())
8526 if (!is_array && !
sax->key(
key))
8549 std::int32_t document_size{};
8562 return sax->end_array();
8583 case std::char_traits<char_type>::eof():
8615 std::uint8_t number{};
8621 std::uint16_t number{};
8627 std::uint32_t number{};
8633 std::uint64_t number{};
8662 return sax->number_integer(
static_cast<std::int8_t
>(0x20 - 1 -
current));
8666 std::uint8_t number{};
8672 std::uint16_t number{};
8678 std::uint32_t number{};
8684 std::uint64_t number{};
8794 std::uint16_t len{};
8800 std::uint32_t len{};
8806 std::uint64_t len{};
8848 std::uint16_t len{};
8854 std::uint32_t len{};
8860 std::uint64_t len{};
8887 switch (tag_handler)
8902 std::uint8_t subtype_to_ignore{};
8908 std::uint16_t subtype_to_ignore{};
8914 std::uint32_t subtype_to_ignore{};
8920 std::uint64_t subtype_to_ignore{};
8938 std::uint8_t subtype{};
8940 b.set_subtype(detail::conditional_static_cast<typename binary_t::subtype_type>(subtype));
8945 std::uint16_t subtype{};
8947 b.set_subtype(detail::conditional_static_cast<typename binary_t::subtype_type>(subtype));
8952 std::uint32_t subtype{};
8954 b.set_subtype(detail::conditional_static_cast<typename binary_t::subtype_type>(subtype));
8959 std::uint64_t subtype{};
8961 b.set_subtype(detail::conditional_static_cast<typename binary_t::subtype_type>(subtype));
8978 return sax->boolean(
false);
8981 return sax->boolean(
true);
8988 const auto byte1_raw =
get();
8993 const auto byte2_raw =
get();
8999 const auto byte1 =
static_cast<unsigned char>(byte1_raw);
9000 const auto byte2 =
static_cast<unsigned char>(byte2_raw);
9010 const auto half =
static_cast<unsigned int>((byte1 << 8u) + byte2);
9011 const double val = [&half]
9013 const int exp = (half >> 10u) & 0x1Fu;
9014 const unsigned int mant = half & 0x3FFu;
9020 return std::ldexp(mant, -24);
9023 ? std::numeric_limits<double>::infinity()
9024 : std::numeric_limits<double>::quiet_NaN();
9026 return std::ldexp(mant + 1024, exp - 25);
9029 return sax->number_float((half & 0x8000u) != 0
9111 std::uint16_t len{};
9117 std::uint32_t len{};
9123 std::uint64_t len{};
9129 while (
get() != 0xFF)
9136 result.append(chunk);
9207 std::uint16_t len{};
9214 std::uint32_t len{};
9221 std::uint64_t len{};
9228 while (
get() != 0xFF)
9235 result.insert(result.end(), chunk.begin(), chunk.end());
9274 while (
get() != 0xFF)
9283 return sax->end_array();
9322 while (
get() != 0xFF)
9338 return sax->end_object();
9353 case std::char_traits<char_type>::eof():
9570 return sax->boolean(
false);
9573 return sax->boolean(
true);
9605 std::uint8_t number{};
9611 std::uint16_t number{};
9617 std::uint32_t number{};
9623 std::uint64_t number{};
9629 std::int8_t number{};
9635 std::int16_t number{};
9641 std::int32_t number{};
9647 std::int64_t number{};
9653 std::uint16_t len{};
9659 std::uint32_t len{};
9665 std::uint16_t len{};
9671 std::uint32_t len{};
9708 return sax->number_integer(
static_cast<std::int8_t
>(
current));
9782 std::uint16_t len{};
9788 std::uint32_t len{};
9813 auto assign_and_return_true = [&result](std::int8_t subtype)
9815 result.set_subtype(
static_cast<std::uint8_t
>(subtype));
9830 std::uint16_t len{};
9837 std::uint32_t len{};
9845 std::int8_t subtype{};
9849 assign_and_return_true(subtype);
9854 std::uint16_t len{};
9855 std::int8_t subtype{};
9859 assign_and_return_true(subtype);
9864 std::uint32_t len{};
9865 std::int8_t subtype{};
9869 assign_and_return_true(subtype);
9874 std::int8_t subtype{};
9877 assign_and_return_true(subtype);
9882 std::int8_t subtype{};
9885 assign_and_return_true(subtype);
9890 std::int8_t subtype{};
9893 assign_and_return_true(subtype);
9898 std::int8_t subtype{};
9901 assign_and_return_true(subtype);
9906 std::int8_t subtype{};
9909 assign_and_return_true(subtype);
9936 return sax->end_array();
9966 return sax->end_object();
10015 std::uint8_t len{};
10027 std::int16_t len{};
10033 std::int32_t len{};
10039 std::int64_t len{};
10045 return sax->parse_error(
chars_read, last_token,
parse_error::create(113,
chars_read,
exception_message(
input_format_t::ubjson,
"expected length type specification (U, i, I, l, L); last byte: 0x" + last_token,
"string"), BasicJsonType()));
10059 std::uint8_t number{};
10070 std::int8_t number{};
10081 std::int16_t number{};
10092 std::int32_t number{};
10103 std::int64_t number{};
10115 return sax->parse_error(
chars_read, last_token,
parse_error::create(113,
chars_read,
exception_message(
input_format_t::ubjson,
"expected length type specification (U, i, I, l, L) after '#'; last byte: 0x" + last_token,
"size"), BasicJsonType()));
10132 result.first = string_t::npos;
10139 result.second =
get();
10175 case std::char_traits<char_type>::eof():
10179 return sax->boolean(
true);
10181 return sax->boolean(
false);
10184 return sax->null();
10188 std::uint8_t number{};
10194 std::int8_t number{};
10200 std::int16_t number{};
10206 std::int32_t number{};
10212 std::int64_t number{};
10246 return sax->string(
s);
10274 std::pair<std::size_t, char_int_type> size_and_type;
10280 if (size_and_type.first != string_t::npos)
10287 if (size_and_type.second != 0)
10289 if (size_and_type.second !=
'N')
10291 for (
std::size_t i = 0; i < size_and_type.first; ++i)
10302 for (
std::size_t i = 0; i < size_and_type.first; ++i)
10328 return sax->end_array();
10336 std::pair<std::size_t, char_int_type> size_and_type;
10343 if (size_and_type.first != string_t::npos)
10350 if (size_and_type.second != 0)
10352 for (
std::size_t i = 0; i < size_and_type.first; ++i)
10367 for (
std::size_t i = 0; i < size_and_type.first; ++i)
10403 return sax->end_object();
10420 std::vector<char> number_vector;
10428 number_vector.push_back(
static_cast<char>(
current));
10434 const auto result_number = number_lexer.scan();
10435 const auto number_string = number_lexer.get_token_string();
10436 const auto result_remainder = number_lexer.scan();
10445 switch (result_number)
10447 case token_type::value_integer:
10448 return sax->number_integer(number_lexer.get_number_integer());
10449 case token_type::value_unsigned:
10450 return sax->number_unsigned(number_lexer.get_number_unsigned());
10451 case token_type::value_float:
10452 return sax->number_float(number_lexer.get_number_float(),
std::move(number_string));
10453 case token_type::uninitialized:
10454 case token_type::literal_true:
10455 case token_type::literal_false:
10456 case token_type::literal_null:
10457 case token_type::value_string:
10458 case token_type::begin_array:
10459 case token_type::begin_object:
10460 case token_type::end_array:
10461 case token_type::end_object:
10462 case token_type::name_separator:
10463 case token_type::value_separator:
10464 case token_type::parse_error:
10465 case token_type::end_of_input:
10466 case token_type::literal_or_value:
10518 template<
typename NumberType,
bool InputIsLittleEndian = false>
10522 std::array<std::uint8_t,
sizeof(NumberType)> vec{};
10523 for (
std::size_t i = 0; i <
sizeof(NumberType); ++i)
10534 vec[
sizeof(NumberType) - i - 1] =
static_cast<std::uint8_t
>(
current);
10538 vec[i] =
static_cast<std::uint8_t
>(
current);
10543 std::memcpy(&result, vec.data(),
sizeof(NumberType));
10561 template<
typename NumberType>
10563 const NumberType len,
10566 bool success =
true;
10567 for (NumberType i = 0; i < len; i++)
10575 result.push_back(
static_cast<typename string_t::value_type
>(
current));
10594 template<
typename NumberType>
10596 const NumberType len,
10599 bool success =
true;
10600 for (NumberType i = 0; i < len; i++)
10608 result.push_back(
static_cast<std::uint8_t
>(
current));
10634 std::array<char, 3> cr{{}};
10635 static_cast<void>((std::snprintf)(cr.data(), cr.size(),
"%.2hhX",
static_cast<unsigned char>(
current)));
10636 return std::string{cr.data()};
10646 const std::string&
detail,
10647 const std::string& context)
const
10649 std::string error_msg =
"syntax error while parsing ";
10654 error_msg +=
"CBOR";
10658 error_msg +=
"MessagePack";
10662 error_msg +=
"UBJSON";
10666 error_msg +=
"BSON";
10674 return error_msg +
" " + context +
": " +
detail;
10705 #include <functional>
10749 template<
typename BasicJsonType>
10758 template<
typename BasicJsonType,
typename InputAdapterType>
10772 const bool allow_exceptions_ =
true,
10773 const bool skip_comments =
false)
10792 void parse(
const bool strict, BasicJsonType& result)
10817 if (result.is_discarded())
10843 result.assert_invariant();
10858 template<
typename SAX>
10877 template<
typename SAX>
10883 std::vector<bool> states;
10885 bool skip_to_state_evaluation =
false;
10889 if (!skip_to_state_evaluation)
10894 case token_type::begin_object:
10902 if (
get_token() == token_type::end_object)
10932 states.push_back(
false);
10939 case token_type::begin_array:
10947 if (
get_token() == token_type::end_array)
10957 states.push_back(
true);
10963 case token_type::value_float:
10982 case token_type::literal_false:
10991 case token_type::literal_null:
11000 case token_type::literal_true:
11009 case token_type::value_integer:
11018 case token_type::value_string:
11027 case token_type::value_unsigned:
11036 case token_type::parse_error:
11044 case token_type::uninitialized:
11045 case token_type::end_array:
11046 case token_type::end_object:
11047 case token_type::name_separator:
11048 case token_type::value_separator:
11049 case token_type::end_of_input:
11050 case token_type::literal_or_value:
11061 skip_to_state_evaluation =
false;
11065 if (states.empty())
11074 if (
get_token() == token_type::value_separator)
11095 skip_to_state_evaluation =
true;
11107 if (
get_token() == token_type::value_separator)
11149 skip_to_state_evaluation =
true;
11167 std::string error_msg =
"syntax error ";
11169 if (!context.empty())
11171 error_msg +=
"while parsing " + context +
" ";
11186 if (expected != token_type::uninitialized)
11276 return lhs.m_it == rhs.m_it;
11281 return lhs.m_it < rhs.m_it;
11286 auto result = *
this;
11293 return lhs.m_it - rhs.m_it;
11304 auto result = *
this;
11317 auto result = *
this;
11363 #include <iterator>
11364 #include <type_traits>
11386 template<
typename IteratorType>
class iteration_proxy;
11387 template<
typename IteratorType>
class iteration_proxy_value;
11405 template<
typename BasicJsonType>
11420 "iter_impl only accepts (const) basic_json");
11436 using pointer =
typename std::conditional<std::is_const<BasicJsonType>::value,
11437 typename BasicJsonType::const_pointer,
11438 typename BasicJsonType::pointer>::type;
11441 typename std::conditional<std::is_const<BasicJsonType>::value,
11442 typename BasicJsonType::const_reference,
11460 switch (m_object->m_type)
11507 : m_object(other.m_object),
m_it(other.m_it)
11518 if (&other !=
this)
11520 m_object = other.m_object;
11532 : m_object(other.m_object),
m_it(other.m_it)
11543 m_object = other.m_object;
11553 void set_begin() noexcept
11557 switch (m_object->m_type)
11601 switch (m_object->m_type)
11640 switch (m_object->m_type)
11684 switch (m_object->m_type)
11724 auto result = *
this;
11737 switch (m_object->m_type)
11775 auto result = *
this;
11788 switch (m_object->m_type)
11824 template <
typename IterImpl, detail::enable_if_t < (std::is_same<IterImpl, iter_impl>::value || std::is_same<IterImpl, other_iter_impl>::value), std::
nullptr_t > =
nullptr >
11835 switch (m_object->m_type)
11860 template <
typename IterImpl, detail::enable_if_t < (std::is_same<IterImpl, iter_impl>::value || std::is_same<IterImpl, other_iter_impl>::value), std::
nullptr_t > =
nullptr >
11880 switch (m_object->m_type)
11907 return !other.operator < (*this);
11936 switch (m_object->m_type)
11980 auto result = *
this;
12002 auto result = *
this;
12015 switch (m_object->m_type)
12044 switch (m_object->m_type)
12078 const typename object_t::key_type&
key()
const
12114 #include <iterator>
12143 template<
typename Base>
12217 auto it = --this->base();
12224 auto it = --this->base();
12225 return it.operator * ();
12236 #include <algorithm>
12258 template<
typename BasicJsonType>
12278 [](
const std::string & a,
const std::string & b)
12280 return a +
"/" + detail::escape(b);
12286 operator std::string()
const
12296 ptr.reference_tokens.begin(),
12297 ptr.reference_tokens.end());
12313 return *
this /= std::to_string(array_idx);
12408 static typename BasicJsonType::size_type
array_index(
const std::string& s)
12410 using size_type =
typename BasicJsonType::size_type;
12425 unsigned long long res = 0;
12428 res = std::stoull(
s, &processed_chars);
12443 if (res >=
static_cast<unsigned long long>((std::numeric_limits<size_type>::max)()))
12448 return static_cast<size_type
>(res);
12485 if (reference_token ==
"0")
12557 if (
ptr->is_null())
12561 std::all_of(reference_token.begin(), reference_token.end(),
12562 [](
const unsigned char x)
12564 return std::isdigit(x);
12568 *
ptr = (nums || reference_token ==
"-")
12573 switch (
ptr->type())
12578 ptr = &
ptr->operator[](reference_token);
12584 if (reference_token ==
"-")
12587 ptr = &
ptr->operator[](
ptr->m_value.array->size());
12623 switch (
ptr->type())
12628 ptr = &
ptr->at(reference_token);
12638 "array index '-' (" + std::to_string(
ptr->m_value.array->size()) +
12639 ") is out of range", *
ptr));
12680 switch (
ptr->type())
12685 ptr = &
ptr->operator[](reference_token);
12728 switch (
ptr->type())
12733 ptr = &
ptr->at(reference_token);
12743 "array index '-' (" + std::to_string(
ptr->m_value.array->size()) +
12744 ") is out of range", *
ptr));
12776 switch (
ptr->type())
12780 if (!
ptr->contains(reference_token))
12786 ptr = &
ptr->operator[](reference_token);
12797 if (
JSON_HEDLEY_UNLIKELY(reference_token.size() == 1 && !(
"0" <= reference_token && reference_token <=
"9")))
12809 for (
std::size_t i = 1; i < reference_token.size(); i++)
12820 if (idx >=
ptr->size())
12826 ptr = &
ptr->operator[](idx);
12860 static std::vector<std::string>
split(
const std::string& reference_string)
12862 std::vector<std::string>
result;
12865 if (reference_string.empty())
12881 std::size_t slash = reference_string.find_first_of(
'/', 1),
12888 start = (slash == std::string::npos) ? 0 : slash + 1,
12890 slash = reference_string.find_first_of(
'/',
start))
12894 auto reference_token = reference_string.substr(
start, slash -
start);
12897 for (
std::size_t pos = reference_token.find_first_of(
'~');
12898 pos != std::string::npos;
12899 pos = reference_token.find_first_of(
'~', pos + 1))
12905 (reference_token[pos + 1] !=
'0' &&
12906 reference_token[pos + 1] !=
'1')))
12928 static void flatten(
const std::string& reference_string,
12932 switch (value.type())
12936 if (value.m_value.array->empty())
12939 result[reference_string] =
nullptr;
12944 for (
std::size_t i = 0; i < value.m_value.array->size(); ++i)
12946 flatten(reference_string +
"/" + std::to_string(i),
12947 value.m_value.array->operator[](i),
result);
12955 if (value.m_value.object->empty())
12958 result[reference_string] =
nullptr;
12963 for (
const auto& element : *value.m_value.object)
12982 result[reference_string] = value;
13009 for (
const auto& element : *value.m_value.object)
13040 return lhs.reference_tokens == rhs.reference_tokens;
13057 return !(lhs == rhs);
13068 #include <initializer_list>
13078 template<
typename BasicJsonType>
13147 #include <algorithm>
13163 #include <algorithm>
13165 #include <iterator>
13173 #endif // JSON_NO_IO
13185 virtual void write_character(CharType c) = 0;
13186 virtual void write_characters(
const CharType*
s,
std::size_t length) = 0;
13197 template<
typename CharType>
13201 template<
typename CharType,
typename AllocatorType = std::allocator<CharType>>
13215 void write_characters(const CharType* s,
std::
size_t length)
override
13221 std::vector<CharType, AllocatorType>&
v;
13225 template<
typename CharType>
13240 void write_characters(const CharType* s,
std::
size_t length)
override
13242 stream.write(
s,
static_cast<std::streamsize
>(length));
13248 #endif // JSON_NO_IO
13251 template<
typename CharType,
typename StringType = std::basic_
string<CharType>>
13265 void write_characters(const CharType* s,
std::
size_t length)
override
13267 str.append(
s, length);
13274 template<
typename CharType,
typename StringType = std::basic_
string<CharType>>
13278 template<
typename AllocatorType = std::allocator<CharType>>
13285 #endif // JSON_NO_IO
13313 template<
typename BasicJsonType,
typename CharType>
13376 oa->write_character(j.m_value.boolean
13384 if (j.m_value.number_integer >= 0)
13389 if (j.m_value.number_integer <= 0x17)
13391 write_number(
static_cast<std::uint8_t
>(j.m_value.number_integer));
13393 else if (j.m_value.number_integer <= (std::numeric_limits<std::uint8_t>::max)())
13396 write_number(
static_cast<std::uint8_t
>(j.m_value.number_integer));
13398 else if (j.m_value.number_integer <= (std::numeric_limits<std::uint16_t>::max)())
13401 write_number(
static_cast<std::uint16_t
>(j.m_value.number_integer));
13403 else if (j.m_value.number_integer <= (std::numeric_limits<std::uint32_t>::max)())
13406 write_number(
static_cast<std::uint32_t
>(j.m_value.number_integer));
13411 write_number(
static_cast<std::uint64_t
>(j.m_value.number_integer));
13418 const auto positive_number = -1 - j.m_value.number_integer;
13419 if (j.m_value.number_integer >= -24)
13421 write_number(
static_cast<std::uint8_t
>(0x20 + positive_number));
13423 else if (positive_number <= (std::numeric_limits<std::uint8_t>::max)())
13426 write_number(
static_cast<std::uint8_t
>(positive_number));
13428 else if (positive_number <= (std::numeric_limits<std::uint16_t>::max)())
13431 write_number(
static_cast<std::uint16_t
>(positive_number));
13433 else if (positive_number <= (std::numeric_limits<std::uint32_t>::max)())
13436 write_number(
static_cast<std::uint32_t
>(positive_number));
13441 write_number(
static_cast<std::uint64_t
>(positive_number));
13449 if (j.m_value.number_unsigned <= 0x17)
13451 write_number(
static_cast<std::uint8_t
>(j.m_value.number_unsigned));
13453 else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint8_t>::max)())
13456 write_number(
static_cast<std::uint8_t
>(j.m_value.number_unsigned));
13458 else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint16_t>::max)())
13461 write_number(
static_cast<std::uint16_t
>(j.m_value.number_unsigned));
13463 else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint32_t>::max)())
13466 write_number(
static_cast<std::uint32_t
>(j.m_value.number_unsigned));
13471 write_number(
static_cast<std::uint64_t
>(j.m_value.number_unsigned));
13485 else if (std::isinf(j.m_value.number_float))
13502 const auto N = j.m_value.string->size();
13507 else if (N <= (std::numeric_limits<std::uint8_t>::max)())
13512 else if (N <= (std::numeric_limits<std::uint16_t>::max)())
13517 else if (N <= (std::numeric_limits<std::uint32_t>::max)())
13523 else if (N <= (std::numeric_limits<std::uint64_t>::max)())
13531 oa->write_characters(
13532 reinterpret_cast<const CharType*
>(j.m_value.string->c_str()),
13533 j.m_value.string->size());
13540 const auto N = j.m_value.array->size();
13545 else if (N <= (std::numeric_limits<std::uint8_t>::max)())
13550 else if (N <= (std::numeric_limits<std::uint16_t>::max)())
13555 else if (N <= (std::numeric_limits<std::uint32_t>::max)())
13561 else if (N <= (std::numeric_limits<std::uint64_t>::max)())
13569 for (
const auto& el : *j.m_value.array)
13578 if (j.m_value.binary->has_subtype())
13580 if (j.m_value.binary->subtype() <= (std::numeric_limits<std::uint8_t>::max)())
13583 write_number(
static_cast<std::uint8_t
>(j.m_value.binary->subtype()));
13585 else if (j.m_value.binary->subtype() <= (std::numeric_limits<std::uint16_t>::max)())
13588 write_number(
static_cast<std::uint16_t
>(j.m_value.binary->subtype()));
13590 else if (j.m_value.binary->subtype() <= (std::numeric_limits<std::uint32_t>::max)())
13593 write_number(
static_cast<std::uint32_t
>(j.m_value.binary->subtype()));
13595 else if (j.m_value.binary->subtype() <= (std::numeric_limits<std::uint64_t>::max)())
13598 write_number(
static_cast<std::uint64_t
>(j.m_value.binary->subtype()));
13603 const auto N = j.m_value.binary->size();
13608 else if (N <= (std::numeric_limits<std::uint8_t>::max)())
13613 else if (N <= (std::numeric_limits<std::uint16_t>::max)())
13618 else if (N <= (std::numeric_limits<std::uint32_t>::max)())
13624 else if (N <= (std::numeric_limits<std::uint64_t>::max)())
13632 oa->write_characters(
13633 reinterpret_cast<const CharType*
>(j.m_value.binary->data()),
13642 const auto N = j.m_value.object->size();
13647 else if (N <= (std::numeric_limits<std::uint8_t>::max)())
13652 else if (N <= (std::numeric_limits<std::uint16_t>::max)())
13657 else if (N <= (std::numeric_limits<std::uint32_t>::max)())
13663 else if (N <= (std::numeric_limits<std::uint64_t>::max)())
13671 for (
const auto& el : *j.m_value.object)
13700 oa->write_character(j.m_value.boolean
13708 if (j.m_value.number_integer >= 0)
13713 if (j.m_value.number_unsigned < 128)
13716 write_number(
static_cast<std::uint8_t
>(j.m_value.number_integer));
13718 else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint8_t>::max)())
13722 write_number(
static_cast<std::uint8_t
>(j.m_value.number_integer));
13724 else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint16_t>::max)())
13728 write_number(
static_cast<std::uint16_t
>(j.m_value.number_integer));
13730 else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint32_t>::max)())
13734 write_number(
static_cast<std::uint32_t
>(j.m_value.number_integer));
13736 else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint64_t>::max)())
13740 write_number(
static_cast<std::uint64_t
>(j.m_value.number_integer));
13745 if (j.m_value.number_integer >= -32)
13748 write_number(
static_cast<std::int8_t
>(j.m_value.number_integer));
13750 else if (j.m_value.number_integer >= (std::numeric_limits<std::int8_t>::min)() &&
13751 j.m_value.number_integer <= (std::numeric_limits<std::int8_t>::max)())
13755 write_number(
static_cast<std::int8_t
>(j.m_value.number_integer));
13757 else if (j.m_value.number_integer >= (std::numeric_limits<std::int16_t>::min)() &&
13758 j.m_value.number_integer <= (std::numeric_limits<std::int16_t>::max)())
13762 write_number(
static_cast<std::int16_t
>(j.m_value.number_integer));
13764 else if (j.m_value.number_integer >= (std::numeric_limits<std::int32_t>::min)() &&
13765 j.m_value.number_integer <= (std::numeric_limits<std::int32_t>::max)())
13769 write_number(
static_cast<std::int32_t
>(j.m_value.number_integer));
13771 else if (j.m_value.number_integer >= (std::numeric_limits<std::int64_t>::min)() &&
13772 j.m_value.number_integer <= (std::numeric_limits<std::int64_t>::max)())
13776 write_number(
static_cast<std::int64_t
>(j.m_value.number_integer));
13784 if (j.m_value.number_unsigned < 128)
13787 write_number(
static_cast<std::uint8_t
>(j.m_value.number_integer));
13789 else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint8_t>::max)())
13793 write_number(
static_cast<std::uint8_t
>(j.m_value.number_integer));
13795 else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint16_t>::max)())
13799 write_number(
static_cast<std::uint16_t
>(j.m_value.number_integer));
13801 else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint32_t>::max)())
13805 write_number(
static_cast<std::uint32_t
>(j.m_value.number_integer));
13807 else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint64_t>::max)())
13811 write_number(
static_cast<std::uint64_t
>(j.m_value.number_integer));
13825 const auto N = j.m_value.string->size();
13831 else if (N <= (std::numeric_limits<std::uint8_t>::max)())
13837 else if (N <= (std::numeric_limits<std::uint16_t>::max)())
13843 else if (N <= (std::numeric_limits<std::uint32_t>::max)())
13851 oa->write_characters(
13852 reinterpret_cast<const CharType*
>(j.m_value.string->c_str()),
13853 j.m_value.string->size());
13860 const auto N = j.m_value.array->size();
13866 else if (N <= (std::numeric_limits<std::uint16_t>::max)())
13872 else if (N <= (std::numeric_limits<std::uint32_t>::max)())
13880 for (
const auto& el : *j.m_value.array)
13891 const bool use_ext = j.m_value.binary->has_subtype();
13894 const auto N = j.m_value.binary->size();
13895 if (N <= (std::numeric_limits<std::uint8_t>::max)())
13897 std::uint8_t output_type{};
13904 output_type = 0xD4;
13907 output_type = 0xD5;
13910 output_type = 0xD6;
13913 output_type = 0xD7;
13916 output_type = 0xD8;
13919 output_type = 0xC7;
13927 output_type = 0xC4;
13937 else if (N <= (std::numeric_limits<std::uint16_t>::max)())
13939 std::uint8_t output_type = use_ext
13946 else if (N <= (std::numeric_limits<std::uint32_t>::max)())
13948 std::uint8_t output_type = use_ext
13959 write_number(
static_cast<std::int8_t
>(j.m_value.binary->subtype()));
13963 oa->write_characters(
13964 reinterpret_cast<const CharType*
>(j.m_value.binary->data()),
13973 const auto N = j.m_value.object->size();
13977 write_number(
static_cast<std::uint8_t
>(0x80 | (N & 0xF)));
13979 else if (N <= (std::numeric_limits<std::uint16_t>::max)())
13985 else if (N <= (std::numeric_limits<std::uint32_t>::max)())
13993 for (
const auto& el : *j.m_value.object)
14014 const bool use_type,
const bool add_prefix =
true)
14031 oa->write_character(j.m_value.boolean
14063 oa->write_characters(
14064 reinterpret_cast<const CharType*
>(j.m_value.string->c_str()),
14065 j.m_value.string->size());
14076 bool prefix_required =
true;
14077 if (use_type && !j.m_value.array->empty())
14081 const bool same_prefix = std::all_of(j.begin() + 1, j.end(),
14082 [
this, first_prefix](
const BasicJsonType & v)
14084 return ubjson_prefix(v) == first_prefix;
14089 prefix_required =
false;
14091 oa->write_character(first_prefix);
14101 for (
const auto& el : *j.m_value.array)
14103 write_ubjson(el, use_count, use_type, prefix_required);
14121 if (use_type && !j.m_value.binary->empty())
14125 oa->write_character(
'U');
14136 oa->write_characters(
14137 reinterpret_cast<const CharType*
>(j.m_value.binary->data()),
14138 j.m_value.binary->size());
14142 for (
size_t i = 0; i < j.m_value.binary->size(); ++i)
14145 oa->write_character(j.m_value.binary->data()[i]);
14164 bool prefix_required =
true;
14165 if (use_type && !j.m_value.object->empty())
14169 const bool same_prefix = std::all_of(j.begin(), j.end(),
14170 [
this, first_prefix](
const BasicJsonType & v)
14172 return ubjson_prefix(v) == first_prefix;
14177 prefix_required =
false;
14179 oa->write_character(first_prefix);
14189 for (
const auto& el : *j.m_value.object)
14192 oa->write_characters(
14193 reinterpret_cast<const CharType*
>(el.first.c_str()),
14195 write_ubjson(el.second, use_count, use_type, prefix_required);
14223 const auto it = name.find(
static_cast<typename string_t::value_type
>(0));
14227 static_cast<void>(j);
14230 return 1ul + name.size() + 1u;
14237 const std::uint8_t element_type)
14240 oa->write_characters(
14241 reinterpret_cast<const CharType*
>(name.c_str()),
14259 const double value)
14262 write_number<double, true>(
value);
14270 return sizeof(std::int32_t) +
value.size() + 1ul;
14281 write_number<std::int32_t, true>(
static_cast<std::int32_t
>(
value.size() + 1ul));
14282 oa->write_characters(
14283 reinterpret_cast<const CharType*
>(
value.c_str()),
14300 return (std::numeric_limits<std::int32_t>::min)() <=
value &&
value <= (std::numeric_limits<std::int32_t>::max)()
14301 ?
sizeof(std::int32_t)
14302 :
sizeof(std::int64_t);
14309 const std::int64_t value)
14311 if ((std::numeric_limits<std::int32_t>::min)() <=
value &&
value <= (std::numeric_limits<std::int32_t>::max)())
14314 write_number<std::int32_t, true>(
static_cast<std::int32_t
>(
value));
14319 write_number<std::int64_t, true>(
static_cast<std::int64_t
>(
value));
14328 return (
value <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int32_t>::max)()))
14329 ?
sizeof(std::int32_t)
14330 :
sizeof(std::int64_t);
14337 const BasicJsonType& j)
14339 if (j.m_value.number_unsigned <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int32_t>::max)()))
14342 write_number<std::int32_t, true>(
static_cast<std::int32_t
>(j.m_value.number_unsigned));
14344 else if (j.m_value.number_unsigned <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int64_t>::max)()))
14347 write_number<std::int64_t, true>(
static_cast<std::int64_t
>(j.m_value.number_unsigned));
14351 JSON_THROW(
out_of_range::create(407,
"integer number " + std::to_string(j.m_value.number_unsigned) +
" cannot be represented by BSON as it does not fit int64", j));
14359 const typename BasicJsonType::object_t& value)
14372 const std::size_t embedded_document_size = std::accumulate(std::begin(
value), std::end(
value),
static_cast<std::size_t>(0), [&array_index](
std::size_t result,
const typename BasicJsonType::array_t::value_type & el)
14377 return sizeof(std::int32_t) + embedded_document_size + 1ul;
14385 return sizeof(std::int32_t) +
value.size() + 1ul;
14392 const typename BasicJsonType::array_t& value)
14399 for (
const auto& el :
value)
14415 write_number<std::int32_t, true>(
static_cast<std::int32_t
>(
value.size()));
14416 write_number(
value.has_subtype() ?
static_cast<std::uint8_t
>(
value.subtype()) :
static_cast<std::uint8_t
>(0x00));
14418 oa->write_characters(
reinterpret_cast<const CharType*
>(
value.data()),
value.size());
14426 const BasicJsonType& j)
14441 return header_size + 1ul;
14444 return header_size + 8ul;
14456 return header_size + 0ul;
14474 const BasicJsonType& j)
14523 [](
size_t result,
const typename BasicJsonType::object_t::value_type & el)
14525 return result += calc_bson_element_size(el.first, el.second);
14528 return sizeof(std::int32_t) + document_size + 1ul;
14539 for (
const auto& el :
value)
14580 template<
typename NumberType,
typename std::enable_if<
14581 std::is_floating_point<NumberType>::value,
int>::type = 0>
14583 const bool add_prefix)
14593 template<
typename NumberType,
typename std::enable_if<
14594 std::is_unsigned<NumberType>::value,
int>::type = 0>
14596 const bool add_prefix)
14598 if (n <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int8_t>::max)()))
14606 else if (n <= (std::numeric_limits<std::uint8_t>::max)())
14614 else if (n <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int16_t>::max)()))
14622 else if (n <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int32_t>::max)()))
14630 else if (n <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int64_t>::max)()))
14645 const auto number = BasicJsonType(n).dump();
14649 oa->write_character(
to_char_type(
static_cast<std::uint8_t
>(number[i])));
14655 template <
typename NumberType,
typename std::enable_if <
14656 std::is_signed<NumberType>::value&&
14657 !std::is_floating_point<NumberType>::value,
int >::type = 0 >
14659 const bool add_prefix)
14661 if ((std::numeric_limits<std::int8_t>::min)() <= n && n <= (std::numeric_limits<std::int8_t>::max)())
14669 else if (
static_cast<std::int64_t
>((std::numeric_limits<std::uint8_t>::min)()) <= n && n <=
static_cast<std::int64_t
>((std::numeric_limits<std::uint8_t>::max)()))
14677 else if ((std::numeric_limits<std::int16_t>::min)() <= n && n <= (std::numeric_limits<std::int16_t>::max)())
14685 else if ((std::numeric_limits<std::int32_t>::min)() <= n && n <= (std::numeric_limits<std::int32_t>::max)())
14693 else if ((std::numeric_limits<std::int64_t>::min)() <= n && n <= (std::numeric_limits<std::int64_t>::max)())
14709 const auto number = BasicJsonType(n).dump();
14713 oa->write_character(
to_char_type(
static_cast<std::uint8_t
>(number[i])));
14730 return j.m_value.boolean ?
'T' :
'F';
14734 if ((std::numeric_limits<std::int8_t>::min)() <= j.m_value.number_integer && j.m_value.number_integer <= (std::numeric_limits<std::int8_t>::max)())
14738 if ((std::numeric_limits<std::uint8_t>::min)() <= j.m_value.number_integer && j.m_value.number_integer <= (std::numeric_limits<std::uint8_t>::max)())
14742 if ((std::numeric_limits<std::int16_t>::min)() <= j.m_value.number_integer && j.m_value.number_integer <= (std::numeric_limits<std::int16_t>::max)())
14746 if ((std::numeric_limits<std::int32_t>::min)() <= j.m_value.number_integer && j.m_value.number_integer <= (std::numeric_limits<std::int32_t>::max)())
14750 if ((std::numeric_limits<std::int64_t>::min)() <= j.m_value.number_integer && j.m_value.number_integer <= (std::numeric_limits<std::int64_t>::max)())
14760 if (j.m_value.number_unsigned <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int8_t>::max)()))
14764 if (j.m_value.number_unsigned <=
static_cast<std::uint64_t
>((std::numeric_limits<std::uint8_t>::max)()))
14768 if (j.m_value.number_unsigned <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int16_t>::max)()))
14772 if (j.m_value.number_unsigned <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int32_t>::max)()))
14776 if (j.m_value.number_unsigned <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int64_t>::max)()))
14828 template<
typename NumberType,
bool OutputIsLittleEndian = false>
14832 std::array<CharType,
sizeof(NumberType)> vec{};
14833 std::memcpy(vec.data(), &n,
sizeof(NumberType));
14839 std::reverse(vec.begin(), vec.end());
14842 oa->write_characters(vec.data(),
sizeof(NumberType));
14848 #pragma GCC diagnostic push
14849 #pragma GCC diagnostic ignored "-Wfloat-equal"
14851 if (
static_cast<double>(n) >=
static_cast<double>(std::numeric_limits<float>::lowest()) &&
14852 static_cast<double>(n) <=
static_cast<double>((std::numeric_limits<float>::max)()) &&
14853 static_cast<double>(
static_cast<float>(n)) ==
static_cast<double>(n))
14868 #pragma GCC diagnostic pop
14877 template <
typename C = CharType,
14881 return *
reinterpret_cast<char*
>(&
x);
14884 template <
typename C = CharType,
14888 static_assert(
sizeof(std::uint8_t) ==
sizeof(CharType),
"size of CharType must be equal to std::uint8_t");
14889 static_assert(std::is_trivial<CharType>::value,
"CharType must be trivial");
14891 std::memcpy(&result, &
x,
sizeof(
x));
14895 template<
typename C = CharType,
14902 template <
typename InputCharType,
typename C = CharType,
14904 std::is_signed<C>::value &&
14905 std::is_signed<char>::value &&
14928 #include <algorithm>
14939 #include <type_traits>
14950 #include <type_traits>
14979 namespace dtoa_impl
14982 template<
typename Target,
typename Source>
14985 static_assert(
sizeof(Target) ==
sizeof(Source),
"size mismatch");
14988 std::memcpy(&target, &
source,
sizeof(Source));
14999 constexpr
diyfp(std::uint64_t f_,
int e_) noexcept :
f(f_),
e(e_) {}
15010 return {
x.f -
y.f,
x.e};
15019 static_assert(
kPrecision == 64,
"internal error");
15044 const std::uint64_t u_lo =
x.f & 0xFFFFFFFFu;
15045 const std::uint64_t u_hi =
x.f >> 32u;
15046 const std::uint64_t v_lo =
y.f & 0xFFFFFFFFu;
15047 const std::uint64_t v_hi =
y.f >> 32u;
15049 const std::uint64_t p0 = u_lo * v_lo;
15050 const std::uint64_t p1 = u_lo * v_hi;
15051 const std::uint64_t p2 = u_hi * v_lo;
15052 const std::uint64_t p3 = u_hi * v_hi;
15054 const std::uint64_t p0_hi = p0 >> 32u;
15055 const std::uint64_t p1_lo = p1 & 0xFFFFFFFFu;
15056 const std::uint64_t p1_hi = p1 >> 32u;
15057 const std::uint64_t p2_lo = p2 & 0xFFFFFFFFu;
15058 const std::uint64_t p2_hi = p2 >> 32u;
15060 std::uint64_t Q = p0_hi + p1_lo + p2_lo;
15071 Q += std::uint64_t{1} << (64u - 32u - 1u);
15073 const std::uint64_t h = p3 + p2_hi + p1_hi + (Q >> 32u);
15075 return {h,
x.e +
y.e + 64};
15086 while ((
x.f >> 63u) == 0)
15101 const int delta =
x.e - target_exponent;
15106 return {
x.f << delta, target_exponent};
15123 template<
typename FloatType>
15136 static_assert(std::numeric_limits<FloatType>::is_iec559,
15137 "internal error: dtoa_short requires an IEEE-754 floating-point implementation");
15139 constexpr
int kPrecision = std::numeric_limits<FloatType>::digits;
15140 constexpr
int kBias = std::numeric_limits<FloatType>::max_exponent - 1 + (kPrecision - 1);
15141 constexpr
int kMinExp = 1 - kBias;
15142 constexpr std::uint64_t kHiddenBit = std::uint64_t{1} << (kPrecision - 1);
15146 const auto bits =
static_cast<std::uint64_t
>(reinterpret_bits<bits_type>(
value));
15147 const std::uint64_t E = bits >> (kPrecision - 1);
15148 const std::uint64_t F = bits & (kHiddenBit - 1);
15150 const bool is_denormal = E == 0;
15151 const diyfp v = is_denormal
15152 ?
diyfp(F, kMinExp)
15153 :
diyfp(F + kHiddenBit,
static_cast<int>(E) - kBias);
15176 const bool lower_boundary_is_closer = F == 0 && E > 1;
15178 const diyfp m_minus = lower_boundary_is_closer
15179 ?
diyfp(4 * v.
f - 1, v.
e - 2)
15180 :
diyfp(2 * v.
f - 1, v.
e - 1);
15315 constexpr
int kCachedPowersMinDecExp = -300;
15316 constexpr
int kCachedPowersDecStep = 8;
15318 static constexpr std::array<cached_power, 79> kCachedPowers =
15321 { 0xAB70FE17C79AC6CA, -1060, -300 },
15322 { 0xFF77B1FCBEBCDC4F, -1034, -292 },
15323 { 0xBE5691EF416BD60C, -1007, -284 },
15324 { 0x8DD01FAD907FFC3C, -980, -276 },
15325 { 0xD3515C2831559A83, -954, -268 },
15326 { 0x9D71AC8FADA6C9B5, -927, -260 },
15327 { 0xEA9C227723EE8BCB, -901, -252 },
15328 { 0xAECC49914078536D, -874, -244 },
15329 { 0x823C12795DB6CE57, -847, -236 },
15330 { 0xC21094364DFB5637, -821, -228 },
15331 { 0x9096EA6F3848984F, -794, -220 },
15332 { 0xD77485CB25823AC7, -768, -212 },
15333 { 0xA086CFCD97BF97F4, -741, -204 },
15334 { 0xEF340A98172AACE5, -715, -196 },
15335 { 0xB23867FB2A35B28E, -688, -188 },
15336 { 0x84C8D4DFD2C63F3B, -661, -180 },
15337 { 0xC5DD44271AD3CDBA, -635, -172 },
15338 { 0x936B9FCEBB25C996, -608, -164 },
15339 { 0xDBAC6C247D62A584, -582, -156 },
15340 { 0xA3AB66580D5FDAF6, -555, -148 },
15341 { 0xF3E2F893DEC3F126, -529, -140 },
15342 { 0xB5B5ADA8AAFF80B8, -502, -132 },
15343 { 0x87625F056C7C4A8B, -475, -124 },
15344 { 0xC9BCFF6034C13053, -449, -116 },
15345 { 0x964E858C91BA2655, -422, -108 },
15346 { 0xDFF9772470297EBD, -396, -100 },
15347 { 0xA6DFBD9FB8E5B88F, -369, -92 },
15348 { 0xF8A95FCF88747D94, -343, -84 },
15349 { 0xB94470938FA89BCF, -316, -76 },
15350 { 0x8A08F0F8BF0F156B, -289, -68 },
15351 { 0xCDB02555653131B6, -263, -60 },
15352 { 0x993FE2C6D07B7FAC, -236, -52 },
15353 { 0xE45C10C42A2B3B06, -210, -44 },
15354 { 0xAA242499697392D3, -183, -36 },
15355 { 0xFD87B5F28300CA0E, -157, -28 },
15356 { 0xBCE5086492111AEB, -130, -20 },
15357 { 0x8CBCCC096F5088CC, -103, -12 },
15358 { 0xD1B71758E219652C, -77, -4 },
15359 { 0x9C40000000000000, -50, 4 },
15360 { 0xE8D4A51000000000, -24, 12 },
15361 { 0xAD78EBC5AC620000, 3, 20 },
15362 { 0x813F3978F8940984, 30, 28 },
15363 { 0xC097CE7BC90715B3, 56, 36 },
15364 { 0x8F7E32CE7BEA5C70, 83, 44 },
15365 { 0xD5D238A4ABE98068, 109, 52 },
15366 { 0x9F4F2726179A2245, 136, 60 },
15367 { 0xED63A231D4C4FB27, 162, 68 },
15368 { 0xB0DE65388CC8ADA8, 189, 76 },
15369 { 0x83C7088E1AAB65DB, 216, 84 },
15370 { 0xC45D1DF942711D9A, 242, 92 },
15371 { 0x924D692CA61BE758, 269, 100 },
15372 { 0xDA01EE641A708DEA, 295, 108 },
15373 { 0xA26DA3999AEF774A, 322, 116 },
15374 { 0xF209787BB47D6B85, 348, 124 },
15375 { 0xB454E4A179DD1877, 375, 132 },
15376 { 0x865B86925B9BC5C2, 402, 140 },
15377 { 0xC83553C5C8965D3D, 428, 148 },
15378 { 0x952AB45CFA97A0B3, 455, 156 },
15379 { 0xDE469FBD99A05FE3, 481, 164 },
15380 { 0xA59BC234DB398C25, 508, 172 },
15381 { 0xF6C69A72A3989F5C, 534, 180 },
15382 { 0xB7DCBF5354E9BECE, 561, 188 },
15383 { 0x88FCF317F22241E2, 588, 196 },
15384 { 0xCC20CE9BD35C78A5, 614, 204 },
15385 { 0x98165AF37B2153DF, 641, 212 },
15386 { 0xE2A0B5DC971F303A, 667, 220 },
15387 { 0xA8D9D1535CE3B396, 694, 228 },
15388 { 0xFB9B7CD9A4A7443C, 720, 236 },
15389 { 0xBB764C4CA7A44410, 747, 244 },
15390 { 0x8BAB8EEFB6409C1A, 774, 252 },
15391 { 0xD01FEF10A657842C, 800, 260 },
15392 { 0x9B10A4E5E9913129, 827, 268 },
15393 { 0xE7109BFBA19C0C9D, 853, 276 },
15394 { 0xAC2820D9623BF429, 880, 284 },
15395 { 0x80444B5E7AA7CF85, 907, 292 },
15396 { 0xBF21E44003ACDD2D, 933, 300 },
15397 { 0x8E679C2F5E44FF8F, 960, 308 },
15398 { 0xD433179D9C8CB841, 986, 316 },
15399 { 0x9E19DB92B4E31BA9, 1013, 324 },
15409 const int f =
kAlpha - e - 1;
15410 const int k = (
f * 78913) / (1 << 18) +
static_cast<int>(
f > 0);
15412 const int index = (-kCachedPowersMinDecExp + k + (kCachedPowersDecStep - 1)) / kCachedPowersDecStep;
15430 if (n >= 1000000000)
15432 pow10 = 1000000000;
15436 if (n >= 100000000)
15481 inline void grisu2_round(
char* buf,
int len, std::uint64_t dist, std::uint64_t delta,
15482 std::uint64_t rest, std::uint64_t ten_k)
15509 && delta - rest >= ten_k
15510 && (rest + ten_k < dist || dist - rest > rest + ten_k - dist))
15525 static_assert(
kAlpha >= -60,
"internal error");
15526 static_assert(
kGamma <= -32,
"internal error");
15543 std::uint64_t delta =
diyfp::sub(M_plus, M_minus).
f;
15553 const diyfp one(std::uint64_t{1} << -M_plus.
e, M_plus.
e);
15555 auto p1 =
static_cast<std::uint32_t
>(M_plus.
f >> -one.e);
15556 std::uint64_t p2 = M_plus.
f & (one.f - 1);
15564 std::uint32_t
pow10{};
15592 const std::uint32_t
d = p1 /
pow10;
15593 const std::uint32_t r = p1 %
pow10;
15599 buffer[length++] =
static_cast<char>(
'0' +
d);
15618 const std::uint64_t rest = (std::uint64_t{p1} << -one.e) + p2;
15623 decimal_exponent += n;
15634 const std::uint64_t ten_n = std::uint64_t{
pow10} << -one.e;
15635 grisu2_round(buffer, length, dist, delta, rest, ten_n);
15696 JSON_ASSERT(p2 <= (std::numeric_limits<std::uint64_t>::max)() / 10);
15698 const std::uint64_t
d = p2 >> -one.e;
15699 const std::uint64_t r = p2 & (one.f - 1);
15706 buffer[length++] =
static_cast<char>(
'0' +
d);
15731 decimal_exponent -= m;
15739 const std::uint64_t ten_m = one.f;
15763 inline
void grisu2(
char* buf,
int& len,
int& decimal_exponent,
15780 const diyfp c_minus_k(cached.
f, cached.
e);
15808 const diyfp M_minus(w_minus.
f + 1, w_minus.
e);
15809 const diyfp M_plus (w_plus.
f - 1, w_plus.
e );
15811 decimal_exponent = -cached.
k;
15821 template<
typename FloatType>
15823 void grisu2(
char* buf,
int& len,
int& decimal_exponent, FloatType value)
15826 "internal error: not enough precision");
15878 auto k =
static_cast<std::uint32_t
>(e);
15884 *buf++ =
static_cast<char>(
'0' + k);
15888 *buf++ =
static_cast<char>(
'0' + k / 10);
15890 *buf++ =
static_cast<char>(
'0' + k);
15894 *buf++ =
static_cast<char>(
'0' + k / 100);
15896 *buf++ =
static_cast<char>(
'0' + k / 10);
15898 *buf++ =
static_cast<char>(
'0' + k);
15916 int min_exp,
int max_exp)
15922 const int n = len + decimal_exponent;
15928 if (k <= n && n <= max_exp)
15933 std::memset(buf + k,
'0',
static_cast<size_t>(n) -
static_cast<size_t>(k));
15937 return buf + (
static_cast<size_t>(n) + 2);
15940 if (0 < n && n <= max_exp)
15947 std::memmove(buf + (
static_cast<size_t>(n) + 1), buf + n,
static_cast<size_t>(k) -
static_cast<size_t>(n));
15949 return buf + (
static_cast<size_t>(k) + 1U);
15952 if (min_exp < n && n <= 0)
15957 std::memmove(buf + (2 +
static_cast<size_t>(-n)), buf,
static_cast<size_t>(k));
15960 std::memset(buf + 2,
'0',
static_cast<size_t>(-n));
15961 return buf + (2U +
static_cast<size_t>(-n) +
static_cast<size_t>(k));
15976 std::memmove(buf + 2, buf + 1,
static_cast<size_t>(k) - 1);
15978 buf += 1 +
static_cast<size_t>(k);
15997 template<
typename FloatType>
16002 static_cast<void>(last);
16013 #pragma GCC diagnostic push
16014 #pragma GCC diagnostic ignored "-Wfloat-equal"
16025 #pragma GCC diagnostic pop
16028 JSON_ASSERT(last -
first >= std::numeric_limits<FloatType>::max_digits10);
16035 int decimal_exponent = 0;
16038 JSON_ASSERT(len <= std::numeric_limits<FloatType>::max_digits10);
16041 constexpr
int kMinExp = -4;
16046 JSON_ASSERT(last -
first >= 2 + (-kMinExp - 1) + std::numeric_limits<FloatType>::max_digits10);
16047 JSON_ASSERT(last -
first >= std::numeric_limits<FloatType>::max_digits10 + 6);
16084 template<
typename BasicJsonType>
16104 ,
loc(
std::localeconv())
16142 const bool pretty_print,
16144 const unsigned int indent_step,
16145 const unsigned int current_indent = 0)
16147 switch (val.m_type)
16151 if (val.m_value.object->empty())
16153 o->write_characters(
"{}", 2);
16159 o->write_characters(
"{\n", 2);
16162 const auto new_indent = current_indent + indent_step;
16169 auto i = val.m_value.object->cbegin();
16170 for (
std::size_t cnt = 0; cnt < val.m_value.object->size() - 1; ++cnt, ++i)
16173 o->write_character(
'\"');
16175 o->write_characters(
"\": ", 3);
16177 o->write_characters(
",\n", 2);
16182 JSON_ASSERT(std::next(i) == val.m_value.object->cend());
16184 o->write_character(
'\"');
16186 o->write_characters(
"\": ", 3);
16189 o->write_character(
'\n');
16190 o->write_characters(
indent_string.c_str(), current_indent);
16191 o->write_character(
'}');
16195 o->write_character(
'{');
16198 auto i = val.m_value.object->cbegin();
16199 for (
std::size_t cnt = 0; cnt < val.m_value.object->size() - 1; ++cnt, ++i)
16201 o->write_character(
'\"');
16203 o->write_characters(
"\":", 2);
16205 o->write_character(
',');
16210 JSON_ASSERT(std::next(i) == val.m_value.object->cend());
16211 o->write_character(
'\"');
16213 o->write_characters(
"\":", 2);
16216 o->write_character(
'}');
16224 if (val.m_value.array->empty())
16226 o->write_characters(
"[]", 2);
16232 o->write_characters(
"[\n", 2);
16235 const auto new_indent = current_indent + indent_step;
16242 for (
auto i = val.m_value.array->cbegin();
16243 i != val.m_value.array->cend() - 1; ++i)
16247 o->write_characters(
",\n", 2);
16253 dump(val.m_value.array->back(),
true,
ensure_ascii, indent_step, new_indent);
16255 o->write_character(
'\n');
16256 o->write_characters(
indent_string.c_str(), current_indent);
16257 o->write_character(
']');
16261 o->write_character(
'[');
16264 for (
auto i = val.m_value.array->cbegin();
16265 i != val.m_value.array->cend() - 1; ++i)
16268 o->write_character(
',');
16273 dump(val.m_value.array->back(),
false,
ensure_ascii, indent_step, current_indent);
16275 o->write_character(
']');
16283 o->write_character(
'\"');
16285 o->write_character(
'\"');
16293 o->write_characters(
"{\n", 2);
16296 const auto new_indent = current_indent + indent_step;
16304 o->write_characters(
"\"bytes\": [", 10);
16306 if (!val.m_value.binary->empty())
16308 for (
auto i = val.m_value.binary->cbegin();
16309 i != val.m_value.binary->cend() - 1; ++i)
16312 o->write_characters(
", ", 2);
16314 dump_integer(val.m_value.binary->back());
16317 o->write_characters(
"],\n", 3);
16320 o->write_characters(
"\"subtype\": ", 11);
16321 if (val.m_value.binary->has_subtype())
16323 dump_integer(val.m_value.binary->subtype());
16327 o->write_characters(
"null", 4);
16329 o->write_character(
'\n');
16330 o->write_characters(
indent_string.c_str(), current_indent);
16331 o->write_character(
'}');
16335 o->write_characters(
"{\"bytes\":[", 10);
16337 if (!val.m_value.binary->empty())
16339 for (
auto i = val.m_value.binary->cbegin();
16340 i != val.m_value.binary->cend() - 1; ++i)
16343 o->write_character(
',');
16345 dump_integer(val.m_value.binary->back());
16348 o->write_characters(
"],\"subtype\":", 12);
16349 if (val.m_value.binary->has_subtype())
16351 dump_integer(val.m_value.binary->subtype());
16352 o->write_character(
'}');
16356 o->write_characters(
"null}", 5);
16364 if (val.m_value.boolean)
16366 o->write_characters(
"true", 4);
16370 o->write_characters(
"false", 5);
16377 dump_integer(val.m_value.number_integer);
16383 dump_integer(val.m_value.number_unsigned);
16389 dump_float(val.m_value.number_float);
16395 o->write_characters(
"<discarded>", 11);
16401 o->write_characters(
"null", 4);
16437 const auto byte =
static_cast<std::uint8_t
>(
s[i]);
16504 static_cast<std::uint16_t
>(
codepoint)));
16510 static_cast<void>((std::snprintf)(
string_buffer.data() +
bytes, 13,
"\\u%04x\\u%04x",
16511 static_cast<std::uint16_t
>(0xD7C0u + (
codepoint >> 10u)),
16512 static_cast<std::uint16_t
>(0xDC00u + (
codepoint & 0x3FFu))));
16547 std::stringstream ss;
16548 ss << std::uppercase << std::setfill(
'0') << std::setw(2) << std::hex << (
byte | 0);
16641 std::stringstream ss;
16642 ss << std::uppercase << std::setfill('0') << std::setw(2) << std::hex << (static_cast<std::uint8_t>(
s.back()) | 0);
16660 o->write_characters(
"\\ufffd", 6);
16664 o->write_characters(
"\xEF\xBF\xBD", 3);
16686 unsigned int n_digits = 1;
16695 return n_digits + 1;
16699 return n_digits + 2;
16703 return n_digits + 3;
16711 template <typename NumberType, enable_if_t<std::is_signed<NumberType>::value,
int> = 0>
16712 bool is_negative_number(NumberType
x)
16717 template < typename NumberType, enable_if_t <std::is_unsigned<NumberType>::value,
int > = 0 >
16718 bool is_negative_number(NumberType )
16733 std::is_integral<NumberType>::value ||
16734 std::is_same<NumberType, number_unsigned_t>::value ||
16735 std::is_same<NumberType, number_integer_t>::value ||
16736 std::is_same<NumberType, binary_char_t>::value,
16738 void dump_integer(NumberType
x)
16740 static constexpr std::array<std::array<char, 2>, 100> digits_to_99
16743 {{
'0',
'0'}}, {{
'0',
'1'}}, {{
'0',
'2'}}, {{
'0',
'3'}}, {{
'0',
'4'}}, {{
'0',
'5'}}, {{
'0',
'6'}}, {{
'0',
'7'}}, {{
'0',
'8'}}, {{
'0',
'9'}},
16744 {{
'1',
'0'}}, {{
'1',
'1'}}, {{
'1',
'2'}}, {{
'1',
'3'}}, {{
'1',
'4'}}, {{
'1',
'5'}}, {{
'1',
'6'}}, {{
'1',
'7'}}, {{
'1',
'8'}}, {{
'1',
'9'}},
16745 {{
'2',
'0'}}, {{
'2',
'1'}}, {{
'2',
'2'}}, {{
'2',
'3'}}, {{
'2',
'4'}}, {{
'2',
'5'}}, {{
'2',
'6'}}, {{
'2',
'7'}}, {{
'2',
'8'}}, {{
'2',
'9'}},
16746 {{
'3',
'0'}}, {{
'3',
'1'}}, {{
'3',
'2'}}, {{
'3',
'3'}}, {{
'3',
'4'}}, {{
'3',
'5'}}, {{
'3',
'6'}}, {{
'3',
'7'}}, {{
'3',
'8'}}, {{
'3',
'9'}},
16747 {{
'4',
'0'}}, {{
'4',
'1'}}, {{
'4',
'2'}}, {{
'4',
'3'}}, {{
'4',
'4'}}, {{
'4',
'5'}}, {{
'4',
'6'}}, {{
'4',
'7'}}, {{
'4',
'8'}}, {{
'4',
'9'}},
16748 {{
'5',
'0'}}, {{
'5',
'1'}}, {{
'5',
'2'}}, {{
'5',
'3'}}, {{
'5',
'4'}}, {{
'5',
'5'}}, {{
'5',
'6'}}, {{
'5',
'7'}}, {{
'5',
'8'}}, {{
'5',
'9'}},
16749 {{
'6',
'0'}}, {{
'6',
'1'}}, {{
'6',
'2'}}, {{
'6',
'3'}}, {{
'6',
'4'}}, {{
'6',
'5'}}, {{
'6',
'6'}}, {{
'6',
'7'}}, {{
'6',
'8'}}, {{
'6',
'9'}},
16750 {{
'7',
'0'}}, {{
'7',
'1'}}, {{
'7',
'2'}}, {{
'7',
'3'}}, {{
'7',
'4'}}, {{
'7',
'5'}}, {{
'7',
'6'}}, {{
'7',
'7'}}, {{
'7',
'8'}}, {{
'7',
'9'}},
16751 {{
'8',
'0'}}, {{
'8',
'1'}}, {{
'8',
'2'}}, {{
'8',
'3'}}, {{
'8',
'4'}}, {{
'8',
'5'}}, {{
'8',
'6'}}, {{
'8',
'7'}}, {{
'8',
'8'}}, {{
'8',
'9'}},
16752 {{
'9',
'0'}}, {{
'9',
'1'}}, {{
'9',
'2'}}, {{
'9',
'3'}}, {{
'9',
'4'}}, {{
'9',
'5'}}, {{
'9',
'6'}}, {{
'9',
'7'}}, {{
'9',
'8'}}, {{
'9',
'9'}},
16759 o->write_character(
'0');
16768 unsigned int n_chars{};
16770 if (is_negative_number(
x))
16789 buffer_ptr += n_chars;
16793 while (abs_value >= 100)
16795 const auto digits_index =
static_cast<unsigned>((abs_value % 100));
16797 *(--buffer_ptr) = digits_to_99[digits_index][1];
16798 *(--buffer_ptr) = digits_to_99[digits_index][0];
16801 if (abs_value >= 10)
16803 const auto digits_index =
static_cast<unsigned>(abs_value);
16804 *(--buffer_ptr) = digits_to_99[digits_index][1];
16805 *(--buffer_ptr) = digits_to_99[digits_index][0];
16809 *(--buffer_ptr) =
static_cast<char>(
'0' + abs_value);
16828 o->write_characters(
"null", 4);
16837 static constexpr
bool is_ieee_single_or_double
16838 = (std::numeric_limits<number_float_t>::is_iec559 && std::numeric_limits<number_float_t>::digits == 24 && std::numeric_limits<number_float_t>::max_exponent == 128) ||
16839 (std::numeric_limits<number_float_t>::is_iec559 && std::numeric_limits<number_float_t>::digits == 53 && std::numeric_limits<number_float_t>::max_exponent == 1024);
16841 dump_float(
x, std::integral_constant<bool, is_ieee_single_or_double>());
16849 o->write_characters(begin,
static_cast<size_t>(end - begin));
16855 static constexpr
auto d = std::numeric_limits<number_float_t>::max_digits10;
16890 const bool value_is_int_like =
16894 return c ==
'.' || c ==
'e';
16897 if (value_is_int_like)
16899 o->write_characters(
".0", 2);
16924 static std::uint8_t decode(std::uint8_t&
state, std::uint32_t& codep,
const std::uint8_t
byte) noexcept
16926 static const std::array<std::uint8_t, 400> utf8d =
16929 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
16930 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
16931 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
16932 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
16933 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,
16934 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
16935 8, 8, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
16936 0xA, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x4, 0x3, 0x3,
16937 0xB, 0x6, 0x6, 0x6, 0x5, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8,
16938 0x0, 0x1, 0x2, 0x3, 0x5, 0x8, 0x7, 0x1, 0x1, 0x1, 0x4, 0x6, 0x1, 0x1, 0x1, 0x1,
16939 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1,
16940 1, 2, 1, 1, 1, 1, 1, 2, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1,
16941 1, 2, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 1, 3, 1, 1, 1, 1, 1, 1,
16942 1, 3, 1, 1, 1, 1, 1, 3, 1, 3, 1, 1, 1, 1, 1, 1, 1, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
16947 const std::uint8_t
type = utf8d[byte];
16950 ? (
byte & 0x3fu) | (codep << 6u)
16951 : (0xFFu >> type) & (byte);
16981 JSON_ASSERT(
x < 0 &&
x < (std::numeric_limits<number_integer_t>::max)());
16987 output_adapter_t<char> o =
nullptr;
17020 #include <functional>
17021 #include <initializer_list>
17022 #include <iterator>
17024 #include <stdexcept>
17025 #include <type_traits>
17037 template <
class Key,
class T,
class IgnoredLess = std::less<Key>,
17038 class Allocator = std::allocator<std::pair<const Key, T>>>
17039 struct ordered_map : std::vector<std::pair<const Key, T>, Allocator>
17043 using Container = std::vector<std::pair<const Key, T>, Allocator>;
17052 template <
class It>
17055 ordered_map(std::initializer_list<T> init,
const Allocator& alloc = Allocator() )
17060 for (
auto it = this->begin(); it != this->end(); ++it)
17062 if (it->first == key)
17064 return {it,
false};
17067 Container::emplace_back(key, t);
17068 return {--this->end(),
true};
17083 for (
auto it = this->begin(); it != this->end(); ++it)
17085 if (it->first == key)
17091 JSON_THROW(std::out_of_range(
"key not found"));
17094 const T&
at(
const Key& key)
const
17096 for (
auto it = this->begin(); it != this->end(); ++it)
17098 if (it->first == key)
17104 JSON_THROW(std::out_of_range(
"key not found"));
17109 for (
auto it = this->begin(); it != this->end(); ++it)
17111 if (it->first == key)
17114 for (
auto next = it; ++
next != this->end(); ++it)
17119 Container::pop_back();
17128 return erase(pos, std::next(pos));
17133 const auto elements_affected = std::distance(
first, last);
17134 const auto offset = std::distance(Container::begin(),
first);
17156 for (
auto it =
first; std::next(it, elements_affected) != Container::end(); ++it)
17167 Container::resize(this->
size() -
static_cast<size_type>(elements_affected));
17176 return Container::begin() + offset;
17181 for (
auto it = this->begin(); it != this->end(); ++it)
17183 if (it->first == key)
17193 for (
auto it = this->begin(); it != this->end(); ++it)
17195 if (it->first == key)
17200 return Container::end();
17205 for (
auto it = this->begin(); it != this->end(); ++it)
17207 if (it->first == key)
17212 return Container::end();
17222 for (
auto it = this->begin(); it != this->end(); ++it)
17224 if (it->first == value.first)
17226 return {it,
false};
17229 Container::push_back(value);
17230 return {--this->end(),
true};
17233 template<
typename InputIt>
17234 using require_input_iter =
typename std::enable_if<std::is_convertible<typename std::iterator_traits<InputIt>::iterator_category,
17235 std::input_iterator_tag>::value>::type;
17237 template<
typename InputIt,
typename = require_input_iter<InputIt>>
17240 for (
auto it =
first; it != last; ++it)
17250 #if defined(JSON_HAS_CPP_17)
17251 #include <string_view>
17285 friend ::nlohmann::json_pointer<basic_json>;
17287 template<
typename BasicJsonType,
typename InputType>
17289 friend ::nlohmann::detail::serializer<basic_json>;
17290 template<
typename BasicJsonType>
17291 friend class ::nlohmann::detail::iter_impl;
17292 template<
typename BasicJsonType,
typename CharType>
17293 friend class ::nlohmann::detail::binary_writer;
17294 template<
typename BasicJsonType,
typename InputType,
typename SAX>
17295 friend class ::nlohmann::detail::binary_reader;
17296 template<
typename BasicJsonType>
17297 friend class ::nlohmann::detail::json_sax_dom_parser;
17298 template<
typename BasicJsonType>
17299 friend class ::nlohmann::detail::json_sax_dom_callback_parser;
17300 friend class ::nlohmann::detail::exception;
17309 template<
typename InputAdapterType>
17310 static ::nlohmann::detail::parser<basic_json, InputAdapterType>
parser(
17311 InputAdapterType adapter,
17313 const bool allow_exceptions =
true,
17314 const bool ignore_comments =
false
17317 return ::nlohmann::detail::parser<basic_json, InputAdapterType>(
std::move(adapter),
17318 std::move(cb), allow_exceptions, ignore_comments);
17323 template<
typename BasicJsonType>
17325 template<
typename BasicJsonType>
17327 template<
typename Iterator>
17331 template<
typename CharType>
17334 template<
typename InputType>
17345 template<
typename T,
typename SFINAE>
17402 using pointer =
typename std::allocator_traits<allocator_type>::pointer;
17404 using const_pointer =
typename std::allocator_traits<allocator_type>::const_pointer;
17432 result[
"copyright"] =
"(C) 2013-2022 Niels Lohmann";
17433 result[
"name"] =
"JSON for Modern C++";
17434 result[
"url"] =
"https://github.com/nlohmann/json";
17435 result[
"version"][
"string"] =
17444 result[
"platform"] =
"win32";
17445 #elif defined __linux__
17446 result[
"platform"] =
"linux";
17447 #elif defined __APPLE__
17448 result[
"platform"] =
"apple";
17449 #elif defined __unix__
17450 result[
"platform"] =
"unix";
17452 result[
"platform"] =
"unknown";
17455 #if defined(__ICC) || defined(__INTEL_COMPILER)
17456 result[
"compiler"] = {{
"family",
"icc"}, {
"version", __INTEL_COMPILER}};
17457 #elif defined(__clang__)
17458 result[
"compiler"] = {{
"family",
"clang"}, {
"version", __clang_version__}};
17459 #elif defined(__GNUC__) || defined(__GNUG__)
17460 result[
"compiler"] = {{
"family",
"gcc"}, {
"version", std::to_string(__GNUC__) +
"." + std::to_string(__GNUC_MINOR__) +
"." + std::to_string(__GNUC_PATCHLEVEL__)}};
17461 #elif defined(__HP_cc) || defined(__HP_aCC)
17462 result[
"compiler"] =
"hp"
17463 #elif defined(__IBMCPP__)
17464 result[
"compiler"] = {{
"family",
"ilecpp"}, {
"version", __IBMCPP__}};
17465 #elif defined(_MSC_VER)
17466 result[
"compiler"] = {{
"family",
"msvc"}, {
"version", _MSC_VER}};
17467 #elif defined(__PGI)
17468 result[
"compiler"] = {{
"family",
"pgcpp"}, {
"version", __PGI}};
17469 #elif defined(__SUNPRO_CC)
17470 result[
"compiler"] = {{
"family",
"sunpro"}, {
"version", __SUNPRO_CC}};
17472 result[
"compiler"] = {{
"family",
"unknown"}, {
"version",
"unknown"}};
17476 result[
"compiler"][
"c++"] = std::to_string(__cplusplus);
17478 result[
"compiler"][
"c++"] =
"unknown";
17495 #if defined(JSON_HAS_CPP_14)
17505 using object_t = ObjectType<StringType,
17508 AllocatorType<std::pair<
const StringType,
17513 using array_t = ArrayType<basic_json, AllocatorType<basic_json>>;
17544 template<
typename T,
typename... Args>
17548 AllocatorType<T> alloc;
17549 using AllocatorTraits = std::allocator_traits<AllocatorType<T>>;
17551 auto deleter = [&](T * obj)
17553 AllocatorTraits::deallocate(alloc, obj, 1);
17555 std::unique_ptr<T, decltype(deleter)> obj(AllocatorTraits::allocate(alloc, 1), deleter);
17558 return obj.release();
17627 object = create<object_t>();
17633 array = create<array_t>();
17639 string = create<string_t>(
"");
17645 binary = create<binary_t>();
17651 boolean =
static_cast<boolean_t>(
false);
17727 std::vector<basic_json> stack;
17732 stack.reserve(
array->size());
17738 for (
auto&& it : *
object)
17744 while (!stack.empty())
17752 if (current_item.is_array())
17754 std::move(current_item.m_value.array->begin(), current_item.m_value.array->end(), std::back_inserter(stack));
17756 current_item.m_value.array->clear();
17758 else if (current_item.is_object())
17760 for (
auto&& it : *current_item.m_value.object)
17765 current_item.m_value.object->clear();
17777 AllocatorType<object_t> alloc;
17778 std::allocator_traits<decltype(alloc)>
::destroy(alloc,
object);
17779 std::allocator_traits<decltype(alloc)>::deallocate(alloc,
object, 1);
17785 AllocatorType<array_t> alloc;
17787 std::allocator_traits<decltype(alloc)>::deallocate(alloc,
array, 1);
17793 AllocatorType<string_t> alloc;
17794 std::allocator_traits<decltype(alloc)>
::destroy(alloc,
string);
17795 std::allocator_traits<decltype(alloc)>::deallocate(alloc,
string, 1);
17801 AllocatorType<binary_t> alloc;
17803 std::allocator_traits<decltype(alloc)>::deallocate(alloc,
binary, 1);
17847 #if JSON_DIAGNOSTICS
17853 return j.m_parent ==
this;
17858 static_cast<void>(check_parents);
17863 #if JSON_DIAGNOSTICS
17868 for (
auto& element : *
m_value.array)
17870 element.m_parent =
this;
17877 for (
auto& element : *
m_value.object)
17879 element.second.m_parent =
this;
17900 #if JSON_DIAGNOSTICS
17903 (it + i)->m_parent =
this;
17906 static_cast<void>(count_set_parents);
17913 #if JSON_DIAGNOSTICS
17914 if (old_capacity !=
static_cast<std::size_t>(-1))
17928 #ifdef JSON_HEDLEY_MSVC_VERSION
17929 #pragma warning(push )
17930 #pragma warning(disable : 4127) // ignore warning to replace if with if constexpr
17937 #ifdef JSON_HEDLEY_MSVC_VERSION
17938 #pragma warning( pop )
17943 static_cast<void>(j);
17944 static_cast<void>(old_capacity);
17989 template <
typename CompatibleType,
17995 std::forward<CompatibleType>(val))))
18004 template <
typename BasicJsonType,
18009 using other_boolean_t =
typename BasicJsonType::boolean_t;
18010 using other_number_float_t =
typename BasicJsonType::number_float_t;
18011 using other_number_integer_t =
typename BasicJsonType::number_integer_t;
18012 using other_number_unsigned_t =
typename BasicJsonType::number_unsigned_t;
18013 using other_string_t =
typename BasicJsonType::string_t;
18014 using other_object_t =
typename BasicJsonType::object_t;
18015 using other_array_t =
typename BasicJsonType::array_t;
18016 using other_binary_t =
typename BasicJsonType::binary_t;
18018 switch (val.type())
18060 bool type_deduction =
true,
18065 bool is_an_object = std::all_of(
init.begin(),
init.end(),
18068 return element_ref->is_array() && element_ref->size() == 2 && (*element_ref)[0].is_string();
18072 if (!type_deduction)
18077 is_an_object =
false;
18093 for (
auto& element_ref :
init)
18097 std::move(*((*element.m_value.array)[0].m_value.string)),
18098 std::move((*element.m_value.array)[1]));
18119 res.m_value =
init;
18177 m_value.array = create<array_t>(cnt, val);
18184 template <
class InputIT,
typename std::enable_if <
18185 std::is_same<InputIT, typename basic_json_t::iterator>::value ||
18186 std::is_same<InputIT, typename basic_json_t::const_iterator>::value,
int >
::type = 0 >
18199 m_type =
first.m_object->m_type;
18211 || !last.m_it.primitive_iterator.is_end()))
18231 m_value.number_integer =
first.m_object->m_value.number_integer;
18237 m_value.number_unsigned =
first.m_object->m_value.number_unsigned;
18243 m_value.number_float =
first.m_object->m_value.number_float;
18261 m_value.object = create<object_t>(
first.m_it.object_iterator,
18262 last.m_it.object_iterator);
18268 m_value.array = create<array_t>(
first.m_it.array_iterator,
18269 last.m_it.array_iterator);
18294 template<
typename JsonRef,
18296 std::is_same<typename JsonRef::value_type, basic_json>>
::value,
int> = 0 >
18302 : m_type(other.m_type)
18305 other.assert_invariant();
18311 m_value = *other.m_value.object;
18317 m_value = *other.m_value.array;
18323 m_value = *other.m_value.string;
18329 m_value = other.m_value.boolean;
18335 m_value = other.m_value.number_integer;
18341 m_value = other.m_value.number_unsigned;
18347 m_value = other.m_value.number_float;
18353 m_value = *other.m_value.binary;
18374 other.assert_invariant(
false);
18378 other.m_value = {};
18387 std::is_nothrow_move_constructible<value_t>::value&&
18388 std::is_nothrow_move_assignable<value_t>::value&&
18389 std::is_nothrow_move_constructible<json_value>::value&&
18390 std::is_nothrow_move_assignable<json_value>::value
18397 swap(m_type, other.m_type);
18427 const char indent_char =
' ',
18428 const bool ensure_ascii =
false,
18436 s.dump(*
this,
true, ensure_ascii,
static_cast<unsigned int>(indent));
18440 s.dump(*
this,
false, ensure_ascii, 0);
18676 template<
typename ReferenceType,
typename ThisType>
18697 template<
typename PointerType,
typename std::enable_if<
18698 std::is_pointer<PointerType>::value,
int>
::type = 0>
18702 return get_impl_ptr(
static_cast<PointerType
>(
nullptr));
18707 template <
typename PointerType,
typename std::enable_if <
18708 std::is_pointer<PointerType>::value&&
18713 return get_impl_ptr(
static_cast<PointerType
>(
nullptr));
18755 template <
typename ValueType,
18763 auto ret = ValueType();
18798 template <
typename ValueType,
18823 template <
typename BasicJsonType,
18846 template<
typename BasicJsonType,
18848 std::is_same<BasicJsonType, basic_json_t>::value,
18859 template<
typename PointerType,
18861 std::is_pointer<PointerType>::value,
18864 -> decltype(std::declval<const basic_json_t&>().
template get_ptr<PointerType>())
18867 return get_ptr<PointerType>();
18894 template <
typename ValueTypeCV,
typename ValueType = detail::uncvref_t<ValueTypeCV>>
18895 #if defined(JSON_HAS_CPP_14)
18905 static_assert(!std::is_reference<ValueTypeCV>::value,
18906 "get() cannot be used with reference types, you might want to use get_ref()");
18907 return get_impl<ValueType>(detail::priority_tag<4> {});
18937 template<
typename PointerType,
typename std::enable_if<
18938 std::is_pointer<PointerType>::value,
int>
::type = 0>
18942 return get_ptr<PointerType>();
18947 template <
typename ValueType,
18952 ValueType &
get_to(ValueType& v)
const noexcept(noexcept(
18961 template<
typename ValueType,
18973 typename Array = T (&)[N],
18978 std::declval<const basic_json_t&>(), v)))
18986 template<
typename ReferenceType,
typename std::enable_if<
18987 std::is_reference<ReferenceType>::value,
int>
::type = 0>
18991 return get_ref_impl<ReferenceType>(*
this);
18996 template <
typename ReferenceType,
typename std::enable_if <
18997 std::is_reference<ReferenceType>::value&&
19002 return get_ref_impl<ReferenceType>(*
this);
19034 template <
typename ValueType,
typename std::enable_if <
19042 #if defined(JSON_HAS_CPP_17) && (defined(__GNUC__) || (defined(_MSC_VER) && _MSC_VER >= 1910 && _MSC_VER <= 1914))
19050 return get<ValueType>();
19062 return *get_ptr<binary_t*>();
19074 return *get_ptr<const binary_t*>();
19120 return m_value.array->at(idx);
19166 return m_value.object->at(key);
19188 m_value.array = create<array_t>();
19196 if (idx >=
m_value.array->size())
19198 #if JSON_DIAGNOSTICS
19200 const auto old_size =
m_value.array->size();
19201 const auto old_capacity =
m_value.array->capacity();
19203 m_value.array->resize(idx + 1);
19205 #if JSON_DIAGNOSTICS
19220 return m_value.array->operator[](idx);
19233 return m_value.array->operator[](idx);
19247 m_value.object = create<object_t>();
19268 return m_value.object->find(key)->second;
19276 template<
typename T>
19299 template<
typename T>
19307 return m_value.object->find(key)->second;
19316 template <
class ValueType,
typename std::enable_if <
19318 && !std::is_same<value_t, ValueType>::value,
int >
::type = 0 >
19319 ValueType
value(
const typename object_t::key_type& key,
const ValueType& default_value)
const
19325 const auto it =
find(key);
19328 return it->template get<ValueType>();
19340 string_t value(
const typename object_t::key_type& key,
const char* default_value)
const
19347 template<
class ValueType,
typename std::enable_if<
19357 return ptr.get_checked(
this).template get<ValueType>();
19411 template <
class IteratorType,
typename std::enable_if <
19412 std::is_same<IteratorType, typename basic_json_t::iterator>::value ||
19413 std::is_same<IteratorType, typename basic_json_t::const_iterator>::value,
int >
::type
19423 IteratorType result =
end();
19441 AllocatorType<string_t> alloc;
19443 std::allocator_traits<decltype(alloc)>::deallocate(alloc,
m_value.string, 1);
19448 AllocatorType<binary_t> alloc;
19450 std::allocator_traits<decltype(alloc)>::deallocate(alloc,
m_value.binary, 1);
19461 result.m_it.object_iterator =
m_value.object->erase(pos.m_it.object_iterator);
19467 result.m_it.array_iterator =
m_value.array->erase(pos.m_it.array_iterator);
19482 template <
class IteratorType,
typename std::enable_if <
19483 std::is_same<IteratorType, typename basic_json_t::iterator>::value ||
19484 std::is_same<IteratorType, typename basic_json_t::const_iterator>::value,
int >
::type
19494 IteratorType result =
end();
19506 || !last.m_it.primitive_iterator.is_end()))
19513 AllocatorType<string_t> alloc;
19515 std::allocator_traits<decltype(alloc)>::deallocate(alloc,
m_value.string, 1);
19520 AllocatorType<binary_t> alloc;
19522 std::allocator_traits<decltype(alloc)>::deallocate(alloc,
m_value.binary, 1);
19533 result.m_it.object_iterator =
m_value.object->erase(
first.m_it.object_iterator,
19534 last.m_it.object_iterator);
19540 result.m_it.array_iterator =
m_value.array->erase(
first.m_it.array_iterator,
19541 last.m_it.array_iterator);
19561 return m_value.object->erase(key);
19599 template<
typename KeyT>
19602 auto result =
end();
19606 result.m_it.object_iterator =
m_value.object->find(std::forward<KeyT>(key));
19614 template<
typename KeyT>
19617 auto result =
cend();
19621 result.m_it.object_iterator =
m_value.object->find(std::forward<KeyT>(key));
19629 template<
typename KeyT>
19638 template <
typename KeyT,
typename std::enable_if <
19649 return ptr.contains(
this);
19667 result.set_begin();
19683 result.set_begin();
19763 return ref.items();
19774 return ref.items();
19816 return m_value.array->empty();
19822 return m_value.object->empty();
19855 return m_value.array->size();
19861 return m_value.object->size();
19888 return m_value.array->max_size();
19894 return m_value.object->max_size();
20003 const auto old_capacity =
m_value.array->capacity();
20036 const auto old_capacity =
m_value.array->capacity();
20037 m_value.array->push_back(val);
20068 auto res =
m_value.object->insert(val);
20087 push_back(
typename object_t::value_type(
20106 template<
class... Args>
20124 const auto old_capacity =
m_value.array->capacity();
20125 m_value.array->emplace_back(std::forward<Args>(
args)...);
20131 template<
class... Args>
20149 auto res =
m_value.object->emplace(std::forward<Args>(
args)...);
20154 it.m_it.object_iterator = res.first;
20157 return {it, res.second};
20163 template<
typename... Args>
20205 return insert(pos, val);
20319 m_value.object = create<object_t>();
20340 for (
auto it =
first; it != last; ++it)
20342 if (merge_objects && it.value().is_object())
20344 auto it2 =
m_value.object->find(it.key());
20345 if (it2 !=
m_value.object->end())
20347 it2->second.update(it.value(),
true);
20351 m_value.object->operator[](it.key()) = it.value();
20352 #if JSON_DIAGNOSTICS
20353 m_value.object->operator[](it.key()).m_parent =
this;
20361 std::is_nothrow_move_constructible<value_t>::value&&
20362 std::is_nothrow_move_assignable<value_t>::value&&
20363 std::is_nothrow_move_constructible<json_value>::value&&
20364 std::is_nothrow_move_assignable<json_value>::value
20371 other.set_parents();
20378 std::is_nothrow_move_constructible<value_t>::value&&
20379 std::is_nothrow_move_assignable<value_t>::value&&
20380 std::is_nothrow_move_constructible<json_value>::value&&
20381 std::is_nothrow_move_assignable<json_value>::value
20477 #pragma GCC diagnostic push
20478 #pragma GCC diagnostic ignored "-Wfloat-equal"
20480 const auto lhs_type = lhs.type();
20481 const auto rhs_type = rhs.type();
20483 if (lhs_type == rhs_type)
20488 return *lhs.m_value.array == *rhs.m_value.array;
20491 return *lhs.m_value.object == *rhs.m_value.object;
20497 return *lhs.m_value.string == *rhs.m_value.string;
20500 return lhs.m_value.boolean == rhs.m_value.boolean;
20503 return lhs.m_value.number_integer == rhs.m_value.number_integer;
20506 return lhs.m_value.number_unsigned == rhs.m_value.number_unsigned;
20509 return lhs.m_value.number_float == rhs.m_value.number_float;
20512 return *lhs.m_value.binary == *rhs.m_value.binary;
20521 return static_cast<number_float_t>(lhs.m_value.number_integer) == rhs.m_value.number_float;
20525 return lhs.m_value.number_float ==
static_cast<number_float_t>(rhs.m_value.number_integer);
20529 return static_cast<number_float_t>(lhs.m_value.number_unsigned) == rhs.m_value.number_float;
20533 return lhs.m_value.number_float ==
static_cast<number_float_t>(rhs.m_value.number_unsigned);
20537 return static_cast<number_integer_t>(lhs.m_value.number_unsigned) == rhs.m_value.number_integer;
20541 return lhs.m_value.number_integer ==
static_cast<number_integer_t>(rhs.m_value.number_unsigned);
20546 #pragma GCC diagnostic pop
20552 template<
typename ScalarType,
typename std::enable_if<
20553 std::is_scalar<ScalarType>::value,
int>
::type = 0>
20561 template<
typename ScalarType,
typename std::enable_if<
20562 std::is_scalar<ScalarType>::value,
int>
::type = 0>
20572 return !(lhs == rhs);
20577 template<
typename ScalarType,
typename std::enable_if<
20578 std::is_scalar<ScalarType>::value,
int>
::type = 0>
20586 template<
typename ScalarType,
typename std::enable_if<
20587 std::is_scalar<ScalarType>::value,
int>
::type = 0>
20597 const auto lhs_type = lhs.type();
20598 const auto rhs_type = rhs.type();
20600 if (lhs_type == rhs_type)
20607 return (*lhs.m_value.array) < (*rhs.m_value.array);
20610 return (*lhs.m_value.object) < (*rhs.m_value.object);
20616 return (*lhs.m_value.string) < (*rhs.m_value.string);
20619 return (lhs.m_value.boolean) < (rhs.m_value.boolean);
20622 return (lhs.m_value.number_integer) < (rhs.m_value.number_integer);
20625 return (lhs.m_value.number_unsigned) < (rhs.m_value.number_unsigned);
20628 return (lhs.m_value.number_float) < (rhs.m_value.number_float);
20631 return (*lhs.m_value.binary) < (*rhs.m_value.binary);
20640 return static_cast<number_float_t>(lhs.m_value.number_integer) < rhs.m_value.number_float;
20644 return lhs.m_value.number_float <
static_cast<number_float_t>(rhs.m_value.number_integer);
20648 return static_cast<number_float_t>(lhs.m_value.number_unsigned) < rhs.m_value.number_float;
20652 return lhs.m_value.number_float <
static_cast<number_float_t>(rhs.m_value.number_unsigned);
20656 return lhs.m_value.number_integer <
static_cast<number_integer_t>(rhs.m_value.number_unsigned);
20660 return static_cast<number_integer_t>(lhs.m_value.number_unsigned) < rhs.m_value.number_integer;
20671 template<
typename ScalarType,
typename std::enable_if<
20672 std::is_scalar<ScalarType>::value,
int>
::type = 0>
20680 template<
typename ScalarType,
typename std::enable_if<
20681 std::is_scalar<ScalarType>::value,
int>
::type = 0>
20691 return !(rhs < lhs);
20696 template<
typename ScalarType,
typename std::enable_if<
20697 std::is_scalar<ScalarType>::value,
int>
::type = 0>
20705 template<
typename ScalarType,
typename std::enable_if<
20706 std::is_scalar<ScalarType>::value,
int>
::type = 0>
20716 return !(lhs <= rhs);
20721 template<
typename ScalarType,
typename std::enable_if<
20722 std::is_scalar<ScalarType>::value,
int>
::type = 0>
20730 template<
typename ScalarType,
typename std::enable_if<
20731 std::is_scalar<ScalarType>::value,
int>
::type = 0>
20741 return !(lhs < rhs);
20746 template<
typename ScalarType,
typename std::enable_if<
20747 std::is_scalar<ScalarType>::value,
int>
::type = 0>
20755 template<
typename ScalarType,
typename std::enable_if<
20756 std::is_scalar<ScalarType>::value,
int>
::type = 0>
20776 const bool pretty_print = o.width() > 0;
20777 const auto indentation = pretty_print ? o.width() : 0;
20784 s.dump(j, pretty_print,
false,
static_cast<unsigned int>(indentation));
20799 #endif // JSON_NO_IO
20812 template<
typename InputType>
20816 const bool allow_exceptions =
true,
20817 const bool ignore_comments =
false)
20826 template<
typename IteratorType>
20831 const bool allow_exceptions =
true,
20832 const bool ignore_comments =
false)
20843 const
bool allow_exceptions = true,
20844 const
bool ignore_comments = false)
20847 parser(i.get(), cb, allow_exceptions, ignore_comments).parse(
true, result);
20853 template<
typename InputType>
20855 const bool ignore_comments =
false)
20862 template<
typename IteratorType>
20864 const bool ignore_comments =
false)
20872 const
bool ignore_comments = false)
20874 return parser(i.get(),
nullptr,
false, ignore_comments).accept(
true);
20879 template <
typename InputType,
typename SAX>
20883 const
bool strict = true,
20884 const
bool ignore_comments = false)
20888 ?
parser(
std::move(ia),
nullptr,
true, ignore_comments).sax_parse(sax, strict)
20894 template<
class IteratorType,
class SAX>
20898 const
bool strict = true,
20899 const
bool ignore_comments = false)
20903 ?
parser(
std::move(ia),
nullptr,
true, ignore_comments).sax_parse(sax, strict)
20912 template <
typename SAX>
20917 const
bool strict = true,
20918 const
bool ignore_comments = false)
20923 ?
parser(
std::move(ia),
nullptr,
true, ignore_comments).sax_parse(sax, strict)
20947 #endif // JSON_NO_IO
20974 return "discarded";
20995 #if JSON_DIAGNOSTICS
21012 std::vector<std::uint8_t> result;
21035 std::vector<std::uint8_t> result;
21057 const bool use_size =
false,
21058 const bool use_type =
false)
21060 std::vector<std::uint8_t> result;
21061 to_ubjson(j, result, use_size, use_type);
21068 const bool use_size =
false,
const bool use_type =
false)
21076 const bool use_size =
false,
const bool use_type =
false)
21085 std::vector<std::uint8_t> result;
21106 template<
typename InputType>
21109 const bool strict =
true,
21110 const bool allow_exceptions =
true,
21122 template<
typename IteratorType>
21125 const bool strict =
true,
21126 const bool allow_exceptions =
true,
21136 template<
typename T>
21140 const
bool strict = true,
21141 const
bool allow_exceptions = true,
21144 return from_cbor(
ptr,
ptr + len, strict, allow_exceptions, tag_handler);
21151 const
bool strict = true,
21152 const
bool allow_exceptions = true,
21165 template<
typename InputType>
21168 const bool strict =
true,
21169 const bool allow_exceptions =
true)
21180 template<
typename IteratorType>
21183 const bool strict =
true,
21184 const bool allow_exceptions =
true)
21193 template<
typename T>
21197 const
bool strict = true,
21198 const
bool allow_exceptions = true)
21206 const
bool strict = true,
21207 const
bool allow_exceptions = true)
21219 template<
typename InputType>
21222 const bool strict =
true,
21223 const bool allow_exceptions =
true)
21234 template<
typename IteratorType>
21237 const bool strict =
true,
21238 const bool allow_exceptions =
true)
21247 template<
typename T>
21251 const
bool strict = true,
21252 const
bool allow_exceptions = true)
21260 const
bool strict = true,
21261 const
bool allow_exceptions = true)
21273 template<
typename InputType>
21276 const bool strict =
true,
21277 const bool allow_exceptions =
true)
21288 template<
typename IteratorType>
21291 const bool strict =
true,
21292 const bool allow_exceptions =
true)
21301 template<
typename T>
21305 const
bool strict = true,
21306 const
bool allow_exceptions = true)
21314 const
bool strict = true,
21315 const
bool allow_exceptions = true)
21337 return ptr.get_unchecked(
this);
21344 return ptr.get_unchecked(
this);
21351 return ptr.get_checked(
this);
21358 return ptr.get_checked(
this);
21394 enum class patch_operations {add,
remove, replace,
move,
copy, test, invalid};
21396 const auto get_op = [](
const std::string &
op)
21400 return patch_operations::add;
21402 if (
op ==
"remove")
21406 if (
op ==
"replace")
21408 return patch_operations::replace;
21420 return patch_operations::test;
21423 return patch_operations::invalid;
21438 if (top_pointer !=
ptr)
21440 result.at(top_pointer);
21444 const auto last_path =
ptr.back();
21448 switch (parent.m_type)
21454 parent[last_path] = val;
21460 if (last_path ==
"-")
21463 parent.push_back(val);
21475 parent.insert(parent.begin() +
static_cast<difference_type>(idx), val);
21497 const auto last_path =
ptr.back();
21502 if (parent.is_object())
21505 auto it = parent.find(last_path);
21515 else if (parent.is_array())
21529 for (
const auto& val : json_patch)
21532 const auto get_value = [&val](
const std::string &
op,
21533 const std::string & member,
21537 auto it = val.
m_value.object->find(member);
21540 const auto error_msg = (
op ==
"op") ?
"operation" :
"operation '" +
op +
"'";
21567 const auto op =
get_value(
"op",
"op",
true).template get<std::string>();
21568 const auto path =
get_value(
op,
"path",
true).template get<std::string>();
21571 switch (get_op(
op))
21573 case patch_operations::add:
21581 operation_remove(
ptr);
21585 case patch_operations::replace:
21588 result.at(
ptr) =
get_value(
"replace",
"value",
false);
21594 const auto from_path =
get_value(
"move",
"from",
true).template get<std::string>();
21604 operation_remove(from_ptr);
21605 operation_add(
ptr, v);
21611 const auto from_path =
get_value(
"copy",
"from",
true).template get<std::string>();
21620 operation_add(
ptr, v);
21624 case patch_operations::test:
21626 bool success =
false;
21631 success = (result.at(
ptr) ==
get_value(
"test",
"value",
false));
21647 case patch_operations::invalid:
21664 const std::string& path =
"")
21675 if (
source.type() != target.type())
21680 {
"op",
"replace"}, {
"path", path}, {
"value", target}
21691 while (i <
source.size() && i < target.size())
21694 auto temp_diff =
diff(
source[i], target[i], path +
"/" + std::to_string(i));
21695 result.insert(result.end(), temp_diff.begin(), temp_diff.end());
21704 while (i <
source.size())
21708 result.insert(result.begin() + end_index,
object(
21711 {
"path", path +
"/" + std::to_string(i)}
21717 while (i < target.size())
21722 {
"path", path +
"/-"},
21723 {
"value", target[i]}
21734 for (
auto it =
source.cbegin(); it !=
source.cend(); ++it)
21739 if (target.find(it.key()) != target.end())
21742 auto temp_diff =
diff(it.value(), target[it.key()], path_key);
21743 result.insert(result.end(), temp_diff.begin(), temp_diff.end());
21748 result.push_back(
object(
21750 {
"op",
"remove"}, {
"path", path_key}
21756 for (
auto it = target.cbegin(); it != target.cend(); ++it)
21764 {
"op",
"add"}, {
"path", path_key},
21765 {
"value", it.value()}
21786 {
"op",
"replace"}, {
"path", path}, {
"value", target}
21808 if (apply_patch.is_object())
21814 for (
auto it = apply_patch.begin(); it != apply_patch.end(); ++it)
21816 if (it.value().is_null())
21828 *
this = apply_patch;
21879 #ifndef JSON_HAS_CPP_20
21885 is_nothrow_move_constructible<nlohmann::NLOHMANN_BASIC_JSON_TPL>::value&&
21886 is_nothrow_move_assignable<nlohmann::NLOHMANN_BASIC_JSON_TPL>::value)
21915 #if defined(__clang__)
21916 #pragma clang diagnostic pop
21921 #undef JSON_INTERNAL_CATCH
21925 #undef JSON_PRIVATE_UNLESS_TESTED
21926 #undef JSON_HAS_CPP_11
21927 #undef JSON_HAS_CPP_14
21928 #undef JSON_HAS_CPP_17
21929 #undef JSON_HAS_CPP_20
21930 #undef JSON_HAS_FILESYSTEM
21931 #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM
21932 #undef NLOHMANN_BASIC_JSON_TPL_DECLARATION
21933 #undef NLOHMANN_BASIC_JSON_TPL
21934 #undef JSON_EXPLICIT
21935 #undef NLOHMANN_CAN_CALL_STD_FUNC_IMPL
21940 #undef JSON_HEDLEY_ALWAYS_INLINE
21941 #undef JSON_HEDLEY_ARM_VERSION
21942 #undef JSON_HEDLEY_ARM_VERSION_CHECK
21943 #undef JSON_HEDLEY_ARRAY_PARAM
21944 #undef JSON_HEDLEY_ASSUME
21945 #undef JSON_HEDLEY_BEGIN_C_DECLS
21946 #undef JSON_HEDLEY_CLANG_HAS_ATTRIBUTE
21947 #undef JSON_HEDLEY_CLANG_HAS_BUILTIN
21948 #undef JSON_HEDLEY_CLANG_HAS_CPP_ATTRIBUTE
21949 #undef JSON_HEDLEY_CLANG_HAS_DECLSPEC_DECLSPEC_ATTRIBUTE
21950 #undef JSON_HEDLEY_CLANG_HAS_EXTENSION
21951 #undef JSON_HEDLEY_CLANG_HAS_FEATURE
21952 #undef JSON_HEDLEY_CLANG_HAS_WARNING
21953 #undef JSON_HEDLEY_COMPCERT_VERSION
21954 #undef JSON_HEDLEY_COMPCERT_VERSION_CHECK
21955 #undef JSON_HEDLEY_CONCAT
21956 #undef JSON_HEDLEY_CONCAT3
21957 #undef JSON_HEDLEY_CONCAT3_EX
21958 #undef JSON_HEDLEY_CONCAT_EX
21959 #undef JSON_HEDLEY_CONST
21960 #undef JSON_HEDLEY_CONSTEXPR
21961 #undef JSON_HEDLEY_CONST_CAST
21962 #undef JSON_HEDLEY_CPP_CAST
21963 #undef JSON_HEDLEY_CRAY_VERSION
21964 #undef JSON_HEDLEY_CRAY_VERSION_CHECK
21965 #undef JSON_HEDLEY_C_DECL
21966 #undef JSON_HEDLEY_DEPRECATED
21967 #undef JSON_HEDLEY_DEPRECATED_FOR
21968 #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL
21969 #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_
21970 #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED
21971 #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES
21972 #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS
21973 #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION
21974 #undef JSON_HEDLEY_DIAGNOSTIC_POP
21975 #undef JSON_HEDLEY_DIAGNOSTIC_PUSH
21976 #undef JSON_HEDLEY_DMC_VERSION
21977 #undef JSON_HEDLEY_DMC_VERSION_CHECK
21978 #undef JSON_HEDLEY_EMPTY_BASES
21979 #undef JSON_HEDLEY_EMSCRIPTEN_VERSION
21980 #undef JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK
21981 #undef JSON_HEDLEY_END_C_DECLS
21982 #undef JSON_HEDLEY_FLAGS
21983 #undef JSON_HEDLEY_FLAGS_CAST
21984 #undef JSON_HEDLEY_GCC_HAS_ATTRIBUTE
21985 #undef JSON_HEDLEY_GCC_HAS_BUILTIN
21986 #undef JSON_HEDLEY_GCC_HAS_CPP_ATTRIBUTE
21987 #undef JSON_HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE
21988 #undef JSON_HEDLEY_GCC_HAS_EXTENSION
21989 #undef JSON_HEDLEY_GCC_HAS_FEATURE
21990 #undef JSON_HEDLEY_GCC_HAS_WARNING
21991 #undef JSON_HEDLEY_GCC_NOT_CLANG_VERSION_CHECK
21992 #undef JSON_HEDLEY_GCC_VERSION
21993 #undef JSON_HEDLEY_GCC_VERSION_CHECK
21994 #undef JSON_HEDLEY_GNUC_HAS_ATTRIBUTE
21995 #undef JSON_HEDLEY_GNUC_HAS_BUILTIN
21996 #undef JSON_HEDLEY_GNUC_HAS_CPP_ATTRIBUTE
21997 #undef JSON_HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE
21998 #undef JSON_HEDLEY_GNUC_HAS_EXTENSION
21999 #undef JSON_HEDLEY_GNUC_HAS_FEATURE
22000 #undef JSON_HEDLEY_GNUC_HAS_WARNING
22001 #undef JSON_HEDLEY_GNUC_VERSION
22002 #undef JSON_HEDLEY_GNUC_VERSION_CHECK
22003 #undef JSON_HEDLEY_HAS_ATTRIBUTE
22004 #undef JSON_HEDLEY_HAS_BUILTIN
22005 #undef JSON_HEDLEY_HAS_CPP_ATTRIBUTE
22006 #undef JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS
22007 #undef JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE
22008 #undef JSON_HEDLEY_HAS_EXTENSION
22009 #undef JSON_HEDLEY_HAS_FEATURE
22010 #undef JSON_HEDLEY_HAS_WARNING
22011 #undef JSON_HEDLEY_IAR_VERSION
22012 #undef JSON_HEDLEY_IAR_VERSION_CHECK
22013 #undef JSON_HEDLEY_IBM_VERSION
22014 #undef JSON_HEDLEY_IBM_VERSION_CHECK
22015 #undef JSON_HEDLEY_IMPORT
22016 #undef JSON_HEDLEY_INLINE
22017 #undef JSON_HEDLEY_INTEL_CL_VERSION
22018 #undef JSON_HEDLEY_INTEL_CL_VERSION_CHECK
22019 #undef JSON_HEDLEY_INTEL_VERSION
22020 #undef JSON_HEDLEY_INTEL_VERSION_CHECK
22021 #undef JSON_HEDLEY_IS_CONSTANT
22022 #undef JSON_HEDLEY_IS_CONSTEXPR_
22023 #undef JSON_HEDLEY_LIKELY
22024 #undef JSON_HEDLEY_MALLOC
22025 #undef JSON_HEDLEY_MCST_LCC_VERSION
22026 #undef JSON_HEDLEY_MCST_LCC_VERSION_CHECK
22027 #undef JSON_HEDLEY_MESSAGE
22028 #undef JSON_HEDLEY_MSVC_VERSION
22029 #undef JSON_HEDLEY_MSVC_VERSION_CHECK
22030 #undef JSON_HEDLEY_NEVER_INLINE
22031 #undef JSON_HEDLEY_NON_NULL
22032 #undef JSON_HEDLEY_NO_ESCAPE
22033 #undef JSON_HEDLEY_NO_RETURN
22034 #undef JSON_HEDLEY_NO_THROW
22035 #undef JSON_HEDLEY_NULL
22036 #undef JSON_HEDLEY_PELLES_VERSION
22037 #undef JSON_HEDLEY_PELLES_VERSION_CHECK
22038 #undef JSON_HEDLEY_PGI_VERSION
22039 #undef JSON_HEDLEY_PGI_VERSION_CHECK
22040 #undef JSON_HEDLEY_PREDICT
22041 #undef JSON_HEDLEY_PRINTF_FORMAT
22042 #undef JSON_HEDLEY_PRIVATE
22043 #undef JSON_HEDLEY_PUBLIC
22044 #undef JSON_HEDLEY_PURE
22045 #undef JSON_HEDLEY_REINTERPRET_CAST
22046 #undef JSON_HEDLEY_REQUIRE
22047 #undef JSON_HEDLEY_REQUIRE_CONSTEXPR
22048 #undef JSON_HEDLEY_REQUIRE_MSG
22049 #undef JSON_HEDLEY_RESTRICT
22050 #undef JSON_HEDLEY_RETURNS_NON_NULL
22051 #undef JSON_HEDLEY_SENTINEL
22052 #undef JSON_HEDLEY_STATIC_ASSERT
22053 #undef JSON_HEDLEY_STATIC_CAST
22054 #undef JSON_HEDLEY_STRINGIFY
22055 #undef JSON_HEDLEY_STRINGIFY_EX
22056 #undef JSON_HEDLEY_SUNPRO_VERSION
22057 #undef JSON_HEDLEY_SUNPRO_VERSION_CHECK
22058 #undef JSON_HEDLEY_TINYC_VERSION
22059 #undef JSON_HEDLEY_TINYC_VERSION_CHECK
22060 #undef JSON_HEDLEY_TI_ARMCL_VERSION
22061 #undef JSON_HEDLEY_TI_ARMCL_VERSION_CHECK
22062 #undef JSON_HEDLEY_TI_CL2000_VERSION
22063 #undef JSON_HEDLEY_TI_CL2000_VERSION_CHECK
22064 #undef JSON_HEDLEY_TI_CL430_VERSION
22065 #undef JSON_HEDLEY_TI_CL430_VERSION_CHECK
22066 #undef JSON_HEDLEY_TI_CL6X_VERSION
22067 #undef JSON_HEDLEY_TI_CL6X_VERSION_CHECK
22068 #undef JSON_HEDLEY_TI_CL7X_VERSION
22069 #undef JSON_HEDLEY_TI_CL7X_VERSION_CHECK
22070 #undef JSON_HEDLEY_TI_CLPRU_VERSION
22071 #undef JSON_HEDLEY_TI_CLPRU_VERSION_CHECK
22072 #undef JSON_HEDLEY_TI_VERSION
22073 #undef JSON_HEDLEY_TI_VERSION_CHECK
22074 #undef JSON_HEDLEY_UNAVAILABLE
22075 #undef JSON_HEDLEY_UNLIKELY
22076 #undef JSON_HEDLEY_UNPREDICTABLE
22077 #undef JSON_HEDLEY_UNREACHABLE
22078 #undef JSON_HEDLEY_UNREACHABLE_RETURN
22079 #undef JSON_HEDLEY_VERSION
22080 #undef JSON_HEDLEY_VERSION_DECODE_MAJOR
22081 #undef JSON_HEDLEY_VERSION_DECODE_MINOR
22082 #undef JSON_HEDLEY_VERSION_DECODE_REVISION
22083 #undef JSON_HEDLEY_VERSION_ENCODE
22084 #undef JSON_HEDLEY_WARNING
22085 #undef JSON_HEDLEY_WARN_UNUSED_RESULT
22086 #undef JSON_HEDLEY_WARN_UNUSED_RESULT_MSG
22087 #undef JSON_HEDLEY_FALL_THROUGH
22091 #endif // INCLUDE_NLOHMANN_JSON_HPP_