30#ifndef INCLUDE_NLOHMANN_JSON_HPP_
31#define INCLUDE_NLOHMANN_JSON_HPP_
33#define NLOHMANN_JSON_VERSION_MAJOR 3
34#define NLOHMANN_JSON_VERSION_MINOR 9
35#define NLOHMANN_JSON_VERSION_PATCH 1
40#include <initializer_list>
59#include <forward_list>
65#include <unordered_map>
96 constexpr operator size_t()
const
122#if !defined(JSON_HEDLEY_VERSION) || (JSON_HEDLEY_VERSION < 13)
123#if defined(JSON_HEDLEY_VERSION)
124 #undef JSON_HEDLEY_VERSION
126#define JSON_HEDLEY_VERSION 13
128#if defined(JSON_HEDLEY_STRINGIFY_EX)
129 #undef JSON_HEDLEY_STRINGIFY_EX
131#define JSON_HEDLEY_STRINGIFY_EX(x) #x
133#if defined(JSON_HEDLEY_STRINGIFY)
134 #undef JSON_HEDLEY_STRINGIFY
136#define JSON_HEDLEY_STRINGIFY(x) JSON_HEDLEY_STRINGIFY_EX(x)
138#if defined(JSON_HEDLEY_CONCAT_EX)
139 #undef JSON_HEDLEY_CONCAT_EX
141#define JSON_HEDLEY_CONCAT_EX(a,b) a##b
143#if defined(JSON_HEDLEY_CONCAT)
144 #undef JSON_HEDLEY_CONCAT
146#define JSON_HEDLEY_CONCAT(a,b) JSON_HEDLEY_CONCAT_EX(a,b)
148#if defined(JSON_HEDLEY_CONCAT3_EX)
149 #undef JSON_HEDLEY_CONCAT3_EX
151#define JSON_HEDLEY_CONCAT3_EX(a,b,c) a##b##c
153#if defined(JSON_HEDLEY_CONCAT3)
154 #undef JSON_HEDLEY_CONCAT3
156#define JSON_HEDLEY_CONCAT3(a,b,c) JSON_HEDLEY_CONCAT3_EX(a,b,c)
158#if defined(JSON_HEDLEY_VERSION_ENCODE)
159 #undef JSON_HEDLEY_VERSION_ENCODE
161#define JSON_HEDLEY_VERSION_ENCODE(major,minor,revision) (((major) * 1000000) + ((minor) * 1000) + (revision))
163#if defined(JSON_HEDLEY_VERSION_DECODE_MAJOR)
164 #undef JSON_HEDLEY_VERSION_DECODE_MAJOR
166#define JSON_HEDLEY_VERSION_DECODE_MAJOR(version) ((version) / 1000000)
168#if defined(JSON_HEDLEY_VERSION_DECODE_MINOR)
169 #undef JSON_HEDLEY_VERSION_DECODE_MINOR
171#define JSON_HEDLEY_VERSION_DECODE_MINOR(version) (((version) % 1000000) / 1000)
173#if defined(JSON_HEDLEY_VERSION_DECODE_REVISION)
174 #undef JSON_HEDLEY_VERSION_DECODE_REVISION
176#define JSON_HEDLEY_VERSION_DECODE_REVISION(version) ((version) % 1000)
178#if defined(JSON_HEDLEY_GNUC_VERSION)
179 #undef JSON_HEDLEY_GNUC_VERSION
181#if defined(__GNUC__) && defined(__GNUC_PATCHLEVEL__)
182 #define JSON_HEDLEY_GNUC_VERSION JSON_HEDLEY_VERSION_ENCODE(__GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__)
183#elif defined(__GNUC__)
184 #define JSON_HEDLEY_GNUC_VERSION JSON_HEDLEY_VERSION_ENCODE(__GNUC__, __GNUC_MINOR__, 0)
187#if defined(JSON_HEDLEY_GNUC_VERSION_CHECK)
188 #undef JSON_HEDLEY_GNUC_VERSION_CHECK
190#if defined(JSON_HEDLEY_GNUC_VERSION)
191 #define JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_GNUC_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
193 #define JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) (0)
196#if defined(JSON_HEDLEY_MSVC_VERSION)
197 #undef JSON_HEDLEY_MSVC_VERSION
199#if defined(_MSC_FULL_VER) && (_MSC_FULL_VER >= 140000000)
200 #define JSON_HEDLEY_MSVC_VERSION JSON_HEDLEY_VERSION_ENCODE(_MSC_FULL_VER / 10000000, (_MSC_FULL_VER % 10000000) / 100000, (_MSC_FULL_VER % 100000) / 100)
201#elif defined(_MSC_FULL_VER)
202 #define JSON_HEDLEY_MSVC_VERSION JSON_HEDLEY_VERSION_ENCODE(_MSC_FULL_VER / 1000000, (_MSC_FULL_VER % 1000000) / 10000, (_MSC_FULL_VER % 10000) / 10)
203#elif defined(_MSC_VER)
204 #define JSON_HEDLEY_MSVC_VERSION JSON_HEDLEY_VERSION_ENCODE(_MSC_VER / 100, _MSC_VER % 100, 0)
207#if defined(JSON_HEDLEY_MSVC_VERSION_CHECK)
208 #undef JSON_HEDLEY_MSVC_VERSION_CHECK
210#if !defined(_MSC_VER)
211 #define JSON_HEDLEY_MSVC_VERSION_CHECK(major,minor,patch) (0)
212#elif defined(_MSC_VER) && (_MSC_VER >= 1400)
213 #define JSON_HEDLEY_MSVC_VERSION_CHECK(major,minor,patch) (_MSC_FULL_VER >= ((major * 10000000) + (minor * 100000) + (patch)))
214#elif defined(_MSC_VER) && (_MSC_VER >= 1200)
215 #define JSON_HEDLEY_MSVC_VERSION_CHECK(major,minor,patch) (_MSC_FULL_VER >= ((major * 1000000) + (minor * 10000) + (patch)))
217 #define JSON_HEDLEY_MSVC_VERSION_CHECK(major,minor,patch) (_MSC_VER >= ((major * 100) + (minor)))
220#if defined(JSON_HEDLEY_INTEL_VERSION)
221 #undef JSON_HEDLEY_INTEL_VERSION
223#if defined(__INTEL_COMPILER) && defined(__INTEL_COMPILER_UPDATE)
224 #define JSON_HEDLEY_INTEL_VERSION JSON_HEDLEY_VERSION_ENCODE(__INTEL_COMPILER / 100, __INTEL_COMPILER % 100, __INTEL_COMPILER_UPDATE)
225#elif defined(__INTEL_COMPILER)
226 #define JSON_HEDLEY_INTEL_VERSION JSON_HEDLEY_VERSION_ENCODE(__INTEL_COMPILER / 100, __INTEL_COMPILER % 100, 0)
229#if defined(JSON_HEDLEY_INTEL_VERSION_CHECK)
230 #undef JSON_HEDLEY_INTEL_VERSION_CHECK
232#if defined(JSON_HEDLEY_INTEL_VERSION)
233 #define JSON_HEDLEY_INTEL_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_INTEL_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
235 #define JSON_HEDLEY_INTEL_VERSION_CHECK(major,minor,patch) (0)
238#if defined(JSON_HEDLEY_PGI_VERSION)
239 #undef JSON_HEDLEY_PGI_VERSION
241#if defined(__PGI) && defined(__PGIC__) && defined(__PGIC_MINOR__) && defined(__PGIC_PATCHLEVEL__)
242 #define JSON_HEDLEY_PGI_VERSION JSON_HEDLEY_VERSION_ENCODE(__PGIC__, __PGIC_MINOR__, __PGIC_PATCHLEVEL__)
245#if defined(JSON_HEDLEY_PGI_VERSION_CHECK)
246 #undef JSON_HEDLEY_PGI_VERSION_CHECK
248#if defined(JSON_HEDLEY_PGI_VERSION)
249 #define JSON_HEDLEY_PGI_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_PGI_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
251 #define JSON_HEDLEY_PGI_VERSION_CHECK(major,minor,patch) (0)
254#if defined(JSON_HEDLEY_SUNPRO_VERSION)
255 #undef JSON_HEDLEY_SUNPRO_VERSION
257#if defined(__SUNPRO_C) && (__SUNPRO_C > 0x1000)
258 #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)
259#elif defined(__SUNPRO_C)
260 #define JSON_HEDLEY_SUNPRO_VERSION JSON_HEDLEY_VERSION_ENCODE((__SUNPRO_C >> 8) & 0xf, (__SUNPRO_C >> 4) & 0xf, (__SUNPRO_C) & 0xf)
261#elif defined(__SUNPRO_CC) && (__SUNPRO_CC > 0x1000)
262 #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)
263#elif defined(__SUNPRO_CC)
264 #define JSON_HEDLEY_SUNPRO_VERSION JSON_HEDLEY_VERSION_ENCODE((__SUNPRO_CC >> 8) & 0xf, (__SUNPRO_CC >> 4) & 0xf, (__SUNPRO_CC) & 0xf)
267#if defined(JSON_HEDLEY_SUNPRO_VERSION_CHECK)
268 #undef JSON_HEDLEY_SUNPRO_VERSION_CHECK
270#if defined(JSON_HEDLEY_SUNPRO_VERSION)
271 #define JSON_HEDLEY_SUNPRO_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_SUNPRO_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
273 #define JSON_HEDLEY_SUNPRO_VERSION_CHECK(major,minor,patch) (0)
276#if defined(JSON_HEDLEY_EMSCRIPTEN_VERSION)
277 #undef JSON_HEDLEY_EMSCRIPTEN_VERSION
279#if defined(__EMSCRIPTEN__)
280 #define JSON_HEDLEY_EMSCRIPTEN_VERSION JSON_HEDLEY_VERSION_ENCODE(__EMSCRIPTEN_major__, __EMSCRIPTEN_minor__, __EMSCRIPTEN_tiny__)
283#if defined(JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK)
284 #undef JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK
286#if defined(JSON_HEDLEY_EMSCRIPTEN_VERSION)
287 #define JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_EMSCRIPTEN_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
289 #define JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK(major,minor,patch) (0)
292#if defined(JSON_HEDLEY_ARM_VERSION)
293 #undef JSON_HEDLEY_ARM_VERSION
295#if defined(__CC_ARM) && defined(__ARMCOMPILER_VERSION)
296 #define JSON_HEDLEY_ARM_VERSION JSON_HEDLEY_VERSION_ENCODE(__ARMCOMPILER_VERSION / 1000000, (__ARMCOMPILER_VERSION % 1000000) / 10000, (__ARMCOMPILER_VERSION % 10000) / 100)
297#elif defined(__CC_ARM) && defined(__ARMCC_VERSION)
298 #define JSON_HEDLEY_ARM_VERSION JSON_HEDLEY_VERSION_ENCODE(__ARMCC_VERSION / 1000000, (__ARMCC_VERSION % 1000000) / 10000, (__ARMCC_VERSION % 10000) / 100)
301#if defined(JSON_HEDLEY_ARM_VERSION_CHECK)
302 #undef JSON_HEDLEY_ARM_VERSION_CHECK
304#if defined(JSON_HEDLEY_ARM_VERSION)
305 #define JSON_HEDLEY_ARM_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_ARM_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
307 #define JSON_HEDLEY_ARM_VERSION_CHECK(major,minor,patch) (0)
310#if defined(JSON_HEDLEY_IBM_VERSION)
311 #undef JSON_HEDLEY_IBM_VERSION
313#if defined(__ibmxl__)
314 #define JSON_HEDLEY_IBM_VERSION JSON_HEDLEY_VERSION_ENCODE(__ibmxl_version__, __ibmxl_release__, __ibmxl_modification__)
315#elif defined(__xlC__) && defined(__xlC_ver__)
316 #define JSON_HEDLEY_IBM_VERSION JSON_HEDLEY_VERSION_ENCODE(__xlC__ >> 8, __xlC__ & 0xff, (__xlC_ver__ >> 8) & 0xff)
317#elif defined(__xlC__)
318 #define JSON_HEDLEY_IBM_VERSION JSON_HEDLEY_VERSION_ENCODE(__xlC__ >> 8, __xlC__ & 0xff, 0)
321#if defined(JSON_HEDLEY_IBM_VERSION_CHECK)
322 #undef JSON_HEDLEY_IBM_VERSION_CHECK
324#if defined(JSON_HEDLEY_IBM_VERSION)
325 #define JSON_HEDLEY_IBM_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_IBM_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
327 #define JSON_HEDLEY_IBM_VERSION_CHECK(major,minor,patch) (0)
330#if defined(JSON_HEDLEY_TI_VERSION)
331 #undef JSON_HEDLEY_TI_VERSION
334 defined(__TI_COMPILER_VERSION__) && \
336 defined(__TMS470__) || defined(__TI_ARM__) || \
337 defined(__MSP430__) || \
338 defined(__TMS320C2000__) \
340#if (__TI_COMPILER_VERSION__ >= 16000000)
341 #define JSON_HEDLEY_TI_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000))
345#if defined(JSON_HEDLEY_TI_VERSION_CHECK)
346 #undef JSON_HEDLEY_TI_VERSION_CHECK
348#if defined(JSON_HEDLEY_TI_VERSION)
349 #define JSON_HEDLEY_TI_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
351 #define JSON_HEDLEY_TI_VERSION_CHECK(major,minor,patch) (0)
354#if defined(JSON_HEDLEY_TI_CL2000_VERSION)
355 #undef JSON_HEDLEY_TI_CL2000_VERSION
357#if defined(__TI_COMPILER_VERSION__) && defined(__TMS320C2000__)
358 #define JSON_HEDLEY_TI_CL2000_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000))
361#if defined(JSON_HEDLEY_TI_CL2000_VERSION_CHECK)
362 #undef JSON_HEDLEY_TI_CL2000_VERSION_CHECK
364#if defined(JSON_HEDLEY_TI_CL2000_VERSION)
365 #define JSON_HEDLEY_TI_CL2000_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_CL2000_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
367 #define JSON_HEDLEY_TI_CL2000_VERSION_CHECK(major,minor,patch) (0)
370#if defined(JSON_HEDLEY_TI_CL430_VERSION)
371 #undef JSON_HEDLEY_TI_CL430_VERSION
373#if defined(__TI_COMPILER_VERSION__) && defined(__MSP430__)
374 #define JSON_HEDLEY_TI_CL430_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000))
377#if defined(JSON_HEDLEY_TI_CL430_VERSION_CHECK)
378 #undef JSON_HEDLEY_TI_CL430_VERSION_CHECK
380#if defined(JSON_HEDLEY_TI_CL430_VERSION)
381 #define JSON_HEDLEY_TI_CL430_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_CL430_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
383 #define JSON_HEDLEY_TI_CL430_VERSION_CHECK(major,minor,patch) (0)
386#if defined(JSON_HEDLEY_TI_ARMCL_VERSION)
387 #undef JSON_HEDLEY_TI_ARMCL_VERSION
389#if defined(__TI_COMPILER_VERSION__) && (defined(__TMS470__) || defined(__TI_ARM__))
390 #define JSON_HEDLEY_TI_ARMCL_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000))
393#if defined(JSON_HEDLEY_TI_ARMCL_VERSION_CHECK)
394 #undef JSON_HEDLEY_TI_ARMCL_VERSION_CHECK
396#if defined(JSON_HEDLEY_TI_ARMCL_VERSION)
397 #define JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_ARMCL_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
399 #define JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(major,minor,patch) (0)
402#if defined(JSON_HEDLEY_TI_CL6X_VERSION)
403 #undef JSON_HEDLEY_TI_CL6X_VERSION
405#if defined(__TI_COMPILER_VERSION__) && defined(__TMS320C6X__)
406 #define JSON_HEDLEY_TI_CL6X_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000))
409#if defined(JSON_HEDLEY_TI_CL6X_VERSION_CHECK)
410 #undef JSON_HEDLEY_TI_CL6X_VERSION_CHECK
412#if defined(JSON_HEDLEY_TI_CL6X_VERSION)
413 #define JSON_HEDLEY_TI_CL6X_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_CL6X_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
415 #define JSON_HEDLEY_TI_CL6X_VERSION_CHECK(major,minor,patch) (0)
418#if defined(JSON_HEDLEY_TI_CL7X_VERSION)
419 #undef JSON_HEDLEY_TI_CL7X_VERSION
421#if defined(__TI_COMPILER_VERSION__) && defined(__C7000__)
422 #define JSON_HEDLEY_TI_CL7X_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000))
425#if defined(JSON_HEDLEY_TI_CL7X_VERSION_CHECK)
426 #undef JSON_HEDLEY_TI_CL7X_VERSION_CHECK
428#if defined(JSON_HEDLEY_TI_CL7X_VERSION)
429 #define JSON_HEDLEY_TI_CL7X_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_CL7X_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
431 #define JSON_HEDLEY_TI_CL7X_VERSION_CHECK(major,minor,patch) (0)
434#if defined(JSON_HEDLEY_TI_CLPRU_VERSION)
435 #undef JSON_HEDLEY_TI_CLPRU_VERSION
437#if defined(__TI_COMPILER_VERSION__) && defined(__PRU__)
438 #define JSON_HEDLEY_TI_CLPRU_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000))
441#if defined(JSON_HEDLEY_TI_CLPRU_VERSION_CHECK)
442 #undef JSON_HEDLEY_TI_CLPRU_VERSION_CHECK
444#if defined(JSON_HEDLEY_TI_CLPRU_VERSION)
445 #define JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_CLPRU_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
447 #define JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(major,minor,patch) (0)
450#if defined(JSON_HEDLEY_CRAY_VERSION)
451 #undef JSON_HEDLEY_CRAY_VERSION
454 #if defined(_RELEASE_PATCHLEVEL)
455 #define JSON_HEDLEY_CRAY_VERSION JSON_HEDLEY_VERSION_ENCODE(_RELEASE_MAJOR, _RELEASE_MINOR, _RELEASE_PATCHLEVEL)
457 #define JSON_HEDLEY_CRAY_VERSION JSON_HEDLEY_VERSION_ENCODE(_RELEASE_MAJOR, _RELEASE_MINOR, 0)
461#if defined(JSON_HEDLEY_CRAY_VERSION_CHECK)
462 #undef JSON_HEDLEY_CRAY_VERSION_CHECK
464#if defined(JSON_HEDLEY_CRAY_VERSION)
465 #define JSON_HEDLEY_CRAY_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_CRAY_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
467 #define JSON_HEDLEY_CRAY_VERSION_CHECK(major,minor,patch) (0)
470#if defined(JSON_HEDLEY_IAR_VERSION)
471 #undef JSON_HEDLEY_IAR_VERSION
473#if defined(__IAR_SYSTEMS_ICC__)
475 #define JSON_HEDLEY_IAR_VERSION JSON_HEDLEY_VERSION_ENCODE((__VER__ / 1000000), ((__VER__ / 1000) % 1000), (__VER__ % 1000))
477 #define JSON_HEDLEY_IAR_VERSION JSON_HEDLEY_VERSION_ENCODE(VER / 100, __VER__ % 100, 0)
481#if defined(JSON_HEDLEY_IAR_VERSION_CHECK)
482 #undef JSON_HEDLEY_IAR_VERSION_CHECK
484#if defined(JSON_HEDLEY_IAR_VERSION)
485 #define JSON_HEDLEY_IAR_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_IAR_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
487 #define JSON_HEDLEY_IAR_VERSION_CHECK(major,minor,patch) (0)
490#if defined(JSON_HEDLEY_TINYC_VERSION)
491 #undef JSON_HEDLEY_TINYC_VERSION
493#if defined(__TINYC__)
494 #define JSON_HEDLEY_TINYC_VERSION JSON_HEDLEY_VERSION_ENCODE(__TINYC__ / 1000, (__TINYC__ / 100) % 10, __TINYC__ % 100)
497#if defined(JSON_HEDLEY_TINYC_VERSION_CHECK)
498 #undef JSON_HEDLEY_TINYC_VERSION_CHECK
500#if defined(JSON_HEDLEY_TINYC_VERSION)
501 #define JSON_HEDLEY_TINYC_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TINYC_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
503 #define JSON_HEDLEY_TINYC_VERSION_CHECK(major,minor,patch) (0)
506#if defined(JSON_HEDLEY_DMC_VERSION)
507 #undef JSON_HEDLEY_DMC_VERSION
510 #define JSON_HEDLEY_DMC_VERSION JSON_HEDLEY_VERSION_ENCODE(__DMC__ >> 8, (__DMC__ >> 4) & 0xf, __DMC__ & 0xf)
513#if defined(JSON_HEDLEY_DMC_VERSION_CHECK)
514 #undef JSON_HEDLEY_DMC_VERSION_CHECK
516#if defined(JSON_HEDLEY_DMC_VERSION)
517 #define JSON_HEDLEY_DMC_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_DMC_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
519 #define JSON_HEDLEY_DMC_VERSION_CHECK(major,minor,patch) (0)
522#if defined(JSON_HEDLEY_COMPCERT_VERSION)
523 #undef JSON_HEDLEY_COMPCERT_VERSION
525#if defined(__COMPCERT_VERSION__)
526 #define JSON_HEDLEY_COMPCERT_VERSION JSON_HEDLEY_VERSION_ENCODE(__COMPCERT_VERSION__ / 10000, (__COMPCERT_VERSION__ / 100) % 100, __COMPCERT_VERSION__ % 100)
529#if defined(JSON_HEDLEY_COMPCERT_VERSION_CHECK)
530 #undef JSON_HEDLEY_COMPCERT_VERSION_CHECK
532#if defined(JSON_HEDLEY_COMPCERT_VERSION)
533 #define JSON_HEDLEY_COMPCERT_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_COMPCERT_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
535 #define JSON_HEDLEY_COMPCERT_VERSION_CHECK(major,minor,patch) (0)
538#if defined(JSON_HEDLEY_PELLES_VERSION)
539 #undef JSON_HEDLEY_PELLES_VERSION
542 #define JSON_HEDLEY_PELLES_VERSION JSON_HEDLEY_VERSION_ENCODE(__POCC__ / 100, __POCC__ % 100, 0)
545#if defined(JSON_HEDLEY_PELLES_VERSION_CHECK)
546 #undef JSON_HEDLEY_PELLES_VERSION_CHECK
548#if defined(JSON_HEDLEY_PELLES_VERSION)
549 #define JSON_HEDLEY_PELLES_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_PELLES_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
551 #define JSON_HEDLEY_PELLES_VERSION_CHECK(major,minor,patch) (0)
554#if defined(JSON_HEDLEY_GCC_VERSION)
555 #undef JSON_HEDLEY_GCC_VERSION
558 defined(JSON_HEDLEY_GNUC_VERSION) && \
559 !defined(__clang__) && \
560 !defined(JSON_HEDLEY_INTEL_VERSION) && \
561 !defined(JSON_HEDLEY_PGI_VERSION) && \
562 !defined(JSON_HEDLEY_ARM_VERSION) && \
563 !defined(JSON_HEDLEY_TI_VERSION) && \
564 !defined(JSON_HEDLEY_TI_ARMCL_VERSION) && \
565 !defined(JSON_HEDLEY_TI_CL430_VERSION) && \
566 !defined(JSON_HEDLEY_TI_CL2000_VERSION) && \
567 !defined(JSON_HEDLEY_TI_CL6X_VERSION) && \
568 !defined(JSON_HEDLEY_TI_CL7X_VERSION) && \
569 !defined(JSON_HEDLEY_TI_CLPRU_VERSION) && \
570 !defined(__COMPCERT__)
571 #define JSON_HEDLEY_GCC_VERSION JSON_HEDLEY_GNUC_VERSION
574#if defined(JSON_HEDLEY_GCC_VERSION_CHECK)
575 #undef JSON_HEDLEY_GCC_VERSION_CHECK
577#if defined(JSON_HEDLEY_GCC_VERSION)
578 #define JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_GCC_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
580 #define JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) (0)
583#if defined(JSON_HEDLEY_HAS_ATTRIBUTE)
584 #undef JSON_HEDLEY_HAS_ATTRIBUTE
586#if defined(__has_attribute)
587 #define JSON_HEDLEY_HAS_ATTRIBUTE(attribute) __has_attribute(attribute)
589 #define JSON_HEDLEY_HAS_ATTRIBUTE(attribute) (0)
592#if defined(JSON_HEDLEY_GNUC_HAS_ATTRIBUTE)
593 #undef JSON_HEDLEY_GNUC_HAS_ATTRIBUTE
595#if defined(__has_attribute)
596 #define JSON_HEDLEY_GNUC_HAS_ATTRIBUTE(attribute,major,minor,patch) __has_attribute(attribute)
598 #define JSON_HEDLEY_GNUC_HAS_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch)
601#if defined(JSON_HEDLEY_GCC_HAS_ATTRIBUTE)
602 #undef JSON_HEDLEY_GCC_HAS_ATTRIBUTE
604#if defined(__has_attribute)
605 #define JSON_HEDLEY_GCC_HAS_ATTRIBUTE(attribute,major,minor,patch) __has_attribute(attribute)
607 #define JSON_HEDLEY_GCC_HAS_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch)
610#if defined(JSON_HEDLEY_HAS_CPP_ATTRIBUTE)
611 #undef JSON_HEDLEY_HAS_CPP_ATTRIBUTE
614 defined(__has_cpp_attribute) && \
615 defined(__cplusplus) && \
616 (!defined(JSON_HEDLEY_SUNPRO_VERSION) || JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,15,0))
617 #define JSON_HEDLEY_HAS_CPP_ATTRIBUTE(attribute) __has_cpp_attribute(attribute)
619 #define JSON_HEDLEY_HAS_CPP_ATTRIBUTE(attribute) (0)
622#if defined(JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS)
623 #undef JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS
625#if !defined(__cplusplus) || !defined(__has_cpp_attribute)
626 #define JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS(ns,attribute) (0)
628 !defined(JSON_HEDLEY_PGI_VERSION) && \
629 !defined(JSON_HEDLEY_IAR_VERSION) && \
630 (!defined(JSON_HEDLEY_SUNPRO_VERSION) || JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,15,0)) && \
631 (!defined(JSON_HEDLEY_MSVC_VERSION) || JSON_HEDLEY_MSVC_VERSION_CHECK(19,20,0))
632 #define JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS(ns,attribute) JSON_HEDLEY_HAS_CPP_ATTRIBUTE(ns::attribute)
634 #define JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS(ns,attribute) (0)
637#if defined(JSON_HEDLEY_GNUC_HAS_CPP_ATTRIBUTE)
638 #undef JSON_HEDLEY_GNUC_HAS_CPP_ATTRIBUTE
640#if defined(__has_cpp_attribute) && defined(__cplusplus)
641 #define JSON_HEDLEY_GNUC_HAS_CPP_ATTRIBUTE(attribute,major,minor,patch) __has_cpp_attribute(attribute)
643 #define JSON_HEDLEY_GNUC_HAS_CPP_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch)
646#if defined(JSON_HEDLEY_GCC_HAS_CPP_ATTRIBUTE)
647 #undef JSON_HEDLEY_GCC_HAS_CPP_ATTRIBUTE
649#if defined(__has_cpp_attribute) && defined(__cplusplus)
650 #define JSON_HEDLEY_GCC_HAS_CPP_ATTRIBUTE(attribute,major,minor,patch) __has_cpp_attribute(attribute)
652 #define JSON_HEDLEY_GCC_HAS_CPP_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch)
655#if defined(JSON_HEDLEY_HAS_BUILTIN)
656 #undef JSON_HEDLEY_HAS_BUILTIN
658#if defined(__has_builtin)
659 #define JSON_HEDLEY_HAS_BUILTIN(builtin) __has_builtin(builtin)
661 #define JSON_HEDLEY_HAS_BUILTIN(builtin) (0)
664#if defined(JSON_HEDLEY_GNUC_HAS_BUILTIN)
665 #undef JSON_HEDLEY_GNUC_HAS_BUILTIN
667#if defined(__has_builtin)
668 #define JSON_HEDLEY_GNUC_HAS_BUILTIN(builtin,major,minor,patch) __has_builtin(builtin)
670 #define JSON_HEDLEY_GNUC_HAS_BUILTIN(builtin,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch)
673#if defined(JSON_HEDLEY_GCC_HAS_BUILTIN)
674 #undef JSON_HEDLEY_GCC_HAS_BUILTIN
676#if defined(__has_builtin)
677 #define JSON_HEDLEY_GCC_HAS_BUILTIN(builtin,major,minor,patch) __has_builtin(builtin)
679 #define JSON_HEDLEY_GCC_HAS_BUILTIN(builtin,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch)
682#if defined(JSON_HEDLEY_HAS_FEATURE)
683 #undef JSON_HEDLEY_HAS_FEATURE
685#if defined(__has_feature)
686 #define JSON_HEDLEY_HAS_FEATURE(feature) __has_feature(feature)
688 #define JSON_HEDLEY_HAS_FEATURE(feature) (0)
691#if defined(JSON_HEDLEY_GNUC_HAS_FEATURE)
692 #undef JSON_HEDLEY_GNUC_HAS_FEATURE
694#if defined(__has_feature)
695 #define JSON_HEDLEY_GNUC_HAS_FEATURE(feature,major,minor,patch) __has_feature(feature)
697 #define JSON_HEDLEY_GNUC_HAS_FEATURE(feature,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch)
700#if defined(JSON_HEDLEY_GCC_HAS_FEATURE)
701 #undef JSON_HEDLEY_GCC_HAS_FEATURE
703#if defined(__has_feature)
704 #define JSON_HEDLEY_GCC_HAS_FEATURE(feature,major,minor,patch) __has_feature(feature)
706 #define JSON_HEDLEY_GCC_HAS_FEATURE(feature,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch)
709#if defined(JSON_HEDLEY_HAS_EXTENSION)
710 #undef JSON_HEDLEY_HAS_EXTENSION
712#if defined(__has_extension)
713 #define JSON_HEDLEY_HAS_EXTENSION(extension) __has_extension(extension)
715 #define JSON_HEDLEY_HAS_EXTENSION(extension) (0)
718#if defined(JSON_HEDLEY_GNUC_HAS_EXTENSION)
719 #undef JSON_HEDLEY_GNUC_HAS_EXTENSION
721#if defined(__has_extension)
722 #define JSON_HEDLEY_GNUC_HAS_EXTENSION(extension,major,minor,patch) __has_extension(extension)
724 #define JSON_HEDLEY_GNUC_HAS_EXTENSION(extension,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch)
727#if defined(JSON_HEDLEY_GCC_HAS_EXTENSION)
728 #undef JSON_HEDLEY_GCC_HAS_EXTENSION
730#if defined(__has_extension)
731 #define JSON_HEDLEY_GCC_HAS_EXTENSION(extension,major,minor,patch) __has_extension(extension)
733 #define JSON_HEDLEY_GCC_HAS_EXTENSION(extension,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch)
736#if defined(JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE)
737 #undef JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE
739#if defined(__has_declspec_attribute)
740 #define JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE(attribute) __has_declspec_attribute(attribute)
742 #define JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE(attribute) (0)
745#if defined(JSON_HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE)
746 #undef JSON_HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE
748#if defined(__has_declspec_attribute)
749 #define JSON_HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE(attribute,major,minor,patch) __has_declspec_attribute(attribute)
751 #define JSON_HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch)
754#if defined(JSON_HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE)
755 #undef JSON_HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE
757#if defined(__has_declspec_attribute)
758 #define JSON_HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE(attribute,major,minor,patch) __has_declspec_attribute(attribute)
760 #define JSON_HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch)
763#if defined(JSON_HEDLEY_HAS_WARNING)
764 #undef JSON_HEDLEY_HAS_WARNING
766#if defined(__has_warning)
767 #define JSON_HEDLEY_HAS_WARNING(warning) __has_warning(warning)
769 #define JSON_HEDLEY_HAS_WARNING(warning) (0)
772#if defined(JSON_HEDLEY_GNUC_HAS_WARNING)
773 #undef JSON_HEDLEY_GNUC_HAS_WARNING
775#if defined(__has_warning)
776 #define JSON_HEDLEY_GNUC_HAS_WARNING(warning,major,minor,patch) __has_warning(warning)
778 #define JSON_HEDLEY_GNUC_HAS_WARNING(warning,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch)
781#if defined(JSON_HEDLEY_GCC_HAS_WARNING)
782 #undef JSON_HEDLEY_GCC_HAS_WARNING
784#if defined(__has_warning)
785 #define JSON_HEDLEY_GCC_HAS_WARNING(warning,major,minor,patch) __has_warning(warning)
787 #define JSON_HEDLEY_GCC_HAS_WARNING(warning,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch)
792#if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_)
793 #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_
795#if defined(__cplusplus)
796# if JSON_HEDLEY_HAS_WARNING("-Wc++98-compat")
797# if JSON_HEDLEY_HAS_WARNING("-Wc++17-extensions")
798# define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(xpr) \
799 JSON_HEDLEY_DIAGNOSTIC_PUSH \
800 _Pragma("clang diagnostic ignored \"-Wc++98-compat\"") \
801 _Pragma("clang diagnostic ignored \"-Wc++17-extensions\"") \
803 JSON_HEDLEY_DIAGNOSTIC_POP
805# define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(xpr) \
806 JSON_HEDLEY_DIAGNOSTIC_PUSH \
807 _Pragma("clang diagnostic ignored \"-Wc++98-compat\"") \
809 JSON_HEDLEY_DIAGNOSTIC_POP
813#if !defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_)
814 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(x) x
817#if defined(JSON_HEDLEY_CONST_CAST)
818 #undef JSON_HEDLEY_CONST_CAST
820#if defined(__cplusplus)
821# define JSON_HEDLEY_CONST_CAST(T, expr) (const_cast<T>(expr))
823 JSON_HEDLEY_HAS_WARNING("-Wcast-qual") || \
824 JSON_HEDLEY_GCC_VERSION_CHECK(4,6,0) || \
825 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0)
826# define JSON_HEDLEY_CONST_CAST(T, expr) (__extension__ ({ \
827 JSON_HEDLEY_DIAGNOSTIC_PUSH \
828 JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL \
830 JSON_HEDLEY_DIAGNOSTIC_POP \
833# define JSON_HEDLEY_CONST_CAST(T, expr) ((T) (expr))
836#if defined(JSON_HEDLEY_REINTERPRET_CAST)
837 #undef JSON_HEDLEY_REINTERPRET_CAST
839#if defined(__cplusplus)
840 #define JSON_HEDLEY_REINTERPRET_CAST(T, expr) (reinterpret_cast<T>(expr))
842 #define JSON_HEDLEY_REINTERPRET_CAST(T, expr) ((T) (expr))
845#if defined(JSON_HEDLEY_STATIC_CAST)
846 #undef JSON_HEDLEY_STATIC_CAST
848#if defined(__cplusplus)
849 #define JSON_HEDLEY_STATIC_CAST(T, expr) (static_cast<T>(expr))
851 #define JSON_HEDLEY_STATIC_CAST(T, expr) ((T) (expr))
854#if defined(JSON_HEDLEY_CPP_CAST)
855 #undef JSON_HEDLEY_CPP_CAST
857#if defined(__cplusplus)
858# if JSON_HEDLEY_HAS_WARNING("-Wold-style-cast")
859# define JSON_HEDLEY_CPP_CAST(T, expr) \
860 JSON_HEDLEY_DIAGNOSTIC_PUSH \
861 _Pragma("clang diagnostic ignored \"-Wold-style-cast\"") \
863 JSON_HEDLEY_DIAGNOSTIC_POP
864# elif JSON_HEDLEY_IAR_VERSION_CHECK(8,3,0)
865# define JSON_HEDLEY_CPP_CAST(T, expr) \
866 JSON_HEDLEY_DIAGNOSTIC_PUSH \
867 _Pragma("diag_suppress=Pe137") \
868 JSON_HEDLEY_DIAGNOSTIC_POP \
870# define JSON_HEDLEY_CPP_CAST(T, expr) ((T) (expr))
873# define JSON_HEDLEY_CPP_CAST(T, expr) (expr)
877 (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)) || \
878 defined(__clang__) || \
879 JSON_HEDLEY_GCC_VERSION_CHECK(3,0,0) || \
880 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
881 JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) || \
882 JSON_HEDLEY_PGI_VERSION_CHECK(18,4,0) || \
883 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
884 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
885 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,7,0) || \
886 JSON_HEDLEY_TI_CL430_VERSION_CHECK(2,0,1) || \
887 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,1,0) || \
888 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,0,0) || \
889 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
890 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
891 JSON_HEDLEY_CRAY_VERSION_CHECK(5,0,0) || \
892 JSON_HEDLEY_TINYC_VERSION_CHECK(0,9,17) || \
893 JSON_HEDLEY_SUNPRO_VERSION_CHECK(8,0,0) || \
894 (JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) && defined(__C99_PRAGMA_OPERATOR))
895 #define JSON_HEDLEY_PRAGMA(value) _Pragma(#value)
896#elif JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0)
897 #define JSON_HEDLEY_PRAGMA(value) __pragma(value)
899 #define JSON_HEDLEY_PRAGMA(value)
902#if defined(JSON_HEDLEY_DIAGNOSTIC_PUSH)
903 #undef JSON_HEDLEY_DIAGNOSTIC_PUSH
905#if defined(JSON_HEDLEY_DIAGNOSTIC_POP)
906 #undef JSON_HEDLEY_DIAGNOSTIC_POP
908#if defined(__clang__)
909 #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("clang diagnostic push")
910 #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("clang diagnostic pop")
911#elif JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0)
912 #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("warning(push)")
913 #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("warning(pop)")
914#elif JSON_HEDLEY_GCC_VERSION_CHECK(4,6,0)
915 #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("GCC diagnostic push")
916 #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("GCC diagnostic pop")
917#elif JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0)
918 #define JSON_HEDLEY_DIAGNOSTIC_PUSH __pragma(warning(push))
919 #define JSON_HEDLEY_DIAGNOSTIC_POP __pragma(warning(pop))
920#elif JSON_HEDLEY_ARM_VERSION_CHECK(5,6,0)
921 #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("push")
922 #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("pop")
924 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
925 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
926 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,4,0) || \
927 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,1,0) || \
928 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
929 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0)
930 #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("diag_push")
931 #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("diag_pop")
932#elif JSON_HEDLEY_PELLES_VERSION_CHECK(2,90,0)
933 #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("warning(push)")
934 #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("warning(pop)")
936 #define JSON_HEDLEY_DIAGNOSTIC_PUSH
937 #define JSON_HEDLEY_DIAGNOSTIC_POP
940#if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED)
941 #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED
943#if JSON_HEDLEY_HAS_WARNING("-Wdeprecated-declarations")
944 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("clang diagnostic ignored \"-Wdeprecated-declarations\"")
945#elif JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0)
946 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("warning(disable:1478 1786)")
947#elif JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0)
948 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress 1215,1444")
949#elif JSON_HEDLEY_GCC_VERSION_CHECK(4,3,0)
950 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"")
951#elif JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0)
952 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED __pragma(warning(disable:4996))
954 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
955 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
956 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
957 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
958 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
959 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
960 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
961 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
962 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
963 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
964 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0)
965 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress 1291,1718")
966#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,13,0) && !defined(__cplusplus)
967 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("error_messages(off,E_DEPRECATED_ATT,E_DEPRECATED_ATT_MESS)")
968#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,13,0) && defined(__cplusplus)
969 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("error_messages(off,symdeprecated,symdeprecated2)")
970#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
971 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress=Pe1444,Pe1215")
972#elif JSON_HEDLEY_PELLES_VERSION_CHECK(2,90,0)
973 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("warn(disable:2241)")
975 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED
978#if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS)
979 #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS
981#if JSON_HEDLEY_HAS_WARNING("-Wunknown-pragmas")
982 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("clang diagnostic ignored \"-Wunknown-pragmas\"")
983#elif JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0)
984 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("warning(disable:161)")
985#elif JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0)
986 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress 1675")
987#elif JSON_HEDLEY_GCC_VERSION_CHECK(4,3,0)
988 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("GCC diagnostic ignored \"-Wunknown-pragmas\"")
989#elif JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0)
990 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS __pragma(warning(disable:4068))
992 JSON_HEDLEY_TI_VERSION_CHECK(16,9,0) || \
993 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,0,0) || \
994 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
995 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,3,0)
996 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress 163")
997#elif JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,0,0)
998 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress 163")
999#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
1000 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress=Pe161")
1002 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS
1005#if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES)
1006 #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES
1008#if JSON_HEDLEY_HAS_WARNING("-Wunknown-attributes")
1009 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("clang diagnostic ignored \"-Wunknown-attributes\"")
1010#elif JSON_HEDLEY_GCC_VERSION_CHECK(4,6,0)
1011 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"")
1012#elif JSON_HEDLEY_INTEL_VERSION_CHECK(17,0,0)
1013 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("warning(disable:1292)")
1014#elif JSON_HEDLEY_MSVC_VERSION_CHECK(19,0,0)
1015 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES __pragma(warning(disable:5030))
1016#elif JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0)
1017 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress 1097")
1018#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,14,0) && defined(__cplusplus)
1019 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("error_messages(off,attrskipunsup)")
1021 JSON_HEDLEY_TI_VERSION_CHECK(18,1,0) || \
1022 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,3,0) || \
1023 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0)
1024 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress 1173")
1025#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
1026 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress=Pe1097")
1028 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES
1031#if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL)
1032 #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL
1034#if JSON_HEDLEY_HAS_WARNING("-Wcast-qual")
1035 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL _Pragma("clang diagnostic ignored \"-Wcast-qual\"")
1036#elif JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0)
1037 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL _Pragma("warning(disable:2203 2331)")
1038#elif JSON_HEDLEY_GCC_VERSION_CHECK(3,0,0)
1039 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL _Pragma("GCC diagnostic ignored \"-Wcast-qual\"")
1041 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL
1044#if defined(JSON_HEDLEY_DEPRECATED)
1045 #undef JSON_HEDLEY_DEPRECATED
1047#if defined(JSON_HEDLEY_DEPRECATED_FOR)
1048 #undef JSON_HEDLEY_DEPRECATED_FOR
1050#if JSON_HEDLEY_MSVC_VERSION_CHECK(14,0,0)
1051 #define JSON_HEDLEY_DEPRECATED(since) __declspec(deprecated("Since " # since))
1052 #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) __declspec(deprecated("Since " #since "; use " #replacement))
1053#elif defined(__cplusplus) && (__cplusplus >= 201402L)
1054 #define JSON_HEDLEY_DEPRECATED(since) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[deprecated("Since " #since)]])
1055 #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[deprecated("Since " #since "; use " #replacement)]])
1057 JSON_HEDLEY_HAS_EXTENSION(attribute_deprecated_with_message) || \
1058 JSON_HEDLEY_GCC_VERSION_CHECK(4,5,0) || \
1059 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1060 JSON_HEDLEY_ARM_VERSION_CHECK(5,6,0) || \
1061 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,13,0) || \
1062 JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) || \
1063 JSON_HEDLEY_TI_VERSION_CHECK(18,1,0) || \
1064 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(18,1,0) || \
1065 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,3,0) || \
1066 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1067 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,3,0)
1068 #define JSON_HEDLEY_DEPRECATED(since) __attribute__((__deprecated__("Since " #since)))
1069 #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) __attribute__((__deprecated__("Since " #since "; use " #replacement)))
1071 JSON_HEDLEY_HAS_ATTRIBUTE(deprecated) || \
1072 JSON_HEDLEY_GCC_VERSION_CHECK(3,1,0) || \
1073 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1074 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1075 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1076 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1077 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1078 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1079 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1080 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1081 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1082 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1083 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1084 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0)
1085 #define JSON_HEDLEY_DEPRECATED(since) __attribute__((__deprecated__))
1086 #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) __attribute__((__deprecated__))
1088 JSON_HEDLEY_MSVC_VERSION_CHECK(13,10,0) || \
1089 JSON_HEDLEY_PELLES_VERSION_CHECK(6,50,0)
1090 #define JSON_HEDLEY_DEPRECATED(since) __declspec(deprecated)
1091 #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) __declspec(deprecated)
1092#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
1093 #define JSON_HEDLEY_DEPRECATED(since) _Pragma("deprecated")
1094 #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) _Pragma("deprecated")
1096 #define JSON_HEDLEY_DEPRECATED(since)
1097 #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement)
1100#if defined(JSON_HEDLEY_UNAVAILABLE)
1101 #undef JSON_HEDLEY_UNAVAILABLE
1104 JSON_HEDLEY_HAS_ATTRIBUTE(warning) || \
1105 JSON_HEDLEY_GCC_VERSION_CHECK(4,3,0) || \
1106 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0)
1107 #define JSON_HEDLEY_UNAVAILABLE(available_since) __attribute__((__warning__("Not available until " #available_since)))
1109 #define JSON_HEDLEY_UNAVAILABLE(available_since)
1112#if defined(JSON_HEDLEY_WARN_UNUSED_RESULT)
1113 #undef JSON_HEDLEY_WARN_UNUSED_RESULT
1115#if defined(JSON_HEDLEY_WARN_UNUSED_RESULT_MSG)
1116 #undef JSON_HEDLEY_WARN_UNUSED_RESULT_MSG
1118#if (JSON_HEDLEY_HAS_CPP_ATTRIBUTE(nodiscard) >= 201907L)
1119 #define JSON_HEDLEY_WARN_UNUSED_RESULT JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[nodiscard]])
1120 #define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[nodiscard(msg)]])
1121#elif JSON_HEDLEY_HAS_CPP_ATTRIBUTE(nodiscard)
1122 #define JSON_HEDLEY_WARN_UNUSED_RESULT JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[nodiscard]])
1123 #define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[nodiscard]])
1125 JSON_HEDLEY_HAS_ATTRIBUTE(warn_unused_result) || \
1126 JSON_HEDLEY_GCC_VERSION_CHECK(3,4,0) || \
1127 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1128 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1129 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1130 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1131 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1132 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1133 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1134 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1135 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1136 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1137 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1138 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1139 (JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,15,0) && defined(__cplusplus)) || \
1140 JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0)
1141 #define JSON_HEDLEY_WARN_UNUSED_RESULT __attribute__((__warn_unused_result__))
1142 #define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg) __attribute__((__warn_unused_result__))
1143#elif defined(_Check_return_)
1144 #define JSON_HEDLEY_WARN_UNUSED_RESULT _Check_return_
1145 #define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg) _Check_return_
1147 #define JSON_HEDLEY_WARN_UNUSED_RESULT
1148 #define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg)
1151#if defined(JSON_HEDLEY_SENTINEL)
1152 #undef JSON_HEDLEY_SENTINEL
1155 JSON_HEDLEY_HAS_ATTRIBUTE(sentinel) || \
1156 JSON_HEDLEY_GCC_VERSION_CHECK(4,0,0) || \
1157 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1158 JSON_HEDLEY_ARM_VERSION_CHECK(5,4,0)
1159 #define JSON_HEDLEY_SENTINEL(position) __attribute__((__sentinel__(position)))
1161 #define JSON_HEDLEY_SENTINEL(position)
1164#if defined(JSON_HEDLEY_NO_RETURN)
1165 #undef JSON_HEDLEY_NO_RETURN
1167#if JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
1168 #define JSON_HEDLEY_NO_RETURN __noreturn
1169#elif JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0)
1170 #define JSON_HEDLEY_NO_RETURN __attribute__((__noreturn__))
1171#elif defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L
1172 #define JSON_HEDLEY_NO_RETURN _Noreturn
1173#elif defined(__cplusplus) && (__cplusplus >= 201103L)
1174 #define JSON_HEDLEY_NO_RETURN JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[noreturn]])
1176 JSON_HEDLEY_HAS_ATTRIBUTE(noreturn) || \
1177 JSON_HEDLEY_GCC_VERSION_CHECK(3,2,0) || \
1178 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \
1179 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1180 JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
1181 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1182 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1183 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1184 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1185 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1186 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1187 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1188 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1189 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1190 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1191 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0)
1192 #define JSON_HEDLEY_NO_RETURN __attribute__((__noreturn__))
1193#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0)
1194 #define JSON_HEDLEY_NO_RETURN _Pragma("does_not_return")
1195#elif JSON_HEDLEY_MSVC_VERSION_CHECK(13,10,0)
1196 #define JSON_HEDLEY_NO_RETURN __declspec(noreturn)
1197#elif JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6,0,0) && defined(__cplusplus)
1198 #define JSON_HEDLEY_NO_RETURN _Pragma("FUNC_NEVER_RETURNS;")
1199#elif JSON_HEDLEY_COMPCERT_VERSION_CHECK(3,2,0)
1200 #define JSON_HEDLEY_NO_RETURN __attribute((noreturn))
1201#elif JSON_HEDLEY_PELLES_VERSION_CHECK(9,0,0)
1202 #define JSON_HEDLEY_NO_RETURN __declspec(noreturn)
1204 #define JSON_HEDLEY_NO_RETURN
1207#if defined(JSON_HEDLEY_NO_ESCAPE)
1208 #undef JSON_HEDLEY_NO_ESCAPE
1210#if JSON_HEDLEY_HAS_ATTRIBUTE(noescape)
1211 #define JSON_HEDLEY_NO_ESCAPE __attribute__((__noescape__))
1213 #define JSON_HEDLEY_NO_ESCAPE
1216#if defined(JSON_HEDLEY_UNREACHABLE)
1217 #undef JSON_HEDLEY_UNREACHABLE
1219#if defined(JSON_HEDLEY_UNREACHABLE_RETURN)
1220 #undef JSON_HEDLEY_UNREACHABLE_RETURN
1222#if defined(JSON_HEDLEY_ASSUME)
1223 #undef JSON_HEDLEY_ASSUME
1226 JSON_HEDLEY_MSVC_VERSION_CHECK(13,10,0) || \
1227 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0)
1228 #define JSON_HEDLEY_ASSUME(expr) __assume(expr)
1229#elif JSON_HEDLEY_HAS_BUILTIN(__builtin_assume)
1230 #define JSON_HEDLEY_ASSUME(expr) __builtin_assume(expr)
1232 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,2,0) || \
1233 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(4,0,0)
1234 #if defined(__cplusplus)
1235 #define JSON_HEDLEY_ASSUME(expr) std::_nassert(expr)
1237 #define JSON_HEDLEY_ASSUME(expr) _nassert(expr)
1241 (JSON_HEDLEY_HAS_BUILTIN(__builtin_unreachable) && (!defined(JSON_HEDLEY_ARM_VERSION))) || \
1242 JSON_HEDLEY_GCC_VERSION_CHECK(4,5,0) || \
1243 JSON_HEDLEY_PGI_VERSION_CHECK(18,10,0) || \
1244 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1245 JSON_HEDLEY_IBM_VERSION_CHECK(13,1,5)
1246 #define JSON_HEDLEY_UNREACHABLE() __builtin_unreachable()
1247#elif defined(JSON_HEDLEY_ASSUME)
1248 #define JSON_HEDLEY_UNREACHABLE() JSON_HEDLEY_ASSUME(0)
1250#if !defined(JSON_HEDLEY_ASSUME)
1251 #if defined(JSON_HEDLEY_UNREACHABLE)
1252 #define JSON_HEDLEY_ASSUME(expr) JSON_HEDLEY_STATIC_CAST(void, ((expr) ? 1 : (JSON_HEDLEY_UNREACHABLE(), 1)))
1254 #define JSON_HEDLEY_ASSUME(expr) JSON_HEDLEY_STATIC_CAST(void, expr)
1257#if defined(JSON_HEDLEY_UNREACHABLE)
1259 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,2,0) || \
1260 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(4,0,0)
1261 #define JSON_HEDLEY_UNREACHABLE_RETURN(value) return (JSON_HEDLEY_STATIC_CAST(void, JSON_HEDLEY_ASSUME(0)), (value))
1263 #define JSON_HEDLEY_UNREACHABLE_RETURN(value) JSON_HEDLEY_UNREACHABLE()
1266 #define JSON_HEDLEY_UNREACHABLE_RETURN(value) return (value)
1268#if !defined(JSON_HEDLEY_UNREACHABLE)
1269 #define JSON_HEDLEY_UNREACHABLE() JSON_HEDLEY_ASSUME(0)
1273#if JSON_HEDLEY_HAS_WARNING("-Wpedantic")
1274 #pragma clang diagnostic ignored "-Wpedantic"
1276#if JSON_HEDLEY_HAS_WARNING("-Wc++98-compat-pedantic") && defined(__cplusplus)
1277 #pragma clang diagnostic ignored "-Wc++98-compat-pedantic"
1279#if JSON_HEDLEY_GCC_HAS_WARNING("-Wvariadic-macros",4,0,0)
1280 #if defined(__clang__)
1281 #pragma clang diagnostic ignored "-Wvariadic-macros"
1282 #elif defined(JSON_HEDLEY_GCC_VERSION)
1283 #pragma GCC diagnostic ignored "-Wvariadic-macros"
1286#if defined(JSON_HEDLEY_NON_NULL)
1287 #undef JSON_HEDLEY_NON_NULL
1290 JSON_HEDLEY_HAS_ATTRIBUTE(nonnull) || \
1291 JSON_HEDLEY_GCC_VERSION_CHECK(3,3,0) || \
1292 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1293 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0)
1294 #define JSON_HEDLEY_NON_NULL(...) __attribute__((__nonnull__(__VA_ARGS__)))
1296 #define JSON_HEDLEY_NON_NULL(...)
1300#if defined(JSON_HEDLEY_PRINTF_FORMAT)
1301 #undef JSON_HEDLEY_PRINTF_FORMAT
1303#if defined(__MINGW32__) && JSON_HEDLEY_GCC_HAS_ATTRIBUTE(format,4,4,0) && !defined(__USE_MINGW_ANSI_STDIO)
1304 #define JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) __attribute__((__format__(ms_printf, string_idx, first_to_check)))
1305#elif defined(__MINGW32__) && JSON_HEDLEY_GCC_HAS_ATTRIBUTE(format,4,4,0) && defined(__USE_MINGW_ANSI_STDIO)
1306 #define JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) __attribute__((__format__(gnu_printf, string_idx, first_to_check)))
1308 JSON_HEDLEY_HAS_ATTRIBUTE(format) || \
1309 JSON_HEDLEY_GCC_VERSION_CHECK(3,1,0) || \
1310 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1311 JSON_HEDLEY_ARM_VERSION_CHECK(5,6,0) || \
1312 JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
1313 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1314 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1315 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1316 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1317 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1318 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1319 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1320 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1321 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1322 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1323 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0)
1324 #define JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) __attribute__((__format__(__printf__, string_idx, first_to_check)))
1325#elif JSON_HEDLEY_PELLES_VERSION_CHECK(6,0,0)
1326 #define JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) __declspec(vaformat(printf,string_idx,first_to_check))
1328 #define JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check)
1331#if defined(JSON_HEDLEY_CONSTEXPR)
1332 #undef JSON_HEDLEY_CONSTEXPR
1334#if defined(__cplusplus)
1335 #if __cplusplus >= 201103L
1336 #define JSON_HEDLEY_CONSTEXPR JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(constexpr)
1339#if !defined(JSON_HEDLEY_CONSTEXPR)
1340 #define JSON_HEDLEY_CONSTEXPR
1343#if defined(JSON_HEDLEY_PREDICT)
1344 #undef JSON_HEDLEY_PREDICT
1346#if defined(JSON_HEDLEY_LIKELY)
1347 #undef JSON_HEDLEY_LIKELY
1349#if defined(JSON_HEDLEY_UNLIKELY)
1350 #undef JSON_HEDLEY_UNLIKELY
1352#if defined(JSON_HEDLEY_UNPREDICTABLE)
1353 #undef JSON_HEDLEY_UNPREDICTABLE
1355#if JSON_HEDLEY_HAS_BUILTIN(__builtin_unpredictable)
1356 #define JSON_HEDLEY_UNPREDICTABLE(expr) __builtin_unpredictable((expr))
1359 JSON_HEDLEY_HAS_BUILTIN(__builtin_expect_with_probability) || \
1360 JSON_HEDLEY_GCC_VERSION_CHECK(9,0,0)
1361# define JSON_HEDLEY_PREDICT(expr, value, probability) __builtin_expect_with_probability( (expr), (value), (probability))
1362# define JSON_HEDLEY_PREDICT_TRUE(expr, probability) __builtin_expect_with_probability(!!(expr), 1 , (probability))
1363# define JSON_HEDLEY_PREDICT_FALSE(expr, probability) __builtin_expect_with_probability(!!(expr), 0 , (probability))
1364# define JSON_HEDLEY_LIKELY(expr) __builtin_expect (!!(expr), 1 )
1365# define JSON_HEDLEY_UNLIKELY(expr) __builtin_expect (!!(expr), 0 )
1367 JSON_HEDLEY_HAS_BUILTIN(__builtin_expect) || \
1368 JSON_HEDLEY_GCC_VERSION_CHECK(3,0,0) || \
1369 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1370 (JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,15,0) && defined(__cplusplus)) || \
1371 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1372 JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
1373 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1374 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,7,0) || \
1375 JSON_HEDLEY_TI_CL430_VERSION_CHECK(3,1,0) || \
1376 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,1,0) || \
1377 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6,1,0) || \
1378 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1379 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1380 JSON_HEDLEY_TINYC_VERSION_CHECK(0,9,27) || \
1381 JSON_HEDLEY_CRAY_VERSION_CHECK(8,1,0)
1382# define JSON_HEDLEY_PREDICT(expr, expected, probability) \
1383 (((probability) >= 0.9) ? __builtin_expect((expr), (expected)) : (JSON_HEDLEY_STATIC_CAST(void, expected), (expr)))
1384# define JSON_HEDLEY_PREDICT_TRUE(expr, probability) \
1386 double hedley_probability_ = (probability); \
1387 ((hedley_probability_ >= 0.9) ? __builtin_expect(!!(expr), 1) : ((hedley_probability_ <= 0.1) ? __builtin_expect(!!(expr), 0) : !!(expr))); \
1389# define JSON_HEDLEY_PREDICT_FALSE(expr, probability) \
1391 double hedley_probability_ = (probability); \
1392 ((hedley_probability_ >= 0.9) ? __builtin_expect(!!(expr), 0) : ((hedley_probability_ <= 0.1) ? __builtin_expect(!!(expr), 1) : !!(expr))); \
1394# define JSON_HEDLEY_LIKELY(expr) __builtin_expect(!!(expr), 1)
1395# define JSON_HEDLEY_UNLIKELY(expr) __builtin_expect(!!(expr), 0)
1397# define JSON_HEDLEY_PREDICT(expr, expected, probability) (JSON_HEDLEY_STATIC_CAST(void, expected), (expr))
1398# define JSON_HEDLEY_PREDICT_TRUE(expr, probability) (!!(expr))
1399# define JSON_HEDLEY_PREDICT_FALSE(expr, probability) (!!(expr))
1400# define JSON_HEDLEY_LIKELY(expr) (!!(expr))
1401# define JSON_HEDLEY_UNLIKELY(expr) (!!(expr))
1403#if !defined(JSON_HEDLEY_UNPREDICTABLE)
1404 #define JSON_HEDLEY_UNPREDICTABLE(expr) JSON_HEDLEY_PREDICT(expr, 1, 0.5)
1407#if defined(JSON_HEDLEY_MALLOC)
1408 #undef JSON_HEDLEY_MALLOC
1411 JSON_HEDLEY_HAS_ATTRIBUTE(malloc) || \
1412 JSON_HEDLEY_GCC_VERSION_CHECK(3,1,0) || \
1413 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1414 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \
1415 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1416 JSON_HEDLEY_IBM_VERSION_CHECK(12,1,0) || \
1417 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1418 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1419 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1420 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1421 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1422 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1423 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1424 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1425 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1426 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1427 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0)
1428 #define JSON_HEDLEY_MALLOC __attribute__((__malloc__))
1429#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0)
1430 #define JSON_HEDLEY_MALLOC _Pragma("returns_new_memory")
1431#elif JSON_HEDLEY_MSVC_VERSION_CHECK(14, 0, 0)
1432 #define JSON_HEDLEY_MALLOC __declspec(restrict)
1434 #define JSON_HEDLEY_MALLOC
1437#if defined(JSON_HEDLEY_PURE)
1438 #undef JSON_HEDLEY_PURE
1441 JSON_HEDLEY_HAS_ATTRIBUTE(pure) || \
1442 JSON_HEDLEY_GCC_VERSION_CHECK(2,96,0) || \
1443 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1444 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \
1445 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1446 JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
1447 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1448 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1449 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1450 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1451 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1452 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1453 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1454 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1455 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1456 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1457 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1458 JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0)
1459# define JSON_HEDLEY_PURE __attribute__((__pure__))
1460#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0)
1461# define JSON_HEDLEY_PURE _Pragma("does_not_write_global_data")
1462#elif defined(__cplusplus) && \
1464 JSON_HEDLEY_TI_CL430_VERSION_CHECK(2,0,1) || \
1465 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(4,0,0) || \
1466 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) \
1468# define JSON_HEDLEY_PURE _Pragma("FUNC_IS_PURE;")
1470# define JSON_HEDLEY_PURE
1473#if defined(JSON_HEDLEY_CONST)
1474 #undef JSON_HEDLEY_CONST
1477 JSON_HEDLEY_HAS_ATTRIBUTE(const) || \
1478 JSON_HEDLEY_GCC_VERSION_CHECK(2,5,0) || \
1479 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1480 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \
1481 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1482 JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
1483 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1484 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1485 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1486 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1487 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1488 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1489 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1490 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1491 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1492 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1493 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1494 JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0)
1495 #define JSON_HEDLEY_CONST __attribute__((__const__))
1497 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0)
1498 #define JSON_HEDLEY_CONST _Pragma("no_side_effect")
1500 #define JSON_HEDLEY_CONST JSON_HEDLEY_PURE
1503#if defined(JSON_HEDLEY_RESTRICT)
1504 #undef JSON_HEDLEY_RESTRICT
1506#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) && !defined(__cplusplus)
1507 #define JSON_HEDLEY_RESTRICT restrict
1509 JSON_HEDLEY_GCC_VERSION_CHECK(3,1,0) || \
1510 JSON_HEDLEY_MSVC_VERSION_CHECK(14,0,0) || \
1511 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1512 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1513 JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
1514 JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) || \
1515 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1516 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,2,4) || \
1517 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,1,0) || \
1518 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1519 (JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,14,0) && defined(__cplusplus)) || \
1520 JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) || \
1522 #define JSON_HEDLEY_RESTRICT __restrict
1523#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,3,0) && !defined(__cplusplus)
1524 #define JSON_HEDLEY_RESTRICT _Restrict
1526 #define JSON_HEDLEY_RESTRICT
1529#if defined(JSON_HEDLEY_INLINE)
1530 #undef JSON_HEDLEY_INLINE
1533 (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)) || \
1534 (defined(__cplusplus) && (__cplusplus >= 199711L))
1535 #define JSON_HEDLEY_INLINE inline
1537 defined(JSON_HEDLEY_GCC_VERSION) || \
1538 JSON_HEDLEY_ARM_VERSION_CHECK(6,2,0)
1539 #define JSON_HEDLEY_INLINE __inline__
1541 JSON_HEDLEY_MSVC_VERSION_CHECK(12,0,0) || \
1542 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1543 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,1,0) || \
1544 JSON_HEDLEY_TI_CL430_VERSION_CHECK(3,1,0) || \
1545 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,2,0) || \
1546 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,0,0) || \
1547 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1548 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0)
1549 #define JSON_HEDLEY_INLINE __inline
1551 #define JSON_HEDLEY_INLINE
1554#if defined(JSON_HEDLEY_ALWAYS_INLINE)
1555 #undef JSON_HEDLEY_ALWAYS_INLINE
1558 JSON_HEDLEY_HAS_ATTRIBUTE(always_inline) || \
1559 JSON_HEDLEY_GCC_VERSION_CHECK(4,0,0) || \
1560 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1561 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \
1562 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1563 JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
1564 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1565 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1566 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1567 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1568 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1569 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1570 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1571 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1572 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1573 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1574 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0)
1575# define JSON_HEDLEY_ALWAYS_INLINE __attribute__((__always_inline__)) JSON_HEDLEY_INLINE
1576#elif JSON_HEDLEY_MSVC_VERSION_CHECK(12,0,0)
1577# define JSON_HEDLEY_ALWAYS_INLINE __forceinline
1578#elif defined(__cplusplus) && \
1580 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1581 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1582 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1583 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6,1,0) || \
1584 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1585 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) \
1587# define JSON_HEDLEY_ALWAYS_INLINE _Pragma("FUNC_ALWAYS_INLINE;")
1588#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
1589# define JSON_HEDLEY_ALWAYS_INLINE _Pragma("inline=forced")
1591# define JSON_HEDLEY_ALWAYS_INLINE JSON_HEDLEY_INLINE
1594#if defined(JSON_HEDLEY_NEVER_INLINE)
1595 #undef JSON_HEDLEY_NEVER_INLINE
1598 JSON_HEDLEY_HAS_ATTRIBUTE(noinline) || \
1599 JSON_HEDLEY_GCC_VERSION_CHECK(4,0,0) || \
1600 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1601 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \
1602 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1603 JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
1604 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1605 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1606 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1607 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1608 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1609 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1610 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1611 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1612 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1613 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1614 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0)
1615 #define JSON_HEDLEY_NEVER_INLINE __attribute__((__noinline__))
1616#elif JSON_HEDLEY_MSVC_VERSION_CHECK(13,10,0)
1617 #define JSON_HEDLEY_NEVER_INLINE __declspec(noinline)
1618#elif JSON_HEDLEY_PGI_VERSION_CHECK(10,2,0)
1619 #define JSON_HEDLEY_NEVER_INLINE _Pragma("noinline")
1620#elif JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6,0,0) && defined(__cplusplus)
1621 #define JSON_HEDLEY_NEVER_INLINE _Pragma("FUNC_CANNOT_INLINE;")
1622#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
1623 #define JSON_HEDLEY_NEVER_INLINE _Pragma("inline=never")
1624#elif JSON_HEDLEY_COMPCERT_VERSION_CHECK(3,2,0)
1625 #define JSON_HEDLEY_NEVER_INLINE __attribute((noinline))
1626#elif JSON_HEDLEY_PELLES_VERSION_CHECK(9,0,0)
1627 #define JSON_HEDLEY_NEVER_INLINE __declspec(noinline)
1629 #define JSON_HEDLEY_NEVER_INLINE
1632#if defined(JSON_HEDLEY_PRIVATE)
1633 #undef JSON_HEDLEY_PRIVATE
1635#if defined(JSON_HEDLEY_PUBLIC)
1636 #undef JSON_HEDLEY_PUBLIC
1638#if defined(JSON_HEDLEY_IMPORT)
1639 #undef JSON_HEDLEY_IMPORT
1641#if defined(_WIN32) || defined(__CYGWIN__)
1642# define JSON_HEDLEY_PRIVATE
1643# define JSON_HEDLEY_PUBLIC __declspec(dllexport)
1644# define JSON_HEDLEY_IMPORT __declspec(dllimport)
1647 JSON_HEDLEY_HAS_ATTRIBUTE(visibility) || \
1648 JSON_HEDLEY_GCC_VERSION_CHECK(3,3,0) || \
1649 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \
1650 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1651 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1652 JSON_HEDLEY_IBM_VERSION_CHECK(13,1,0) || \
1654 defined(__TI_EABI__) && \
1656 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1657 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) \
1660# define JSON_HEDLEY_PRIVATE __attribute__((__visibility__("hidden")))
1661# define JSON_HEDLEY_PUBLIC __attribute__((__visibility__("default")))
1663# define JSON_HEDLEY_PRIVATE
1664# define JSON_HEDLEY_PUBLIC
1666# define JSON_HEDLEY_IMPORT extern
1669#if defined(JSON_HEDLEY_NO_THROW)
1670 #undef JSON_HEDLEY_NO_THROW
1673 JSON_HEDLEY_HAS_ATTRIBUTE(nothrow) || \
1674 JSON_HEDLEY_GCC_VERSION_CHECK(3,3,0) || \
1675 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0)
1676 #define JSON_HEDLEY_NO_THROW __attribute__((__nothrow__))
1678 JSON_HEDLEY_MSVC_VERSION_CHECK(13,1,0) || \
1679 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0)
1680 #define JSON_HEDLEY_NO_THROW __declspec(nothrow)
1682 #define JSON_HEDLEY_NO_THROW
1685#if defined(JSON_HEDLEY_FALL_THROUGH)
1686 #undef JSON_HEDLEY_FALL_THROUGH
1689 JSON_HEDLEY_HAS_ATTRIBUTE(fallthrough) || \
1690 JSON_HEDLEY_GCC_VERSION_CHECK(7,0,0)
1691 #define JSON_HEDLEY_FALL_THROUGH __attribute__((__fallthrough__))
1692#elif JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS(clang,fallthrough)
1693 #define JSON_HEDLEY_FALL_THROUGH JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[clang::fallthrough]])
1694#elif JSON_HEDLEY_HAS_CPP_ATTRIBUTE(fallthrough)
1695 #define JSON_HEDLEY_FALL_THROUGH JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[fallthrough]])
1696#elif defined(__fallthrough)
1697 #define JSON_HEDLEY_FALL_THROUGH __fallthrough
1699 #define JSON_HEDLEY_FALL_THROUGH
1702#if defined(JSON_HEDLEY_RETURNS_NON_NULL)
1703 #undef JSON_HEDLEY_RETURNS_NON_NULL
1706 JSON_HEDLEY_HAS_ATTRIBUTE(returns_nonnull) || \
1707 JSON_HEDLEY_GCC_VERSION_CHECK(4,9,0)
1708 #define JSON_HEDLEY_RETURNS_NON_NULL __attribute__((__returns_nonnull__))
1709#elif defined(_Ret_notnull_)
1710 #define JSON_HEDLEY_RETURNS_NON_NULL _Ret_notnull_
1712 #define JSON_HEDLEY_RETURNS_NON_NULL
1715#if defined(JSON_HEDLEY_ARRAY_PARAM)
1716 #undef JSON_HEDLEY_ARRAY_PARAM
1719 defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) && \
1720 !defined(__STDC_NO_VLA__) && \
1721 !defined(__cplusplus) && \
1722 !defined(JSON_HEDLEY_PGI_VERSION) && \
1723 !defined(JSON_HEDLEY_TINYC_VERSION)
1724 #define JSON_HEDLEY_ARRAY_PARAM(name) (name)
1726 #define JSON_HEDLEY_ARRAY_PARAM(name)
1729#if defined(JSON_HEDLEY_IS_CONSTANT)
1730 #undef JSON_HEDLEY_IS_CONSTANT
1732#if defined(JSON_HEDLEY_REQUIRE_CONSTEXPR)
1733 #undef JSON_HEDLEY_REQUIRE_CONSTEXPR
1737#if defined(JSON_HEDLEY_IS_CONSTEXPR_)
1738 #undef JSON_HEDLEY_IS_CONSTEXPR_
1741 JSON_HEDLEY_HAS_BUILTIN(__builtin_constant_p) || \
1742 JSON_HEDLEY_GCC_VERSION_CHECK(3,4,0) || \
1743 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1744 JSON_HEDLEY_TINYC_VERSION_CHECK(0,9,19) || \
1745 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1746 JSON_HEDLEY_IBM_VERSION_CHECK(13,1,0) || \
1747 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6,1,0) || \
1748 (JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0) && !defined(__cplusplus)) || \
1749 JSON_HEDLEY_CRAY_VERSION_CHECK(8,1,0)
1750 #define JSON_HEDLEY_IS_CONSTANT(expr) __builtin_constant_p(expr)
1752#if !defined(__cplusplus)
1754 JSON_HEDLEY_HAS_BUILTIN(__builtin_types_compatible_p) || \
1755 JSON_HEDLEY_GCC_VERSION_CHECK(3,4,0) || \
1756 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1757 JSON_HEDLEY_IBM_VERSION_CHECK(13,1,0) || \
1758 JSON_HEDLEY_CRAY_VERSION_CHECK(8,1,0) || \
1759 JSON_HEDLEY_ARM_VERSION_CHECK(5,4,0) || \
1760 JSON_HEDLEY_TINYC_VERSION_CHECK(0,9,24)
1761#if defined(__INTPTR_TYPE__)
1762 #define JSON_HEDLEY_IS_CONSTEXPR_(expr) __builtin_types_compatible_p(__typeof__((1 ? (void*) ((__INTPTR_TYPE__) ((expr) * 0)) : (int*) 0)), int*)
1765 #define JSON_HEDLEY_IS_CONSTEXPR_(expr) __builtin_types_compatible_p(__typeof__((1 ? (void*) ((intptr_t) ((expr) * 0)) : (int*) 0)), int*)
1769 defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L) && \
1770 !defined(JSON_HEDLEY_SUNPRO_VERSION) && \
1771 !defined(JSON_HEDLEY_PGI_VERSION) && \
1772 !defined(JSON_HEDLEY_IAR_VERSION)) || \
1773 JSON_HEDLEY_HAS_EXTENSION(c_generic_selections) || \
1774 JSON_HEDLEY_GCC_VERSION_CHECK(4,9,0) || \
1775 JSON_HEDLEY_INTEL_VERSION_CHECK(17,0,0) || \
1776 JSON_HEDLEY_IBM_VERSION_CHECK(12,1,0) || \
1777 JSON_HEDLEY_ARM_VERSION_CHECK(5,3,0)
1778#if defined(__INTPTR_TYPE__)
1779 #define JSON_HEDLEY_IS_CONSTEXPR_(expr) _Generic((1 ? (void*) ((__INTPTR_TYPE__) ((expr) * 0)) : (int*) 0), int*: 1, void*: 0)
1782 #define JSON_HEDLEY_IS_CONSTEXPR_(expr) _Generic((1 ? (void*) ((intptr_t) * 0) : (int*) 0), int*: 1, void*: 0)
1785 defined(JSON_HEDLEY_GCC_VERSION) || \
1786 defined(JSON_HEDLEY_INTEL_VERSION) || \
1787 defined(JSON_HEDLEY_TINYC_VERSION) || \
1788 defined(JSON_HEDLEY_TI_ARMCL_VERSION) || \
1789 JSON_HEDLEY_TI_CL430_VERSION_CHECK(18,12,0) || \
1790 defined(JSON_HEDLEY_TI_CL2000_VERSION) || \
1791 defined(JSON_HEDLEY_TI_CL6X_VERSION) || \
1792 defined(JSON_HEDLEY_TI_CL7X_VERSION) || \
1793 defined(JSON_HEDLEY_TI_CLPRU_VERSION) || \
1795# define JSON_HEDLEY_IS_CONSTEXPR_(expr) ( \
1799 ((void*) ((expr) * 0L) ) : \
1800((struct { char v[sizeof(void) * 2]; } *) 1) \
1806#if defined(JSON_HEDLEY_IS_CONSTEXPR_)
1807 #if !defined(JSON_HEDLEY_IS_CONSTANT)
1808 #define JSON_HEDLEY_IS_CONSTANT(expr) JSON_HEDLEY_IS_CONSTEXPR_(expr)
1810 #define JSON_HEDLEY_REQUIRE_CONSTEXPR(expr) (JSON_HEDLEY_IS_CONSTEXPR_(expr) ? (expr) : (-1))
1812 #if !defined(JSON_HEDLEY_IS_CONSTANT)
1813 #define JSON_HEDLEY_IS_CONSTANT(expr) (0)
1815 #define JSON_HEDLEY_REQUIRE_CONSTEXPR(expr) (expr)
1818#if defined(JSON_HEDLEY_BEGIN_C_DECLS)
1819 #undef JSON_HEDLEY_BEGIN_C_DECLS
1821#if defined(JSON_HEDLEY_END_C_DECLS)
1822 #undef JSON_HEDLEY_END_C_DECLS
1824#if defined(JSON_HEDLEY_C_DECL)
1825 #undef JSON_HEDLEY_C_DECL
1827#if defined(__cplusplus)
1828 #define JSON_HEDLEY_BEGIN_C_DECLS extern "C" {
1829 #define JSON_HEDLEY_END_C_DECLS }
1830 #define JSON_HEDLEY_C_DECL extern "C"
1832 #define JSON_HEDLEY_BEGIN_C_DECLS
1833 #define JSON_HEDLEY_END_C_DECLS
1834 #define JSON_HEDLEY_C_DECL
1837#if defined(JSON_HEDLEY_STATIC_ASSERT)
1838 #undef JSON_HEDLEY_STATIC_ASSERT
1841 !defined(__cplusplus) && ( \
1842 (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L)) || \
1843 JSON_HEDLEY_HAS_FEATURE(c_static_assert) || \
1844 JSON_HEDLEY_GCC_VERSION_CHECK(6,0,0) || \
1845 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1846 defined(_Static_assert) \
1848# define JSON_HEDLEY_STATIC_ASSERT(expr, message) _Static_assert(expr, message)
1850 (defined(__cplusplus) && (__cplusplus >= 201103L)) || \
1851 JSON_HEDLEY_MSVC_VERSION_CHECK(16,0,0)
1852# define JSON_HEDLEY_STATIC_ASSERT(expr, message) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(static_assert(expr, message))
1854# define JSON_HEDLEY_STATIC_ASSERT(expr, message)
1857#if defined(JSON_HEDLEY_NULL)
1858 #undef JSON_HEDLEY_NULL
1860#if defined(__cplusplus)
1861 #if __cplusplus >= 201103L
1862 #define JSON_HEDLEY_NULL JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(nullptr)
1864 #define JSON_HEDLEY_NULL NULL
1866 #define JSON_HEDLEY_NULL JSON_HEDLEY_STATIC_CAST(void*, 0)
1869 #define JSON_HEDLEY_NULL NULL
1871 #define JSON_HEDLEY_NULL ((void*) 0)
1874#if defined(JSON_HEDLEY_MESSAGE)
1875 #undef JSON_HEDLEY_MESSAGE
1877#if JSON_HEDLEY_HAS_WARNING("-Wunknown-pragmas")
1878# define JSON_HEDLEY_MESSAGE(msg) \
1879 JSON_HEDLEY_DIAGNOSTIC_PUSH \
1880 JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS \
1881 JSON_HEDLEY_PRAGMA(message msg) \
1882 JSON_HEDLEY_DIAGNOSTIC_POP
1884 JSON_HEDLEY_GCC_VERSION_CHECK(4,4,0) || \
1885 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0)
1886# define JSON_HEDLEY_MESSAGE(msg) JSON_HEDLEY_PRAGMA(message msg)
1887#elif JSON_HEDLEY_CRAY_VERSION_CHECK(5,0,0)
1888# define JSON_HEDLEY_MESSAGE(msg) JSON_HEDLEY_PRAGMA(_CRI message msg)
1889#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
1890# define JSON_HEDLEY_MESSAGE(msg) JSON_HEDLEY_PRAGMA(message(msg))
1891#elif JSON_HEDLEY_PELLES_VERSION_CHECK(2,0,0)
1892# define JSON_HEDLEY_MESSAGE(msg) JSON_HEDLEY_PRAGMA(message(msg))
1894# define JSON_HEDLEY_MESSAGE(msg)
1897#if defined(JSON_HEDLEY_WARNING)
1898 #undef JSON_HEDLEY_WARNING
1900#if JSON_HEDLEY_HAS_WARNING("-Wunknown-pragmas")
1901# define JSON_HEDLEY_WARNING(msg) \
1902 JSON_HEDLEY_DIAGNOSTIC_PUSH \
1903 JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS \
1904 JSON_HEDLEY_PRAGMA(clang warning msg) \
1905 JSON_HEDLEY_DIAGNOSTIC_POP
1907 JSON_HEDLEY_GCC_VERSION_CHECK(4,8,0) || \
1908 JSON_HEDLEY_PGI_VERSION_CHECK(18,4,0) || \
1909 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0)
1910# define JSON_HEDLEY_WARNING(msg) JSON_HEDLEY_PRAGMA(GCC warning msg)
1911#elif JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0)
1912# define JSON_HEDLEY_WARNING(msg) JSON_HEDLEY_PRAGMA(message(msg))
1914# define JSON_HEDLEY_WARNING(msg) JSON_HEDLEY_MESSAGE(msg)
1917#if defined(JSON_HEDLEY_REQUIRE)
1918 #undef JSON_HEDLEY_REQUIRE
1920#if defined(JSON_HEDLEY_REQUIRE_MSG)
1921 #undef JSON_HEDLEY_REQUIRE_MSG
1923#if JSON_HEDLEY_HAS_ATTRIBUTE(diagnose_if)
1924# if JSON_HEDLEY_HAS_WARNING("-Wgcc-compat")
1925# define JSON_HEDLEY_REQUIRE(expr) \
1926 JSON_HEDLEY_DIAGNOSTIC_PUSH \
1927 _Pragma("clang diagnostic ignored \"-Wgcc-compat\"") \
1928 __attribute__((diagnose_if(!(expr), #expr, "error"))) \
1929 JSON_HEDLEY_DIAGNOSTIC_POP
1930# define JSON_HEDLEY_REQUIRE_MSG(expr,msg) \
1931 JSON_HEDLEY_DIAGNOSTIC_PUSH \
1932 _Pragma("clang diagnostic ignored \"-Wgcc-compat\"") \
1933 __attribute__((diagnose_if(!(expr), msg, "error"))) \
1934 JSON_HEDLEY_DIAGNOSTIC_POP
1936# define JSON_HEDLEY_REQUIRE(expr) __attribute__((diagnose_if(!(expr), #expr, "error")))
1937# define JSON_HEDLEY_REQUIRE_MSG(expr,msg) __attribute__((diagnose_if(!(expr), msg, "error")))
1940# define JSON_HEDLEY_REQUIRE(expr)
1941# define JSON_HEDLEY_REQUIRE_MSG(expr,msg)
1944#if defined(JSON_HEDLEY_FLAGS)
1945 #undef JSON_HEDLEY_FLAGS
1947#if JSON_HEDLEY_HAS_ATTRIBUTE(flag_enum)
1948 #define JSON_HEDLEY_FLAGS __attribute__((__flag_enum__))
1951#if defined(JSON_HEDLEY_FLAGS_CAST)
1952 #undef JSON_HEDLEY_FLAGS_CAST
1954#if JSON_HEDLEY_INTEL_VERSION_CHECK(19,0,0)
1955# define JSON_HEDLEY_FLAGS_CAST(T, expr) (__extension__ ({ \
1956 JSON_HEDLEY_DIAGNOSTIC_PUSH \
1957 _Pragma("warning(disable:188)") \
1959 JSON_HEDLEY_DIAGNOSTIC_POP \
1962# define JSON_HEDLEY_FLAGS_CAST(T, expr) JSON_HEDLEY_STATIC_CAST(T, expr)
1965#if defined(JSON_HEDLEY_EMPTY_BASES)
1966 #undef JSON_HEDLEY_EMPTY_BASES
1968#if JSON_HEDLEY_MSVC_VERSION_CHECK(19,0,23918) && !JSON_HEDLEY_MSVC_VERSION_CHECK(20,0,0)
1969 #define JSON_HEDLEY_EMPTY_BASES __declspec(empty_bases)
1971 #define JSON_HEDLEY_EMPTY_BASES
1976#if defined(JSON_HEDLEY_GCC_NOT_CLANG_VERSION_CHECK)
1977 #undef JSON_HEDLEY_GCC_NOT_CLANG_VERSION_CHECK
1979#if defined(__clang__)
1980 #define JSON_HEDLEY_GCC_NOT_CLANG_VERSION_CHECK(major,minor,patch) (0)
1982 #define JSON_HEDLEY_GCC_NOT_CLANG_VERSION_CHECK(major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch)
1985#if defined(JSON_HEDLEY_CLANG_HAS_ATTRIBUTE)
1986 #undef JSON_HEDLEY_CLANG_HAS_ATTRIBUTE
1988#define JSON_HEDLEY_CLANG_HAS_ATTRIBUTE(attribute) JSON_HEDLEY_HAS_ATTRIBUTE(attribute)
1990#if defined(JSON_HEDLEY_CLANG_HAS_CPP_ATTRIBUTE)
1991 #undef JSON_HEDLEY_CLANG_HAS_CPP_ATTRIBUTE
1993#define JSON_HEDLEY_CLANG_HAS_CPP_ATTRIBUTE(attribute) JSON_HEDLEY_HAS_CPP_ATTRIBUTE(attribute)
1995#if defined(JSON_HEDLEY_CLANG_HAS_BUILTIN)
1996 #undef JSON_HEDLEY_CLANG_HAS_BUILTIN
1998#define JSON_HEDLEY_CLANG_HAS_BUILTIN(builtin) JSON_HEDLEY_HAS_BUILTIN(builtin)
2000#if defined(JSON_HEDLEY_CLANG_HAS_FEATURE)
2001 #undef JSON_HEDLEY_CLANG_HAS_FEATURE
2003#define JSON_HEDLEY_CLANG_HAS_FEATURE(feature) JSON_HEDLEY_HAS_FEATURE(feature)
2005#if defined(JSON_HEDLEY_CLANG_HAS_EXTENSION)
2006 #undef JSON_HEDLEY_CLANG_HAS_EXTENSION
2008#define JSON_HEDLEY_CLANG_HAS_EXTENSION(extension) JSON_HEDLEY_HAS_EXTENSION(extension)
2010#if defined(JSON_HEDLEY_CLANG_HAS_DECLSPEC_DECLSPEC_ATTRIBUTE)
2011 #undef JSON_HEDLEY_CLANG_HAS_DECLSPEC_DECLSPEC_ATTRIBUTE
2013#define JSON_HEDLEY_CLANG_HAS_DECLSPEC_ATTRIBUTE(attribute) JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE(attribute)
2015#if defined(JSON_HEDLEY_CLANG_HAS_WARNING)
2016 #undef JSON_HEDLEY_CLANG_HAS_WARNING
2018#define JSON_HEDLEY_CLANG_HAS_WARNING(warning) JSON_HEDLEY_HAS_WARNING(warning)
2027#if !defined(JSON_SKIP_UNSUPPORTED_COMPILER_CHECK)
2028 #if defined(__clang__)
2029 #if (__clang_major__ * 10000 + __clang_minor__ * 100 + __clang_patchlevel__) < 30400
2030 #error "unsupported Clang version - see https://github.com/nlohmann/json#supported-compilers"
2032 #elif defined(__GNUC__) && !(defined(__ICC) || defined(__INTEL_COMPILER))
2033 #if (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) < 40800
2034 #error "unsupported GCC version - see https://github.com/nlohmann/json#supported-compilers"
2040#if (defined(__cplusplus) && __cplusplus >= 202002L) || (defined(_MSVC_LANG) && _MSVC_LANG >= 202002L)
2041 #define JSON_HAS_CPP_20
2042 #define JSON_HAS_CPP_17
2043 #define JSON_HAS_CPP_14
2044#elif (defined(__cplusplus) && __cplusplus >= 201703L) || (defined(_HAS_CXX17) && _HAS_CXX17 == 1)
2045 #define JSON_HAS_CPP_17
2046 #define JSON_HAS_CPP_14
2047#elif (defined(__cplusplus) && __cplusplus >= 201402L) || (defined(_HAS_CXX14) && _HAS_CXX14 == 1)
2048 #define JSON_HAS_CPP_14
2052#if defined(__clang__) || defined(__GNUC__) || defined(__GNUG__)
2053 #pragma GCC diagnostic push
2054 #pragma GCC diagnostic ignored "-Wfloat-equal"
2058#if defined(__clang__)
2059 #pragma GCC diagnostic push
2060 #pragma GCC diagnostic ignored "-Wdocumentation"
2064#if (defined(__cpp_exceptions) || defined(__EXCEPTIONS) || defined(_CPPUNWIND)) && !defined(JSON_NOEXCEPTION)
2065 #define JSON_THROW(exception) throw exception
2066 #define JSON_TRY try
2067 #define JSON_CATCH(exception) catch(exception)
2068 #define JSON_INTERNAL_CATCH(exception) catch(exception)
2071 #define JSON_THROW(exception) std::abort()
2072 #define JSON_TRY if(true)
2073 #define JSON_CATCH(exception) if(false)
2074 #define JSON_INTERNAL_CATCH(exception) if(false)
2078#if defined(JSON_THROW_USER)
2080 #define JSON_THROW JSON_THROW_USER
2082#if defined(JSON_TRY_USER)
2084 #define JSON_TRY JSON_TRY_USER
2086#if defined(JSON_CATCH_USER)
2088 #define JSON_CATCH JSON_CATCH_USER
2089 #undef JSON_INTERNAL_CATCH
2090 #define JSON_INTERNAL_CATCH JSON_CATCH_USER
2092#if defined(JSON_INTERNAL_CATCH_USER)
2093 #undef JSON_INTERNAL_CATCH
2094 #define JSON_INTERNAL_CATCH JSON_INTERNAL_CATCH_USER
2098#if !defined(JSON_ASSERT)
2100 #define JSON_ASSERT(x) assert(x)
2108#define NLOHMANN_JSON_SERIALIZE_ENUM(ENUM_TYPE, ...) \
2109 template<typename BasicJsonType> \
2110 inline void to_json(BasicJsonType& j, const ENUM_TYPE& e) \
2112 static_assert(std::is_enum<ENUM_TYPE>::value, #ENUM_TYPE " must be an enum!"); \
2113 static const std::pair<ENUM_TYPE, BasicJsonType> m[] = __VA_ARGS__; \
2114 auto it = std::find_if(std::begin(m), std::end(m), \
2115 [e](const std::pair<ENUM_TYPE, BasicJsonType>& ej_pair) -> bool \
2117 return ej_pair.first == e; \
2119 j = ((it != std::end(m)) ? it : std::begin(m))->second; \
2121 template<typename BasicJsonType> \
2122 inline void from_json(const BasicJsonType& j, ENUM_TYPE& e) \
2124 static_assert(std::is_enum<ENUM_TYPE>::value, #ENUM_TYPE " must be an enum!"); \
2125 static const std::pair<ENUM_TYPE, BasicJsonType> m[] = __VA_ARGS__; \
2126 auto it = std::find_if(std::begin(m), std::end(m), \
2127 [&j](const std::pair<ENUM_TYPE, BasicJsonType>& ej_pair) -> bool \
2129 return ej_pair.second == j; \
2131 e = ((it != std::end(m)) ? it : std::begin(m))->first; \
2137#define NLOHMANN_BASIC_JSON_TPL_DECLARATION \
2138 template<template<typename, typename, typename...> class ObjectType, \
2139 template<typename, typename...> class ArrayType, \
2140 class StringType, class BooleanType, class NumberIntegerType, \
2141 class NumberUnsignedType, class NumberFloatType, \
2142 template<typename> class AllocatorType, \
2143 template<typename, typename = void> class JSONSerializer, \
2146#define NLOHMANN_BASIC_JSON_TPL \
2147 basic_json<ObjectType, ArrayType, StringType, BooleanType, \
2148 NumberIntegerType, NumberUnsignedType, NumberFloatType, \
2149 AllocatorType, JSONSerializer, BinaryType>
2153#define NLOHMANN_JSON_EXPAND( x ) x
2154#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
2155#define NLOHMANN_JSON_PASTE(...) NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_GET_MACRO(__VA_ARGS__, \
2156 NLOHMANN_JSON_PASTE64, \
2157 NLOHMANN_JSON_PASTE63, \
2158 NLOHMANN_JSON_PASTE62, \
2159 NLOHMANN_JSON_PASTE61, \
2160 NLOHMANN_JSON_PASTE60, \
2161 NLOHMANN_JSON_PASTE59, \
2162 NLOHMANN_JSON_PASTE58, \
2163 NLOHMANN_JSON_PASTE57, \
2164 NLOHMANN_JSON_PASTE56, \
2165 NLOHMANN_JSON_PASTE55, \
2166 NLOHMANN_JSON_PASTE54, \
2167 NLOHMANN_JSON_PASTE53, \
2168 NLOHMANN_JSON_PASTE52, \
2169 NLOHMANN_JSON_PASTE51, \
2170 NLOHMANN_JSON_PASTE50, \
2171 NLOHMANN_JSON_PASTE49, \
2172 NLOHMANN_JSON_PASTE48, \
2173 NLOHMANN_JSON_PASTE47, \
2174 NLOHMANN_JSON_PASTE46, \
2175 NLOHMANN_JSON_PASTE45, \
2176 NLOHMANN_JSON_PASTE44, \
2177 NLOHMANN_JSON_PASTE43, \
2178 NLOHMANN_JSON_PASTE42, \
2179 NLOHMANN_JSON_PASTE41, \
2180 NLOHMANN_JSON_PASTE40, \
2181 NLOHMANN_JSON_PASTE39, \
2182 NLOHMANN_JSON_PASTE38, \
2183 NLOHMANN_JSON_PASTE37, \
2184 NLOHMANN_JSON_PASTE36, \
2185 NLOHMANN_JSON_PASTE35, \
2186 NLOHMANN_JSON_PASTE34, \
2187 NLOHMANN_JSON_PASTE33, \
2188 NLOHMANN_JSON_PASTE32, \
2189 NLOHMANN_JSON_PASTE31, \
2190 NLOHMANN_JSON_PASTE30, \
2191 NLOHMANN_JSON_PASTE29, \
2192 NLOHMANN_JSON_PASTE28, \
2193 NLOHMANN_JSON_PASTE27, \
2194 NLOHMANN_JSON_PASTE26, \
2195 NLOHMANN_JSON_PASTE25, \
2196 NLOHMANN_JSON_PASTE24, \
2197 NLOHMANN_JSON_PASTE23, \
2198 NLOHMANN_JSON_PASTE22, \
2199 NLOHMANN_JSON_PASTE21, \
2200 NLOHMANN_JSON_PASTE20, \
2201 NLOHMANN_JSON_PASTE19, \
2202 NLOHMANN_JSON_PASTE18, \
2203 NLOHMANN_JSON_PASTE17, \
2204 NLOHMANN_JSON_PASTE16, \
2205 NLOHMANN_JSON_PASTE15, \
2206 NLOHMANN_JSON_PASTE14, \
2207 NLOHMANN_JSON_PASTE13, \
2208 NLOHMANN_JSON_PASTE12, \
2209 NLOHMANN_JSON_PASTE11, \
2210 NLOHMANN_JSON_PASTE10, \
2211 NLOHMANN_JSON_PASTE9, \
2212 NLOHMANN_JSON_PASTE8, \
2213 NLOHMANN_JSON_PASTE7, \
2214 NLOHMANN_JSON_PASTE6, \
2215 NLOHMANN_JSON_PASTE5, \
2216 NLOHMANN_JSON_PASTE4, \
2217 NLOHMANN_JSON_PASTE3, \
2218 NLOHMANN_JSON_PASTE2, \
2219 NLOHMANN_JSON_PASTE1)(__VA_ARGS__))
2220#define NLOHMANN_JSON_PASTE2(func, v1) func(v1)
2221#define NLOHMANN_JSON_PASTE3(func, v1, v2) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE2(func, v2)
2222#define NLOHMANN_JSON_PASTE4(func, v1, v2, v3) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE3(func, v2, v3)
2223#define NLOHMANN_JSON_PASTE5(func, v1, v2, v3, v4) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE4(func, v2, v3, v4)
2224#define NLOHMANN_JSON_PASTE6(func, v1, v2, v3, v4, v5) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE5(func, v2, v3, v4, v5)
2225#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)
2226#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)
2227#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)
2228#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)
2229#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)
2230#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)
2231#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)
2232#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)
2233#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)
2234#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)
2235#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)
2236#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)
2237#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)
2238#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)
2239#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)
2240#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)
2241#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)
2242#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)
2243#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)
2244#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)
2245#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)
2246#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)
2247#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)
2248#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)
2249#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)
2250#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)
2251#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)
2252#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)
2253#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)
2254#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)
2255#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)
2256#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)
2257#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)
2258#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)
2259#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)
2260#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)
2261#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)
2262#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)
2263#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)
2264#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)
2265#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)
2266#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)
2267#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)
2268#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)
2269#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)
2270#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)
2271#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)
2272#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)
2273#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)
2274#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)
2275#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)
2276#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)
2277#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)
2278#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)
2279#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)
2280#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)
2281#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)
2282#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)
2284#define NLOHMANN_JSON_TO(v1) nlohmann_json_j[#v1] = nlohmann_json_t.v1;
2285#define NLOHMANN_JSON_FROM(v1) nlohmann_json_j.at(#v1).get_to(nlohmann_json_t.v1);
2292#define NLOHMANN_DEFINE_TYPE_INTRUSIVE(Type, ...) \
2293 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__)) } \
2294 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__)) }
2301#define NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(Type, ...) \
2302 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__)) } \
2303 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__)) }
2305#ifndef JSON_USE_IMPLICIT_CONVERSIONS
2306 #define JSON_USE_IMPLICIT_CONVERSIONS 1
2309#if JSON_USE_IMPLICIT_CONVERSIONS
2310 #define JSON_EXPLICIT
2312 #define JSON_EXPLICIT explicit
2357 const char*
what() const noexcept
override
2367 exception(
int id_, const
char* what_arg) :
id(id_),
m(what_arg) {}
2369 static std::string
name(
const std::string& ename,
int id_)
2371 return "[json.exception." + ename +
"." + std::to_string(id_) +
"] ";
2376 std::runtime_error
m;
2446 (byte_ != 0 ? (
" at byte " + std::to_string(byte_)) :
"") +
2468 return " at line " + std::to_string(pos.
lines_read + 1) +
2671#include <type_traits>
2678template<
bool B,
typename T =
void>
2682using uncvref_t =
typename std::remove_cv<typename std::remove_reference<T>::type>::type;
2686template<std::size_t... Ints>
2691 static constexpr std::size_t
size() noexcept
2693 return sizeof...(Ints);
2697template<
class Sequence1,
class Sequence2>
2700template<std::size_t... I1, std::size_t... I2>
2704template<std::
size_t N>
2707 typename make_index_sequence < N - N / 2 >::type > {};
2712template<
typename... Ts>
2735#include <type_traits>
2765template<
typename It,
typename =
void>
2768template<
typename It>
2772 typename It::reference, typename It::iterator_category >>
2783template<
typename T,
typename =
void>
2813#include <type_traits>
2833template<
class Default,
2835 template<
class...>
class Op,
2843template<
class Default,
template<
class...>
class Op,
class... Args>
2850template<
template<
class...>
class Op,
class... Args>
2853template<
template<
class...>
class Op,
class... Args>
2856template<
class Default,
template<
class...>
class Op,
class... Args>
2859template<
class Default,
template<
class...>
class Op,
class... Args>
2862template<
class Expected,
template<
class...>
class Op,
class... Args>
2865template<
class To,
template<
class...>
class Op,
class... Args>
2867 std::is_convertible<
detected_t<Op, Args...>, To>;
2872#ifndef INCLUDE_NLOHMANN_JSON_FWD_HPP_
2873#define INCLUDE_NLOHMANN_JSON_FWD_HPP_
2895template<
typename T =
void,
typename SFINAE =
void>
2896struct adl_serializer;
2898template<
template<
typename U,
typename V,
typename... Args>
class ObjectType =
2900 template<
typename U,
typename... Args>
class ArrayType = std::vector,
2901 class StringType = std::string,
class BooleanType = bool,
2902 class NumberIntegerType = std::int64_t,
2903 class NumberUnsignedType = std::uint64_t,
2904 class NumberFloatType =
double,
2905 template<
typename U>
class AllocatorType = std::allocator,
2906 template<
typename T,
typename SFINAE =
void>
class JSONSerializer =
2908 class BinaryType = std::vector<std::uint8_t>>
2922template<
typename BasicJsonType>
2935template<
class Key,
class T,
class IgnoredLess,
class Allocator>
3023template<
typename T,
typename... Args>
3026template<
typename T,
typename... Args>
3029template<
typename T,
typename U>
3033template<
typename BasicJsonType,
typename T,
typename =
void>
3040template <
typename BasicJsonType,
typename T>
3046template<
typename BasicJsonType,
typename T>
3050 using serializer =
typename BasicJsonType::template json_serializer<T, void>;
3054 const BasicJsonType&, T&>
::value;
3059template<
typename BasicJsonType,
typename T,
typename =
void>
3062template<
typename BasicJsonType,
typename T>
3065 using serializer =
typename BasicJsonType::template json_serializer<T, void>;
3074template<
typename BasicJsonType,
typename T,
typename =
void>
3077template<
typename BasicJsonType,
typename T>
3080 using serializer =
typename BasicJsonType::template json_serializer<T, void>;
3092template<
typename T,
typename =
void>
3112template<
typename T,
typename =
void>
3118template<
typename BasicJsonType,
typename CompatibleObjectType,
3122template<
typename BasicJsonType,
typename CompatibleObjectType>
3124 BasicJsonType, CompatibleObjectType,
3133 std::is_constructible<
typename object_t::key_type,
3134 typename CompatibleObjectType::key_type>
::value &&
3135 std::is_constructible<
typename object_t::mapped_type,
3136 typename CompatibleObjectType::mapped_type>
::value;
3139template<
typename BasicJsonType,
typename CompatibleObjectType>
3143template<
typename BasicJsonType,
typename ConstructibleObjectType,
3147template<
typename BasicJsonType,
typename ConstructibleObjectType>
3149 BasicJsonType, ConstructibleObjectType,
3156 (std::is_default_constructible<ConstructibleObjectType>::value &&
3157 (std::is_move_assignable<ConstructibleObjectType>::value ||
3158 std::is_copy_assignable<ConstructibleObjectType>::value) &&
3159 (std::is_constructible<
typename ConstructibleObjectType::key_type,
3160 typename object_t::key_type>
::value &&
3162 typename object_t::mapped_type,
3163 typename ConstructibleObjectType::mapped_type >
::value)) ||
3165 typename ConstructibleObjectType::mapped_type>
::value ||
3168 typename ConstructibleObjectType::mapped_type >
::value);
3171template<
typename BasicJsonType,
typename ConstructibleObjectType>
3174 ConstructibleObjectType> {};
3176template<
typename BasicJsonType,
typename CompatibleStringType,
3180template<
typename BasicJsonType,
typename CompatibleStringType>
3182 BasicJsonType, CompatibleStringType,
3187 std::is_constructible<typename BasicJsonType::string_t, CompatibleStringType>::value;
3190template<
typename BasicJsonType,
typename ConstructibleStringType>
3194template<
typename BasicJsonType,
typename ConstructibleStringType,
3198template<
typename BasicJsonType,
typename ConstructibleStringType>
3200 BasicJsonType, ConstructibleStringType,
3205 std::is_constructible<ConstructibleStringType,
3206 typename BasicJsonType::string_t>
::value;
3209template<
typename BasicJsonType,
typename ConstructibleStringType>
3213template<
typename BasicJsonType,
typename CompatibleArrayType,
typename =
void>
3216template<
typename BasicJsonType,
typename CompatibleArrayType>
3218 BasicJsonType, CompatibleArrayType,
3225 iterator_traits<CompatibleArrayType >>
::value >>
3228 std::is_constructible<BasicJsonType,
3229 typename CompatibleArrayType::value_type>
::value;
3232template<
typename BasicJsonType,
typename CompatibleArrayType>
3236template<
typename BasicJsonType,
typename ConstructibleArrayType,
typename =
void>
3239template<
typename BasicJsonType,
typename ConstructibleArrayType>
3241 BasicJsonType, ConstructibleArrayType,
3243 typename BasicJsonType::value_type>
::value >>
3244 : std::true_type {};
3246template<
typename BasicJsonType,
typename ConstructibleArrayType>
3248 BasicJsonType, ConstructibleArrayType,
3250 typename BasicJsonType::value_type>
::value&&
3251 std::is_default_constructible<ConstructibleArrayType>
::value&&
3252(std::is_move_assignable<ConstructibleArrayType>::value ||
3253 std::is_copy_assignable<ConstructibleArrayType>::value)&&
3257detected_t<value_type_t, ConstructibleArrayType >>
::value >>
3267 (std::is_same<
typename ConstructibleArrayType::value_type,
3268 typename BasicJsonType::array_t::value_type>
::value ||
3270 typename ConstructibleArrayType::value_type>
::value ||
3272 BasicJsonType,
typename ConstructibleArrayType::value_type >
::value);
3275template<
typename BasicJsonType,
typename ConstructibleArrayType>
3279template<
typename RealIntegerType,
typename CompatibleNumberIntegerType,
3283template<
typename RealIntegerType,
typename CompatibleNumberIntegerType>
3285 RealIntegerType, CompatibleNumberIntegerType,
3287 std::is_integral<CompatibleNumberIntegerType>
::value&&
3288 !std::is_same<bool, CompatibleNumberIntegerType>
::value >>
3295 std::is_constructible<RealIntegerType,
3296 CompatibleNumberIntegerType>
::value &&
3297 CompatibleLimits::is_integer &&
3298 RealLimits::is_signed == CompatibleLimits::is_signed;
3301template<
typename RealIntegerType,
typename CompatibleNumberIntegerType>
3304 CompatibleNumberIntegerType> {};
3306template<
typename BasicJsonType,
typename CompatibleType,
typename =
void>
3309template<
typename BasicJsonType,
typename CompatibleType>
3311 BasicJsonType, CompatibleType,
3318template<
typename BasicJsonType,
typename CompatibleType>
3325template<
class B1,
class... Bn>
3327: std::conditional<bool(B1::value), conjunction<Bn...>, B1>::type {};
3329template<
typename T1,
typename T2>
3332template<
typename T1,
typename... Args>
3406 static constexpr std::array<std::uint8_t, 9> order = {{
3413 const auto l_index =
static_cast<std::size_t
>(lhs);
3414 const auto r_index =
static_cast<std::size_t
>(rhs);
3415 return l_index < order.size() && r_index < order.size() && order[l_index] < order[r_index];
3425template<
typename BasicJsonType>
3426void from_json(
const BasicJsonType& j,
typename std::nullptr_t& n)
3436template <
typename BasicJsonType,
typename ArithmeticType,
3437 enable_if_t < std::is_arithmetic<ArithmeticType>::value&&
3438 !std::is_same<ArithmeticType, typename BasicJsonType::boolean_t>::value,
3442 switch (
static_cast<value_t>(j))
3446 val =
static_cast<ArithmeticType
>(*j.template get_ptr<const typename BasicJsonType::number_unsigned_t*>());
3451 val =
static_cast<ArithmeticType
>(*j.template get_ptr<const typename BasicJsonType::number_integer_t*>());
3456 val =
static_cast<ArithmeticType
>(*j.template get_ptr<const typename BasicJsonType::number_float_t*>());
3465template<
typename BasicJsonType>
3466void from_json(
const BasicJsonType& j,
typename BasicJsonType::boolean_t& b)
3472 b = *j.template get_ptr<const typename BasicJsonType::boolean_t*>();
3475template<
typename BasicJsonType>
3476void from_json(
const BasicJsonType& j,
typename BasicJsonType::string_t& s)
3482 s = *j.template get_ptr<const typename BasicJsonType::string_t*>();
3486 typename BasicJsonType,
typename ConstructibleStringType,
3488 is_constructible_string_type<BasicJsonType, ConstructibleStringType>::value&&
3489 !std::is_same<
typename BasicJsonType::string_t,
3490 ConstructibleStringType>
::value,
3492void from_json(
const BasicJsonType& j, ConstructibleStringType& s)
3499 s = *j.template get_ptr<const typename BasicJsonType::string_t*>();
3502template<
typename BasicJsonType>
3503void from_json(
const BasicJsonType& j,
typename BasicJsonType::number_float_t& val)
3508template<
typename BasicJsonType>
3509void from_json(
const BasicJsonType& j,
typename BasicJsonType::number_unsigned_t& val)
3514template<
typename BasicJsonType>
3515void from_json(
const BasicJsonType& j,
typename BasicJsonType::number_integer_t& val)
3520template<
typename BasicJsonType,
typename EnumType,
3521 enable_if_t<std::is_enum<EnumType>::value,
int> = 0>
3524 typename std::underlying_type<EnumType>::type val;
3526 e =
static_cast<EnumType
>(val);
3530template<
typename BasicJsonType,
typename T,
typename Allocator,
3531 enable_if_t<is_getable<BasicJsonType, T>::value,
int> = 0>
3532void from_json(
const BasicJsonType& j, std::forward_list<T, Allocator>& l)
3539 std::transform(j.rbegin(), j.rend(),
3540 std::front_inserter(l), [](
const BasicJsonType & i)
3542 return i.template get<T>();
3547template<
typename BasicJsonType,
typename T,
3548 enable_if_t<is_getable<BasicJsonType, T>::value,
int> = 0>
3556 std::transform(j.begin(), j.end(), std::begin(l),
3557 [](
const BasicJsonType & elem)
3559 return elem.template get<T>();
3563template<
typename BasicJsonType,
typename T, std::
size_t N>
3565->
decltype(j.template get<T>(), void())
3567 for (std::size_t i = 0; i < N; ++i)
3569 arr[i] = j.at(i).template get<T>();
3573template<
typename BasicJsonType>
3576 arr = *j.template get_ptr<const typename BasicJsonType::array_t*>();
3579template<
typename BasicJsonType,
typename T, std::
size_t N>
3582->
decltype(j.template get<T>(), void())
3584 for (std::size_t i = 0; i < N; ++i)
3586 arr[i] = j.at(i).template get<T>();
3590template<
typename BasicJsonType,
typename ConstructibleArrayType>
3593 arr.reserve(std::declval<typename ConstructibleArrayType::size_type>()),
3594 j.template get<typename ConstructibleArrayType::value_type>(),
3599 ConstructibleArrayType ret;
3600 ret.reserve(j.size());
3601 std::transform(j.begin(), j.end(),
3602 std::inserter(ret, end(ret)), [](
const BasicJsonType & i)
3606 return i.template get<typename ConstructibleArrayType::value_type>();
3608 arr = std::move(ret);
3611template<
typename BasicJsonType,
typename ConstructibleArrayType>
3617 ConstructibleArrayType ret;
3619 j.begin(), j.end(), std::inserter(ret, end(ret)),
3620 [](
const BasicJsonType & i)
3624 return i.template get<typename ConstructibleArrayType::value_type>();
3626 arr = std::move(ret);
3629template <
typename BasicJsonType,
typename ConstructibleArrayType,
3631 is_constructible_array_type<BasicJsonType, ConstructibleArrayType>::value&&
3632 !is_constructible_object_type<BasicJsonType, ConstructibleArrayType>::value&&
3633 !is_constructible_string_type<BasicJsonType, ConstructibleArrayType>::value&&
3634 !std::is_same<ConstructibleArrayType, typename BasicJsonType::binary_t>::value&&
3635 !is_basic_json<ConstructibleArrayType>::value,
3637auto from_json(
const BasicJsonType& j, ConstructibleArrayType& arr)
3639j.template get<typename ConstructibleArrayType::value_type>(),
3645 std::string(j.type_name())));
3651template<
typename BasicJsonType>
3652void from_json(
const BasicJsonType& j,
typename BasicJsonType::binary_t& bin)
3659 bin = *j.template get_ptr<const typename BasicJsonType::binary_t*>();
3662template<
typename BasicJsonType,
typename ConstructibleObjectType,
3663 enable_if_t<is_constructible_object_type<BasicJsonType, ConstructibleObjectType>::value,
int> = 0>
3664void from_json(
const BasicJsonType& j, ConstructibleObjectType& obj)
3671 ConstructibleObjectType ret;
3672 auto inner_object = j.template get_ptr<const typename BasicJsonType::object_t*>();
3673 using value_type =
typename ConstructibleObjectType::value_type;
3675 inner_object->begin(), inner_object->end(),
3676 std::inserter(ret, ret.begin()),
3677 [](
typename BasicJsonType::object_t::value_type
const & p)
3679 return value_type(p.first, p.second.template get<typename ConstructibleObjectType::mapped_type>());
3681 obj = std::move(ret);
3688template <
typename BasicJsonType,
typename ArithmeticType,
3690 std::is_arithmetic<ArithmeticType>::value&&
3691 !std::is_same<ArithmeticType, typename BasicJsonType::number_unsigned_t>::value&&
3692 !std::is_same<ArithmeticType, typename BasicJsonType::number_integer_t>::value&&
3693 !std::is_same<ArithmeticType, typename BasicJsonType::number_float_t>::value&&
3694 !std::is_same<ArithmeticType, typename BasicJsonType::boolean_t>::value,
3698 switch (
static_cast<value_t>(j))
3702 val =
static_cast<ArithmeticType
>(*j.template get_ptr<const typename BasicJsonType::number_unsigned_t*>());
3707 val =
static_cast<ArithmeticType
>(*j.template get_ptr<const typename BasicJsonType::number_integer_t*>());
3712 val =
static_cast<ArithmeticType
>(*j.template get_ptr<const typename BasicJsonType::number_float_t*>());
3717 val =
static_cast<ArithmeticType
>(*j.template get_ptr<const typename BasicJsonType::boolean_t*>());
3726template<
typename BasicJsonType,
typename A1,
typename A2>
3729 p = {j.at(0).template get<A1>(), j.at(1).template get<A2>()};
3732template<
typename BasicJsonType,
typename Tuple, std::size_t... Idx>
3735 t = std::make_tuple(j.at(Idx).template
get<
typename std::tuple_element<Idx, Tuple>::type>()...);
3738template<
typename BasicJsonType,
typename... Args>
3739void from_json(
const BasicJsonType& j, std::tuple<Args...>& t)
3744template <
typename BasicJsonType,
typename Key,
typename Value,
typename Compare,
typename Allocator,
3746 typename BasicJsonType::string_t, Key >
::value >>
3747void from_json(
const BasicJsonType& j, std::map<Key, Value, Compare, Allocator>& m)
3754 for (
const auto& p : j)
3760 m.emplace(p.at(0).template get<Key>(), p.at(1).template get<Value>());
3764template <
typename BasicJsonType,
typename Key,
typename Value,
typename Hash,
typename KeyEqual,
typename Allocator,
3766 typename BasicJsonType::string_t, Key >
::value >>
3767void from_json(
const BasicJsonType& j, std::unordered_map<Key, Value, Hash, KeyEqual, Allocator>& m)
3774 for (
const auto& p : j)
3780 m.emplace(p.at(0).template get<Key>(), p.at(1).template get<Value>());
3786 template<
typename BasicJsonType,
typename T>
3812#include <type_traits>
3834template<
typename string_type>
3838 using std::to_string;
3849 using string_type =
typename std::remove_cv< typename std::remove_reference<decltype( std::declval<IteratorType>().
key() ) >::type >::type;
3898 switch (
anchor.m_object->type())
3922 typename IteratorType::reference
value()
const
3955template<std::
size_t N,
typename IteratorType, enable_if_t<N == 0,
int> = 0>
3963template<std::
size_t N,
typename IteratorType, enable_if_t<N == 1,
int> = 0>
3977#if defined(__clang__)
3979 #pragma clang diagnostic push
3980 #pragma clang diagnostic ignored "-Wmismatched-tags"
3982template<
typename IteratorType>
3984 :
public std::integral_constant<std::size_t, 2> {};
3986template<std::
size_t N,
typename IteratorType>
3991 get<N>(std::declval <
3994#if defined(__clang__)
3995 #pragma clang diagnostic pop
4019 template<
typename BasicJsonType>
4020 static void construct(BasicJsonType& j,
typename BasicJsonType::boolean_t b)
noexcept
4024 j.assert_invariant();
4031 template<
typename BasicJsonType>
4032 static void construct(BasicJsonType& j,
const typename BasicJsonType::string_t& s)
4036 j.assert_invariant();
4039 template<
typename BasicJsonType>
4040 static void construct(BasicJsonType& j,
typename BasicJsonType::string_t&& s)
4043 j.m_value = std::move(s);
4044 j.assert_invariant();
4047 template <
typename BasicJsonType,
typename CompatibleStringType,
4048 enable_if_t < !std::is_same<CompatibleStringType, typename BasicJsonType::string_t>::value,
4050 static void construct(BasicJsonType& j,
const CompatibleStringType& str)
4053 j.m_value.string = j.template create<typename BasicJsonType::string_t>(str);
4054 j.assert_invariant();
4061 template<
typename BasicJsonType>
4062 static void construct(BasicJsonType& j,
const typename BasicJsonType::binary_t& b)
4065 typename BasicJsonType::binary_t
value{b};
4067 j.assert_invariant();
4070 template<
typename BasicJsonType>
4071 static void construct(BasicJsonType& j,
typename BasicJsonType::binary_t&& b)
4074 typename BasicJsonType::binary_t
value{std::move(b)};
4076 j.assert_invariant();
4083 template<
typename BasicJsonType>
4084 static void construct(BasicJsonType& j,
typename BasicJsonType::number_float_t val)
noexcept
4088 j.assert_invariant();
4095 template<
typename BasicJsonType>
4096 static void construct(BasicJsonType& j,
typename BasicJsonType::number_unsigned_t val)
noexcept
4100 j.assert_invariant();
4107 template<
typename BasicJsonType>
4108 static void construct(BasicJsonType& j,
typename BasicJsonType::number_integer_t val)
noexcept
4112 j.assert_invariant();
4119 template<
typename BasicJsonType>
4120 static void construct(BasicJsonType& j,
const typename BasicJsonType::array_t& arr)
4124 j.assert_invariant();
4127 template<
typename BasicJsonType>
4128 static void construct(BasicJsonType& j,
typename BasicJsonType::array_t&& arr)
4131 j.m_value = std::move(arr);
4132 j.assert_invariant();
4135 template <
typename BasicJsonType,
typename CompatibleArrayType,
4136 enable_if_t < !std::is_same<CompatibleArrayType, typename BasicJsonType::array_t>::value,
4138 static void construct(BasicJsonType& j,
const CompatibleArrayType& arr)
4143 j.m_value.array = j.template create<typename BasicJsonType::array_t>(begin(arr), end(arr));
4144 j.assert_invariant();
4147 template<
typename BasicJsonType>
4148 static void construct(BasicJsonType& j,
const std::vector<bool>& arr)
4152 j.m_value.array->reserve(arr.size());
4153 for (
const bool x : arr)
4155 j.m_value.array->push_back(x);
4157 j.assert_invariant();
4160 template<
typename BasicJsonType,
typename T,
4162 static void construct(BasicJsonType& j,
const std::valarray<T>& arr)
4166 j.m_value.array->resize(arr.size());
4169 std::copy(std::begin(arr), std::end(arr), j.m_value.array->begin());
4171 j.assert_invariant();
4178 template<
typename BasicJsonType>
4179 static void construct(BasicJsonType& j,
const typename BasicJsonType::object_t& obj)
4183 j.assert_invariant();
4186 template<
typename BasicJsonType>
4187 static void construct(BasicJsonType& j,
typename BasicJsonType::object_t&& obj)
4190 j.m_value = std::move(obj);
4191 j.assert_invariant();
4194 template <
typename BasicJsonType,
typename CompatibleObjectType,
4195 enable_if_t < !std::is_same<CompatibleObjectType, typename BasicJsonType::object_t>::value,
int > = 0 >
4196 static void construct(BasicJsonType& j,
const CompatibleObjectType& obj)
4202 j.m_value.object = j.template create<typename BasicJsonType::object_t>(begin(obj), end(obj));
4203 j.assert_invariant();
4211template<
typename BasicJsonType,
typename T,
4212 enable_if_t<std::is_same<T, typename BasicJsonType::boolean_t>::value,
int> = 0>
4218template<
typename BasicJsonType,
typename CompatibleString,
4219 enable_if_t<std::is_constructible<typename BasicJsonType::string_t, CompatibleString>::value,
int> = 0>
4220void to_json(BasicJsonType& j,
const CompatibleString& s)
4225template<
typename BasicJsonType>
4226void to_json(BasicJsonType& j,
typename BasicJsonType::string_t&& s)
4231template<
typename BasicJsonType,
typename FloatType,
4232 enable_if_t<std::is_floating_point<FloatType>::value,
int> = 0>
4233void to_json(BasicJsonType& j, FloatType val)
noexcept
4238template<
typename BasicJsonType,
typename CompatibleNumberUnsignedType,
4239 enable_if_t<is_compatible_integer_type<typename BasicJsonType::number_unsigned_t, CompatibleNumberUnsignedType>::value,
int> = 0>
4240void to_json(BasicJsonType& j, CompatibleNumberUnsignedType val)
noexcept
4245template<
typename BasicJsonType,
typename CompatibleNumberIntegerType,
4246 enable_if_t<is_compatible_integer_type<typename BasicJsonType::number_integer_t, CompatibleNumberIntegerType>::value,
int> = 0>
4247void to_json(BasicJsonType& j, CompatibleNumberIntegerType val)
noexcept
4252template<
typename BasicJsonType,
typename EnumType,
4253 enable_if_t<std::is_enum<EnumType>::value,
int> = 0>
4254void to_json(BasicJsonType& j, EnumType e)
noexcept
4256 using underlying_type =
typename std::underlying_type<EnumType>::type;
4260template<
typename BasicJsonType>
4261void to_json(BasicJsonType& j,
const std::vector<bool>& e)
4266template <
typename BasicJsonType,
typename CompatibleArrayType,
4267 enable_if_t < is_compatible_array_type<BasicJsonType,
4269 !is_compatible_object_type<BasicJsonType, CompatibleArrayType>::value&&
4270 !is_compatible_string_type<BasicJsonType, CompatibleArrayType>::value&&
4271 !std::is_same<typename BasicJsonType::binary_t, CompatibleArrayType>::value&&
4272 !is_basic_json<CompatibleArrayType>::value,
4274void to_json(BasicJsonType& j,
const CompatibleArrayType& arr)
4279template<
typename BasicJsonType>
4280void to_json(BasicJsonType& j,
const typename BasicJsonType::binary_t& bin)
4285template<
typename BasicJsonType,
typename T,
4286 enable_if_t<std::is_convertible<T, BasicJsonType>::value,
int> = 0>
4287void to_json(BasicJsonType& j,
const std::valarray<T>& arr)
4292template<
typename BasicJsonType>
4293void to_json(BasicJsonType& j,
typename BasicJsonType::array_t&& arr)
4298template <
typename BasicJsonType,
typename CompatibleObjectType,
4299 enable_if_t < is_compatible_object_type<BasicJsonType, CompatibleObjectType>::value&& !is_basic_json<CompatibleObjectType>::value,
int > = 0 >
4300void to_json(BasicJsonType& j,
const CompatibleObjectType& obj)
4305template<
typename BasicJsonType>
4306void to_json(BasicJsonType& j,
typename BasicJsonType::object_t&& obj)
4312 typename BasicJsonType,
typename T, std::size_t N,
4313 enable_if_t < !std::is_constructible<
typename BasicJsonType::string_t,
4321template < typename BasicJsonType, typename T1, typename T2, enable_if_t < std::is_constructible<BasicJsonType, T1>::value&& std::is_constructible<BasicJsonType, T2>::value,
int > = 0 >
4322void to_json(BasicJsonType& j,
const std::pair<T1, T2>& p)
4324 j = { p.first, p.second };
4328template<
typename BasicJsonType,
typename T,
4329 enable_if_t<std::is_same<T, iteration_proxy_value<typename BasicJsonType::iterator>>
::value,
int> = 0>
4332 j = { {b.key(), b.value()} };
4335template<
typename BasicJsonType,
typename Tuple, std::size_t... Idx>
4338 j = { std::get<Idx>(t)... };
4341template<typename BasicJsonType, typename T, enable_if_t<is_constructible_tuple<BasicJsonType, T>::value,
int > = 0>
4342void to_json(BasicJsonType& j,
const T& t)
4349 template<
typename BasicJsonType,
typename T>
4350 auto operator()(BasicJsonType& j, T&& val)
const noexcept(
noexcept(
to_json(j, std::forward<T>(val))))
4351 ->
decltype(
to_json(j, std::forward<T>(val)), void())
4353 return to_json(j, std::forward<T>(val));
4369template<
typename,
typename>
4381 template<
typename BasicJsonType,
typename ValueType>
4382 static auto from_json(BasicJsonType&& j, ValueType& val)
noexcept(
4383 noexcept(::nlohmann::from_json(std::forward<BasicJsonType>(j), val)))
4384 ->
decltype(::nlohmann::from_json(std::forward<BasicJsonType>(j), val), void())
4386 ::nlohmann::from_json(std::forward<BasicJsonType>(j), val);
4398 template<
typename BasicJsonType,
typename ValueType>
4399 static auto to_json(BasicJsonType& j, ValueType&& val)
noexcept(
4400 noexcept(::nlohmann::to_json(j, std::forward<ValueType>(val))))
4401 ->
decltype(::nlohmann::to_json(j, std::forward<ValueType>(val)), void())
4403 ::nlohmann::to_json(j, std::forward<ValueType>(val));
4432template<
typename BinaryType>
4471 return !(rhs == *
this);
4587#include <functional>
4595inline std::size_t
combine(std::size_t seed, std::size_t h)
noexcept
4597 seed ^= h + 0x9e3779b9 + (seed << 6U) + (seed >> 2U);
4612template<
typename BasicJsonType>
4613std::size_t
hash(
const BasicJsonType& j)
4615 using string_t =
typename BasicJsonType::string_t;
4616 using number_integer_t =
typename BasicJsonType::number_integer_t;
4617 using number_unsigned_t =
typename BasicJsonType::number_unsigned_t;
4618 using number_float_t =
typename BasicJsonType::number_float_t;
4620 const auto type =
static_cast<std::size_t
>(j.type());
4623 case BasicJsonType::value_t::null:
4624 case BasicJsonType::value_t::discarded:
4629 case BasicJsonType::value_t::object:
4631 auto seed =
combine(type, j.size());
4632 for (
const auto& element : j.items())
4634 const auto h = std::hash<string_t> {}(element.key());
4641 case BasicJsonType::value_t::array:
4643 auto seed =
combine(type, j.size());
4644 for (
const auto& element : j)
4651 case BasicJsonType::value_t::string:
4653 const auto h = std::hash<string_t> {}(j.template get_ref<const string_t&>());
4657 case BasicJsonType::value_t::boolean:
4659 const auto h = std::hash<bool> {}(j.template get<bool>());
4663 case BasicJsonType::value_t::number_integer:
4665 const auto h = std::hash<number_integer_t> {}(j.template get<number_integer_t>());
4671 const auto h = std::hash<number_unsigned_t> {}(j.template get<number_unsigned_t>());
4677 const auto h = std::hash<number_float_t> {}(j.template get<number_float_t>());
4683 auto seed =
combine(type, j.get_binary().size());
4684 const auto h = std::hash<bool> {}(j.get_binary().has_subtype());
4686 seed =
combine(seed, j.get_binary().subtype());
4687 for (
const auto byte : j.get_binary())
4689 seed =
combine(seed, std::hash<std::uint8_t> {}(byte));
4731#include <type_traits>
4772 return std::fgetc(
m_file);
4801 is->clear(
is->rdstate() & std::ios::eofbit);
4806 :
is(&i),
sb(i.rdbuf())
4825 auto res =
sb->sbumpc();
4829 is->clear(
is->rdstate() | std::ios::eofbit);
4836 std::istream*
is =
nullptr;
4837 std::streambuf*
sb =
nullptr;
4842template<
typename IteratorType>
4846 using char_type =
typename std::iterator_traits<IteratorType>::value_type;
4855 auto result = std::char_traits<char_type>::to_int_type(*
current);
4861 return std::char_traits<char_type>::eof();
4869 template<
typename BaseInputAdapter,
size_t T>
4880template<
typename BaseInputAdapter,
size_t T>
4883template<
typename BaseInputAdapter>
4888 std::array<std::char_traits<char>::int_type, 4>& utf8_bytes,
4889 size_t& utf8_bytes_index,
4890 size_t& utf8_bytes_filled)
4892 utf8_bytes_index = 0;
4896 utf8_bytes[0] = std::char_traits<char>::eof();
4897 utf8_bytes_filled = 1;
4902 const auto wc = input.get_character();
4907 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(wc);
4908 utf8_bytes_filled = 1;
4910 else if (wc <= 0x7FF)
4912 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(0xC0u | ((
static_cast<unsigned int>(wc) >> 6u) & 0x1Fu));
4913 utf8_bytes[1] =
static_cast<std::char_traits<char>::int_type
>(0x80u | (
static_cast<unsigned int>(wc) & 0x3Fu));
4914 utf8_bytes_filled = 2;
4916 else if (wc <= 0xFFFF)
4918 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(0xE0u | ((
static_cast<unsigned int>(wc) >> 12u) & 0x0Fu));
4919 utf8_bytes[1] =
static_cast<std::char_traits<char>::int_type
>(0x80u | ((
static_cast<unsigned int>(wc) >> 6u) & 0x3Fu));
4920 utf8_bytes[2] =
static_cast<std::char_traits<char>::int_type
>(0x80u | (
static_cast<unsigned int>(wc) & 0x3Fu));
4921 utf8_bytes_filled = 3;
4923 else if (wc <= 0x10FFFF)
4925 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(0xF0u | ((
static_cast<unsigned int>(wc) >> 18u) & 0x07u));
4926 utf8_bytes[1] =
static_cast<std::char_traits<char>::int_type
>(0x80u | ((
static_cast<unsigned int>(wc) >> 12u) & 0x3Fu));
4927 utf8_bytes[2] =
static_cast<std::char_traits<char>::int_type
>(0x80u | ((
static_cast<unsigned int>(wc) >> 6u) & 0x3Fu));
4928 utf8_bytes[3] =
static_cast<std::char_traits<char>::int_type
>(0x80u | (
static_cast<unsigned int>(wc) & 0x3Fu));
4929 utf8_bytes_filled = 4;
4934 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(wc);
4935 utf8_bytes_filled = 1;
4941template<
typename BaseInputAdapter>
4946 std::array<std::char_traits<char>::int_type, 4>& utf8_bytes,
4947 size_t& utf8_bytes_index,
4948 size_t& utf8_bytes_filled)
4950 utf8_bytes_index = 0;
4954 utf8_bytes[0] = std::char_traits<char>::eof();
4955 utf8_bytes_filled = 1;
4960 const auto wc = input.get_character();
4965 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(wc);
4966 utf8_bytes_filled = 1;
4968 else if (wc <= 0x7FF)
4970 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(0xC0u | ((
static_cast<unsigned int>(wc) >> 6u)));
4971 utf8_bytes[1] =
static_cast<std::char_traits<char>::int_type
>(0x80u | (
static_cast<unsigned int>(wc) & 0x3Fu));
4972 utf8_bytes_filled = 2;
4974 else if (0xD800 > wc || wc >= 0xE000)
4976 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(0xE0u | ((
static_cast<unsigned int>(wc) >> 12u)));
4977 utf8_bytes[1] =
static_cast<std::char_traits<char>::int_type
>(0x80u | ((
static_cast<unsigned int>(wc) >> 6u) & 0x3Fu));
4978 utf8_bytes[2] =
static_cast<std::char_traits<char>::int_type
>(0x80u | (
static_cast<unsigned int>(wc) & 0x3Fu));
4979 utf8_bytes_filled = 3;
4985 const auto wc2 =
static_cast<unsigned int>(input.get_character());
4986 const auto charcode = 0x10000u + (((
static_cast<unsigned int>(wc) & 0x3FFu) << 10u) | (wc2 & 0x3FFu));
4987 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(0xF0u | (charcode >> 18u));
4988 utf8_bytes[1] =
static_cast<std::char_traits<char>::int_type
>(0x80u | ((charcode >> 12u) & 0x3Fu));
4989 utf8_bytes[2] =
static_cast<std::char_traits<char>::int_type
>(0x80u | ((charcode >> 6u) & 0x3Fu));
4990 utf8_bytes[3] =
static_cast<std::char_traits<char>::int_type
>(0x80u | (charcode & 0x3Fu));
4991 utf8_bytes_filled = 4;
4995 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(wc);
4996 utf8_bytes_filled = 1;
5004template<
typename BaseInputAdapter,
typename W
ideCharType>
5018 fill_buffer<sizeof(WideCharType)>();
5040 std::array<std::char_traits<char>::int_type, 4>
utf8_bytes = {{0, 0, 0, 0}};
5049template<
typename IteratorType,
typename Enable =
void>
5053 using char_type =
typename std::iterator_traits<iterator_type>::value_type;
5058 return adapter_type(std::move(first), std::move(last));
5072template<
typename IteratorType>
5076 using char_type =
typename std::iterator_traits<iterator_type>::value_type;
5087template<
typename IteratorType>
5091 return factory_type::create(first, last);
5095template<
typename ContainerType>
5124template <
typename CharT,
5125 typename std::enable_if <
5126 std::is_pointer<CharT>::value&&
5127 !std::is_array<CharT>::value&&
5128 std::is_integral<typename std::remove_pointer<CharT>::type>
::value&&
5129 sizeof(
typename std::remove_pointer<CharT>::type) == 1,
5133 auto length = std::strlen(
reinterpret_cast<const char*
>(b));
5134 const auto* ptr =
reinterpret_cast<const char*
>(b);
5138template<
typename T, std::
size_t N>
5150 template <
typename CharT,
5151 typename std::enable_if <
5152 std::is_pointer<CharT>::value&&
5153 std::is_integral<typename std::remove_pointer<CharT>::type>
::value&&
5154 sizeof(
typename std::remove_pointer<CharT>::type) == 1,
5157 : ia(
reinterpret_cast<const char*
>(b),
reinterpret_cast<const char*
>(b) + l) {}
5159 template<
class IteratorType,
5160 typename std::enable_if<
5161 std::is_same<typename iterator_traits<IteratorType>::iterator_category, std::random_access_iterator_tag>
::value,
5168 return std::move(ia);
5201template<
typename BasicJsonType>
5305 const std::string& last_token,
5327template<
typename BasicJsonType>
5402 "excessive object size: " + std::to_string(len)));
5428 "excessive array size: " + std::to_string(len)));
5440 template<
class Exception>
5442 const Exception& ex)
5445 static_cast<void>(ex);
5465 template<
typename Value>
5471 root = BasicJsonType(std::forward<Value>(v));
5479 ref_stack.back()->m_value.array->emplace_back(std::forward<Value>(v));
5480 return &(
ref_stack.back()->m_value.array->back());
5501template<
typename BasicJsonType>
5515 const bool allow_exceptions_ =
true)
5576 auto val =
handle_value(BasicJsonType::value_t::object,
true);
5590 BasicJsonType k = BasicJsonType(val);
5623 if (it->is_discarded())
5639 auto val =
handle_value(BasicJsonType::value_t::array,
true);
5673 ref_stack.back()->m_value.array->pop_back();
5679 template<
class Exception>
5681 const Exception& ex)
5684 static_cast<void>(ex);
5713 template<
typename Value>
5714 std::pair<bool, BasicJsonType*>
handle_value(Value&& v,
const bool skip_callback =
false)
5722 return {
false,
nullptr};
5726 auto value = BasicJsonType(std::forward<Value>(v));
5734 return {
false,
nullptr};
5740 return {
true, &
root};
5747 return {
false,
nullptr};
5757 return {
true, &(
ref_stack.back()->m_value.array->back())};
5769 return {
false,
nullptr};
5794 BasicJsonType
discarded = BasicJsonType::value_t::discarded;
5797template<
typename BasicJsonType>
5884#include <initializer_list>
5904template<
typename BasicJsonType>
5938 return "<uninitialized>";
5940 return "true literal";
5942 return "false literal";
5944 return "null literal";
5946 return "string literal";
5950 return "number literal";
5964 return "<parse error>";
5966 return "end of input";
5968 return "'[', '{', or a literal";
5971 return "unknown token";
5981template<
typename BasicJsonType,
typename InputAdapterType>
5994 explicit lexer(InputAdapterType&& adapter,
bool ignore_comments_ =
false)
5995 :
ia(
std::move(adapter))
6016 const auto* loc = localeconv();
6018 return (loc->decimal_point ==
nullptr) ?
'.' : *(loc->decimal_point);
6046 const auto factors = { 12u, 8u, 4u, 0u };
6047 for (
const auto factor : factors)
6053 codepoint +=
static_cast<int>((
static_cast<unsigned int>(
current) - 0x30u) << factor);
6057 codepoint +=
static_cast<int>((
static_cast<unsigned int>(
current) - 0x37u) << factor);
6061 codepoint +=
static_cast<int>((
static_cast<unsigned int>(
current) - 0x57u) << factor);
6069 JSON_ASSERT(0x0000 <= codepoint && codepoint <= 0xFFFF);
6090 JSON_ASSERT(ranges.size() == 2 || ranges.size() == 4 || ranges.size() == 6);
6093 for (
auto range = ranges.begin(); range != ranges.end(); ++range)
6139 case std::char_traits<char_type>::eof():
6142 return token_type::parse_error;
6148 return token_type::value_string;
6193 int codepoint = codepoint1;
6197 error_message =
"invalid string: '\\u' must be followed by 4 hex digits";
6198 return token_type::parse_error;
6202 if (0xD800 <= codepoint1 && codepoint1 <= 0xDBFF)
6211 error_message =
"invalid string: '\\u' must be followed by 4 hex digits";
6212 return token_type::parse_error;
6219 codepoint =
static_cast<int>(
6221 (
static_cast<unsigned int>(codepoint1) << 10u)
6223 +
static_cast<unsigned int>(codepoint2)
6231 error_message =
"invalid string: surrogate U+D800..U+DBFF must be followed by U+DC00..U+DFFF";
6232 return token_type::parse_error;
6237 error_message =
"invalid string: surrogate U+D800..U+DBFF must be followed by U+DC00..U+DFFF";
6238 return token_type::parse_error;
6245 error_message =
"invalid string: surrogate U+DC00..U+DFFF must follow U+D800..U+DBFF";
6246 return token_type::parse_error;
6251 JSON_ASSERT(0x00 <= codepoint && codepoint <= 0x10FFFF);
6254 if (codepoint < 0x80)
6259 else if (codepoint <= 0x7FF)
6262 add(
static_cast<char_int_type>(0xC0u | (
static_cast<unsigned int>(codepoint) >> 6u)));
6263 add(
static_cast<char_int_type>(0x80u | (
static_cast<unsigned int>(codepoint) & 0x3Fu)));
6265 else if (codepoint <= 0xFFFF)
6268 add(
static_cast<char_int_type>(0xE0u | (
static_cast<unsigned int>(codepoint) >> 12u)));
6269 add(
static_cast<char_int_type>(0x80u | ((
static_cast<unsigned int>(codepoint) >> 6u) & 0x3Fu)));
6270 add(
static_cast<char_int_type>(0x80u | (
static_cast<unsigned int>(codepoint) & 0x3Fu)));
6275 add(
static_cast<char_int_type>(0xF0u | (
static_cast<unsigned int>(codepoint) >> 18u)));
6276 add(
static_cast<char_int_type>(0x80u | ((
static_cast<unsigned int>(codepoint) >> 12u) & 0x3Fu)));
6277 add(
static_cast<char_int_type>(0x80u | ((
static_cast<unsigned int>(codepoint) >> 6u) & 0x3Fu)));
6278 add(
static_cast<char_int_type>(0x80u | (
static_cast<unsigned int>(codepoint) & 0x3Fu)));
6286 error_message =
"invalid string: forbidden character after backslash";
6287 return token_type::parse_error;
6296 error_message =
"invalid string: control character U+0000 (NUL) must be escaped to \\u0000";
6297 return token_type::parse_error;
6302 error_message =
"invalid string: control character U+0001 (SOH) must be escaped to \\u0001";
6303 return token_type::parse_error;
6308 error_message =
"invalid string: control character U+0002 (STX) must be escaped to \\u0002";
6309 return token_type::parse_error;
6314 error_message =
"invalid string: control character U+0003 (ETX) must be escaped to \\u0003";
6315 return token_type::parse_error;
6320 error_message =
"invalid string: control character U+0004 (EOT) must be escaped to \\u0004";
6321 return token_type::parse_error;
6326 error_message =
"invalid string: control character U+0005 (ENQ) must be escaped to \\u0005";
6327 return token_type::parse_error;
6332 error_message =
"invalid string: control character U+0006 (ACK) must be escaped to \\u0006";
6333 return token_type::parse_error;
6338 error_message =
"invalid string: control character U+0007 (BEL) must be escaped to \\u0007";
6339 return token_type::parse_error;
6344 error_message =
"invalid string: control character U+0008 (BS) must be escaped to \\u0008 or \\b";
6345 return token_type::parse_error;
6350 error_message =
"invalid string: control character U+0009 (HT) must be escaped to \\u0009 or \\t";
6351 return token_type::parse_error;
6356 error_message =
"invalid string: control character U+000A (LF) must be escaped to \\u000A or \\n";
6357 return token_type::parse_error;
6362 error_message =
"invalid string: control character U+000B (VT) must be escaped to \\u000B";
6363 return token_type::parse_error;
6368 error_message =
"invalid string: control character U+000C (FF) must be escaped to \\u000C or \\f";
6369 return token_type::parse_error;
6374 error_message =
"invalid string: control character U+000D (CR) must be escaped to \\u000D or \\r";
6375 return token_type::parse_error;
6380 error_message =
"invalid string: control character U+000E (SO) must be escaped to \\u000E";
6381 return token_type::parse_error;
6386 error_message =
"invalid string: control character U+000F (SI) must be escaped to \\u000F";
6387 return token_type::parse_error;
6392 error_message =
"invalid string: control character U+0010 (DLE) must be escaped to \\u0010";
6393 return token_type::parse_error;
6398 error_message =
"invalid string: control character U+0011 (DC1) must be escaped to \\u0011";
6399 return token_type::parse_error;
6404 error_message =
"invalid string: control character U+0012 (DC2) must be escaped to \\u0012";
6405 return token_type::parse_error;
6410 error_message =
"invalid string: control character U+0013 (DC3) must be escaped to \\u0013";
6411 return token_type::parse_error;
6416 error_message =
"invalid string: control character U+0014 (DC4) must be escaped to \\u0014";
6417 return token_type::parse_error;
6422 error_message =
"invalid string: control character U+0015 (NAK) must be escaped to \\u0015";
6423 return token_type::parse_error;
6428 error_message =
"invalid string: control character U+0016 (SYN) must be escaped to \\u0016";
6429 return token_type::parse_error;
6434 error_message =
"invalid string: control character U+0017 (ETB) must be escaped to \\u0017";
6435 return token_type::parse_error;
6440 error_message =
"invalid string: control character U+0018 (CAN) must be escaped to \\u0018";
6441 return token_type::parse_error;
6446 error_message =
"invalid string: control character U+0019 (EM) must be escaped to \\u0019";
6447 return token_type::parse_error;
6452 error_message =
"invalid string: control character U+001A (SUB) must be escaped to \\u001A";
6453 return token_type::parse_error;
6458 error_message =
"invalid string: control character U+001B (ESC) must be escaped to \\u001B";
6459 return token_type::parse_error;
6464 error_message =
"invalid string: control character U+001C (FS) must be escaped to \\u001C";
6465 return token_type::parse_error;
6470 error_message =
"invalid string: control character U+001D (GS) must be escaped to \\u001D";
6471 return token_type::parse_error;
6476 error_message =
"invalid string: control character U+001E (RS) must be escaped to \\u001E";
6477 return token_type::parse_error;
6482 error_message =
"invalid string: control character U+001F (US) must be escaped to \\u001F";
6483 return token_type::parse_error;
6620 return token_type::parse_error;
6630 return token_type::parse_error;
6654 return token_type::parse_error;
6664 return token_type::parse_error;
6674 return token_type::parse_error;
6686 return token_type::parse_error;
6696 return token_type::parse_error;
6705 return token_type::parse_error;
6728 case std::char_traits<char_type>::eof():
6745 case std::char_traits<char_type>::eof():
6776 error_message =
"invalid comment; expecting '/' or '*' after '/'";
6783 static
void strtof(
float& f, const
char* str,
char** endptr) noexcept
6785 f = std::strtof(str, endptr);
6789 static
void strtof(
double& f, const
char* str,
char** endptr) noexcept
6791 f = std::strtod(str, endptr);
6795 static
void strtof(
long double& f, const
char* str,
char** endptr) noexcept
6797 f = std::strtold(str, endptr);
6847 token_type number_type = token_type::value_unsigned;
6855 goto scan_number_minus;
6861 goto scan_number_zero;
6875 goto scan_number_any1;
6885 number_type = token_type::value_integer;
6891 goto scan_number_zero;
6905 goto scan_number_any1;
6911 return token_type::parse_error;
6922 goto scan_number_decimal1;
6929 goto scan_number_exponent;
6933 goto scan_number_done;
6952 goto scan_number_any1;
6958 goto scan_number_decimal1;
6965 goto scan_number_exponent;
6969 goto scan_number_done;
6972scan_number_decimal1:
6974 number_type = token_type::value_float;
6989 goto scan_number_decimal2;
6995 return token_type::parse_error;
6999scan_number_decimal2:
7015 goto scan_number_decimal2;
7022 goto scan_number_exponent;
7026 goto scan_number_done;
7029scan_number_exponent:
7031 number_type = token_type::value_float;
7038 goto scan_number_sign;
7053 goto scan_number_any2;
7059 "invalid number; expected '+', '-', or digit after exponent";
7060 return token_type::parse_error;
7080 goto scan_number_any2;
7085 error_message =
"invalid number; expected digit after exponent sign";
7086 return token_type::parse_error;
7106 goto scan_number_any2;
7110 goto scan_number_done;
7118 char* endptr =
nullptr;
7122 if (number_type == token_type::value_unsigned)
7124 const auto x = std::strtoull(
token_buffer.data(), &endptr, 10);
7134 return token_type::value_unsigned;
7138 else if (number_type == token_type::value_integer)
7140 const auto x = std::strtoll(
token_buffer.data(), &endptr, 10);
7150 return token_type::value_integer;
7162 return token_type::value_float;
7175 for (std::size_t i = 1; i < length; ++i)
7180 return token_type::parse_error;
7274 token_buffer.push_back(
static_cast<typename string_t::value_type
>(c));
7325 if (
static_cast<unsigned char>(c) <=
'\x1F')
7328 std::array<char, 9> cs{{}};
7329 (std::snprintf)(cs.data(), cs.size(),
"<U+%.4X>",
static_cast<unsigned char>(c));
7330 result += cs.data();
7335 result.push_back(
static_cast<std::string::value_type
>(c));
7362 return get() == 0xBB &&
get() == 0xBF;
7385 error_message =
"invalid BOM; must be 0xEF 0xBB 0xBF if given";
7386 return token_type::parse_error;
7397 return token_type::parse_error;
7408 return token_type::begin_array;
7410 return token_type::end_array;
7412 return token_type::begin_object;
7414 return token_type::end_object;
7416 return token_type::name_separator;
7418 return token_type::value_separator;
7423 std::array<char_type, 4> true_literal = {{
't',
'r',
'u',
'e'}};
7424 return scan_literal(true_literal.data(), true_literal.size(), token_type::literal_true);
7428 std::array<char_type, 5> false_literal = {{
'f',
'a',
'l',
's',
'e'}};
7429 return scan_literal(false_literal.data(), false_literal.size(), token_type::literal_false);
7433 std::array<char_type, 4> null_literal = {{
'n',
'u',
'l',
'l'}};
7434 return scan_literal(null_literal.data(), null_literal.size(), token_type::literal_null);
7458 case std::char_traits<char_type>::eof():
7459 return token_type::end_of_input;
7464 return token_type::parse_error;
7527 decltype(std::declval<T&>().boolean(std::declval<bool>()));
7529template<
typename T,
typename Integer>
7531 decltype(std::declval<T&>().number_integer(std::declval<Integer>()));
7533template<
typename T,
typename Un
signed>
7535 decltype(std::declval<T&>().number_unsigned(std::declval<Unsigned>()));
7537template<
typename T,
typename Float,
typename String>
7539 std::declval<Float>(), std::declval<const String&>()));
7541template<
typename T,
typename String>
7543 decltype(std::declval<T&>().string(std::declval<String&>()));
7545template<
typename T,
typename Binary>
7547 decltype(std::declval<T&>().binary(std::declval<Binary&>()));
7551 decltype(std::declval<T&>().start_object(std::declval<std::size_t>()));
7553template<
typename T,
typename String>
7555 decltype(std::declval<T&>().key(std::declval<String&>()));
7562 decltype(std::declval<T&>().start_array(std::declval<std::size_t>()));
7567template<
typename T,
typename Exception>
7569 std::declval<std::size_t>(), std::declval<const std::string&>(),
7570 std::declval<const Exception&>()));
7572template<
typename SAX,
typename BasicJsonType>
7577 "BasicJsonType must be of type basic_json<...>");
7603template<
typename SAX,
typename BasicJsonType>
7608 "BasicJsonType must be of type basic_json<...>");
7619 "Missing/invalid function: bool null()");
7621 "Missing/invalid function: bool boolean(bool)");
7623 "Missing/invalid function: bool boolean(bool)");
7627 "Missing/invalid function: bool number_integer(number_integer_t)");
7631 "Missing/invalid function: bool number_unsigned(number_unsigned_t)");
7634 "Missing/invalid function: bool number_float(number_float_t, const string_t&)");
7637 "Missing/invalid function: bool string(string_t&)");
7640 "Missing/invalid function: bool binary(binary_t&)");
7642 "Missing/invalid function: bool start_object(std::size_t)");
7644 "Missing/invalid function: bool key(string_t&)");
7646 "Missing/invalid function: bool end_object()");
7648 "Missing/invalid function: bool start_array(std::size_t)");
7650 "Missing/invalid function: bool end_array()");
7653 "Missing/invalid function: bool parse_error(std::size_t, const "
7654 "std::string&, const exception&)");
7683 return *
reinterpret_cast<char*
>(&num) == 1;
7694template<
typename BasicJsonType,
typename InputAdapterType,
typename SAX = json_sax_dom_parser<BasicJsonType>>
7735 const
bool strict = true,
7739 bool result =
false;
7796 std::int32_t document_size{};
7809 return sax->end_object();
7821 auto out = std::back_inserter(result);
7833 *out++ =
static_cast<typename string_t::value_type
>(
current);
7848 template<
typename NumberType>
7869 template<
typename NumberType>
7879 std::uint8_t subtype{};
7881 result.set_subtype(subtype);
7897 const std::size_t element_type_parse_position)
7899 switch (element_type)
7933 return sax->boolean(
get() != 0);
7943 std::int32_t
value{};
7949 std::int64_t
value{};
7955 std::array<char, 3> cr{{}};
7956 (std::snprintf)(cr.data(), cr.size(),
"%.2hhX",
static_cast<unsigned char>(element_type));
7957 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())));
7978 while (
auto element_type =
get())
7985 const std::size_t element_type_parse_position =
chars_read;
7991 if (!is_array && !
sax->key(
key))
8014 std::int32_t document_size{};
8027 return sax->end_array();
8048 case std::char_traits<char_type>::eof():
8080 std::uint8_t number{};
8086 std::uint16_t number{};
8092 std::uint32_t number{};
8098 std::uint64_t number{};
8127 return sax->number_integer(
static_cast<std::int8_t
>(0x20 - 1 -
current));
8131 std::uint8_t number{};
8137 std::uint16_t number{};
8143 std::uint32_t number{};
8149 std::uint64_t number{};
8249 return get_cbor_array(
static_cast<std::size_t
>(
static_cast<unsigned int>(
current) & 0x1Fu), tag_handler);
8259 std::uint16_t len{};
8265 std::uint32_t len{};
8271 std::uint64_t len{};
8303 return get_cbor_object(
static_cast<std::size_t
>(
static_cast<unsigned int>(
current) & 0x1Fu), tag_handler);
8313 std::uint16_t len{};
8319 std::uint32_t len{};
8325 std::uint64_t len{};
8352 switch (tag_handler)
8372 std::uint16_t len{};
8378 std::uint32_t len{};
8384 std::uint64_t len{};
8400 return sax->boolean(
false);
8403 return sax->boolean(
true);
8410 const auto byte1_raw =
get();
8415 const auto byte2_raw =
get();
8421 const auto byte1 =
static_cast<unsigned char>(byte1_raw);
8422 const auto byte2 =
static_cast<unsigned char>(byte2_raw);
8432 const auto half =
static_cast<unsigned int>((byte1 << 8u) + byte2);
8433 const double val = [&half]
8435 const int exp = (half >> 10u) & 0x1Fu;
8436 const unsigned int mant = half & 0x3FFu;
8442 return std::ldexp(mant, -24);
8445 ? std::numeric_limits<double>::infinity()
8446 : std::numeric_limits<double>::quiet_NaN();
8448 return std::ldexp(mant + 1024, exp - 25);
8451 return sax->number_float((half & 0x8000u) != 0
8533 std::uint16_t len{};
8539 std::uint32_t len{};
8545 std::uint64_t len{};
8551 while (
get() != 0xFF)
8558 result.append(chunk);
8629 std::uint16_t len{};
8636 std::uint32_t len{};
8643 std::uint64_t len{};
8650 while (
get() != 0xFF)
8657 result.insert(result.end(), chunk.begin(), chunk.end());
8684 if (len != std::size_t(-1))
8686 for (std::size_t i = 0; i < len; ++i)
8696 while (
get() != 0xFF)
8705 return sax->end_array();
8723 if (len != std::size_t(-1))
8725 for (std::size_t i = 0; i < len; ++i)
8742 while (
get() != 0xFF)
8757 return sax->end_object();
8772 case std::char_traits<char_type>::eof():
8989 return sax->boolean(
false);
8992 return sax->boolean(
true);
9024 std::uint8_t number{};
9030 std::uint16_t number{};
9036 std::uint32_t number{};
9042 std::uint64_t number{};
9048 std::int8_t number{};
9054 std::int16_t number{};
9060 std::int32_t number{};
9066 std::int64_t number{};
9072 std::uint16_t len{};
9078 std::uint32_t len{};
9084 std::uint16_t len{};
9090 std::uint32_t len{};
9127 return sax->number_integer(
static_cast<std::int8_t
>(
current));
9201 std::uint16_t len{};
9207 std::uint32_t len{};
9232 auto assign_and_return_true = [&result](std::int8_t subtype)
9234 result.set_subtype(
static_cast<std::uint8_t
>(subtype));
9249 std::uint16_t len{};
9256 std::uint32_t len{};
9264 std::int8_t subtype{};
9268 assign_and_return_true(subtype);
9273 std::uint16_t len{};
9274 std::int8_t subtype{};
9278 assign_and_return_true(subtype);
9283 std::uint32_t len{};
9284 std::int8_t subtype{};
9288 assign_and_return_true(subtype);
9293 std::int8_t subtype{};
9296 assign_and_return_true(subtype);
9301 std::int8_t subtype{};
9304 assign_and_return_true(subtype);
9309 std::int8_t subtype{};
9312 assign_and_return_true(subtype);
9317 std::int8_t subtype{};
9320 assign_and_return_true(subtype);
9325 std::int8_t subtype{};
9328 assign_and_return_true(subtype);
9347 for (std::size_t i = 0; i < len; ++i)
9355 return sax->end_array();
9370 for (std::size_t i = 0; i < len; ++i)
9385 return sax->end_object();
9464 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")));
9478 std::uint8_t number{};
9483 result =
static_cast<std::size_t
>(number);
9489 std::int8_t number{};
9494 result =
static_cast<std::size_t
>(number);
9500 std::int16_t number{};
9505 result =
static_cast<std::size_t
>(number);
9511 std::int32_t number{};
9516 result =
static_cast<std::size_t
>(number);
9522 std::int64_t number{};
9527 result =
static_cast<std::size_t
>(number);
9534 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")));
9551 result.first = string_t::npos;
9558 result.second =
get();
9594 case std::char_traits<char_type>::eof():
9598 return sax->boolean(
true);
9600 return sax->boolean(
false);
9607 std::uint8_t number{};
9613 std::int8_t number{};
9619 std::int16_t number{};
9625 std::int32_t number{};
9631 std::int64_t number{};
9665 return sax->string(s);
9693 std::pair<std::size_t, char_int_type> size_and_type;
9699 if (size_and_type.first != string_t::npos)
9706 if (size_and_type.second != 0)
9708 if (size_and_type.second !=
'N')
9710 for (std::size_t i = 0; i < size_and_type.first; ++i)
9721 for (std::size_t i = 0; i < size_and_type.first; ++i)
9747 return sax->end_array();
9755 std::pair<std::size_t, char_int_type> size_and_type;
9762 if (size_and_type.first != string_t::npos)
9769 if (size_and_type.second != 0)
9771 for (std::size_t i = 0; i < size_and_type.first; ++i)
9786 for (std::size_t i = 0; i < size_and_type.first; ++i)
9822 return sax->end_object();
9839 std::vector<char> number_vector;
9840 for (std::size_t i = 0; i < size; ++i)
9847 number_vector.push_back(
static_cast<char>(
current));
9853 const auto result_number = number_lexer.scan();
9854 const auto number_string = number_lexer.get_token_string();
9855 const auto result_remainder = number_lexer.scan();
9864 switch (result_number)
9866 case token_type::value_integer:
9867 return sax->number_integer(number_lexer.get_number_integer());
9868 case token_type::value_unsigned:
9869 return sax->number_unsigned(number_lexer.get_number_unsigned());
9870 case token_type::value_float:
9871 return sax->number_float(number_lexer.get_number_float(), std::move(number_string));
9923 template<
typename NumberType,
bool InputIsLittleEndian = false>
9927 std::array<std::uint8_t,
sizeof(NumberType)> vec;
9928 for (std::size_t i = 0; i <
sizeof(NumberType); ++i)
9939 vec[
sizeof(NumberType) - i - 1] =
static_cast<std::uint8_t
>(
current);
9943 vec[i] =
static_cast<std::uint8_t
>(
current);
9948 std::memcpy(&result, vec.data(),
sizeof(NumberType));
9966 template<
typename NumberType>
9968 const NumberType len,
9971 bool success =
true;
9972 for (NumberType i = 0; i < len; i++)
9980 result.push_back(
static_cast<typename string_t::value_type
>(
current));
9999 template<
typename NumberType>
10001 const NumberType len,
10004 bool success =
true;
10005 for (NumberType i = 0; i < len; i++)
10013 result.push_back(
static_cast<std::uint8_t
>(
current));
10039 std::array<char, 3> cr{{}};
10040 (std::snprintf)(cr.data(), cr.size(),
"%.2hhX",
static_cast<unsigned char>(
current));
10041 return std::string{cr.data()};
10051 const std::string& detail,
10052 const std::string& context)
const
10054 std::string error_msg =
"syntax error while parsing ";
10059 error_msg +=
"CBOR";
10063 error_msg +=
"MessagePack";
10067 error_msg +=
"UBJSON";
10071 error_msg +=
"BSON";
10078 return error_msg +
" " + context +
": " + detail;
10109#include <functional>
10153template<
typename BasicJsonType>
10155 std::function<bool(
int depth,
parse_event_t event, BasicJsonType& parsed)>;
10162template<
typename BasicJsonType,
typename InputAdapterType>
10176 const bool allow_exceptions_ =
true,
10177 const bool skip_comments =
false)
10179 ,
m_lexer(
std::move(adapter), skip_comments)
10202 result.assert_invariant();
10222 if (result.is_discarded())
10231 result.assert_invariant();
10263 template<
typename SAX>
10273 return sax->parse_error(
m_lexer.get_position(),
10283 template<
typename SAX>
10289 std::vector<bool> states;
10291 bool skip_to_state_evaluation =
false;
10295 if (!skip_to_state_evaluation)
10300 case token_type::begin_object:
10308 if (
get_token() == token_type::end_object)
10320 return sax->parse_error(
m_lexer.get_position(),
10333 return sax->parse_error(
m_lexer.get_position(),
10340 states.push_back(
false);
10347 case token_type::begin_array:
10355 if (
get_token() == token_type::end_array)
10365 states.push_back(
true);
10371 case token_type::value_float:
10373 const auto res =
m_lexer.get_number_float();
10377 return sax->parse_error(
m_lexer.get_position(),
10390 case token_type::literal_false:
10399 case token_type::literal_null:
10408 case token_type::literal_true:
10417 case token_type::value_integer:
10426 case token_type::value_string:
10435 case token_type::value_unsigned:
10444 case token_type::parse_error:
10447 return sax->parse_error(
m_lexer.get_position(),
10455 return sax->parse_error(
m_lexer.get_position(),
10464 skip_to_state_evaluation =
false;
10468 if (states.empty())
10477 if (
get_token() == token_type::value_separator)
10498 skip_to_state_evaluation =
true;
10502 return sax->parse_error(
m_lexer.get_position(),
10510 if (
get_token() == token_type::value_separator)
10515 return sax->parse_error(
m_lexer.get_position(),
10529 return sax->parse_error(
m_lexer.get_position(),
10554 skip_to_state_evaluation =
true;
10558 return sax->parse_error(
m_lexer.get_position(),
10574 std::string error_msg =
"syntax error ";
10576 if (!context.empty())
10578 error_msg +=
"while parsing " + context +
" ";
10585 error_msg += std::string(
m_lexer.get_error_message()) +
"; last read: '" +
10586 m_lexer.get_token_string() +
"'";
10590 error_msg +=
"unexpected " + std::string(lexer_t::token_type_name(
last_token));
10593 if (expected != token_type::uninitialized)
10595 error_msg +=
"; expected " + std::string(lexer_t::token_type_name(expected));
10678 return lhs.m_it == rhs.m_it;
10683 return lhs.m_it < rhs.m_it;
10688 auto result = *
this;
10695 return lhs.m_it - rhs.m_it;
10706 auto result = *
this;
10719 auto result = *
this;
10766#include <type_traits>
10788template<
typename IteratorType>
class iteration_proxy;
10789template<
typename IteratorType>
class iteration_proxy_value;
10807template<
typename BasicJsonType>
10820 "iter_impl only accepts (const) basic_json");
10836 using pointer =
typename std::conditional<std::is_const<BasicJsonType>::value,
10837 typename BasicJsonType::const_pointer,
10838 typename BasicJsonType::pointer>::type;
10841 typename std::conditional<std::is_const<BasicJsonType>::value,
10842 typename BasicJsonType::const_reference,
10843 typename BasicJsonType::reference>::type;
11081 auto result = *
this;
11124 auto result = *
this;
11230 return !other.operator < (*this);
11295 auto result = *
this;
11317 auto result = *
this;
11378 const typename object_t::key_type&
key()
const
11443template<
typename Base>
11517 auto it = --this->base();
11524 auto it = --this->base();
11525 return it.operator * ();
11536#include <algorithm>
11553template<
typename BasicJsonType>
11604 [](
const std::string & a,
const std::string & b)
11606 return a +
"/" + escape(b);
11611 operator std::string()
const
11680 return *
this /= std::to_string(array_idx);
11869 static typename BasicJsonType::size_type
array_index(
const std::string& s)
11871 using size_type =
typename BasicJsonType::size_type;
11877 "array index '" + s +
11878 "' must not begin with '0'"));
11887 std::size_t processed_chars = 0;
11888 unsigned long long res = 0;
11891 res = std::stoull(s, &processed_chars);
11906 if (res >=
static_cast<unsigned long long>((std::numeric_limits<size_type>::max)()))
11911 return static_cast<size_type
>(res);
11942 switch (result->type())
11946 if (reference_token ==
"0")
11949 result = &result->operator[](0);
11954 result = &result->operator[](reference_token);
11962 result = &result->operator[](reference_token);
11969 result = &result->operator[](
array_index(reference_token));
12011 if (ptr->is_null())
12015 std::all_of(reference_token.begin(), reference_token.end(),
12016 [](
const unsigned char x)
12018 return std::isdigit(x);
12022 *ptr = (nums || reference_token ==
"-")
12027 switch (ptr->type())
12032 ptr = &ptr->operator[](reference_token);
12038 if (reference_token ==
"-")
12041 ptr = &ptr->operator[](ptr->m_value.array->size());
12046 ptr = &ptr->operator[](
array_index(reference_token));
12069 switch (ptr->type())
12074 ptr = &ptr->at(reference_token);
12084 "array index '-' (" + std::to_string(ptr->m_value.array->size()) +
12085 ") is out of range"));
12118 switch (ptr->type())
12123 ptr = &ptr->operator[](reference_token);
12133 "array index '-' (" + std::to_string(ptr->m_value.array->size()) +
12134 ") is out of range"));
12138 ptr = &ptr->operator[](
array_index(reference_token));
12160 switch (ptr->type())
12165 ptr = &ptr->at(reference_token);
12175 "array index '-' (" + std::to_string(ptr->m_value.array->size()) +
12176 ") is out of range"));
12200 switch (ptr->type())
12204 if (!ptr->contains(reference_token))
12210 ptr = &ptr->operator[](reference_token);
12221 if (
JSON_HEDLEY_UNLIKELY(reference_token.size() == 1 && !(
"0" <= reference_token && reference_token <=
"9")))
12233 for (std::size_t i = 1; i < reference_token.size(); i++)
12244 if (idx >= ptr->size())
12250 ptr = &ptr->operator[](idx);
12276 static std::vector<std::string>
split(
const std::string& reference_string)
12278 std::vector<std::string> result;
12281 if (reference_string.empty())
12290 "JSON pointer must be empty or begin with '/' - was: '" +
12291 reference_string +
"'"));
12299 std::size_t slash = reference_string.find_first_of(
'/', 1),
12306 start = (slash == std::string::npos) ? 0 : slash + 1,
12308 slash = reference_string.find_first_of(
'/', start))
12312 auto reference_token = reference_string.substr(start, slash - start);
12315 for (std::size_t pos = reference_token.find_first_of(
'~');
12316 pos != std::string::npos;
12317 pos = reference_token.find_first_of(
'~', pos + 1))
12323 (reference_token[pos + 1] !=
'0' &&
12324 reference_token[pos + 1] !=
'1')))
12332 result.push_back(reference_token);
12352 const std::string& t)
12355 for (
auto pos = s.find(f);
12356 pos != std::string::npos;
12357 s.replace(pos, f.size(), t),
12358 pos = s.find(f, pos + t.size()))
12384 static void flatten(
const std::string& reference_string,
12385 const BasicJsonType& value,
12386 BasicJsonType& result)
12388 switch (value.type())
12392 if (value.m_value.array->empty())
12395 result[reference_string] =
nullptr;
12400 for (std::size_t i = 0; i < value.m_value.array->size(); ++i)
12402 flatten(reference_string +
"/" + std::to_string(i),
12403 value.m_value.array->operator[](i), result);
12411 if (value.m_value.object->empty())
12414 result[reference_string] =
nullptr;
12419 for (
const auto& element : *value.m_value.object)
12421 flatten(reference_string +
"/" +
escape(element.first), element.second, result);
12430 result[reference_string] = value;
12446 static BasicJsonType
12454 BasicJsonType result;
12457 for (
const auto& element : *value.m_value.object)
12488 return lhs.reference_tokens == rhs.reference_tokens;
12505 return !(lhs == rhs);
12516#include <initializer_list>
12526template<
typename BasicJsonType>
12601#include <algorithm>
12616#include <algorithm>
12640template<
typename CharType>
12644template<
typename CharType>
12658 void write_characters(const CharType* s,
std::
size_t length)
override
12660 std::copy(s, s + length, std::back_inserter(v));
12664 std::vector<CharType>&
v;
12668template<
typename CharType>
12682 void write_characters(const CharType* s,
std::
size_t length)
override
12684 stream.write(s,
static_cast<std::streamsize
>(length));
12692template<
typename CharType,
typename StringType = std::basic_
string<CharType>>
12706 void write_characters(const CharType* s,
std::
size_t length)
override
12708 str.append(s, length);
12715template<
typename CharType,
typename StringType = std::basic_
string<CharType>>
12751template<
typename BasicJsonType,
typename CharType>
12805 oa->write_character(j.m_value.boolean
12813 if (j.m_value.number_integer >= 0)
12818 if (j.m_value.number_integer <= 0x17)
12820 write_number(
static_cast<std::uint8_t
>(j.m_value.number_integer));
12822 else if (j.m_value.number_integer <= (std::numeric_limits<std::uint8_t>::max)())
12825 write_number(
static_cast<std::uint8_t
>(j.m_value.number_integer));
12827 else if (j.m_value.number_integer <= (std::numeric_limits<std::uint16_t>::max)())
12830 write_number(
static_cast<std::uint16_t
>(j.m_value.number_integer));
12832 else if (j.m_value.number_integer <= (std::numeric_limits<std::uint32_t>::max)())
12835 write_number(
static_cast<std::uint32_t
>(j.m_value.number_integer));
12840 write_number(
static_cast<std::uint64_t
>(j.m_value.number_integer));
12847 const auto positive_number = -1 - j.m_value.number_integer;
12848 if (j.m_value.number_integer >= -24)
12850 write_number(
static_cast<std::uint8_t
>(0x20 + positive_number));
12852 else if (positive_number <= (std::numeric_limits<std::uint8_t>::max)())
12855 write_number(
static_cast<std::uint8_t
>(positive_number));
12857 else if (positive_number <= (std::numeric_limits<std::uint16_t>::max)())
12860 write_number(
static_cast<std::uint16_t
>(positive_number));
12862 else if (positive_number <= (std::numeric_limits<std::uint32_t>::max)())
12865 write_number(
static_cast<std::uint32_t
>(positive_number));
12870 write_number(
static_cast<std::uint64_t
>(positive_number));
12878 if (j.m_value.number_unsigned <= 0x17)
12880 write_number(
static_cast<std::uint8_t
>(j.m_value.number_unsigned));
12882 else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint8_t>::max)())
12885 write_number(
static_cast<std::uint8_t
>(j.m_value.number_unsigned));
12887 else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint16_t>::max)())
12890 write_number(
static_cast<std::uint16_t
>(j.m_value.number_unsigned));
12892 else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint32_t>::max)())
12895 write_number(
static_cast<std::uint32_t
>(j.m_value.number_unsigned));
12900 write_number(
static_cast<std::uint64_t
>(j.m_value.number_unsigned));
12907 if (std::isnan(j.m_value.number_float))
12914 else if (std::isinf(j.m_value.number_float))
12931 const auto N = j.m_value.string->size();
12936 else if (N <= (std::numeric_limits<std::uint8_t>::max)())
12941 else if (N <= (std::numeric_limits<std::uint16_t>::max)())
12946 else if (N <= (std::numeric_limits<std::uint32_t>::max)())
12952 else if (N <= (std::numeric_limits<std::uint64_t>::max)())
12960 oa->write_characters(
12961 reinterpret_cast<const CharType*
>(j.m_value.string->c_str()),
12962 j.m_value.string->size());
12969 const auto N = j.m_value.array->size();
12974 else if (N <= (std::numeric_limits<std::uint8_t>::max)())
12979 else if (N <= (std::numeric_limits<std::uint16_t>::max)())
12984 else if (N <= (std::numeric_limits<std::uint32_t>::max)())
12990 else if (N <= (std::numeric_limits<std::uint64_t>::max)())
12998 for (
const auto& el : *j.m_value.array)
13007 if (j.m_value.binary->has_subtype())
13014 const auto N = j.m_value.binary->size();
13019 else if (N <= (std::numeric_limits<std::uint8_t>::max)())
13024 else if (N <= (std::numeric_limits<std::uint16_t>::max)())
13029 else if (N <= (std::numeric_limits<std::uint32_t>::max)())
13035 else if (N <= (std::numeric_limits<std::uint64_t>::max)())
13043 oa->write_characters(
13044 reinterpret_cast<const CharType*
>(j.m_value.binary->data()),
13053 const auto N = j.m_value.object->size();
13058 else if (N <= (std::numeric_limits<std::uint8_t>::max)())
13063 else if (N <= (std::numeric_limits<std::uint16_t>::max)())
13068 else if (N <= (std::numeric_limits<std::uint32_t>::max)())
13074 else if (N <= (std::numeric_limits<std::uint64_t>::max)())
13082 for (
const auto& el : *j.m_value.object)
13110 oa->write_character(j.m_value.boolean
13118 if (j.m_value.number_integer >= 0)
13123 if (j.m_value.number_unsigned < 128)
13126 write_number(
static_cast<std::uint8_t
>(j.m_value.number_integer));
13128 else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint8_t>::max)())
13132 write_number(
static_cast<std::uint8_t
>(j.m_value.number_integer));
13134 else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint16_t>::max)())
13138 write_number(
static_cast<std::uint16_t
>(j.m_value.number_integer));
13140 else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint32_t>::max)())
13144 write_number(
static_cast<std::uint32_t
>(j.m_value.number_integer));
13146 else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint64_t>::max)())
13150 write_number(
static_cast<std::uint64_t
>(j.m_value.number_integer));
13155 if (j.m_value.number_integer >= -32)
13158 write_number(
static_cast<std::int8_t
>(j.m_value.number_integer));
13160 else if (j.m_value.number_integer >= (std::numeric_limits<std::int8_t>::min)() &&
13161 j.m_value.number_integer <= (std::numeric_limits<std::int8_t>::max)())
13165 write_number(
static_cast<std::int8_t
>(j.m_value.number_integer));
13167 else if (j.m_value.number_integer >= (std::numeric_limits<std::int16_t>::min)() &&
13168 j.m_value.number_integer <= (std::numeric_limits<std::int16_t>::max)())
13172 write_number(
static_cast<std::int16_t
>(j.m_value.number_integer));
13174 else if (j.m_value.number_integer >= (std::numeric_limits<std::int32_t>::min)() &&
13175 j.m_value.number_integer <= (std::numeric_limits<std::int32_t>::max)())
13179 write_number(
static_cast<std::int32_t
>(j.m_value.number_integer));
13181 else if (j.m_value.number_integer >= (std::numeric_limits<std::int64_t>::min)() &&
13182 j.m_value.number_integer <= (std::numeric_limits<std::int64_t>::max)())
13186 write_number(
static_cast<std::int64_t
>(j.m_value.number_integer));
13194 if (j.m_value.number_unsigned < 128)
13197 write_number(
static_cast<std::uint8_t
>(j.m_value.number_integer));
13199 else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint8_t>::max)())
13203 write_number(
static_cast<std::uint8_t
>(j.m_value.number_integer));
13205 else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint16_t>::max)())
13209 write_number(
static_cast<std::uint16_t
>(j.m_value.number_integer));
13211 else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint32_t>::max)())
13215 write_number(
static_cast<std::uint32_t
>(j.m_value.number_integer));
13217 else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint64_t>::max)())
13221 write_number(
static_cast<std::uint64_t
>(j.m_value.number_integer));
13235 const auto N = j.m_value.string->size();
13241 else if (N <= (std::numeric_limits<std::uint8_t>::max)())
13247 else if (N <= (std::numeric_limits<std::uint16_t>::max)())
13253 else if (N <= (std::numeric_limits<std::uint32_t>::max)())
13261 oa->write_characters(
13262 reinterpret_cast<const CharType*
>(j.m_value.string->c_str()),
13263 j.m_value.string->size());
13270 const auto N = j.m_value.array->size();
13276 else if (N <= (std::numeric_limits<std::uint16_t>::max)())
13282 else if (N <= (std::numeric_limits<std::uint32_t>::max)())
13290 for (
const auto& el : *j.m_value.array)
13301 const bool use_ext = j.m_value.binary->has_subtype();
13304 const auto N = j.m_value.binary->size();
13305 if (N <= (std::numeric_limits<std::uint8_t>::max)())
13307 std::uint8_t output_type{};
13314 output_type = 0xD4;
13317 output_type = 0xD5;
13320 output_type = 0xD6;
13323 output_type = 0xD7;
13326 output_type = 0xD8;
13329 output_type = 0xC7;
13337 output_type = 0xC4;
13347 else if (N <= (std::numeric_limits<std::uint16_t>::max)())
13349 std::uint8_t output_type = use_ext
13356 else if (N <= (std::numeric_limits<std::uint32_t>::max)())
13358 std::uint8_t output_type = use_ext
13369 write_number(
static_cast<std::int8_t
>(j.m_value.binary->subtype()));
13373 oa->write_characters(
13374 reinterpret_cast<const CharType*
>(j.m_value.binary->data()),
13383 const auto N = j.m_value.object->size();
13387 write_number(
static_cast<std::uint8_t
>(0x80 | (N & 0xF)));
13389 else if (N <= (std::numeric_limits<std::uint16_t>::max)())
13395 else if (N <= (std::numeric_limits<std::uint32_t>::max)())
13403 for (
const auto& el : *j.m_value.object)
13423 const bool use_type,
const bool add_prefix =
true)
13440 oa->write_character(j.m_value.boolean
13472 oa->write_characters(
13473 reinterpret_cast<const CharType*
>(j.m_value.string->c_str()),
13474 j.m_value.string->size());
13485 bool prefix_required =
true;
13486 if (use_type && !j.m_value.array->empty())
13490 const bool same_prefix = std::all_of(j.begin() + 1, j.end(),
13491 [
this, first_prefix](
const BasicJsonType & v)
13493 return ubjson_prefix(v) == first_prefix;
13498 prefix_required =
false;
13500 oa->write_character(first_prefix);
13510 for (
const auto& el : *j.m_value.array)
13512 write_ubjson(el, use_count, use_type, prefix_required);
13530 if (use_type && !j.m_value.binary->empty())
13534 oa->write_character(
'U');
13545 oa->write_characters(
13546 reinterpret_cast<const CharType*
>(j.m_value.binary->data()),
13547 j.m_value.binary->size());
13551 for (
size_t i = 0; i < j.m_value.binary->size(); ++i)
13554 oa->write_character(j.m_value.binary->data()[i]);
13573 bool prefix_required =
true;
13574 if (use_type && !j.m_value.object->empty())
13578 const bool same_prefix = std::all_of(j.begin(), j.end(),
13579 [
this, first_prefix](
const BasicJsonType & v)
13581 return ubjson_prefix(v) == first_prefix;
13586 prefix_required =
false;
13588 oa->write_character(first_prefix);
13598 for (
const auto& el : *j.m_value.object)
13601 oa->write_characters(
13602 reinterpret_cast<const CharType*
>(el.first.c_str()),
13604 write_ubjson(el.second, use_count, use_type, prefix_required);
13631 const auto it = name.find(
static_cast<typename string_t::value_type
>(0));
13635 "BSON key cannot contain code point U+0000 (at byte " + std::to_string(it) +
")"));
13638 return 1ul + name.size() + 1u;
13645 const std::uint8_t element_type)
13648 oa->write_characters(
13649 reinterpret_cast<const CharType*
>(name.c_str()),
13667 const double value)
13670 write_number<double, true>(
value);
13678 return sizeof(std::int32_t) +
value.size() + 1ul;
13689 write_number<std::int32_t, true>(
static_cast<std::int32_t
>(
value.size() + 1ul));
13690 oa->write_characters(
13691 reinterpret_cast<const CharType*
>(
value.c_str()),
13708 return (std::numeric_limits<std::int32_t>::min)() <=
value &&
value <= (std::numeric_limits<std::int32_t>::max)()
13709 ?
sizeof(std::int32_t)
13710 :
sizeof(std::int64_t);
13717 const std::int64_t
value)
13719 if ((std::numeric_limits<std::int32_t>::min)() <=
value &&
value <= (std::numeric_limits<std::int32_t>::max)())
13722 write_number<std::int32_t, true>(
static_cast<std::int32_t
>(
value));
13727 write_number<std::int64_t, true>(
static_cast<std::int64_t
>(
value));
13736 return (
value <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int32_t>::max)()))
13737 ?
sizeof(std::int32_t)
13738 :
sizeof(std::int64_t);
13745 const std::uint64_t
value)
13747 if (
value <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int32_t>::max)()))
13750 write_number<std::int32_t, true>(
static_cast<std::int32_t
>(
value));
13752 else if (
value <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int64_t>::max)()))
13755 write_number<std::int64_t, true>(
static_cast<std::int64_t
>(
value));
13767 const typename BasicJsonType::object_t&
value)
13778 std::size_t array_index = 0ul;
13780 const std::size_t embedded_document_size = std::accumulate(std::begin(
value), std::end(
value), std::size_t(0), [&array_index](std::size_t result,
const typename BasicJsonType::array_t::value_type & el)
13785 return sizeof(std::int32_t) + embedded_document_size + 1ul;
13793 return sizeof(std::int32_t) +
value.size() + 1ul;
13800 const typename BasicJsonType::array_t&
value)
13805 std::size_t array_index = 0ul;
13807 for (
const auto& el :
value)
13823 write_number<std::int32_t, true>(
static_cast<std::int32_t
>(
value.size()));
13826 oa->write_characters(
reinterpret_cast<const CharType*
>(
value.data()),
value.size());
13834 const BasicJsonType& j)
13849 return header_size + 1ul;
13852 return header_size + 8ul;
13864 return header_size + 0ul;
13882 const BasicJsonType& j)
13929 std::size_t document_size = std::accumulate(
value.begin(),
value.end(), std::size_t(0),
13930 [](
size_t result,
const typename BasicJsonType::object_t::value_type & el)
13932 return result += calc_bson_element_size(el.first, el.second);
13935 return sizeof(std::int32_t) + document_size + 1ul;
13946 for (
const auto& el :
value)
13987 template<
typename NumberType,
typename std::enable_if<
13988 std::is_floating_point<NumberType>::value,
int>::type = 0>
13990 const bool add_prefix)
14000 template<
typename NumberType,
typename std::enable_if<
14001 std::is_unsigned<NumberType>::value,
int>::type = 0>
14003 const bool add_prefix)
14005 if (n <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int8_t>::max)()))
14013 else if (n <= (std::numeric_limits<std::uint8_t>::max)())
14021 else if (n <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int16_t>::max)()))
14029 else if (n <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int32_t>::max)()))
14037 else if (n <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int64_t>::max)()))
14052 const auto number = BasicJsonType(n).dump();
14054 for (std::size_t i = 0; i < number.size(); ++i)
14056 oa->write_character(
to_char_type(
static_cast<std::uint8_t
>(number[i])));
14062 template <
typename NumberType,
typename std::enable_if <
14063 std::is_signed<NumberType>::value&&
14064 !std::is_floating_point<NumberType>::value,
int >::type = 0 >
14066 const bool add_prefix)
14068 if ((std::numeric_limits<std::int8_t>::min)() <= n && n <= (std::numeric_limits<std::int8_t>::max)())
14076 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)()))
14084 else if ((std::numeric_limits<std::int16_t>::min)() <= n && n <= (std::numeric_limits<std::int16_t>::max)())
14092 else if ((std::numeric_limits<std::int32_t>::min)() <= n && n <= (std::numeric_limits<std::int32_t>::max)())
14100 else if ((std::numeric_limits<std::int64_t>::min)() <= n && n <= (std::numeric_limits<std::int64_t>::max)())
14116 const auto number = BasicJsonType(n).dump();
14118 for (std::size_t i = 0; i < number.size(); ++i)
14120 oa->write_character(
to_char_type(
static_cast<std::uint8_t
>(number[i])));
14137 return j.m_value.boolean ?
'T' :
'F';
14141 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)())
14145 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)())
14149 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)())
14153 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)())
14157 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)())
14167 if (j.m_value.number_unsigned <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int8_t>::max)()))
14171 if (j.m_value.number_unsigned <=
static_cast<std::uint64_t
>((std::numeric_limits<std::uint8_t>::max)()))
14175 if (j.m_value.number_unsigned <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int16_t>::max)()))
14179 if (j.m_value.number_unsigned <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int32_t>::max)()))
14183 if (j.m_value.number_unsigned <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int64_t>::max)()))
14234 template<
typename NumberType,
bool OutputIsLittleEndian = false>
14238 std::array<CharType,
sizeof(NumberType)> vec;
14239 std::memcpy(vec.data(), &n,
sizeof(NumberType));
14245 std::reverse(vec.begin(), vec.end());
14248 oa->write_characters(vec.data(),
sizeof(NumberType));
14253 if (
static_cast<double>(n) >=
static_cast<double>(std::numeric_limits<float>::lowest()) &&
14254 static_cast<double>(n) <=
static_cast<double>((std::numeric_limits<float>::max)()) &&
14255 static_cast<double>(
static_cast<float>(n)) ==
static_cast<double>(n))
14276 template <
typename C = CharType,
14277 enable_if_t < std::is_signed<C>::value && std::is_signed<char>::value > * =
nullptr >
14280 return *
reinterpret_cast<char*
>(&x);
14283 template <
typename C = CharType,
14284 enable_if_t < std::is_signed<C>::value && std::is_unsigned<char>::value > * =
nullptr >
14287 static_assert(
sizeof(std::uint8_t) ==
sizeof(CharType),
"size of CharType must be equal to std::uint8_t");
14288 static_assert(std::is_trivial<CharType>::value,
"CharType must be trivial");
14290 std::memcpy(&result, &x,
sizeof(x));
14294 template<
typename C = CharType,
14301 template <
typename InputCharType,
typename C = CharType,
14303 std::is_signed<C>::value &&
14304 std::is_signed<char>::value &&
14305 std::is_same<char, typename std::remove_cv<InputCharType>::type>
::value
14327#include <algorithm>
14336#include <type_traits>
14347#include <type_traits>
14379template<
typename Target,
typename Source>
14382 static_assert(
sizeof(Target) ==
sizeof(Source),
"size mismatch");
14385 std::memcpy(&target, &source,
sizeof(Source));
14396 constexpr diyfp(std::uint64_t f_,
int e_) noexcept :
f(f_),
e(e_) {}
14407 return {x.f - y.f, x.e};
14416 static_assert(
kPrecision == 64,
"internal error");
14441 const std::uint64_t u_lo = x.
f & 0xFFFFFFFFu;
14442 const std::uint64_t u_hi = x.f >> 32u;
14443 const std::uint64_t v_lo = y.f & 0xFFFFFFFFu;
14444 const std::uint64_t v_hi = y.f >> 32u;
14446 const std::uint64_t p0 = u_lo * v_lo;
14447 const std::uint64_t p1 = u_lo * v_hi;
14448 const std::uint64_t p2 = u_hi * v_lo;
14449 const std::uint64_t p3 = u_hi * v_hi;
14451 const std::uint64_t p0_hi = p0 >> 32u;
14452 const std::uint64_t p1_lo = p1 & 0xFFFFFFFFu;
14453 const std::uint64_t p1_hi = p1 >> 32u;
14454 const std::uint64_t p2_lo = p2 & 0xFFFFFFFFu;
14455 const std::uint64_t p2_hi = p2 >> 32u;
14457 std::uint64_t Q = p0_hi + p1_lo + p2_lo;
14468 Q += std::uint64_t{1} << (64u - 32u - 1u);
14470 const std::uint64_t h = p3 + p2_hi + p1_hi + (Q >> 32u);
14472 return {h, x.e + y.e + 64};
14483 while ((x.f >> 63u) == 0)
14498 const int delta = x.
e - target_exponent;
14503 return {x.f << delta, target_exponent};
14520template<
typename FloatType>
14533 static_assert(std::numeric_limits<FloatType>::is_iec559,
14534 "internal error: dtoa_short requires an IEEE-754 floating-point implementation");
14536 constexpr int kPrecision = std::numeric_limits<FloatType>::digits;
14537 constexpr int kBias = std::numeric_limits<FloatType>::max_exponent - 1 + (kPrecision - 1);
14538 constexpr int kMinExp = 1 - kBias;
14539 constexpr std::uint64_t kHiddenBit = std::uint64_t{1} << (kPrecision - 1);
14541 using bits_type =
typename std::conditional<kPrecision == 24, std::uint32_t, std::uint64_t >::type;
14543 const std::uint64_t bits = reinterpret_bits<bits_type>(
value);
14544 const std::uint64_t E = bits >> (kPrecision - 1);
14545 const std::uint64_t F = bits & (kHiddenBit - 1);
14547 const bool is_denormal = E == 0;
14548 const diyfp v = is_denormal
14549 ?
diyfp(F, kMinExp)
14550 :
diyfp(F + kHiddenBit,
static_cast<int>(E) - kBias);
14573 const bool lower_boundary_is_closer = F == 0 && E > 1;
14575 const diyfp m_minus = lower_boundary_is_closer
14576 ?
diyfp(4 * v.
f - 1, v.
e - 2)
14577 :
diyfp(2 * v.
f - 1, v.
e - 1);
14712 constexpr int kCachedPowersMinDecExp = -300;
14713 constexpr int kCachedPowersDecStep = 8;
14715 static constexpr std::array<cached_power, 79> kCachedPowers =
14718 { 0xAB70FE17C79AC6CA, -1060, -300 },
14719 { 0xFF77B1FCBEBCDC4F, -1034, -292 },
14720 { 0xBE5691EF416BD60C, -1007, -284 },
14721 { 0x8DD01FAD907FFC3C, -980, -276 },
14722 { 0xD3515C2831559A83, -954, -268 },
14723 { 0x9D71AC8FADA6C9B5, -927, -260 },
14724 { 0xEA9C227723EE8BCB, -901, -252 },
14725 { 0xAECC49914078536D, -874, -244 },
14726 { 0x823C12795DB6CE57, -847, -236 },
14727 { 0xC21094364DFB5637, -821, -228 },
14728 { 0x9096EA6F3848984F, -794, -220 },
14729 { 0xD77485CB25823AC7, -768, -212 },
14730 { 0xA086CFCD97BF97F4, -741, -204 },
14731 { 0xEF340A98172AACE5, -715, -196 },
14732 { 0xB23867FB2A35B28E, -688, -188 },
14733 { 0x84C8D4DFD2C63F3B, -661, -180 },
14734 { 0xC5DD44271AD3CDBA, -635, -172 },
14735 { 0x936B9FCEBB25C996, -608, -164 },
14736 { 0xDBAC6C247D62A584, -582, -156 },
14737 { 0xA3AB66580D5FDAF6, -555, -148 },
14738 { 0xF3E2F893DEC3F126, -529, -140 },
14739 { 0xB5B5ADA8AAFF80B8, -502, -132 },
14740 { 0x87625F056C7C4A8B, -475, -124 },
14741 { 0xC9BCFF6034C13053, -449, -116 },
14742 { 0x964E858C91BA2655, -422, -108 },
14743 { 0xDFF9772470297EBD, -396, -100 },
14744 { 0xA6DFBD9FB8E5B88F, -369, -92 },
14745 { 0xF8A95FCF88747D94, -343, -84 },
14746 { 0xB94470938FA89BCF, -316, -76 },
14747 { 0x8A08F0F8BF0F156B, -289, -68 },
14748 { 0xCDB02555653131B6, -263, -60 },
14749 { 0x993FE2C6D07B7FAC, -236, -52 },
14750 { 0xE45C10C42A2B3B06, -210, -44 },
14751 { 0xAA242499697392D3, -183, -36 },
14752 { 0xFD87B5F28300CA0E, -157, -28 },
14753 { 0xBCE5086492111AEB, -130, -20 },
14754 { 0x8CBCCC096F5088CC, -103, -12 },
14755 { 0xD1B71758E219652C, -77, -4 },
14756 { 0x9C40000000000000, -50, 4 },
14757 { 0xE8D4A51000000000, -24, 12 },
14758 { 0xAD78EBC5AC620000, 3, 20 },
14759 { 0x813F3978F8940984, 30, 28 },
14760 { 0xC097CE7BC90715B3, 56, 36 },
14761 { 0x8F7E32CE7BEA5C70, 83, 44 },
14762 { 0xD5D238A4ABE98068, 109, 52 },
14763 { 0x9F4F2726179A2245, 136, 60 },
14764 { 0xED63A231D4C4FB27, 162, 68 },
14765 { 0xB0DE65388CC8ADA8, 189, 76 },
14766 { 0x83C7088E1AAB65DB, 216, 84 },
14767 { 0xC45D1DF942711D9A, 242, 92 },
14768 { 0x924D692CA61BE758, 269, 100 },
14769 { 0xDA01EE641A708DEA, 295, 108 },
14770 { 0xA26DA3999AEF774A, 322, 116 },
14771 { 0xF209787BB47D6B85, 348, 124 },
14772 { 0xB454E4A179DD1877, 375, 132 },
14773 { 0x865B86925B9BC5C2, 402, 140 },
14774 { 0xC83553C5C8965D3D, 428, 148 },
14775 { 0x952AB45CFA97A0B3, 455, 156 },
14776 { 0xDE469FBD99A05FE3, 481, 164 },
14777 { 0xA59BC234DB398C25, 508, 172 },
14778 { 0xF6C69A72A3989F5C, 534, 180 },
14779 { 0xB7DCBF5354E9BECE, 561, 188 },
14780 { 0x88FCF317F22241E2, 588, 196 },
14781 { 0xCC20CE9BD35C78A5, 614, 204 },
14782 { 0x98165AF37B2153DF, 641, 212 },
14783 { 0xE2A0B5DC971F303A, 667, 220 },
14784 { 0xA8D9D1535CE3B396, 694, 228 },
14785 { 0xFB9B7CD9A4A7443C, 720, 236 },
14786 { 0xBB764C4CA7A44410, 747, 244 },
14787 { 0x8BAB8EEFB6409C1A, 774, 252 },
14788 { 0xD01FEF10A657842C, 800, 260 },
14789 { 0x9B10A4E5E9913129, 827, 268 },
14790 { 0xE7109BFBA19C0C9D, 853, 276 },
14791 { 0xAC2820D9623BF429, 880, 284 },
14792 { 0x80444B5E7AA7CF85, 907, 292 },
14793 { 0xBF21E44003ACDD2D, 933, 300 },
14794 { 0x8E679C2F5E44FF8F, 960, 308 },
14795 { 0xD433179D9C8CB841, 986, 316 },
14796 { 0x9E19DB92B4E31BA9, 1013, 324 },
14806 const int f =
kAlpha - e - 1;
14807 const int k = (f * 78913) / (1 << 18) +
static_cast<int>(f > 0);
14809 const int index = (-kCachedPowersMinDecExp + k + (kCachedPowersDecStep - 1)) / kCachedPowersDecStep;
14811 JSON_ASSERT(
static_cast<std::size_t
>(index) < kCachedPowers.size());
14813 const cached_power cached = kCachedPowers[
static_cast<std::size_t
>(index)];
14827 if (n >= 1000000000)
14829 pow10 = 1000000000;
14833 else if (n >= 100000000)
14838 else if (n >= 10000000)
14843 else if (n >= 1000000)
14848 else if (n >= 100000)
14853 else if (n >= 10000)
14858 else if (n >= 1000)
14880inline void grisu2_round(
char* buf,
int len, std::uint64_t dist, std::uint64_t delta,
14881 std::uint64_t rest, std::uint64_t ten_k)
14908 && delta - rest >= ten_k
14909 && (rest + ten_k < dist || dist - rest > rest + ten_k - dist))
14924 static_assert(
kAlpha >= -60,
"internal error");
14925 static_assert(
kGamma <= -32,
"internal error");
14942 std::uint64_t delta =
diyfp::sub(M_plus, M_minus).
f;
14952 const diyfp one(std::uint64_t{1} << -M_plus.
e, M_plus.
e);
14954 auto p1 =
static_cast<std::uint32_t
>(M_plus.
f >> -one.e);
14955 std::uint64_t p2 = M_plus.
f & (one.f - 1);
14963 std::uint32_t pow10;
14991 const std::uint32_t d = p1 / pow10;
14992 const std::uint32_t r = p1 % pow10;
14998 buffer[length++] =
static_cast<char>(
'0' + d);
15017 const std::uint64_t rest = (std::uint64_t{p1} << -one.e) + p2;
15022 decimal_exponent += n;
15033 const std::uint64_t ten_n = std::uint64_t{pow10} << -one.e;
15034 grisu2_round(buffer, length, dist, delta, rest, ten_n);
15095 JSON_ASSERT(p2 <= (std::numeric_limits<std::uint64_t>::max)() / 10);
15097 const std::uint64_t d = p2 >> -one.e;
15098 const std::uint64_t r = p2 & (one.f - 1);
15105 buffer[length++] =
static_cast<char>(
'0' + d);
15130 decimal_exponent -= m;
15138 const std::uint64_t ten_m = one.f;
15162inline
void grisu2(
char* buf,
int& len,
int& decimal_exponent,
15179 const diyfp c_minus_k(cached.
f, cached.
e);
15207 const diyfp M_minus(w_minus.
f + 1, w_minus.
e);
15208 const diyfp M_plus (w_plus.
f - 1, w_plus.
e );
15210 decimal_exponent = -cached.
k;
15220template<
typename FloatType>
15225 "internal error: not enough precision");
15277 auto k =
static_cast<std::uint32_t
>(e);
15283 *buf++ =
static_cast<char>(
'0' + k);
15287 *buf++ =
static_cast<char>(
'0' + k / 10);
15289 *buf++ =
static_cast<char>(
'0' + k);
15293 *buf++ =
static_cast<char>(
'0' + k / 100);
15295 *buf++ =
static_cast<char>(
'0' + k / 10);
15297 *buf++ =
static_cast<char>(
'0' + k);
15315 int min_exp,
int max_exp)
15321 const int n = len + decimal_exponent;
15327 if (k <= n && n <= max_exp)
15332 std::memset(buf + k,
'0',
static_cast<size_t>(n) -
static_cast<size_t>(k));
15336 return buf + (
static_cast<size_t>(n) + 2);
15339 if (0 < n && n <= max_exp)
15346 std::memmove(buf + (
static_cast<size_t>(n) + 1), buf + n,
static_cast<size_t>(k) -
static_cast<size_t>(n));
15348 return buf + (
static_cast<size_t>(k) + 1U);
15351 if (min_exp < n && n <= 0)
15356 std::memmove(buf + (2 +
static_cast<size_t>(-n)), buf,
static_cast<size_t>(k));
15359 std::memset(buf + 2,
'0',
static_cast<size_t>(-n));
15360 return buf + (2U +
static_cast<size_t>(-n) +
static_cast<size_t>(k));
15375 std::memmove(buf + 2, buf + 1,
static_cast<size_t>(k) - 1);
15377 buf += 1 +
static_cast<size_t>(k);
15396template<
typename FloatType>
15401 static_cast<void>(last);
15405 if (std::signbit(
value))
15420 JSON_ASSERT(last - first >= std::numeric_limits<FloatType>::max_digits10);
15427 int decimal_exponent = 0;
15430 JSON_ASSERT(len <= std::numeric_limits<FloatType>::max_digits10);
15433 constexpr int kMinExp = -4;
15435 constexpr int kMaxExp = std::numeric_limits<FloatType>::digits10;
15438 JSON_ASSERT(last - first >= 2 + (-kMinExp - 1) + std::numeric_limits<FloatType>::max_digits10);
15439 JSON_ASSERT(last - first >= std::numeric_limits<FloatType>::max_digits10 + 6);
15476template<
typename BasicJsonType>
15496 ,
loc(
std::localeconv())
15534 const bool pretty_print,
15535 const bool ensure_ascii,
15536 const unsigned int indent_step,
15537 const unsigned int current_indent = 0)
15539 switch (val.m_type)
15543 if (val.m_value.object->empty())
15545 o->write_characters(
"{}", 2);
15551 o->write_characters(
"{\n", 2);
15554 const auto new_indent = current_indent + indent_step;
15561 auto i = val.m_value.object->cbegin();
15562 for (std::size_t cnt = 0; cnt < val.m_value.object->size() - 1; ++cnt, ++i)
15565 o->write_character(
'\"');
15567 o->write_characters(
"\": ", 3);
15568 dump(i->second,
true, ensure_ascii, indent_step, new_indent);
15569 o->write_characters(
",\n", 2);
15574 JSON_ASSERT(std::next(i) == val.m_value.object->cend());
15576 o->write_character(
'\"');
15578 o->write_characters(
"\": ", 3);
15579 dump(i->second,
true, ensure_ascii, indent_step, new_indent);
15581 o->write_character(
'\n');
15583 o->write_character(
'}');
15587 o->write_character(
'{');
15590 auto i = val.m_value.object->cbegin();
15591 for (std::size_t cnt = 0; cnt < val.m_value.object->size() - 1; ++cnt, ++i)
15593 o->write_character(
'\"');
15595 o->write_characters(
"\":", 2);
15596 dump(i->second,
false, ensure_ascii, indent_step, current_indent);
15597 o->write_character(
',');
15602 JSON_ASSERT(std::next(i) == val.m_value.object->cend());
15603 o->write_character(
'\"');
15605 o->write_characters(
"\":", 2);
15606 dump(i->second,
false, ensure_ascii, indent_step, current_indent);
15608 o->write_character(
'}');
15616 if (val.m_value.array->empty())
15618 o->write_characters(
"[]", 2);
15624 o->write_characters(
"[\n", 2);
15627 const auto new_indent = current_indent + indent_step;
15634 for (
auto i = val.m_value.array->cbegin();
15635 i != val.m_value.array->cend() - 1; ++i)
15638 dump(*i,
true, ensure_ascii, indent_step, new_indent);
15639 o->write_characters(
",\n", 2);
15645 dump(val.m_value.array->back(),
true, ensure_ascii, indent_step, new_indent);
15647 o->write_character(
'\n');
15649 o->write_character(
']');
15653 o->write_character(
'[');
15656 for (
auto i = val.m_value.array->cbegin();
15657 i != val.m_value.array->cend() - 1; ++i)
15659 dump(*i,
false, ensure_ascii, indent_step, current_indent);
15660 o->write_character(
',');
15665 dump(val.m_value.array->back(),
false, ensure_ascii, indent_step, current_indent);
15667 o->write_character(
']');
15675 o->write_character(
'\"');
15677 o->write_character(
'\"');
15685 o->write_characters(
"{\n", 2);
15688 const auto new_indent = current_indent + indent_step;
15696 o->write_characters(
"\"bytes\": [", 10);
15698 if (!val.m_value.binary->empty())
15700 for (
auto i = val.m_value.binary->cbegin();
15701 i != val.m_value.binary->cend() - 1; ++i)
15704 o->write_characters(
", ", 2);
15709 o->write_characters(
"],\n", 3);
15712 o->write_characters(
"\"subtype\": ", 11);
15713 if (val.m_value.binary->has_subtype())
15719 o->write_characters(
"null", 4);
15721 o->write_character(
'\n');
15723 o->write_character(
'}');
15727 o->write_characters(
"{\"bytes\":[", 10);
15729 if (!val.m_value.binary->empty())
15731 for (
auto i = val.m_value.binary->cbegin();
15732 i != val.m_value.binary->cend() - 1; ++i)
15735 o->write_character(
',');
15740 o->write_characters(
"],\"subtype\":", 12);
15741 if (val.m_value.binary->has_subtype())
15744 o->write_character(
'}');
15748 o->write_characters(
"null}", 5);
15756 if (val.m_value.boolean)
15758 o->write_characters(
"true", 4);
15762 o->write_characters(
"false", 5);
15787 o->write_characters(
"<discarded>", 11);
15793 o->write_characters(
"null", 4);
15819 std::uint32_t codepoint;
15821 std::size_t bytes = 0;
15824 std::size_t bytes_after_last_accept = 0;
15825 std::size_t undumped_chars = 0;
15827 for (std::size_t i = 0; i < s.size(); ++i)
15829 const auto byte =
static_cast<uint8_t
>(s[i]);
15831 switch (
decode(state, codepoint,
byte))
15890 if ((codepoint <= 0x1F) || (ensure_ascii && (codepoint >= 0x7F)))
15892 if (codepoint <= 0xFFFF)
15894 (std::snprintf)(
string_buffer.data() + bytes, 7,
"\\u%04x",
15895 static_cast<std::uint16_t
>(codepoint));
15900 (std::snprintf)(
string_buffer.data() + bytes, 13,
"\\u%04x\\u%04x",
15901 static_cast<std::uint16_t
>(0xD7C0u + (codepoint >> 10u)),
15902 static_cast<std::uint16_t
>(0xDC00u + (codepoint & 0x3FFu)));
15926 bytes_after_last_accept = bytes;
15927 undumped_chars = 0;
15937 std::string sn(3,
'\0');
15938 (std::snprintf)(&sn[0], sn.size(),
"%.2X", byte);
15949 if (undumped_chars > 0)
15956 bytes = bytes_after_last_accept;
15986 bytes_after_last_accept = bytes;
15989 undumped_chars = 0;
16031 std::string sn(3,
'\0');
16032 (std::snprintf)(&sn[0], sn.size(),
"%.2X",
static_cast<std::uint8_t
>(s.back()));
16039 o->write_characters(
string_buffer.data(), bytes_after_last_accept);
16046 o->write_characters(
string_buffer.data(), bytes_after_last_accept);
16050 o->write_characters(
"\\ufffd", 6);
16054 o->write_characters(
"\xEF\xBF\xBD", 3);
16075 unsigned int n_digits = 1;
16084 return n_digits + 1;
16088 return n_digits + 2;
16092 return n_digits + 3;
16109 std::is_same<NumberType, number_unsigned_t>::value ||
16110 std::is_same<NumberType, number_integer_t>::value ||
16111 std::is_same<NumberType, binary_char_t>::value,
16115 static constexpr std::array<std::array<char, 2>, 100> digits_to_99
16118 {{
'0',
'0'}}, {{
'0',
'1'}}, {{
'0',
'2'}}, {{
'0',
'3'}}, {{
'0',
'4'}}, {{
'0',
'5'}}, {{
'0',
'6'}}, {{
'0',
'7'}}, {{
'0',
'8'}}, {{
'0',
'9'}},
16119 {{
'1',
'0'}}, {{
'1',
'1'}}, {{
'1',
'2'}}, {{
'1',
'3'}}, {{
'1',
'4'}}, {{
'1',
'5'}}, {{
'1',
'6'}}, {{
'1',
'7'}}, {{
'1',
'8'}}, {{
'1',
'9'}},
16120 {{
'2',
'0'}}, {{
'2',
'1'}}, {{
'2',
'2'}}, {{
'2',
'3'}}, {{
'2',
'4'}}, {{
'2',
'5'}}, {{
'2',
'6'}}, {{
'2',
'7'}}, {{
'2',
'8'}}, {{
'2',
'9'}},
16121 {{
'3',
'0'}}, {{
'3',
'1'}}, {{
'3',
'2'}}, {{
'3',
'3'}}, {{
'3',
'4'}}, {{
'3',
'5'}}, {{
'3',
'6'}}, {{
'3',
'7'}}, {{
'3',
'8'}}, {{
'3',
'9'}},
16122 {{
'4',
'0'}}, {{
'4',
'1'}}, {{
'4',
'2'}}, {{
'4',
'3'}}, {{
'4',
'4'}}, {{
'4',
'5'}}, {{
'4',
'6'}}, {{
'4',
'7'}}, {{
'4',
'8'}}, {{
'4',
'9'}},
16123 {{
'5',
'0'}}, {{
'5',
'1'}}, {{
'5',
'2'}}, {{
'5',
'3'}}, {{
'5',
'4'}}, {{
'5',
'5'}}, {{
'5',
'6'}}, {{
'5',
'7'}}, {{
'5',
'8'}}, {{
'5',
'9'}},
16124 {{
'6',
'0'}}, {{
'6',
'1'}}, {{
'6',
'2'}}, {{
'6',
'3'}}, {{
'6',
'4'}}, {{
'6',
'5'}}, {{
'6',
'6'}}, {{
'6',
'7'}}, {{
'6',
'8'}}, {{
'6',
'9'}},
16125 {{
'7',
'0'}}, {{
'7',
'1'}}, {{
'7',
'2'}}, {{
'7',
'3'}}, {{
'7',
'4'}}, {{
'7',
'5'}}, {{
'7',
'6'}}, {{
'7',
'7'}}, {{
'7',
'8'}}, {{
'7',
'9'}},
16126 {{
'8',
'0'}}, {{
'8',
'1'}}, {{
'8',
'2'}}, {{
'8',
'3'}}, {{
'8',
'4'}}, {{
'8',
'5'}}, {{
'8',
'6'}}, {{
'8',
'7'}}, {{
'8',
'8'}}, {{
'8',
'9'}},
16127 {{
'9',
'0'}}, {{
'9',
'1'}}, {{
'9',
'2'}}, {{
'9',
'3'}}, {{
'9',
'4'}}, {{
'9',
'5'}}, {{
'9',
'6'}}, {{
'9',
'7'}}, {{
'9',
'8'}}, {{
'9',
'9'}},
16134 o->write_character(
'0');
16141 const bool is_negative = std::is_same<NumberType, number_integer_t>::value && !(x >= 0);
16144 unsigned int n_chars;
16165 buffer_ptr += n_chars;
16169 while (abs_value >= 100)
16171 const auto digits_index =
static_cast<unsigned>((abs_value % 100));
16173 *(--buffer_ptr) = digits_to_99[digits_index][1];
16174 *(--buffer_ptr) = digits_to_99[digits_index][0];
16177 if (abs_value >= 10)
16179 const auto digits_index =
static_cast<unsigned>(abs_value);
16180 *(--buffer_ptr) = digits_to_99[digits_index][1];
16181 *(--buffer_ptr) = digits_to_99[digits_index][0];
16185 *(--buffer_ptr) =
static_cast<char>(
'0' + abs_value);
16202 if (!std::isfinite(x))
16204 o->write_characters(
"null", 4);
16213 static constexpr bool is_ieee_single_or_double
16214 = (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) ||
16215 (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);
16217 dump_float(x, std::integral_constant<bool, is_ieee_single_or_double>());
16225 o->write_characters(begin,
static_cast<size_t>(end - begin));
16231 static constexpr auto d = std::numeric_limits<number_float_t>::max_digits10;
16261 o->write_characters(
number_buffer.data(),
static_cast<std::size_t
>(len));
16264 const bool value_is_int_like =
16268 return c ==
'.' || c ==
'e';
16271 if (value_is_int_like)
16273 o->write_characters(
".0", 2);
16298 static std::uint8_t
decode(std::uint8_t& state, std::uint32_t& codep,
const std::uint8_t
byte)
noexcept
16300 static const std::array<std::uint8_t, 400> utf8d =
16303 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,
16304 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,
16305 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,
16306 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,
16307 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,
16308 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,
16309 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,
16310 0xA, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x4, 0x3, 0x3,
16311 0xB, 0x6, 0x6, 0x6, 0x5, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8,
16312 0x0, 0x1, 0x2, 0x3, 0x5, 0x8, 0x7, 0x1, 0x1, 0x1, 0x4, 0x6, 0x1, 0x1, 0x1, 0x1,
16313 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,
16314 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,
16315 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,
16316 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
16320 const std::uint8_t type = utf8d[byte];
16323 ? (
byte & 0x3fu) | (codep << 6u)
16324 : (0xFFu >> type) & (byte);
16326 std::size_t index = 256u +
static_cast<size_t>(state) * 16u +
static_cast<size_t>(type);
16328 state = utf8d[index];
16354 JSON_ASSERT(x < 0 && x < (std::numeric_limits<number_integer_t>::max)());
16393#include <functional>
16403template <
class Key,
class T,
class IgnoredLess = std::less<Key>,
16404 class Allocator = std::allocator<std::pair<const Key, T>>>
16409 using Container = std::vector<std::pair<const Key, T>, Allocator>;
16410 using typename Container::iterator;
16411 using typename Container::const_iterator;
16412 using typename Container::size_type;
16413 using typename Container::value_type;
16418 template <
class It>
16421 ordered_map(std::initializer_list<T> init,
const Allocator& alloc = Allocator() )
16426 for (
auto it = this->begin(); it != this->end(); ++it)
16428 if (it->first == key)
16430 return {it,
false};
16433 Container::emplace_back(key, t);
16434 return {--this->end(),
true};
16439 return emplace(key, T{}).first->second;
16449 for (
auto it = this->begin(); it != this->end(); ++it)
16451 if (it->first == key)
16457 throw std::out_of_range(
"key not found");
16460 const T&
at(
const Key& key)
const
16462 for (
auto it = this->begin(); it != this->end(); ++it)
16464 if (it->first == key)
16470 throw std::out_of_range(
"key not found");
16475 for (
auto it = this->begin(); it != this->end(); ++it)
16477 if (it->first == key)
16480 for (
auto next = it; ++next != this->end(); ++it)
16483 new (&*it) value_type{std::move(*next)};
16485 Container::pop_back();
16497 for (
auto next = it; ++next != this->end(); ++it)
16500 new (&*it) value_type{std::move(*next)};
16502 Container::pop_back();
16508 for (
auto it = this->begin(); it != this->end(); ++it)
16510 if (it->first == key)
16520 for (
auto it = this->begin(); it != this->end(); ++it)
16522 if (it->first == key)
16527 return Container::end();
16530 const_iterator
find(
const Key& key)
const
16532 for (
auto it = this->begin(); it != this->end(); ++it)
16534 if (it->first == key)
16539 return Container::end();
16542 std::pair<iterator, bool>
insert( value_type&& value )
16544 return emplace(value.first, std::move(value.second));
16547 std::pair<iterator, bool>
insert(
const value_type& value )
16549 for (
auto it = this->begin(); it != this->end(); ++it)
16551 if (it->first == value.first)
16553 return {it,
false};
16556 Container::push_back(value);
16557 return {--this->end(),
true};
16661 friend ::nlohmann::json_pointer<basic_json>;
16663 template<
typename BasicJsonType,
typename InputType>
16664 friend class ::nlohmann::detail::parser;
16665 friend ::nlohmann::detail::serializer<basic_json>;
16666 template<
typename BasicJsonType>
16667 friend class ::nlohmann::detail::iter_impl;
16668 template<
typename BasicJsonType,
typename CharType>
16669 friend class ::nlohmann::detail::binary_writer;
16670 template<
typename BasicJsonType,
typename InputType,
typename SAX>
16671 friend class ::nlohmann::detail::binary_reader;
16672 template<
typename BasicJsonType>
16673 friend class ::nlohmann::detail::json_sax_dom_parser;
16674 template<
typename BasicJsonType>
16675 friend class ::nlohmann::detail::json_sax_dom_callback_parser;
16683 template<
typename InputAdapterType>
16684 static ::nlohmann::detail::parser<basic_json, InputAdapterType>
parser(
16685 InputAdapterType adapter,
16687 const bool allow_exceptions =
true,
16688 const bool ignore_comments =
false
16691 return ::nlohmann::detail::parser<basic_json, InputAdapterType>(std::move(adapter),
16692 std::move(cb), allow_exceptions, ignore_comments);
16696 template<
typename BasicJsonType>
16698 template<
typename BasicJsonType>
16700 template<
typename Iterator>
16704 template<
typename CharType>
16707 template<
typename InputType>
16717 template<
typename T,
typename SFINAE>
16780 using pointer =
typename std::allocator_traits<allocator_type>::pointer;
16782 using const_pointer =
typename std::allocator_traits<allocator_type>::const_pointer;
16835 result[
"copyright"] =
"(C) 2013-2020 Niels Lohmann";
16836 result[
"name"] =
"JSON for Modern C++";
16837 result[
"url"] =
"https://github.com/nlohmann/json";
16838 result[
"version"][
"string"] =
16847 result[
"platform"] =
"win32";
16848#elif defined __linux__
16849 result[
"platform"] =
"linux";
16850#elif defined __APPLE__
16851 result[
"platform"] =
"apple";
16852#elif defined __unix__
16853 result[
"platform"] =
"unix";
16855 result[
"platform"] =
"unknown";
16858#if defined(__ICC) || defined(__INTEL_COMPILER)
16859 result[
"compiler"] = {{
"family",
"icc"}, {
"version", __INTEL_COMPILER}};
16860#elif defined(__clang__)
16861 result[
"compiler"] = {{
"family",
"clang"}, {
"version", __clang_version__}};
16862#elif defined(__GNUC__) || defined(__GNUG__)
16863 result[
"compiler"] = {{
"family",
"gcc"}, {
"version", std::to_string(__GNUC__) +
"." + std::to_string(__GNUC_MINOR__) +
"." + std::to_string(__GNUC_PATCHLEVEL__)}};
16864#elif defined(__HP_cc) || defined(__HP_aCC)
16865 result[
"compiler"] =
"hp"
16866#elif defined(__IBMCPP__)
16867 result[
"compiler"] = {{
"family",
"ilecpp"}, {
"version", __IBMCPP__}};
16868#elif defined(_MSC_VER)
16869 result[
"compiler"] = {{
"family",
"msvc"}, {
"version", _MSC_VER}};
16870#elif defined(__PGI)
16871 result[
"compiler"] = {{
"family",
"pgcpp"}, {
"version", __PGI}};
16872#elif defined(__SUNPRO_CC)
16873 result[
"compiler"] = {{
"family",
"sunpro"}, {
"version", __SUNPRO_CC}};
16875 result[
"compiler"] = {{
"family",
"unknown"}, {
"version",
"unknown"}};
16879 result[
"compiler"][
"c++"] = std::to_string(__cplusplus);
16881 result[
"compiler"][
"c++"] =
"unknown";
16896#if defined(JSON_HAS_CPP_14)
16990 AllocatorType<std::pair<
const StringType,
17037 using array_t = ArrayType<basic_json, AllocatorType<basic_json>>;
17404 template<
typename T,
typename... Args>
17408 AllocatorType<T> alloc;
17409 using AllocatorTraits = std::allocator_traits<AllocatorType<T>>;
17411 auto deleter = [&](T *
object)
17413 AllocatorTraits::deallocate(alloc,
object, 1);
17415 std::unique_ptr<T,
decltype(deleter)>
object(AllocatorTraits::allocate(alloc, 1), deleter);
17416 AllocatorTraits::construct(alloc,
object.
get(), std::forward<Args>(args)...);
17418 return object.release();
17484 case value_t::object:
17486 object = create<object_t>();
17490 case value_t::array:
17492 array = create<array_t>();
17496 case value_t::string:
17498 string = create<string_t>(
"");
17502 case value_t::binary:
17504 binary = create<binary_t>();
17508 case value_t::boolean:
17514 case value_t::number_integer:
17520 case value_t::number_unsigned:
17526 case value_t::number_float:
17532 case value_t::null:
17553 string = create<string_t>(
value);
17559 string = create<string_t>(std::move(
value));
17565 object = create<object_t>(
value);
17571 object = create<object_t>(std::move(
value));
17613 std::vector<basic_json> stack;
17616 if (t == value_t::array)
17618 stack.reserve(
array->size());
17619 std::move(
array->begin(),
array->end(), std::back_inserter(stack));
17621 else if (t == value_t::object)
17623 stack.reserve(
object->size());
17624 for (
auto&& it : *
object)
17626 stack.push_back(std::move(it.second));
17630 while (!stack.empty())
17633 basic_json current_item(std::move(stack.back()));
17641 std::back_inserter(stack));
17649 stack.push_back(std::move(it.second));
17661 case value_t::object:
17663 AllocatorType<object_t> alloc;
17664 std::allocator_traits<
decltype(alloc)>
::destroy(alloc,
object);
17665 std::allocator_traits<
decltype(alloc)>::deallocate(alloc,
object, 1);
17669 case value_t::array:
17671 AllocatorType<array_t> alloc;
17673 std::allocator_traits<
decltype(alloc)>::deallocate(alloc,
array, 1);
17677 case value_t::string:
17679 AllocatorType<string_t> alloc;
17680 std::allocator_traits<
decltype(alloc)>
::destroy(alloc,
string);
17681 std::allocator_traits<
decltype(alloc)>::deallocate(alloc,
string, 1);
17685 case value_t::binary:
17687 AllocatorType<binary_t> alloc;
17689 std::allocator_traits<
decltype(alloc)>::deallocate(alloc,
binary, 1);
17923 template <
typename CompatibleType,
17928 JSONSerializer<U>::to_json(std::declval<basic_json_t&>(),
17929 std::forward<CompatibleType>(val))))
17931 JSONSerializer<U>::to_json(*
this, std::forward<CompatibleType>(val));
17961 template <
typename BasicJsonType,
17966 using other_boolean_t =
typename BasicJsonType::boolean_t;
17967 using other_number_float_t =
typename BasicJsonType::number_float_t;
17968 using other_number_integer_t =
typename BasicJsonType::number_integer_t;
17969 using other_number_unsigned_t =
typename BasicJsonType::number_unsigned_t;
17970 using other_string_t =
typename BasicJsonType::string_t;
17971 using other_object_t =
typename BasicJsonType::object_t;
17972 using other_array_t =
typename BasicJsonType::array_t;
17973 using other_binary_t =
typename BasicJsonType::binary_t;
17975 switch (val.type())
17977 case value_t::boolean:
17978 JSONSerializer<other_boolean_t>::to_json(*
this, val.template get<other_boolean_t>());
17980 case value_t::number_float:
17981 JSONSerializer<other_number_float_t>::to_json(*
this, val.template get<other_number_float_t>());
17983 case value_t::number_integer:
17984 JSONSerializer<other_number_integer_t>::to_json(*
this, val.template get<other_number_integer_t>());
17986 case value_t::number_unsigned:
17987 JSONSerializer<other_number_unsigned_t>::to_json(*
this, val.template get<other_number_unsigned_t>());
17989 case value_t::string:
17990 JSONSerializer<other_string_t>::to_json(*
this, val.template get_ref<const other_string_t&>());
17992 case value_t::object:
17993 JSONSerializer<other_object_t>::to_json(*
this, val.template get_ref<const other_object_t&>());
17995 case value_t::array:
17996 JSONSerializer<other_array_t>::to_json(*
this, val.template get_ref<const other_array_t&>());
17998 case value_t::binary:
17999 JSONSerializer<other_binary_t>::to_json(*
this, val.template get_ref<const other_binary_t&>());
18001 case value_t::null:
18004 case value_t::discarded:
18005 m_type = value_t::discarded;
18088 bool type_deduction =
true,
18089 value_t manual_type = value_t::array)
18093 bool is_an_object = std::all_of(init.begin(), init.end(),
18096 return element_ref->is_array() && element_ref->size() == 2 && (*element_ref)[0].is_string();
18100 if (!type_deduction)
18103 if (manual_type == value_t::array)
18105 is_an_object =
false;
18118 m_type = value_t::object;
18123 auto element = element_ref.moved_or_copied();
18124 m_value.object->emplace(
18125 std::move(*((*element.m_value.array)[0].m_value.string)),
18126 std::move((*element.m_value.array)[1]));
18132 m_type = value_t::array;
18133 m_value.
array = create<array_t>(init.begin(), init.end());
18170 res.m_type = value_t::binary;
18171 res.m_value = init;
18207 res.m_type = value_t::binary;
18208 res.m_value =
binary_t(init, subtype);
18217 res.m_type = value_t::binary;
18218 res.m_value = std::move(init);
18227 res.m_type = value_t::binary;
18228 res.m_value =
binary_t(std::move(init), subtype);
18272 return basic_json(init,
false, value_t::array);
18316 return basic_json(init,
false, value_t::object);
18403 template <
class InputIT,
typename std::enable_if <
18404 std::is_same<InputIT, typename basic_json_t::iterator>::value ||
18405 std::is_same<InputIT, typename basic_json_t::const_iterator>::value,
int >
::type = 0 >
18418 m_type = first.m_object->m_type;
18423 case value_t::boolean:
18424 case value_t::number_float:
18425 case value_t::number_integer:
18426 case value_t::number_unsigned:
18427 case value_t::string:
18430 || !last.m_it.primitive_iterator.is_end()))
18443 case value_t::number_integer:
18449 case value_t::number_unsigned:
18455 case value_t::number_float:
18461 case value_t::boolean:
18467 case value_t::string:
18473 case value_t::object:
18475 m_value.
object = create<object_t>(first.m_it.object_iterator,
18476 last.m_it.object_iterator);
18480 case value_t::array:
18482 m_value.
array = create<array_t>(first.m_it.array_iterator,
18483 last.m_it.array_iterator);
18487 case value_t::binary:
18495 std::string(first.m_object->type_name())));
18506 template<
typename JsonRef,
18508 std::is_same<typename JsonRef::value_type, basic_json>>
::value,
int> = 0 >
18544 case value_t::object:
18550 case value_t::array:
18556 case value_t::string:
18562 case value_t::boolean:
18568 case value_t::number_integer:
18574 case value_t::number_unsigned:
18580 case value_t::number_float:
18586 case value_t::binary:
18626 :
m_type(std::move(other.m_type)),
18627 m_value(std::move(other.m_value))
18630 other.assert_invariant();
18633 other.m_type = value_t::null;
18634 other.m_value = {};
18663 std::is_nothrow_move_constructible<value_t>::value&&
18664 std::is_nothrow_move_assignable<value_t>::value&&
18665 std::is_nothrow_move_constructible<json_value>::value&&
18666 std::is_nothrow_move_assignable<json_value>::value
18760 const char indent_char =
' ',
18761 const bool ensure_ascii =
false,
18769 s.
dump(*
this,
true, ensure_ascii,
static_cast<unsigned int>(indent));
18773 s.
dump(*
this,
false, ensure_ascii, 0);
18894 return m_type == value_t::null;
18916 return m_type == value_t::boolean;
18975 return m_type == value_t::number_integer ||
m_type == value_t::number_unsigned;
19003 return m_type == value_t::number_unsigned;
19031 return m_type == value_t::number_float;
19053 return m_type == value_t::object;
19075 return m_type == value_t::array;
19097 return m_type == value_t::string;
19119 return m_type == value_t::binary;
19146 return m_type == value_t::discarded;
19300 template<
typename ReferenceType,
typename ThisType>
19304 auto ptr = obj.template get_ptr<typename std::add_pointer<ReferenceType>::type>();
19357 !std::is_same<BasicJsonType, basic_json>::value&&
19403 template <
typename ValueTypeCV,
typename ValueType = detail::uncvref_t<ValueTypeCV>,
19404 detail::enable_if_t <
19405 !detail::is_basic_json<ValueType>::value &&
19406 detail::has_from_json<basic_json_t, ValueType>::value &&
19407 !detail::has_non_default_from_json<basic_json_t, ValueType>::value,
19409 ValueType
get() const noexcept(noexcept(
19410 JSONSerializer<ValueType>::from_json(
std::declval<const
basic_json_t&>(),
std::declval<ValueType&>())))
19415 static_assert(!std::is_reference<ValueTypeCV>::value,
19416 "get() cannot be used with reference types, you might want to use get_ref()");
19417 static_assert(std::is_default_constructible<ValueType>::value,
19418 "types must be DefaultConstructible when used with get()");
19421 JSONSerializer<ValueType>::from_json(*
this, ret);
19456 template <
typename ValueTypeCV,
typename ValueType = detail::uncvref_t<ValueTypeCV>,
19457 detail::enable_if_t < !std::is_same<basic_json_t, ValueType>::value &&
19458 detail::has_non_default_from_json<basic_json_t, ValueType>::value,
19460 ValueType
get() const noexcept(noexcept(
19461 JSONSerializer<ValueType>::from_json(
std::declval<const
basic_json_t&>())))
19463 static_assert(!std::is_reference<ValueTypeCV>::value,
19464 "get() cannot be used with reference types, you might want to use get_ref()");
19465 return JSONSerializer<ValueType>::from_json(*
this);
19501 template <
typename ValueType,
19506 ValueType &
get_to(ValueType& v)
const noexcept(
noexcept(
19507 JSONSerializer<ValueType>::from_json(std::declval<const basic_json_t&>(), v)))
19509 JSONSerializer<ValueType>::from_json(*
this, v);
19515 template<
typename ValueType,
19526 typename T, std::size_t N,
19527 typename Array = T (&)[N],
19531 noexcept(
noexcept(JSONSerializer<Array>::from_json(
19532 std::declval<const basic_json_t&>(), v)))
19534 JSONSerializer<Array>::from_json(*
this, v);
19565 template<
typename PointerType,
typename std::enable_if<
19566 std::is_pointer<PointerType>::value,
int>
::type = 0>
19570 return get_impl_ptr(
static_cast<PointerType
>(
nullptr));
19577 template <
typename PointerType,
typename std::enable_if <
19578 std::is_pointer<PointerType>::value&&
19579 std::is_const<typename std::remove_pointer<PointerType>::type>
::value,
int >
::type = 0 >
19583 return get_impl_ptr(
static_cast<PointerType
>(
nullptr));
19613 template<
typename PointerType,
typename std::enable_if<
19614 std::is_pointer<PointerType>::value,
int>
::type = 0>
19618 return get_ptr<PointerType>();
19625 template<
typename PointerType,
typename std::enable_if<
19626 std::is_pointer<PointerType>::value,
int>
::type = 0>
19630 return get_ptr<PointerType>();
19659 template<
typename ReferenceType,
typename std::enable_if<
19660 std::is_reference<ReferenceType>::value,
int>
::type = 0>
19664 return get_ref_impl<ReferenceType>(*
this);
19671 template <
typename ReferenceType,
typename std::enable_if <
19672 std::is_reference<ReferenceType>::value&&
19673 std::is_const<typename std::remove_reference<ReferenceType>::type>
::value,
int >
::type = 0 >
19677 return get_ref_impl<ReferenceType>(*
this);
19709 template <
typename ValueType,
typename std::enable_if <
19710 !std::is_pointer<ValueType>::value&&
19711 !std::is_same<ValueType, detail::json_ref<basic_json>>
::value&&
19712 !std::is_same<ValueType, typename string_t::value_type>::value&&
19714 && !std::is_same<ValueType, std::initializer_list<typename string_t::value_type>>
::value
19715#if defined(JSON_HAS_CPP_17) && (defined(__GNUC__) || (defined(_MSC_VER) && _MSC_VER >= 1910 && _MSC_VER <= 1914))
19716 && !std::is_same<ValueType, typename std::string_view>::value
19723 return get<ValueType>();
19742 return *get_ptr<binary_t*>();
19753 return *get_ptr<const binary_t*>();
19993 m_type = value_t::array;
20077 m_type = value_t::object;
20160 template<
typename T>
20167 m_type = value_t::object;
20211 template<
typename T>
20276 template <
class ValueType,
typename std::enable_if <
20278 && !std::is_same<value_t, ValueType>::value,
int >
::type = 0 >
20279 ValueType
value(
const typename object_t::key_type& key,
const ValueType& default_value)
const
20285 const auto it =
find(key);
20288 return it->template get<ValueType>();
20291 return default_value;
20301 string_t value(
const typename object_t::key_type& key,
const char* default_value)
const
20349 template<
class ValueType,
typename std::enable_if<
20359 return ptr.
get_checked(
this).template get<ValueType>();
20363 return default_value;
20512 template <
class IteratorType,
typename std::enable_if <
20513 std::is_same<IteratorType, typename basic_json_t::iterator>::value ||
20514 std::is_same<IteratorType, typename basic_json_t::const_iterator>::value,
int >
::type
20524 IteratorType result =
end();
20528 case value_t::boolean:
20529 case value_t::number_float:
20530 case value_t::number_integer:
20531 case value_t::number_unsigned:
20532 case value_t::string:
20533 case value_t::binary:
20542 AllocatorType<string_t> alloc;
20543 std::allocator_traits<
decltype(alloc)>::destroy(alloc,
m_value.
string);
20544 std::allocator_traits<
decltype(alloc)>::deallocate(alloc,
m_value.
string, 1);
20549 AllocatorType<binary_t> alloc;
20550 std::allocator_traits<
decltype(alloc)>::destroy(alloc,
m_value.
binary);
20551 std::allocator_traits<
decltype(alloc)>::deallocate(alloc,
m_value.
binary, 1);
20560 case value_t::object:
20562 result.m_it.object_iterator =
m_value.
object->erase(pos.m_it.object_iterator);
20566 case value_t::array:
20568 result.m_it.array_iterator =
m_value.
array->erase(pos.m_it.array_iterator);
20625 template <
class IteratorType,
typename std::enable_if <
20626 std::is_same<IteratorType, typename basic_json_t::iterator>::value ||
20627 std::is_same<IteratorType, typename basic_json_t::const_iterator>::value,
int >
::type
20629 IteratorType
erase(IteratorType first, IteratorType last)
20637 IteratorType result =
end();
20641 case value_t::boolean:
20642 case value_t::number_float:
20643 case value_t::number_integer:
20644 case value_t::number_unsigned:
20645 case value_t::string:
20646 case value_t::binary:
20649 || !last.m_it.primitive_iterator.is_end()))
20656 AllocatorType<string_t> alloc;
20657 std::allocator_traits<
decltype(alloc)>::destroy(alloc,
m_value.
string);
20658 std::allocator_traits<
decltype(alloc)>::deallocate(alloc,
m_value.
string, 1);
20663 AllocatorType<binary_t> alloc;
20664 std::allocator_traits<
decltype(alloc)>::destroy(alloc,
m_value.
binary);
20665 std::allocator_traits<
decltype(alloc)>::deallocate(alloc,
m_value.
binary, 1);
20674 case value_t::object:
20676 result.m_it.object_iterator =
m_value.
object->erase(first.m_it.object_iterator,
20677 last.m_it.object_iterator);
20681 case value_t::array:
20683 result.m_it.array_iterator =
m_value.
array->erase(first.m_it.array_iterator,
20684 last.m_it.array_iterator);
20811 template<
typename KeyT>
20814 auto result =
end();
20818 result.m_it.object_iterator =
m_value.
object->find(std::forward<KeyT>(key));
20828 template<
typename KeyT>
20831 auto result =
cend();
20835 result.m_it.object_iterator =
m_value.
object->find(std::forward<KeyT>(key));
20862 template<
typename KeyT>
20894 template <
typename KeyT,
typename std::enable_if <
21276 return ref.items();
21285 return ref.items();
21425 case value_t::null:
21431 case value_t::array:
21437 case value_t::object:
21498 case value_t::null:
21504 case value_t::array:
21510 case value_t::object:
21569 case value_t::array:
21575 case value_t::object:
21640 case value_t::number_integer:
21646 case value_t::number_unsigned:
21652 case value_t::number_float:
21658 case value_t::boolean:
21664 case value_t::string:
21670 case value_t::binary:
21676 case value_t::array:
21682 case value_t::object:
21724 m_type = value_t::array;
21759 m_type = value_t::array;
21809 m_type = value_t::object;
21855 if (
is_object() && init.size() == 2 && (*init.begin())->is_string())
21857 basic_json&& key = init.begin()->moved_or_copied();
21858 push_back(
typename object_t::value_type(
21859 std::move(key.get_ref<
string_t&>()), (init.begin() + 1)->moved_or_copied()));
21900 template<
class... Args>
21912 m_type = value_t::array;
21918#ifdef JSON_HAS_CPP_17
21919 return m_value.
array->emplace_back(std::forward<Args>(args)...);
21921 m_value.
array->emplace_back(std::forward<Args>(args)...);
21953 template<
class... Args>
21965 m_type = value_t::object;
21971 auto res =
m_value.
object->emplace(std::forward<Args>(args)...);
21974 it.m_it.object_iterator = res.first;
21977 return {it, res.second};
21983 template<
typename... Args>
22046 return insert(pos, val);
22262 m_type = value_t::object;
22276 for (
auto it = j.
cbegin(); it != j.
cend(); ++it)
22313 m_type = value_t::object;
22336 for (
auto it = first; it != last; ++it)
22360 std::is_nothrow_move_constructible<value_t>::value&&
22361 std::is_nothrow_move_assignable<value_t>::value&&
22362 std::is_nothrow_move_constructible<json_value>::value&&
22363 std::is_nothrow_move_assignable<json_value>::value
22366 std::swap(
m_type, other.m_type);
22367 std::swap(
m_value, other.m_value);
22390 std::is_nothrow_move_constructible<value_t>::value&&
22391 std::is_nothrow_move_assignable<value_t>::value&&
22392 std::is_nothrow_move_constructible<json_value>::value&&
22393 std::is_nothrow_move_assignable<json_value>::value
22612 const auto lhs_type = lhs.type();
22613 const auto rhs_type = rhs.type();
22615 if (lhs_type == rhs_type)
22619 case value_t::array:
22620 return *lhs.m_value.array == *rhs.m_value.array;
22622 case value_t::object:
22623 return *lhs.m_value.object == *rhs.m_value.object;
22625 case value_t::null:
22628 case value_t::string:
22629 return *lhs.m_value.string == *rhs.m_value.string;
22631 case value_t::boolean:
22632 return lhs.m_value.boolean == rhs.m_value.boolean;
22634 case value_t::number_integer:
22635 return lhs.m_value.number_integer == rhs.m_value.number_integer;
22637 case value_t::number_unsigned:
22638 return lhs.m_value.number_unsigned == rhs.m_value.number_unsigned;
22640 case value_t::number_float:
22641 return lhs.m_value.number_float == rhs.m_value.number_float;
22643 case value_t::binary:
22644 return *lhs.m_value.binary == *rhs.m_value.binary;
22650 else if (lhs_type == value_t::number_integer && rhs_type == value_t::number_float)
22652 return static_cast<number_float_t>(lhs.m_value.number_integer) == rhs.m_value.number_float;
22654 else if (lhs_type == value_t::number_float && rhs_type == value_t::number_integer)
22656 return lhs.m_value.number_float ==
static_cast<number_float_t>(rhs.m_value.number_integer);
22658 else if (lhs_type == value_t::number_unsigned && rhs_type == value_t::number_float)
22660 return static_cast<number_float_t>(lhs.m_value.number_unsigned) == rhs.m_value.number_float;
22662 else if (lhs_type == value_t::number_float && rhs_type == value_t::number_unsigned)
22664 return lhs.m_value.number_float ==
static_cast<number_float_t>(rhs.m_value.number_unsigned);
22666 else if (lhs_type == value_t::number_unsigned && rhs_type == value_t::number_integer)
22668 return static_cast<number_integer_t>(lhs.m_value.number_unsigned) == rhs.m_value.number_integer;
22670 else if (lhs_type == value_t::number_integer && rhs_type == value_t::number_unsigned)
22672 return lhs.m_value.number_integer ==
static_cast<number_integer_t>(rhs.m_value.number_unsigned);
22682 template<
typename ScalarType,
typename std::enable_if<
22683 std::is_scalar<ScalarType>::value,
int>
::type = 0>
22693 template<
typename ScalarType,
typename std::enable_if<
22694 std::is_scalar<ScalarType>::value,
int>
::type = 0>
22720 return !(lhs == rhs);
22727 template<
typename ScalarType,
typename std::enable_if<
22728 std::is_scalar<ScalarType>::value,
int>
::type = 0>
22738 template<
typename ScalarType,
typename std::enable_if<
22739 std::is_scalar<ScalarType>::value,
int>
::type = 0>
22773 const auto lhs_type = lhs.type();
22774 const auto rhs_type = rhs.type();
22776 if (lhs_type == rhs_type)
22780 case value_t::array:
22783 return (*lhs.m_value.array) < (*rhs.m_value.array);
22785 case value_t::object:
22786 return (*lhs.m_value.object) < (*rhs.m_value.object);
22788 case value_t::null:
22791 case value_t::string:
22792 return (*lhs.m_value.string) < (*rhs.m_value.string);
22794 case value_t::boolean:
22795 return (lhs.m_value.boolean) < (rhs.m_value.boolean);
22797 case value_t::number_integer:
22798 return (lhs.m_value.number_integer) < (rhs.m_value.number_integer);
22800 case value_t::number_unsigned:
22801 return (lhs.m_value.number_unsigned) < (rhs.m_value.number_unsigned);
22803 case value_t::number_float:
22804 return (lhs.m_value.number_float) < (rhs.m_value.number_float);
22806 case value_t::binary:
22807 return (*lhs.m_value.binary) < (*rhs.m_value.binary);
22813 else if (lhs_type == value_t::number_integer && rhs_type == value_t::number_float)
22815 return static_cast<number_float_t>(lhs.m_value.number_integer) < rhs.m_value.number_float;
22817 else if (lhs_type == value_t::number_float && rhs_type == value_t::number_integer)
22819 return lhs.m_value.number_float <
static_cast<number_float_t>(rhs.m_value.number_integer);
22821 else if (lhs_type == value_t::number_unsigned && rhs_type == value_t::number_float)
22823 return static_cast<number_float_t>(lhs.m_value.number_unsigned) < rhs.m_value.number_float;
22825 else if (lhs_type == value_t::number_float && rhs_type == value_t::number_unsigned)
22827 return lhs.m_value.number_float <
static_cast<number_float_t>(rhs.m_value.number_unsigned);
22829 else if (lhs_type == value_t::number_integer && rhs_type == value_t::number_unsigned)
22831 return lhs.m_value.number_integer <
static_cast<number_integer_t>(rhs.m_value.number_unsigned);
22833 else if (lhs_type == value_t::number_unsigned && rhs_type == value_t::number_integer)
22835 return static_cast<number_integer_t>(lhs.m_value.number_unsigned) < rhs.m_value.number_integer;
22848 template<
typename ScalarType,
typename std::enable_if<
22849 std::is_scalar<ScalarType>::value,
int>
::type = 0>
22859 template<
typename ScalarType,
typename std::enable_if<
22860 std::is_scalar<ScalarType>::value,
int>
::type = 0>
22887 return !(rhs < lhs);
22894 template<
typename ScalarType,
typename std::enable_if<
22895 std::is_scalar<ScalarType>::value,
int>
::type = 0>
22905 template<
typename ScalarType,
typename std::enable_if<
22906 std::is_scalar<ScalarType>::value,
int>
::type = 0>
22933 return !(lhs <= rhs);
22940 template<
typename ScalarType,
typename std::enable_if<
22941 std::is_scalar<ScalarType>::value,
int>
::type = 0>
22951 template<
typename ScalarType,
typename std::enable_if<
22952 std::is_scalar<ScalarType>::value,
int>
::type = 0>
22979 return !(lhs < rhs);
22986 template<
typename ScalarType,
typename std::enable_if<
22987 std::is_scalar<ScalarType>::value,
int>
::type = 0>
22997 template<
typename ScalarType,
typename std::enable_if<
22998 std::is_scalar<ScalarType>::value,
int>
::type = 0>
23047 const bool pretty_print = o.width() > 0;
23048 const auto indentation = pretty_print ? o.width() : 0;
23055 s.
dump(j, pretty_print,
false,
static_cast<unsigned int>(indentation));
23134 template<
typename InputType>
23138 const bool allow_exceptions =
true,
23139 const bool ignore_comments =
false)
23172 template<
typename IteratorType>
23177 const bool allow_exceptions =
true,
23178 const bool ignore_comments =
false)
23189 const
bool allow_exceptions = true,
23190 const
bool ignore_comments = false)
23193 parser(i.get(), cb, allow_exceptions, ignore_comments).parse(
true, result);
23227 template<
typename InputType>
23229 const bool ignore_comments =
false)
23234 template<
typename IteratorType>
23235 static bool accept(IteratorType first, IteratorType last,
23236 const bool ignore_comments =
false)
23243 static
bool accept(detail::span_input_adapter&& i,
23244 const
bool ignore_comments = false)
23246 return parser(i.get(),
nullptr,
false, ignore_comments).accept(
true);
23289 template <
typename InputType,
typename SAX>
23293 const
bool strict = true,
23294 const
bool ignore_comments = false)
23297 return format == input_format_t::json
23298 ?
parser(std::move(ia),
nullptr,
true, ignore_comments).sax_parse(sax, strict)
23302 template<
class IteratorType,
class SAX>
23304 static
bool sax_parse(IteratorType first, IteratorType last, SAX* sax,
23306 const
bool strict = true,
23307 const
bool ignore_comments = false)
23310 return format == input_format_t::json
23311 ?
parser(std::move(ia),
nullptr,
true, ignore_comments).sax_parse(sax, strict)
23315 template <
typename SAX>
23320 const
bool strict = true,
23321 const
bool ignore_comments = false)
23324 return format == input_format_t::json
23325 ?
parser(std::move(ia),
nullptr,
true, ignore_comments).sax_parse(sax, strict)
23417 case value_t::null:
23419 case value_t::object:
23421 case value_t::array:
23423 case value_t::string:
23425 case value_t::boolean:
23427 case value_t::binary:
23429 case value_t::discarded:
23430 return "discarded";
23553 std::vector<uint8_t> result;
23648 std::vector<uint8_t> result;
23750 const bool use_size =
false,
23751 const bool use_type =
false)
23753 std::vector<uint8_t> result;
23754 to_ubjson(j, result, use_size, use_type);
23759 const bool use_size =
false,
const bool use_type =
false)
23765 const bool use_size =
false,
const bool use_type =
false)
23829 std::vector<uint8_t> result;
23958 template<
typename InputType>
23961 const bool strict =
true,
23962 const bool allow_exceptions =
true,
23969 return res ? result :
basic_json(value_t::discarded);
23975 template<
typename IteratorType>
23978 const bool strict =
true,
23979 const bool allow_exceptions =
true,
23986 return res ? result :
basic_json(value_t::discarded);
23989 template<
typename T>
23993 const
bool strict = true,
23994 const
bool allow_exceptions = true,
23997 return from_cbor(ptr, ptr + len, strict, allow_exceptions, tag_handler);
24004 const
bool strict = true,
24005 const
bool allow_exceptions = true,
24012 return res ? result :
basic_json(value_t::discarded);
24101 template<
typename InputType>
24104 const bool strict =
true,
24105 const bool allow_exceptions =
true)
24111 return res ? result :
basic_json(value_t::discarded);
24117 template<
typename IteratorType>
24120 const bool strict =
true,
24121 const bool allow_exceptions =
true)
24127 return res ? result :
basic_json(value_t::discarded);
24131 template<
typename T>
24135 const
bool strict = true,
24136 const
bool allow_exceptions = true)
24138 return from_msgpack(ptr, ptr + len, strict, allow_exceptions);
24144 const
bool strict = true,
24145 const
bool allow_exceptions = true)
24151 return res ? result :
basic_json(value_t::discarded);
24217 template<
typename InputType>
24220 const bool strict =
true,
24221 const bool allow_exceptions =
true)
24227 return res ? result :
basic_json(value_t::discarded);
24233 template<
typename IteratorType>
24236 const bool strict =
true,
24237 const bool allow_exceptions =
true)
24243 return res ? result :
basic_json(value_t::discarded);
24246 template<
typename T>
24250 const
bool strict = true,
24251 const
bool allow_exceptions = true)
24253 return from_ubjson(ptr, ptr + len, strict, allow_exceptions);
24259 const
bool strict = true,
24260 const
bool allow_exceptions = true)
24266 return res ? result :
basic_json(value_t::discarded);
24330 template<
typename InputType>
24333 const bool strict =
true,
24334 const bool allow_exceptions =
true)
24340 return res ? result :
basic_json(value_t::discarded);
24346 template<
typename IteratorType>
24349 const bool strict =
true,
24350 const bool allow_exceptions =
true)
24356 return res ? result :
basic_json(value_t::discarded);
24359 template<
typename T>
24363 const
bool strict = true,
24364 const
bool allow_exceptions = true)
24366 return from_bson(ptr, ptr + len, strict, allow_exceptions);
24372 const
bool strict = true,
24373 const
bool allow_exceptions = true)
24379 return res ? result :
basic_json(value_t::discarded);
24668 enum class patch_operations {add, remove, replace, move, copy, test, invalid};
24670 const auto get_op = [](
const std::string & op)
24674 return patch_operations::add;
24676 if (op ==
"remove")
24678 return patch_operations::remove;
24680 if (op ==
"replace")
24682 return patch_operations::replace;
24686 return patch_operations::move;
24690 return patch_operations::copy;
24694 return patch_operations::test;
24697 return patch_operations::invalid;
24712 if (top_pointer != ptr)
24714 result.
at(top_pointer);
24718 const auto last_path = ptr.
back();
24724 case value_t::null:
24725 case value_t::object:
24728 parent[last_path] = val;
24732 case value_t::array:
24734 if (last_path ==
"-")
24761 const auto operation_remove = [&result](
json_pointer & ptr)
24764 const auto last_path = ptr.
back();
24772 auto it = parent.
find(last_path);
24796 for (
const auto& val : json_patch)
24799 const auto get_value = [&val](
const std::string & op,
24800 const std::string & member,
24807 const auto error_msg = (op ==
"op") ?
"operation" :
"operation '" + op +
"'";
24832 const auto op = get_value(
"op",
"op",
true).template get<std::string>();
24833 const auto path = get_value(op,
"path",
true).template get<std::string>();
24836 switch (get_op(op))
24838 case patch_operations::add:
24840 operation_add(ptr, get_value(
"add",
"value",
false));
24844 case patch_operations::remove:
24846 operation_remove(ptr);
24850 case patch_operations::replace:
24853 result.
at(ptr) = get_value(
"replace",
"value",
false);
24857 case patch_operations::move:
24859 const auto from_path = get_value(
"move",
"from",
true).template get<std::string>();
24869 operation_remove(from_ptr);
24870 operation_add(ptr, v);
24874 case patch_operations::copy:
24876 const auto from_path = get_value(
"copy",
"from",
true).template get<std::string>();
24885 operation_add(ptr, v);
24889 case patch_operations::test:
24891 bool success =
false;
24896 success = (result.
at(ptr) == get_value(
"test",
"value",
false));
24959 const std::string& path =
"")
24965 if (source == target)
24970 if (source.
type() != target.
type())
24975 {
"op",
"replace"}, {
"path", path}, {
"value", target}
24980 switch (source.
type())
24982 case value_t::array:
24986 while (i < source.
size() && i < target.
size())
24989 auto temp_diff =
diff(source[i], target[i], path +
"/" + std::to_string(i));
24990 result.
insert(result.
end(), temp_diff.begin(), temp_diff.end());
24999 while (i < source.
size())
25006 {
"path", path +
"/" + std::to_string(i)}
25012 while (i < target.
size())
25017 {
"path", path +
"/-"},
25018 {
"value", target[i]}
25026 case value_t::object:
25029 for (
auto it = source.
cbegin(); it != source.
cend(); ++it)
25034 if (target.
find(it.key()) != target.
end())
25037 auto temp_diff =
diff(it.value(), target[it.key()], path +
"/" + key);
25038 result.
insert(result.
end(), temp_diff.begin(), temp_diff.end());
25045 {
"op",
"remove"}, {
"path", path +
"/" + key}
25051 for (
auto it = target.
cbegin(); it != target.
cend(); ++it)
25053 if (source.
find(it.key()) == source.
end())
25059 {
"op",
"add"}, {
"path", path +
"/" + key},
25060 {
"value", it.value()}
25073 {
"op",
"replace"}, {
"path", path}, {
"value", target}
25141 for (
auto it = apply_patch.
begin(); it != apply_patch.
end(); ++it)
25143 if (it.value().is_null())
25155 *
this = apply_patch;
25219#ifndef JSON_HAS_CPP_20
25228 is_nothrow_move_constructible<nlohmann::json>::value&&
25229 is_nothrow_move_assignable<nlohmann::json>::value
25272inline
nlohmann::json::json_pointer operator "" _json_pointer(const
char* s,
std::
size_t n)
25281#if defined(__clang__) || defined(__GNUC__) || defined(__GNUG__)
25282 #pragma GCC diagnostic pop
25284#if defined(__clang__)
25285 #pragma GCC diagnostic pop
25290#undef JSON_INTERNAL_CATCH
25294#undef JSON_HAS_CPP_14
25295#undef JSON_HAS_CPP_17
25296#undef NLOHMANN_BASIC_JSON_TPL_DECLARATION
25297#undef NLOHMANN_BASIC_JSON_TPL
25298#undef JSON_EXPLICIT
25301#undef JSON_HEDLEY_ALWAYS_INLINE
25302#undef JSON_HEDLEY_ARM_VERSION
25303#undef JSON_HEDLEY_ARM_VERSION_CHECK
25304#undef JSON_HEDLEY_ARRAY_PARAM
25305#undef JSON_HEDLEY_ASSUME
25306#undef JSON_HEDLEY_BEGIN_C_DECLS
25307#undef JSON_HEDLEY_CLANG_HAS_ATTRIBUTE
25308#undef JSON_HEDLEY_CLANG_HAS_BUILTIN
25309#undef JSON_HEDLEY_CLANG_HAS_CPP_ATTRIBUTE
25310#undef JSON_HEDLEY_CLANG_HAS_DECLSPEC_DECLSPEC_ATTRIBUTE
25311#undef JSON_HEDLEY_CLANG_HAS_EXTENSION
25312#undef JSON_HEDLEY_CLANG_HAS_FEATURE
25313#undef JSON_HEDLEY_CLANG_HAS_WARNING
25314#undef JSON_HEDLEY_COMPCERT_VERSION
25315#undef JSON_HEDLEY_COMPCERT_VERSION_CHECK
25316#undef JSON_HEDLEY_CONCAT
25317#undef JSON_HEDLEY_CONCAT3
25318#undef JSON_HEDLEY_CONCAT3_EX
25319#undef JSON_HEDLEY_CONCAT_EX
25320#undef JSON_HEDLEY_CONST
25321#undef JSON_HEDLEY_CONSTEXPR
25322#undef JSON_HEDLEY_CONST_CAST
25323#undef JSON_HEDLEY_CPP_CAST
25324#undef JSON_HEDLEY_CRAY_VERSION
25325#undef JSON_HEDLEY_CRAY_VERSION_CHECK
25326#undef JSON_HEDLEY_C_DECL
25327#undef JSON_HEDLEY_DEPRECATED
25328#undef JSON_HEDLEY_DEPRECATED_FOR
25329#undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL
25330#undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_
25331#undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED
25332#undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES
25333#undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS
25334#undef JSON_HEDLEY_DIAGNOSTIC_POP
25335#undef JSON_HEDLEY_DIAGNOSTIC_PUSH
25336#undef JSON_HEDLEY_DMC_VERSION
25337#undef JSON_HEDLEY_DMC_VERSION_CHECK
25338#undef JSON_HEDLEY_EMPTY_BASES
25339#undef JSON_HEDLEY_EMSCRIPTEN_VERSION
25340#undef JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK
25341#undef JSON_HEDLEY_END_C_DECLS
25342#undef JSON_HEDLEY_FLAGS
25343#undef JSON_HEDLEY_FLAGS_CAST
25344#undef JSON_HEDLEY_GCC_HAS_ATTRIBUTE
25345#undef JSON_HEDLEY_GCC_HAS_BUILTIN
25346#undef JSON_HEDLEY_GCC_HAS_CPP_ATTRIBUTE
25347#undef JSON_HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE
25348#undef JSON_HEDLEY_GCC_HAS_EXTENSION
25349#undef JSON_HEDLEY_GCC_HAS_FEATURE
25350#undef JSON_HEDLEY_GCC_HAS_WARNING
25351#undef JSON_HEDLEY_GCC_NOT_CLANG_VERSION_CHECK
25352#undef JSON_HEDLEY_GCC_VERSION
25353#undef JSON_HEDLEY_GCC_VERSION_CHECK
25354#undef JSON_HEDLEY_GNUC_HAS_ATTRIBUTE
25355#undef JSON_HEDLEY_GNUC_HAS_BUILTIN
25356#undef JSON_HEDLEY_GNUC_HAS_CPP_ATTRIBUTE
25357#undef JSON_HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE
25358#undef JSON_HEDLEY_GNUC_HAS_EXTENSION
25359#undef JSON_HEDLEY_GNUC_HAS_FEATURE
25360#undef JSON_HEDLEY_GNUC_HAS_WARNING
25361#undef JSON_HEDLEY_GNUC_VERSION
25362#undef JSON_HEDLEY_GNUC_VERSION_CHECK
25363#undef JSON_HEDLEY_HAS_ATTRIBUTE
25364#undef JSON_HEDLEY_HAS_BUILTIN
25365#undef JSON_HEDLEY_HAS_CPP_ATTRIBUTE
25366#undef JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS
25367#undef JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE
25368#undef JSON_HEDLEY_HAS_EXTENSION
25369#undef JSON_HEDLEY_HAS_FEATURE
25370#undef JSON_HEDLEY_HAS_WARNING
25371#undef JSON_HEDLEY_IAR_VERSION
25372#undef JSON_HEDLEY_IAR_VERSION_CHECK
25373#undef JSON_HEDLEY_IBM_VERSION
25374#undef JSON_HEDLEY_IBM_VERSION_CHECK
25375#undef JSON_HEDLEY_IMPORT
25376#undef JSON_HEDLEY_INLINE
25377#undef JSON_HEDLEY_INTEL_VERSION
25378#undef JSON_HEDLEY_INTEL_VERSION_CHECK
25379#undef JSON_HEDLEY_IS_CONSTANT
25380#undef JSON_HEDLEY_IS_CONSTEXPR_
25381#undef JSON_HEDLEY_LIKELY
25382#undef JSON_HEDLEY_MALLOC
25383#undef JSON_HEDLEY_MESSAGE
25384#undef JSON_HEDLEY_MSVC_VERSION
25385#undef JSON_HEDLEY_MSVC_VERSION_CHECK
25386#undef JSON_HEDLEY_NEVER_INLINE
25387#undef JSON_HEDLEY_NON_NULL
25388#undef JSON_HEDLEY_NO_ESCAPE
25389#undef JSON_HEDLEY_NO_RETURN
25390#undef JSON_HEDLEY_NO_THROW
25391#undef JSON_HEDLEY_NULL
25392#undef JSON_HEDLEY_PELLES_VERSION
25393#undef JSON_HEDLEY_PELLES_VERSION_CHECK
25394#undef JSON_HEDLEY_PGI_VERSION
25395#undef JSON_HEDLEY_PGI_VERSION_CHECK
25396#undef JSON_HEDLEY_PREDICT
25397#undef JSON_HEDLEY_PRINTF_FORMAT
25398#undef JSON_HEDLEY_PRIVATE
25399#undef JSON_HEDLEY_PUBLIC
25400#undef JSON_HEDLEY_PURE
25401#undef JSON_HEDLEY_REINTERPRET_CAST
25402#undef JSON_HEDLEY_REQUIRE
25403#undef JSON_HEDLEY_REQUIRE_CONSTEXPR
25404#undef JSON_HEDLEY_REQUIRE_MSG
25405#undef JSON_HEDLEY_RESTRICT
25406#undef JSON_HEDLEY_RETURNS_NON_NULL
25407#undef JSON_HEDLEY_SENTINEL
25408#undef JSON_HEDLEY_STATIC_ASSERT
25409#undef JSON_HEDLEY_STATIC_CAST
25410#undef JSON_HEDLEY_STRINGIFY
25411#undef JSON_HEDLEY_STRINGIFY_EX
25412#undef JSON_HEDLEY_SUNPRO_VERSION
25413#undef JSON_HEDLEY_SUNPRO_VERSION_CHECK
25414#undef JSON_HEDLEY_TINYC_VERSION
25415#undef JSON_HEDLEY_TINYC_VERSION_CHECK
25416#undef JSON_HEDLEY_TI_ARMCL_VERSION
25417#undef JSON_HEDLEY_TI_ARMCL_VERSION_CHECK
25418#undef JSON_HEDLEY_TI_CL2000_VERSION
25419#undef JSON_HEDLEY_TI_CL2000_VERSION_CHECK
25420#undef JSON_HEDLEY_TI_CL430_VERSION
25421#undef JSON_HEDLEY_TI_CL430_VERSION_CHECK
25422#undef JSON_HEDLEY_TI_CL6X_VERSION
25423#undef JSON_HEDLEY_TI_CL6X_VERSION_CHECK
25424#undef JSON_HEDLEY_TI_CL7X_VERSION
25425#undef JSON_HEDLEY_TI_CL7X_VERSION_CHECK
25426#undef JSON_HEDLEY_TI_CLPRU_VERSION
25427#undef JSON_HEDLEY_TI_CLPRU_VERSION_CHECK
25428#undef JSON_HEDLEY_TI_VERSION
25429#undef JSON_HEDLEY_TI_VERSION_CHECK
25430#undef JSON_HEDLEY_UNAVAILABLE
25431#undef JSON_HEDLEY_UNLIKELY
25432#undef JSON_HEDLEY_UNPREDICTABLE
25433#undef JSON_HEDLEY_UNREACHABLE
25434#undef JSON_HEDLEY_UNREACHABLE_RETURN
25435#undef JSON_HEDLEY_VERSION
25436#undef JSON_HEDLEY_VERSION_DECODE_MAJOR
25437#undef JSON_HEDLEY_VERSION_DECODE_MINOR
25438#undef JSON_HEDLEY_VERSION_DECODE_REVISION
25439#undef JSON_HEDLEY_VERSION_ENCODE
25440#undef JSON_HEDLEY_WARNING
25441#undef JSON_HEDLEY_WARN_UNUSED_RESULT
25442#undef JSON_HEDLEY_WARN_UNUSED_RESULT_MSG
25443#undef JSON_HEDLEY_FALL_THROUGH
#define NLOHMANN_BASIC_JSON_TPL_DECLARATION
#define JSON_HEDLEY_CONST
#define JSON_HEDLEY_DIAGNOSTIC_PUSH
#define JSON_HEDLEY_WARN_UNUSED_RESULT
#define NLOHMANN_JSON_VERSION_PATCH
#define JSON_HEDLEY_LIKELY(expr)
#define JSON_HEDLEY_NON_NULL(...)
#define JSON_INTERNAL_CATCH(exception)
#define JSON_HEDLEY_RETURNS_NON_NULL
#define JSON_CATCH(exception)
#define JSON_THROW(exception)
#define NLOHMANN_JSON_VERSION_MAJOR
#define NLOHMANN_BASIC_JSON_TPL
#define JSON_HEDLEY_UNLIKELY(expr)
#define NLOHMANN_JSON_VERSION_MINOR
#define JSON_HEDLEY_DIAGNOSTIC_POP
#define JSON_HEDLEY_DEPRECATED_FOR(since, replacement)
void swap< nlohmann::json >(nlohmann::json &j1, nlohmann::json &j2) noexcept(is_nothrow_move_constructible< nlohmann::json >::value &&is_nothrow_move_assignable< nlohmann::json >::value)
exchanges the values of two JSON objects
decltype(get< N >(std::declval< ::nlohmann::detail::iteration_proxy_value< IteratorType > >())) type
namespace for Niels Lohmann
NLOHMANN_BASIC_JSON_TPL_DECLARATION std::string to_string(const NLOHMANN_BASIC_JSON_TPL &j)
user-defined to_string function for JSON values
typename std::enable_if< B, T >::type enable_if_t
typename T::reference reference_t
bool operator<(const value_t lhs, const value_t rhs) noexcept
comparison operator for JSON types
decltype(T::from_json(std::declval< Args >()...)) from_json_function
void to_json(BasicJsonType &j, T b) noexcept
typename It::difference_type difference_type
value_t
the JSON type enumeration
@ number_integer
number value (signed integer)
@ discarded
discarded by the parser callback function
@ binary
binary array (ordered collection of bytes)
@ object
object (unordered set of name/value pairs)
@ number_float
number value (floating-point)
@ number_unsigned
number value (unsigned integer)
@ array
array (ordered collection of values)
void from_json(const BasicJsonType &j, typename std::nullptr_t &n)
decltype(std::declval< T & >().parse_error(std::declval< std::size_t >(), std::declval< const std::string & >(), std::declval< const Exception & >())) parse_error_function_t
typename T::pointer pointer_t
decltype(std::declval< T & >().string(std::declval< String & >())) string_function_t
void from_json_tuple_impl(const BasicJsonType &j, Tuple &t, index_sequence< Idx... >)
primitive_iterator_t primitive_iterator
generic iterator for all other types
@ value
the parser finished reading a JSON value
@ key
the parser read a key of a value in an object
@ array_end
the parser read ] and finished processing a JSON array
@ array_start
the parser read [ and started to process a JSON array
@ object_start
the parser read { and started to process a JSON object
@ object_end
the parser read } and finished processing a JSON object
typename T::difference_type difference_type_t
typename detector< nonesuch, void, Op, Args... >::type detected_t
void int_to_string(string_type &target, std::size_t value)
void from_json_array_impl(const BasicJsonType &j, typename BasicJsonType::array_t &arr, priority_tag< 3 >)
decltype(std::declval< T & >().key(std::declval< String & >())) key_function_t
decltype(std::declval< T & >().boolean(std::declval< bool >())) boolean_function_t
decltype(std::declval< T & >().binary(std::declval< Binary & >())) binary_function_t
decltype(std::declval< T & >().number_integer(std::declval< Integer >())) number_integer_function_t
JSON_HEDLEY_RETURNS_NON_NULL char * to_chars(char *first, const char *last, FloatType value)
generates a decimal representation of the floating-point number value in [first, last).
void to_json_tuple_impl(BasicJsonType &j, const Tuple &t, index_sequence< Idx... >)
std::is_convertible< detected_t< Op, Args... >, To > is_detected_convertible
typename std::remove_cv< typename std::remove_reference< T >::type >::type uncvref_t
cbor_tag_handler_t
how to treat CBOR tags
@ error
throw a parse_error exception in case of a tag
error_handler_t
how to treat decoding errors
@ strict
throw a type_error exception in case of invalid UTF-8
@ ignore
ignore invalid UTF-8 sequences
@ replace
replace invalid UTF-8 sequences with U+FFFD
typename It::reference reference
decltype(std::declval< T & >().start_object(std::declval< std::size_t >())) start_object_function_t
iterator_input_adapter_factory< IteratorType >::adapter_type input_adapter(IteratorType first, IteratorType last)
typename T::key_type key_type_t
std::size_t combine(std::size_t seed, std::size_t h) noexcept
std::size_t hash(const BasicJsonType &j)
hash a JSON value
decltype(std::declval< T & >().number_unsigned(std::declval< Unsigned >())) number_unsigned_function_t
std::is_same< Expected, detected_t< Op, Args... > > is_detected_exact
typename detected_or< Default, Op, Args... >::type detected_or_t
decltype(std::declval< T & >().start_array(std::declval< std::size_t >())) start_array_function_t
BasicJsonType::array_t::iterator array_iterator
iterator for JSON arrays
void get_arithmetic_value(const BasicJsonType &j, ArithmeticType &val)
BasicJsonType::object_t::iterator object_iterator
iterator for JSON objects
typename detector< nonesuch, void, Op, Args... >::value_t is_detected
typename make_void< Ts... >::type void_t
std::function< bool(int depth, parse_event_t event, BasicJsonType &parsed)> parser_callback_t
std::random_access_iterator_tag iterator_category
std::shared_ptr< output_adapter_protocol< CharType > > output_adapter_t
a type to simplify interfaces
typename T::mapped_type mapped_type_t
typename T::iterator iterator_t
input_format_t
the supported input formats
typename It::iterator_category iterator_category
typename It::pointer pointer
decltype(std::declval< T >().template get< U >()) get_template_function
decltype(input_adapter(std::declval< const char * >(), std::declval< const char * >())) contiguous_bytes_input_adapter
decltype(std::declval< T & >().null()) null_function_t
typename It::value_type value_type
auto get(const nlohmann::detail::iteration_proxy_value< IteratorType > &i) -> decltype(i.key())
typename T::iterator_category iterator_category_t
static bool little_endianess(int num=1) noexcept
determine system byte order
decltype(std::declval< T & >().number_float(std::declval< Float >(), std::declval< const String & >())) number_float_function_t
ptrdiff_t difference_type
decltype(std::declval< T & >().end_array()) end_array_function_t
decltype(std::declval< T & >().end_object()) end_object_function_t
decltype(T::to_json(std::declval< Args >()...)) to_json_function
typename T::value_type value_type_t
constexpr const auto & to_json
constexpr const auto & from_json
void grisu2(char *buf, int &len, int &decimal_exponent, diyfp m_minus, diyfp v, diyfp m_plus)
JSON_HEDLEY_RETURNS_NON_NULL char * format_buffer(char *buf, int len, int decimal_exponent, int min_exp, int max_exp)
prettify v = buf * 10^decimal_exponent
Target reinterpret_bits(const Source source)
boundaries compute_boundaries(FloatType value)
int find_largest_pow10(const std::uint32_t n, std::uint32_t &pow10)
void grisu2_round(char *buf, int len, std::uint64_t dist, std::uint64_t delta, std::uint64_t rest, std::uint64_t ten_k)
JSON_HEDLEY_RETURNS_NON_NULL char * append_exponent(char *buf, int e)
appends a decimal representation of e to buf
void grisu2_digit_gen(char *buffer, int &length, int &decimal_exponent, diyfp M_minus, diyfp w, diyfp M_plus)
cached_power get_cached_power_for_binary_exponent(int e)
struct to capture the start position of the current token
std::size_t lines_read
the number of lines read
std::size_t chars_read_current_line
the number of characters read in the current line
std::size_t chars_read_total
the total number of characters read
general exception of the basic_json class
const int id
the id of the exception
static std::string name(const std::string &ename, int id_)
std::runtime_error m
an exception object as storage for error messages
JSON_HEDLEY_RETURNS_NON_NULL const char * what() const noexcept override
returns the explanatory string
exception indicating a parse error
parse_error(int id_, std::size_t byte_, const char *what_arg)
static parse_error create(int id_, const position_t &pos, const std::string &what_arg)
create a parse error exception
const std::size_t byte
byte index of the parse error
static parse_error create(int id_, std::size_t byte_, const std::string &what_arg)
static std::string position_string(const position_t &pos)
exception indicating errors with iterators
static invalid_iterator create(int id_, const std::string &what_arg)
exception indicating executing a member function with a wrong type
static type_error create(int id_, const std::string &what_arg)
exception indicating access out of the defined range
static out_of_range create(int id_, const std::string &what_arg)
exception indicating other library errors
static other_error create(int id_, const std::string &what_arg)
static constexpr std::size_t size() noexcept
nonesuch(nonesuch const &)=delete
void operator=(nonesuch &&)=delete
nonesuch(nonesuch const &&)=delete
void operator=(nonesuch const &)=delete
default JSONSerializer template argument
static auto to_json(BasicJsonType &j, ValueType &&val) noexcept(noexcept(::nlohmann::to_json(j, std::forward< ValueType >(val)))) -> decltype(::nlohmann::to_json(j, std::forward< ValueType >(val)), void())
convert any value type to a JSON value
static auto from_json(BasicJsonType &&j, ValueType &val) noexcept(noexcept(::nlohmann::from_json(std::forward< BasicJsonType >(j), val))) -> decltype(::nlohmann::from_json(std::forward< BasicJsonType >(j), val), void())
convert a JSON value to any value type
a class to store JSON values
static std::vector< uint8_t > to_cbor(const basic_json &j)
create a CBOR serialization of a given JSON value
ValueType & get_to(ValueType &v) const
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json binary(typename binary_t::container_type &&init, std::uint8_t subtype)
explicitly create a binary array (with subtype)
constexpr auto get() const noexcept -> decltype(std::declval< const basic_json_t & >().template get_ptr< PointerType >())
get a pointer value (explicit)
void insert(const_iterator first, const_iterator last)
inserts elements
array_t * get_impl_ptr(array_t *) noexcept
get a pointer to the value (array)
detail::parser_callback_t< basic_json > parser_callback_t
per-element parser callback type
bool contains(KeyT &&key) const
check the existence of an element in a JSON object
iteration_proxy< iterator > items() noexcept
helper to access iterator member functions in range-based for
const_reverse_iterator crbegin() const noexcept
returns a const reverse iterator to the last element
constexpr const number_unsigned_t * get_impl_ptr(const number_unsigned_t *) const noexcept
get a pointer to the value (unsigned number)
const_reference operator[](const json_pointer &ptr) const
access specified element via JSON Pointer
basic_json get() const
get special-case overload
reference operator[](const json_pointer &ptr)
access specified element via JSON Pointer
ValueType value(const typename object_t::key_type &key, const ValueType &default_value) const
access specified object element with default value
constexpr bool is_number_float() const noexcept
return whether value is a floating-point number
NumberIntegerType number_integer_t
a type for a number (integer)
friend bool operator==(const_reference lhs, const_reference rhs) noexcept
comparison: equal
friend bool operator>(const ScalarType lhs, const_reference rhs) noexcept
comparison: greater than
NLOHMANN_BASIC_JSON_TPL basic_json_t
workaround type for MSVC
static bool sax_parse(InputType &&i, SAX *sax, input_format_t format=input_format_t::json, const bool strict=true, const bool ignore_comments=false)
generate SAX events
ReferenceType get_ref()
get a reference value (implicit)
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json parse(InputType &&i, const parser_callback_t cb=nullptr, const bool allow_exceptions=true, const bool ignore_comments=false)
deserialize from a compatible input
reference emplace_back(Args &&... args)
add an object to an array
const_iterator find(KeyT &&key) const
find an element in a JSON object
basic_json(const value_t v)
create an empty value with a given type
static void to_ubjson(const basic_json &j, detail::output_adapter< uint8_t > o, const bool use_size=false, const bool use_type=false)
object_t * get_impl_ptr(object_t *) noexcept
get a pointer to the value (object)
size_type max_size() const noexcept
returns the maximum possible number of elements
basic_json(CompatibleType &&val) noexcept(noexcept(JSONSerializer< U >::to_json(std::declval< basic_json_t & >(), std::forward< CompatibleType >(val))))
create a JSON value
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json diff(const basic_json &source, const basic_json &target, const std::string &path="")
creates a diff as a JSON patch
void erase(const size_type idx)
remove element from a JSON array given an index
const_reverse_iterator crend() const noexcept
returns a const reverse iterator to one before the first
const_reference at(const typename object_t::key_type &key) const
access specified object element with bounds checking
reference at(const typename object_t::key_type &key)
access specified object element with bounds checking
iterator begin() noexcept
returns an iterator to the first element
basic_json(InputIT first, InputIT last)
construct a JSON container given an iterator range
static std::vector< uint8_t > to_bson(const basic_json &j)
Serializes the given JSON object j to BSON and returns a vector containing the corresponding BSON-rep...
basic_json(const JsonRef &ref)
basic_json & operator=(basic_json other) noexcept(std::is_nothrow_move_constructible< value_t >::value &&std::is_nothrow_move_assignable< value_t >::value &&std::is_nothrow_move_constructible< json_value >::value &&std::is_nothrow_move_assignable< json_value >::value)
copy assignment
value_t m_type
the type of the current element
static void to_cbor(const basic_json &j, detail::output_adapter< uint8_t > o)
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json array(initializer_list_t init={})
explicitly create an array from an initializer list
const_reverse_iterator rend() const noexcept
returns a const reverse iterator to one before the first
const_iterator cend() const noexcept
returns a const iterator to one past the last element
number_unsigned_t * get_impl_ptr(number_unsigned_t *) noexcept
get a pointer to the value (unsigned number)
reference back()
access the last element
boolean_t * get_impl_ptr(boolean_t *) noexcept
get a pointer to the value (boolean)
const binary_t & get_binary() const
constexpr const boolean_t * get_impl_ptr(const boolean_t *) const noexcept
get a pointer to the value (boolean)
static bool accept(InputType &&i, const bool ignore_comments=false)
check if the input is valid JSON
StringType string_t
a type for a string
size_type size() const noexcept
returns the number of elements
void push_back(const basic_json &val)
add an object to an array
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json meta()
returns version information on the library
ValueType value(const json_pointer &ptr, const ValueType &default_value) const
access specified object element via JSON Pointer with default value
void update(const_reference j)
updates a JSON object from another object, overwriting existing keys
std::size_t size_type
a type to represent container sizes
ValueType & get_to(ValueType &v) const noexcept(noexcept(JSONSerializer< ValueType >::from_json(std::declval< const basic_json_t & >(), v)))
get a value (explicit)
std::ptrdiff_t difference_type
a type to represent differences between iterators
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json binary(const typename binary_t::container_type &init)
explicitly create a binary array (without subtype)
static std::vector< uint8_t > to_msgpack(const basic_json &j)
create a MessagePack serialization of a given JSON value
reference operator[](const typename object_t::key_type &key)
access specified object element
reference operator+=(basic_json &&val)
add an object to an array
basic_json(const BasicJsonType &val)
create a JSON value from an existing one
typename std::allocator_traits< allocator_type >::const_pointer const_pointer
the type of an element const pointer
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json from_bson(IteratorType first, IteratorType last, const bool strict=true, const bool allow_exceptions=true)
friend bool operator>(const_reference lhs, const ScalarType rhs) noexcept
comparison: greater than
typename std::allocator_traits< allocator_type >::pointer pointer
the type of an element pointer
constexpr const binary_t * get_impl_ptr(const binary_t *) const noexcept
get a pointer to the value (binary)
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json from_cbor(InputType &&i, const bool strict=true, const bool allow_exceptions=true, const cbor_tag_handler_t tag_handler=cbor_tag_handler_t::error)
create a JSON value from an input in CBOR format
BooleanType boolean_t
a type for a boolean
void push_back(initializer_list_t init)
add an object to an object
boolean_t get_impl(boolean_t *) const
get a boolean (explicit)
string_t dump(const int indent=-1, const char indent_char=' ', const bool ensure_ascii=false, const error_handler_t error_handler=error_handler_t::strict) const
serialization
static bool accept(IteratorType first, IteratorType last, const bool ignore_comments=false)
IteratorType erase(IteratorType pos)
remove element given an iterator
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json from_bson(InputType &&i, const bool strict=true, const bool allow_exceptions=true)
Create a JSON value from an input in BSON format.
constexpr bool is_structured() const noexcept
return whether type is structured
const_iterator begin() const noexcept
returns a const iterator to the first element
reference at(size_type idx)
access specified array element with bounds checking
reference front()
access the first element
constexpr bool is_primitive() const noexcept
return whether type is primitive
constexpr bool is_number_unsigned() const noexcept
return whether value is an unsigned integer number
static void to_cbor(const basic_json &j, detail::output_adapter< char > o)
void swap(object_t &other)
exchanges the values
constexpr bool is_object() const noexcept
return whether value is an object
const_reference front() const
access the first element
constexpr value_t type() const noexcept
return the type of the JSON value (explicit)
NumberFloatType number_float_t
a type for a number (floating-point)
json_reverse_iterator< typename basic_json::iterator > reverse_iterator
a reverse iterator for a basic_json container
friend std::ostream & operator<<(std::ostream &o, const basic_json &j)
serialize to stream
friend bool operator<=(const_reference lhs, const_reference rhs) noexcept
comparison: less than or equal
bool empty() const noexcept
checks whether the container is empty.
friend bool operator>=(const ScalarType lhs, const_reference rhs) noexcept
comparison: greater than or equal
basic_json(const basic_json &other)
copy constructor
~basic_json() noexcept
destructor
BasicJsonType get() const
get special-case overload
basic_json(basic_json &&other) noexcept
move constructor
static void to_bson(const basic_json &j, detail::output_adapter< uint8_t > o)
Serializes the given JSON object j to BSON and forwards the corresponding BSON-representation to the ...
friend bool operator>=(const_reference lhs, const ScalarType rhs) noexcept
comparison: greater than or equal
static void to_ubjson(const basic_json &j, detail::output_adapter< char > o, const bool use_size=false, const bool use_type=false)
friend bool operator!=(const_reference lhs, const_reference rhs) noexcept
comparison: not equal
iterator insert(const_iterator pos, size_type cnt, const basic_json &val)
inserts elements
json_value m_value
the value of the current element
void swap(typename binary_t::container_type &other)
exchanges the values
friend bool operator>=(const_reference lhs, const_reference rhs) noexcept
comparison: greater than or equal
void swap(array_t &other)
exchanges the values
friend bool operator<(const_reference lhs, const ScalarType rhs) noexcept
comparison: less than
reverse_iterator rend() noexcept
returns an iterator to the reverse-end
static iteration_proxy< iterator > iterator_wrapper(reference ref) noexcept
wrapper to access iterator member functions in range-based for
friend bool operator<=(const_reference lhs, const ScalarType rhs) noexcept
comparison: less than or equal
ReferenceType get_ref() const
get a reference value (implicit)
iterator insert(const_iterator pos, const_iterator first, const_iterator last)
inserts elements
auto get() noexcept -> decltype(std::declval< basic_json_t & >().template get_ptr< PointerType >())
get a pointer value (explicit)
const_reference at(const json_pointer &ptr) const
access specified element via JSON Pointer
const_iterator end() const noexcept
returns a const iterator to one past the last element
void merge_patch(const basic_json &apply_patch)
applies a JSON Merge Patch
auto get_ptr() noexcept -> decltype(std::declval< basic_json_t & >().get_impl_ptr(std::declval< PointerType >()))
get a pointer value (implicit)
iteration_proxy< const_iterator > items() const noexcept
helper to access iterator member functions in range-based for
iterator insert(const_iterator pos, initializer_list_t ilist)
inserts elements
ArrayType< basic_json, AllocatorType< basic_json > > array_t
a type for an array
Array get_to(T(&v)[N]) const noexcept(noexcept(JSONSerializer< Array >::from_json(std::declval< const basic_json_t & >(), v)))
friend bool operator>(const_reference lhs, const_reference rhs) noexcept
comparison: greater than
constexpr const number_integer_t * get_impl_ptr(const number_integer_t *) const noexcept
get a pointer to the value (integer number)
constexpr const string_t * get_impl_ptr(const string_t *) const noexcept
get a pointer to the value (string)
IteratorType erase(IteratorType first, IteratorType last)
remove elements given an iterator range
ValueType get() const noexcept(noexcept(JSONSerializer< ValueType >::from_json(std::declval< const basic_json_t & >(), std::declval< ValueType & >())))
get a value (explicit)
constexpr bool is_boolean() const noexcept
return whether value is a boolean
iterator end() noexcept
returns an iterator to one past the last element
void swap(reference other) noexcept(std::is_nothrow_move_constructible< value_t >::value &&std::is_nothrow_move_assignable< value_t >::value &&std::is_nothrow_move_constructible< json_value >::value &&std::is_nothrow_move_assignable< json_value >::value)
exchanges the values
void clear() noexcept
clears the contents
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json from_msgpack(IteratorType first, IteratorType last, const bool strict=true, const bool allow_exceptions=true)
constexpr bool is_binary() const noexcept
return whether value is a binary array
static JSON_HEDLEY_RETURNS_NON_NULL T * create(Args &&... args)
helper for exception-safe object creation
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json object(initializer_list_t init={})
explicitly create an object from an initializer list
iterator insert(const_iterator pos, basic_json &&val)
inserts element
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json from_ubjson(IteratorType first, IteratorType last, const bool strict=true, const bool allow_exceptions=true)
reference operator[](size_type idx)
access specified array element
static void to_bson(const basic_json &j, detail::output_adapter< char > o)
Serializes the given JSON object j to BSON and forwards the corresponding BSON-representation to the ...
void update(const_iterator first, const_iterator last)
updates a JSON object from another object, overwriting existing keys
reference at(const json_pointer &ptr)
access specified element via JSON Pointer
void swap(binary_t &other)
exchanges the values
json_reverse_iterator< typename basic_json::const_iterator > const_reverse_iterator
a const reverse iterator for a basic_json container
void assert_invariant() const noexcept
checks the class invariants
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json from_ubjson(InputType &&i, const bool strict=true, const bool allow_exceptions=true)
create a JSON value from an input in UBJSON format
::nlohmann::json_pointer< basic_json > json_pointer
JSON Pointer, see nlohmann::json_pointer.
static void to_msgpack(const basic_json &j, detail::output_adapter< uint8_t > o)
const_reverse_iterator rbegin() const noexcept
returns a const reverse iterator to the last element
void swap(string_t &other)
exchanges the values
const_reference back() const
access the last element
friend bool operator<(const_reference lhs, const_reference rhs) noexcept
comparison: less than
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json binary(typename binary_t::container_type &&init)
explicitly create a binary array (without subtype)
friend bool operator!=(const ScalarType lhs, const_reference rhs) noexcept
comparison: not equal
constexpr bool is_string() const noexcept
return whether value is a string
number_integer_t * get_impl_ptr(number_integer_t *) noexcept
get a pointer to the value (integer number)
constexpr bool is_array() const noexcept
return whether value is an array
iterator insert_iterator(const_iterator pos, Args &&... args)
Helper for insertion of an iterator.
basic_json flatten() const
return flattened JSON value
constexpr const number_float_t * get_impl_ptr(const number_float_t *) const noexcept
get a pointer to the value (floating-point number)
constexpr const array_t * get_impl_ptr(const array_t *) const noexcept
get a pointer to the value (array)
JSON_HEDLEY_RETURNS_NON_NULL const char * type_name() const noexcept
return the type as string
void push_back(basic_json &&val)
add an object to an array
friend bool operator==(const_reference lhs, const ScalarType rhs) noexcept
comparison: equal
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json from_cbor(IteratorType first, IteratorType last, const bool strict=true, const bool allow_exceptions=true, const cbor_tag_handler_t tag_handler=cbor_tag_handler_t::error)
size_type count(KeyT &&key) const
returns the number of occurrences of a key in a JSON object
constexpr bool is_number() const noexcept
return whether value is a number
string_t * get_impl_ptr(string_t *) noexcept
get a pointer to the value (string)
friend bool operator<(const ScalarType lhs, const_reference rhs) noexcept
comparison: less than
friend std::ostream & operator>>(const basic_json &j, std::ostream &o)
serialize to stream
std::less< StringType > object_comparator_t
reference operator+=(initializer_list_t init)
add an object to an object
::nlohmann::detail::output_adapter_t< CharType > output_adapter_t
constexpr bool is_number_integer() const noexcept
return whether value is an integer number
std::initializer_list< detail::json_ref< basic_json > > initializer_list_t
helper type for initializer lists of basic_json values
number_float_t * get_impl_ptr(number_float_t *) noexcept
get a pointer to the value (floating-point number)
friend class ::nlohmann::detail::parser
static void to_msgpack(const basic_json &j, detail::output_adapter< char > o)
const_reference operator[](const typename object_t::key_type &key) const
read-only access specified object element
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json binary(const typename binary_t::container_type &init, std::uint8_t subtype)
explicitly create a binary array (with subtype)
iterator find(KeyT &&key)
find an element in a JSON object
basic_json(std::nullptr_t=nullptr) noexcept
create a null object
const_reference operator[](size_type idx) const
access specified array element
AllocatorType< basic_json > allocator_type
the allocator type
nlohmann::byte_container_with_subtype< BinaryType > binary_t
a type for a packed binary type
JSONSerializer< T, SFINAE > json_serializer
void push_back(const typename object_t::value_type &val)
add an object to an object
friend bool operator<=(const ScalarType lhs, const_reference rhs) noexcept
comparison: less than or equal
ValueType get() const noexcept(noexcept(JSONSerializer< ValueType >::from_json(std::declval< const basic_json_t & >())))
get a value (explicit); special case
static std::vector< uint8_t > to_ubjson(const basic_json &j, const bool use_size=false, const bool use_type=false)
create a UBJSON serialization of a given JSON value
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json parse(IteratorType first, IteratorType last, const parser_callback_t cb=nullptr, const bool allow_exceptions=true, const bool ignore_comments=false)
deserialize from a pair of character iterators
bool contains(const json_pointer &ptr) const
check the existence of an element in a JSON object given a JSON pointer
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json from_msgpack(InputType &&i, const bool strict=true, const bool allow_exceptions=true)
create a JSON value from an input in MessagePack format
basic_json patch(const basic_json &json_patch) const
applies a JSON patch
string_t value(const typename object_t::key_type &key, const char *default_value) const
overload for a default value of type const char*
basic_json unflatten() const
unflatten a previously flattened JSON value
NumberUnsignedType number_unsigned_t
a type for a number (unsigned)
reference operator+=(const typename object_t::value_type &val)
add an object to an object
const_iterator cbegin() const noexcept
returns a const iterator to the first element
friend std::istream & operator>>(std::istream &i, basic_json &j)
deserialize from stream
static ::nlohmann::detail::parser< basic_json, InputAdapterType > parser(InputAdapterType adapter, detail::parser_callback_t< basic_json >cb=nullptr, const bool allow_exceptions=true, const bool ignore_comments=false)
basic_json(initializer_list_t init, bool type_deduction=true, value_t manual_type=value_t::array)
create a container (array or object) from an initializer list
const_reference at(size_type idx) const
access specified array element with bounds checking
iterator insert(const_iterator pos, const basic_json &val)
inserts element
constexpr bool is_discarded() const noexcept
return whether value is discarded
constexpr bool is_null() const noexcept
return whether value is null
friend void swap(reference left, reference right) noexcept(std::is_nothrow_move_constructible< value_t >::value &&std::is_nothrow_move_assignable< value_t >::value &&std::is_nothrow_move_constructible< json_value >::value &&std::is_nothrow_move_assignable< json_value >::value)
exchanges the values
binary_t * get_impl_ptr(binary_t *) noexcept
get a pointer to the value (binary)
friend bool operator==(const ScalarType lhs, const_reference rhs) noexcept
comparison: equal
ObjectType< StringType, basic_json, object_comparator_t, AllocatorType< std::pair< const StringType, basic_json > > > object_t
a type for an object
std::pair< iterator, bool > emplace(Args &&... args)
add an object to an object if key does not exist
reference operator+=(const basic_json &val)
add an object to an array
size_type erase(const typename object_t::key_type &key)
remove element from a JSON object given a key
static ReferenceType get_ref_impl(ThisType &obj)
helper function to implement get_ref()
basic_json(size_type cnt, const basic_json &val)
construct an array with count copies of given value
static allocator_type get_allocator()
returns the allocator associated with the container
constexpr const object_t * get_impl_ptr(const object_t *) const noexcept
get a pointer to the value (object)
constexpr auto get_ptr() const noexcept -> decltype(std::declval< const basic_json_t & >().get_impl_ptr(std::declval< PointerType >()))
get a pointer value (implicit)
friend bool operator!=(const_reference lhs, const ScalarType rhs) noexcept
comparison: not equal
reverse_iterator rbegin() noexcept
returns an iterator to the reverse-beginning
std::vector< std::string > reference_tokens
the reference tokens
json_pointer & operator/=(std::string token)
append an unescaped reference token at the end of this JSON pointer
json_pointer & operator/=(const json_pointer &ptr)
append another JSON pointer at the end of this JSON pointer
std::string to_string() const
return a string representation of the JSON pointer
const BasicJsonType & get_unchecked(const BasicJsonType *ptr) const
return a const reference to the pointed to value
friend bool operator==(json_pointer const &lhs, json_pointer const &rhs) noexcept
compares two JSON pointers for equality
void pop_back()
remove last reference token
const std::string & back() const
return last reference token
const BasicJsonType & get_checked(const BasicJsonType *ptr) const
bool empty() const noexcept
return whether pointer points to the root document
friend bool operator!=(json_pointer const &lhs, json_pointer const &rhs) noexcept
compares two JSON pointers for inequality
void push_back(const std::string &token)
append an unescaped token at the end of the reference pointer
json_pointer(const std::string &s="")
create JSON pointer
static std::string escape(std::string s)
escape "~" to "~0" and "/" to "~1"
friend json_pointer operator/(const json_pointer &lhs, const json_pointer &rhs)
create a new JSON pointer by appending the right JSON pointer at the end of the left JSON pointer
bool contains(const BasicJsonType *ptr) const
static BasicJsonType unflatten(const BasicJsonType &value)
friend json_pointer operator/(const json_pointer &ptr, std::string token)
create a new JSON pointer by appending the unescaped token at the end of the JSON pointer
BasicJsonType & get_and_create(BasicJsonType &j) const
create and return a reference to the pointed to value
static void replace_substring(std::string &s, const std::string &f, const std::string &t)
replace all occurrences of a substring by another string
static void flatten(const std::string &reference_string, const BasicJsonType &value, BasicJsonType &result)
static void unescape(std::string &s)
unescape "~1" to tilde and "~0" to slash (order is important!)
void push_back(std::string &&token)
append an unescaped token at the end of the reference pointer
BasicJsonType & get_checked(BasicJsonType *ptr) const
json_pointer & operator/=(std::size_t array_idx)
append an array index at the end of this JSON pointer
static BasicJsonType::size_type array_index(const std::string &s)
BasicJsonType & get_unchecked(BasicJsonType *ptr) const
return a reference to the pointed to value
friend json_pointer operator/(const json_pointer &ptr, std::size_t array_idx)
create a new JSON pointer by appending the array-index-token at the end of the JSON pointer
json_pointer parent_pointer() const
returns the parent of this JSON pointer
static std::vector< std::string > split(const std::string &reference_string)
split the string input to reference tokens
ordered_map: a minimal map-like container that preserves insertion order for use within nlohmann::bas...
ordered_map(std::initializer_list< T > init, const Allocator &alloc=Allocator())
std::vector< std::pair< const Key, T >, Allocator > Container
const T & at(const Key &key) const
iterator find(const Key &key)
iterator erase(iterator pos)
std::pair< iterator, bool > insert(value_type &&value)
const_iterator find(const Key &key) const
size_type erase(const Key &key)
T & operator[](const Key &key)
ordered_map(const Allocator &alloc=Allocator())
ordered_map(It first, It last, const Allocator &alloc=Allocator())
std::pair< iterator, bool > insert(const value_type &value)
size_type count(const Key &key) const
std::pair< iterator, bool > emplace(const key_type &key, T &&t)
const T & operator[](const Key &key) const
json_ref & operator=(const json_ref &)=delete
json_ref(const json_ref &)=delete
json_ref(json_ref &&)=default
value_type const & operator*() const
json_ref(Args &&... args)
json_ref(const value_type &value)
value_type const * operator->() const
json_ref & operator=(json_ref &&)=delete
json_ref(std::initializer_list< json_ref > init)
json_ref(value_type &&value)
value_type moved_or_copied() const
static constexpr bool value
typename BasicJsonType::template json_serializer< T, void > serializer
typename BasicJsonType::template json_serializer< T, void > serializer
typename BasicJsonType::template json_serializer< T, void > serializer
typename BasicJsonType::object_t object_t
typename BasicJsonType::object_t object_t
std::numeric_limits< CompatibleNumberIntegerType > CompatibleLimits
std::numeric_limits< RealIntegerType > RealLimits
auto operator()(const BasicJsonType &j, T &val) const noexcept(noexcept(from_json(j, val))) -> decltype(from_json(j, val), void())
IteratorType anchor
the iterator
std::input_iterator_tag iterator_category
typename std::remove_cv< typename std::remove_reference< decltype(std::declval< IteratorType >().key()) >::type >::type string_type
const string_type empty_str
an empty string (to return a reference for primitive values)
iteration_proxy_value(IteratorType it) noexcept
bool operator!=(const iteration_proxy_value &o) const
inequality operator (needed for range-based for)
std::size_t array_index_last
last stringified array index
string_type array_index_str
a string representation of the array index
IteratorType::reference value() const
return value of the iterator
iteration_proxy_value & operator++()
increment operator (needed for range-based for)
std::size_t array_index
an index for arrays (used to create key names)
iteration_proxy_value & operator*()
dereference operator (needed for range-based for)
std::ptrdiff_t difference_type
const string_type & key() const
return key of the iterator
bool operator==(const iteration_proxy_value &o) const
equality operator (needed for InputIterator)
proxy class for the items() function
iteration_proxy_value< IteratorType > begin() noexcept
return iterator begin (needed for range-based for)
iteration_proxy_value< IteratorType > end() noexcept
return iterator end (needed for range-based for)
IteratorType::reference container
the container to iterate
iteration_proxy(typename IteratorType::reference cont) noexcept
construct iteration proxy from a container
static void construct(BasicJsonType &j, typename BasicJsonType::boolean_t b) noexcept
static void construct(BasicJsonType &j, typename BasicJsonType::string_t &&s)
static void construct(BasicJsonType &j, const CompatibleStringType &str)
static void construct(BasicJsonType &j, const typename BasicJsonType::string_t &s)
static void construct(BasicJsonType &j, const typename BasicJsonType::binary_t &b)
static void construct(BasicJsonType &j, typename BasicJsonType::binary_t &&b)
static void construct(BasicJsonType &j, typename BasicJsonType::number_float_t val) noexcept
static void construct(BasicJsonType &j, typename BasicJsonType::number_unsigned_t val) noexcept
static void construct(BasicJsonType &j, typename BasicJsonType::number_integer_t val) noexcept
static void construct(BasicJsonType &j, const CompatibleArrayType &arr)
static void construct(BasicJsonType &j, const std::valarray< T > &arr)
static void construct(BasicJsonType &j, const std::vector< bool > &arr)
static void construct(BasicJsonType &j, typename BasicJsonType::array_t &&arr)
static void construct(BasicJsonType &j, const typename BasicJsonType::array_t &arr)
static void construct(BasicJsonType &j, typename BasicJsonType::object_t &&obj)
static void construct(BasicJsonType &j, const typename BasicJsonType::object_t &obj)
static void construct(BasicJsonType &j, const CompatibleObjectType &obj)
auto operator()(BasicJsonType &j, T &&val) const noexcept(noexcept(to_json(j, std::forward< T >(val)))) -> decltype(to_json(j, std::forward< T >(val)), void())
an internal type for a backed binary type
BinaryType container_type
the type of the underlying container
byte_container_with_subtype(const container_type &b) noexcept(noexcept(container_type(b)))
byte_container_with_subtype(container_type &&b) noexcept(noexcept(container_type(std::move(b))))
bool operator!=(const byte_container_with_subtype &rhs) const
void clear_subtype() noexcept
clears the binary subtype
byte_container_with_subtype(container_type &&b, std::uint8_t subtype) noexcept(noexcept(container_type(std::move(b))))
byte_container_with_subtype() noexcept(noexcept(container_type()))
constexpr bool has_subtype() const noexcept
return whether the value has a subtype
void set_subtype(std::uint8_t subtype) noexcept
sets the binary subtype
byte_container_with_subtype(const container_type &b, std::uint8_t subtype) noexcept(noexcept(container_type(b)))
constexpr std::uint8_t subtype() const noexcept
return the binary subtype
bool operator==(const byte_container_with_subtype &rhs) const
file_input_adapter(file_input_adapter &&)=default
std::FILE * m_file
the file pointer to read from
file_input_adapter(const file_input_adapter &)=delete
file_input_adapter & operator=(file_input_adapter &&)=delete
file_input_adapter & operator=(const file_input_adapter &)=delete
std::char_traits< char >::int_type get_character() noexcept
input_stream_adapter(input_stream_adapter &&rhs) noexcept
input_stream_adapter & operator=(input_stream_adapter &)=delete
input_stream_adapter(const input_stream_adapter &)=delete
std::istream * is
the associated input stream
std::char_traits< char >::int_type get_character()
input_stream_adapter(std::istream &i)
input_stream_adapter & operator=(input_stream_adapter &&rhs)=delete
typename std::iterator_traits< IteratorType >::value_type char_type
iterator_input_adapter(IteratorType first, IteratorType last)
std::char_traits< char_type >::int_type get_character()
static void fill_buffer(BaseInputAdapter &input, std::array< std::char_traits< char >::int_type, 4 > &utf8_bytes, size_t &utf8_bytes_index, size_t &utf8_bytes_filled)
static void fill_buffer(BaseInputAdapter &input, std::array< std::char_traits< char >::int_type, 4 > &utf8_bytes, size_t &utf8_bytes_index, size_t &utf8_bytes_filled)
std::char_traits< char >::int_type get_character() noexcept
std::size_t utf8_bytes_index
index to the utf8_codes array for the next valid byte
BaseInputAdapter base_adapter
std::size_t utf8_bytes_filled
number of valid bytes in the utf8_codes array
wide_string_input_adapter(BaseInputAdapter base)
std::array< std::char_traits< char >::int_type, 4 > utf8_bytes
a buffer for UTF-8 bytes
typename std::iterator_traits< iterator_type >::value_type char_type
static adapter_type create(IteratorType first, IteratorType last)
iterator_input_adapter< iterator_type > adapter_type
IteratorType iterator_type
typename std::iterator_traits< T >::value_type value_type
IteratorType iterator_type
static adapter_type create(IteratorType first, IteratorType last)
typename std::iterator_traits< iterator_type >::value_type char_type
contiguous_bytes_input_adapter && get()
span_input_adapter(CharT b, std::size_t l)
contiguous_bytes_input_adapter ia
span_input_adapter(IteratorType first, IteratorType last)
virtual bool start_object(std::size_t elements)=0
the beginning of an object was read
virtual bool string(string_t &val)=0
a string was read
virtual bool null()=0
a null value was read
typename BasicJsonType::number_integer_t number_integer_t
typename BasicJsonType::binary_t binary_t
virtual bool end_array()=0
the end of an array was read
virtual bool key(string_t &val)=0
an object key was read
typename BasicJsonType::number_unsigned_t number_unsigned_t
virtual bool binary(binary_t &val)=0
a binary string was read
typename BasicJsonType::number_float_t number_float_t
virtual bool start_array(std::size_t elements)=0
the beginning of an array was read
virtual bool parse_error(std::size_t position, const std::string &last_token, const detail::exception &ex)=0
a parse error occurred
virtual bool boolean(bool val)=0
a boolean value was read
virtual bool end_object()=0
the end of an object was read
virtual bool number_unsigned(number_unsigned_t val)=0
an unsigned integer number was read
typename BasicJsonType::string_t string_t
virtual bool number_float(number_float_t val, const string_t &s)=0
an floating-point number was read
virtual ~json_sax()=default
virtual bool number_integer(number_integer_t val)=0
an integer number was read
SAX implementation to create a JSON value from SAX events.
bool start_array(std::size_t len)
json_sax_dom_parser(const json_sax_dom_parser &)=delete
typename BasicJsonType::binary_t binary_t
json_sax_dom_parser & operator=(json_sax_dom_parser &&)=default
bool number_unsigned(number_unsigned_t val)
bool errored
whether a syntax error occurred
typename BasicJsonType::number_integer_t number_integer_t
~json_sax_dom_parser()=default
bool parse_error(std::size_t, const std::string &, const Exception &ex)
JSON_HEDLEY_RETURNS_NON_NULL BasicJsonType * handle_value(Value &&v)
bool string(string_t &val)
typename BasicJsonType::number_unsigned_t number_unsigned_t
bool start_object(std::size_t len)
BasicJsonType * object_element
helper to hold the reference for the next object element
std::vector< BasicJsonType * > ref_stack
stack to model hierarchy of values
bool binary(binary_t &val)
const bool allow_exceptions
whether to throw exceptions in case of errors
constexpr bool is_errored() const
json_sax_dom_parser(json_sax_dom_parser &&)=default
typename BasicJsonType::number_float_t number_float_t
json_sax_dom_parser & operator=(const json_sax_dom_parser &)=delete
BasicJsonType & root
the parsed JSON value
bool number_float(number_float_t val, const string_t &)
json_sax_dom_parser(BasicJsonType &r, const bool allow_exceptions_=true)
typename BasicJsonType::string_t string_t
bool number_integer(number_integer_t val)
typename BasicJsonType::string_t string_t
json_sax_dom_callback_parser & operator=(const json_sax_dom_callback_parser &)=delete
bool start_object(std::size_t len)
const bool allow_exceptions
whether to throw exceptions in case of errors
constexpr bool is_errored() const
typename BasicJsonType::number_unsigned_t number_unsigned_t
BasicJsonType * object_element
helper to hold the reference for the next object element
typename BasicJsonType::number_integer_t number_integer_t
std::pair< bool, BasicJsonType * > handle_value(Value &&v, const bool skip_callback=false)
const parser_callback_t callback
callback function
typename BasicJsonType::parser_callback_t parser_callback_t
bool start_array(std::size_t len)
~json_sax_dom_callback_parser()=default
json_sax_dom_callback_parser(const json_sax_dom_callback_parser &)=delete
typename BasicJsonType::binary_t binary_t
bool binary(binary_t &val)
bool number_integer(number_integer_t val)
BasicJsonType & root
the parsed JSON value
std::vector< BasicJsonType * > ref_stack
stack to model hierarchy of values
BasicJsonType discarded
a discarded value for the callback
std::vector< bool > key_keep_stack
stack to manage which object keys to keep
typename BasicJsonType::number_float_t number_float_t
typename BasicJsonType::parse_event_t parse_event_t
bool errored
whether a syntax error occurred
std::vector< bool > keep_stack
stack to manage which values to keep
bool number_unsigned(number_unsigned_t val)
json_sax_dom_callback_parser & operator=(json_sax_dom_callback_parser &&)=default
bool string(string_t &val)
bool number_float(number_float_t val, const string_t &)
json_sax_dom_callback_parser(json_sax_dom_callback_parser &&)=default
bool parse_error(std::size_t, const std::string &, const Exception &ex)
json_sax_dom_callback_parser(BasicJsonType &r, const parser_callback_t cb, const bool allow_exceptions_=true)
typename BasicJsonType::string_t string_t
typename BasicJsonType::number_integer_t number_integer_t
typename BasicJsonType::number_float_t number_float_t
typename BasicJsonType::binary_t binary_t
bool start_object(std::size_t=std::size_t(-1))
bool start_array(std::size_t=std::size_t(-1))
bool parse_error(std::size_t, const std::string &, const detail::exception &)
bool number_integer(number_integer_t)
bool number_unsigned(number_unsigned_t)
typename BasicJsonType::number_unsigned_t number_unsigned_t
bool number_float(number_float_t, const string_t &)
JSON_HEDLEY_RETURNS_NON_NULL static JSON_HEDLEY_CONST const char * token_type_name(const token_type t) noexcept
return name of values of type token_type (only used for errors)
token_type
token types for the parser
@ value_float
an floating point number – use get_number_float() for actual value
@ begin_array
the character for array begin [
@ value_string
a string – use get_string() for actual value
@ end_array
the character for array end ]
@ uninitialized
indicating the scanner is uninitialized
@ parse_error
indicating a parse error
@ value_integer
a signed integer – use get_number_integer() for actual value
@ value_separator
the value separator ,
@ end_object
the character for object end }
@ literal_true
the true literal
@ begin_object
the character for object begin {
@ value_unsigned
an unsigned integer – use get_number_unsigned() for actual value
@ literal_null
the null literal
@ end_of_input
indicating the end of the input buffer
@ name_separator
the name separator :
@ literal_or_value
a literal or the begin of a value (only for diagnostics)
@ literal_false
the false literal
string_t & get_string()
return current string value (implicitly resets the token; useful only once)
number_float_t value_float
const bool ignore_comments
whether comments should be ignored (true) or signaled as errors (false)
void add(char_int_type c)
add a character to token_buffer
void reset() noexcept
reset token_buffer; current character is beginning of token
bool next_unget
whether the next get() call should just return current
char_int_type current
the current character
typename BasicJsonType::number_float_t number_float_t
typename std::char_traits< char_type >::int_type char_int_type
static JSON_HEDLEY_PURE char get_decimal_point() noexcept
return the locale-dependent decimal point
number_integer_t value_integer
InputAdapterType ia
input adapter
lexer(InputAdapterType &&adapter, bool ignore_comments_=false)
typename BasicJsonType::number_integer_t number_integer_t
lexer & operator=(lexer &&)=default
static void strtof(float &f, const char *str, char **endptr) noexcept
const char_int_type decimal_point_char
the decimal point
bool skip_bom()
skip the UTF-8 byte order mark
const char * error_message
a description of occurred lexer errors
position_t position
the start position of the current token
constexpr position_t get_position() const noexcept
return position of last read token
std::vector< char_type > token_string
raw input token string (for error messages)
constexpr number_integer_t get_number_integer() const noexcept
return integer value
typename lexer_base< BasicJsonType >::token_type token_type
typename InputAdapterType::char_type char_type
token_type scan_number()
scan a number literal
lexer & operator=(lexer &)=delete
void unget()
unget current character (read it again on next get)
token_type scan_string()
scan a string literal
lexer(const lexer &)=delete
constexpr number_unsigned_t get_number_unsigned() const noexcept
return unsigned integer value
string_t token_buffer
buffer for variable-length tokens (numbers, strings)
token_type scan_literal(const char_type *literal_text, const std::size_t length, token_type return_type)
constexpr number_float_t get_number_float() const noexcept
return floating-point value
int get_codepoint()
get codepoint from 4 hex characters following \u
std::string get_token_string() const
return the last read token (for errors only). Will never contain EOF (an arbitrary value that is not ...
number_unsigned_t value_unsigned
typename BasicJsonType::number_unsigned_t number_unsigned_t
bool next_byte_in_range(std::initializer_list< char_int_type > ranges)
check if the next byte(s) are inside a given range
typename BasicJsonType::string_t string_t
bool scan_comment()
scan a comment
JSON_HEDLEY_RETURNS_NON_NULL constexpr const char * get_error_message() const noexcept
return syntax error message
typename BasicJsonType::number_float_t number_float_t
typename BasicJsonType::number_unsigned_t number_unsigned_t
typename BasicJsonType::exception exception_t
static constexpr bool value
typename BasicJsonType::number_integer_t number_integer_t
typename BasicJsonType::string_t string_t
typename BasicJsonType::binary_t binary_t
typename BasicJsonType::string_t string_t
typename BasicJsonType::exception exception_t
typename BasicJsonType::number_integer_t number_integer_t
typename BasicJsonType::number_float_t number_float_t
typename BasicJsonType::binary_t binary_t
typename BasicJsonType::number_unsigned_t number_unsigned_t
deserialization of CBOR, MessagePack, and UBJSON values
typename BasicJsonType::number_unsigned_t number_unsigned_t
bool get_msgpack_array(const std::size_t len)
binary_reader & operator=(const binary_reader &)=delete
bool get_bson_string(const NumberType len, string_t &result)
Parses a zero-terminated string of length len from the BSON input.
bool parse_bson_element_internal(const char_int_type element_type, const std::size_t element_type_parse_position)
Read a BSON document element of the given element_type.
bool parse_bson_array()
Reads an array from the BSON input and passes it to the SAX-parser.
char_int_type get_ignore_noop()
bool get_ubjson_high_precision_number()
typename BasicJsonType::number_integer_t number_integer_t
bool get_bson_cstr(string_t &result)
Parses a C-style string from the BSON input.
bool get_cbor_array(const std::size_t len, const cbor_tag_handler_t tag_handler)
bool get_msgpack_binary(binary_t &result)
reads a MessagePack byte array
bool get_cbor_object(const std::size_t len, const cbor_tag_handler_t tag_handler)
bool get_ubjson_string(string_t &result, const bool get_char=true)
reads a UBJSON string
bool parse_bson_element_list(const bool is_array)
Read a BSON element list (as specified in the BSON-spec)
bool parse_cbor_internal(const bool get_char, const cbor_tag_handler_t tag_handler)
bool get_string(const input_format_t format, const NumberType len, string_t &result)
create a string by reading characters from the input
bool get_cbor_string(string_t &result)
reads a CBOR string
InputAdapterType ia
input adapter
bool get_binary(const input_format_t format, const NumberType len, binary_t &result)
create a byte array by reading bytes from the input
bool parse_ubjson_internal(const bool get_char=true)
bool unexpect_eof(const input_format_t format, const char *context) const
binary_reader & operator=(binary_reader &&)=default
bool get_ubjson_size_type(std::pair< std::size_t, char_int_type > &result)
determine the type and size for a container
std::string get_token_string() const
bool get_ubjson_value(const char_int_type prefix)
typename BasicJsonType::string_t string_t
bool get_msgpack_object(const std::size_t len)
bool get_bson_binary(const NumberType len, binary_t &result)
Parses a byte array input of length len from the BSON input.
std::string exception_message(const input_format_t format, const std::string &detail, const std::string &context) const
std::size_t chars_read
the number of characters read
typename std::char_traits< char_type >::int_type char_int_type
binary_reader(const binary_reader &)=delete
char_int_type current
the current character
bool sax_parse(const input_format_t format, json_sax_t *sax_, const bool strict=true, const cbor_tag_handler_t tag_handler=cbor_tag_handler_t::error)
json_sax_t * sax
the SAX parser
bool get_ubjson_size_value(std::size_t &result)
typename InputAdapterType::char_type char_type
bool parse_bson_internal()
Reads in a BSON-object and passes it to the SAX-parser.
bool get_number(const input_format_t format, NumberType &result)
bool get_cbor_binary(binary_t &result)
reads a CBOR byte array
binary_reader(binary_reader &&)=default
typename BasicJsonType::binary_t binary_t
char_int_type get()
get next character from the input
const bool is_little_endian
whether we can assume little endianess
binary_reader(InputAdapterType &&adapter)
create a binary reader
bool get_msgpack_string(string_t &result)
reads a MessagePack string
bool parse_msgpack_internal()
typename BasicJsonType::number_float_t number_float_t
bool sax_parse(SAX *sax, const bool strict=true)
token_type get_token()
get next token from lexer
token_type last_token
the type of the last read token
parser(InputAdapterType &&adapter, const parser_callback_t< BasicJsonType > cb=nullptr, const bool allow_exceptions_=true, const bool skip_comments=false)
a parser reading from an input adapter
bool accept(const bool strict=true)
public accept interface
typename BasicJsonType::string_t string_t
typename BasicJsonType::number_unsigned_t number_unsigned_t
typename lexer_t::token_type token_type
lexer< BasicJsonType, InputAdapterType > lexer_t
bool sax_parse_internal(SAX *sax)
const parser_callback_t< BasicJsonType > callback
callback function
void parse(const bool strict, BasicJsonType &result)
public parser interface
std::string exception_message(const token_type expected, const std::string &context)
typename BasicJsonType::number_float_t number_float_t
const bool allow_exceptions
whether to throw exceptions in case of errors
typename BasicJsonType::number_integer_t number_integer_t
primitive_iterator_t operator+(difference_type n) noexcept
primitive_iterator_t & operator++() noexcept
difference_type m_it
iterator as signed integer type
constexpr bool is_end() const noexcept
return whether the iterator is at end
primitive_iterator_t & operator-=(difference_type n) noexcept
constexpr bool is_begin() const noexcept
return whether the iterator can be dereferenced
friend constexpr bool operator<(primitive_iterator_t lhs, primitive_iterator_t rhs) noexcept
void set_begin() noexcept
set iterator to a defined beginning
primitive_iterator_t const operator++(int) noexcept
static constexpr difference_type end_value
friend constexpr bool operator==(primitive_iterator_t lhs, primitive_iterator_t rhs) noexcept
friend constexpr difference_type operator-(primitive_iterator_t lhs, primitive_iterator_t rhs) noexcept
primitive_iterator_t & operator--() noexcept
void set_end() noexcept
set iterator to a defined past the end
constexpr difference_type get_value() const noexcept
primitive_iterator_t const operator--(int) noexcept
std::ptrdiff_t difference_type
primitive_iterator_t & operator+=(difference_type n) noexcept
static constexpr difference_type begin_value
a template for a bidirectional iterator for the basic_json class This class implements a both iterato...
bool operator<(const iter_impl &other) const
comparison: smaller
iter_impl operator-(difference_type i) const
subtract from iterator
iter_impl()=default
default constructor
iter_impl const operator--(int)
post-decrement (it–)
void set_end() noexcept
set the iterator past the last value
bool operator==(const iter_impl &other) const
comparison: equal
typename BasicJsonType::difference_type difference_type
a type to represent differences between iterators
iter_impl & operator--()
pre-decrement (–it)
difference_type operator-(const iter_impl &other) const
return difference
iter_impl & operator=(const iter_impl< const BasicJsonType > &other) noexcept
converting assignment
typename std::conditional< std::is_const< BasicJsonType >::value, typename BasicJsonType::const_reference, typename BasicJsonType::reference >::type reference
defines a reference to the type iterated over (value_type)
reference operator*() const
return a reference to the value pointed to by the iterator
void set_begin() noexcept
set the iterator to the first value
bool operator>=(const iter_impl &other) const
comparison: greater than or equal
typename std::conditional< std::is_const< BasicJsonType >::value, typename BasicJsonType::const_pointer, typename BasicJsonType::pointer >::type pointer
defines a pointer to the type iterated over (value_type)
iter_impl & operator=(const iter_impl< typename std::remove_const< BasicJsonType >::type > &other) noexcept
converting assignment
pointer operator->() const
dereference the iterator
iter_impl(const iter_impl< const BasicJsonType > &other) noexcept
const copy constructor
iter_impl const operator++(int)
post-increment (it++)
iter_impl(const iter_impl< typename std::remove_const< BasicJsonType >::type > &other) noexcept
converting constructor
iter_impl(pointer object) noexcept
constructor for a given JSON instance
internal_iterator< typename std::remove_const< BasicJsonType >::type > m_it
the actual iterator of the associated instance
iter_impl operator+(difference_type i) const
add to iterator
friend iter_impl operator+(difference_type i, const iter_impl &it)
addition of distance and iterator
const object_t::key_type & key() const
return the key of an object iterator
bool operator>(const iter_impl &other) const
comparison: greater than
typename BasicJsonType::value_type value_type
the type of the values when the iterator is dereferenced
reference value() const
return the value of an iterator
typename BasicJsonType::object_t object_t
iter_impl & operator++()
pre-increment (++it)
reference operator[](difference_type n) const
access to successor
bool operator<=(const iter_impl &other) const
comparison: less than or equal
pointer m_object
associated JSON instance
std::bidirectional_iterator_tag iterator_category
The std::iterator class template (used as a base class to provide typedefs) is deprecated in C++17....
iter_impl & operator+=(difference_type i)
add to iterator
bool operator!=(const iter_impl &other) const
comparison: not equal
typename BasicJsonType::array_t array_t
iter_impl & operator-=(difference_type i)
subtract from iterator
a template for a reverse iterator class
json_reverse_iterator(const typename base_iterator::iterator_type &it) noexcept
create reverse iterator from iterator
json_reverse_iterator const operator--(int)
post-decrement (it–)
typename Base::reference reference
the reference type for the pointed-to element
json_reverse_iterator operator-(difference_type i) const
subtract from iterator
json_reverse_iterator & operator+=(difference_type i)
add to iterator
std::reverse_iterator< Base > base_iterator
shortcut to the reverse iterator adapter
json_reverse_iterator(const base_iterator &it) noexcept
create reverse iterator from base class
reference operator[](difference_type n) const
access to successor
std::ptrdiff_t difference_type
difference_type operator-(const json_reverse_iterator &other) const
return difference
json_reverse_iterator operator+(difference_type i) const
add to iterator
json_reverse_iterator const operator++(int)
post-increment (it++)
auto key() const -> decltype(std::declval< Base >().key())
return the key of an object iterator
json_reverse_iterator & operator--()
pre-decrement (–it)
reference value() const
return the value of an iterator
json_reverse_iterator & operator++()
pre-increment (++it)
abstract output adapter interface
virtual void write_characters(const CharType *s, std::size_t length)=0
virtual void write_character(CharType c)=0
virtual ~output_adapter_protocol()=default
output adapter for byte vectors
std::vector< CharType > & v
output_vector_adapter(std::vector< CharType > &vec) noexcept
void write_character(CharType c) override
output adapter for output streams
void write_character(CharType c) override
std::basic_ostream< CharType > & stream
output_stream_adapter(std::basic_ostream< CharType > &s) noexcept
output adapter for basic_string
void write_character(CharType c) override
output_string_adapter(StringType &s) noexcept
output_adapter(std::vector< CharType > &vec)
output_adapter(std::basic_ostream< CharType > &s)
output_adapter(StringType &s)
serialization to CBOR and MessagePack values
void write_bson_array(const string_t &name, const typename BasicJsonType::array_t &value)
Writes a BSON element with key name and array value.
const bool is_little_endian
whether we can assume little endianess
void write_number_with_ubjson_prefix(const NumberType n, const bool add_prefix)
void write_ubjson(const BasicJsonType &j, const bool use_count, const bool use_type, const bool add_prefix=true)
static constexpr CharType get_ubjson_float_prefix(double)
void write_bson_entry_header(const string_t &name, const std::uint8_t element_type)
Writes the given element_type and name to the output adapter.
static std::size_t calc_bson_element_size(const string_t &name, const BasicJsonType &j)
Calculates the size necessary to serialize the JSON value j with its name.
void write_bson_double(const string_t &name, const double value)
Writes a BSON element with key name and double value value.
void write_bson_object(const typename BasicJsonType::object_t &value)
typename BasicJsonType::string_t string_t
static constexpr CharType get_cbor_float_prefix(float)
static constexpr CharType to_char_type(InputCharType x) noexcept
typename BasicJsonType::binary_t binary_t
binary_writer(output_adapter_t< CharType > adapter)
create a binary writer
static constexpr CharType get_msgpack_float_prefix(double)
CharType ubjson_prefix(const BasicJsonType &j) const noexcept
determine the type prefix of container values
void write_bson_integer(const string_t &name, const std::int64_t value)
Writes a BSON element with key name and integer value.
static std::size_t calc_bson_entry_header_size(const string_t &name)
void write_bson_unsigned(const string_t &name, const std::uint64_t value)
Writes a BSON element with key name and unsigned value.
static CharType to_char_type(std::uint8_t x) noexcept
void write_bson_string(const string_t &name, const string_t &value)
Writes a BSON element with key name and string value value.
void write_bson_object_entry(const string_t &name, const typename BasicJsonType::object_t &value)
Writes a BSON element with key name and object value.
static constexpr CharType get_ubjson_float_prefix(float)
void write_number(const NumberType n)
output_adapter_t< CharType > oa
the output
void write_bson_element(const string_t &name, const BasicJsonType &j)
Serializes the JSON value j to BSON and associates it with the key name.
void write_bson_binary(const string_t &name, const binary_t &value)
Writes a BSON element with key name and binary value value.
void write_bson_null(const string_t &name)
Writes a BSON element with key name and null value.
static std::size_t calc_bson_binary_size(const typename BasicJsonType::binary_t &value)
void write_bson(const BasicJsonType &j)
void write_cbor(const BasicJsonType &j)
static constexpr std::size_t calc_bson_unsigned_size(const std::uint64_t value) noexcept
static constexpr CharType to_char_type(std::uint8_t x) noexcept
typename BasicJsonType::number_float_t number_float_t
static std::size_t calc_bson_object_size(const typename BasicJsonType::object_t &value)
Calculates the size of the BSON serialization of the given JSON-object j.
static constexpr CharType get_msgpack_float_prefix(float)
void write_bson_boolean(const string_t &name, const bool value)
Writes a BSON element with key name and boolean value value.
void write_msgpack(const BasicJsonType &j)
void write_compact_float(const number_float_t n, detail::input_format_t format)
static std::size_t calc_bson_string_size(const string_t &value)
static std::size_t calc_bson_integer_size(const std::int64_t value)
static std::size_t calc_bson_array_size(const typename BasicJsonType::array_t &value)
static constexpr CharType get_cbor_float_prefix(double)
static constexpr int kPrecision
static diyfp normalize(diyfp x) noexcept
normalize x such that the significand is >= 2^(q-1)
static diyfp normalize_to(const diyfp &x, const int target_exponent) noexcept
normalize x such that the result has the exponent E
static diyfp mul(const diyfp &x, const diyfp &y) noexcept
returns x * y
constexpr diyfp(std::uint64_t f_, int e_) noexcept
static diyfp sub(const diyfp &x, const diyfp &y) noexcept
returns x - y
const error_handler_t error_handler
error_handler how to react on decoding errors
unsigned int count_digits(number_unsigned_t x) noexcept
count digits
typename BasicJsonType::number_unsigned_t number_unsigned_t
const std::lconv * loc
the locale
std::array< char, 64 > number_buffer
a (hopefully) large enough character buffer
static constexpr std::uint8_t UTF8_ACCEPT
void dump_float(number_float_t x, std::true_type)
serializer(serializer &&)=delete
serializer & operator=(serializer &&)=delete
const char decimal_point
the locale's decimal point character
void dump_float(number_float_t x, std::false_type)
number_unsigned_t remove_sign(number_unsigned_t x)
typename BasicJsonType::number_float_t number_float_t
void dump_float(number_float_t x)
dump a floating-point number
const char thousands_sep
the locale's thousand separator character
serializer & operator=(const serializer &)=delete
static constexpr std::uint8_t UTF8_REJECT
void dump_integer(NumberType x)
dump an integer
void dump(const BasicJsonType &val, const bool pretty_print, const bool ensure_ascii, const unsigned int indent_step, const unsigned int current_indent=0)
internal implementation of the serialization function
const char indent_char
the indentation character
std::array< char, 512 > string_buffer
string buffer
typename BasicJsonType::binary_t::value_type binary_char_t
static std::uint8_t decode(std::uint8_t &state, std::uint32_t &codep, const std::uint8_t byte) noexcept
check whether a string is UTF-8 encoded
serializer(output_adapter_t< char > s, const char ichar, error_handler_t error_handler_=error_handler_t::strict)
void dump_escaped(const string_t &s, const bool ensure_ascii)
dump escaped string
output_adapter_t< char > o
the output of the serializer
typename BasicJsonType::string_t string_t
serializer(const serializer &)=delete
typename BasicJsonType::number_integer_t number_integer_t
string_t indent_string
the indentation string
number_unsigned_t remove_sign(number_integer_t x) noexcept
json_value(array_t &&value)
constructor for rvalue arrays
number_integer_t number_integer
number (integer)
binary_t * binary
binary (stored with pointer to save storage)
json_value(number_integer_t v) noexcept
constructor for numbers (integer)
json_value(const array_t &value)
constructor for arrays
void destroy(value_t t) noexcept
object_t * object
object (stored with pointer to save storage)
json_value(binary_t &&value)
constructor for rvalue binary arrays (internal type)
number_float_t number_float
number (floating-point)
json_value(string_t &&value)
constructor for rvalue strings
number_unsigned_t number_unsigned
number (unsigned integer)
json_value(const object_t &value)
constructor for objects
json_value(const typename binary_t::container_type &value)
constructor for binary arrays
json_value(value_t t)
constructor for empty values of a given type
json_value(boolean_t v) noexcept
constructor for booleans
array_t * array
array (stored with pointer to save storage)
string_t * string
string (stored with pointer to save storage)
json_value(const binary_t &value)
constructor for binary arrays (internal type)
json_value(object_t &&value)
constructor for rvalue objects
json_value()=default
default constructor (for null values)
json_value(typename binary_t::container_type &&value)
constructor for rvalue binary arrays
json_value(const string_t &value)
constructor for strings
json_value(number_float_t v) noexcept
constructor for numbers (floating-point)
json_value(number_unsigned_t v) noexcept
constructor for numbers (unsigned)
std::size_t operator()(const nlohmann::json &j) const
return a hash value for a JSON object
bool operator()(nlohmann::detail::value_t lhs, nlohmann::detail::value_t rhs) const noexcept
compare two value_t enum values