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>
64 #include <type_traits>
65 #include <unordered_map>
96 constexpr
operator size_t()
const
122 #if !defined(JSON_HEDLEY_VERSION) || (JSON_HEDLEY_VERSION < 14)
123 #if defined(JSON_HEDLEY_VERSION)
124 #undef JSON_HEDLEY_VERSION
126 #define JSON_HEDLEY_VERSION 14
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) && !defined(__ICL)
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) && !defined(__ICL)
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) && !defined(__ICL)
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(JSON_HEDLEY_MSVC_VERSION)
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) && !defined(__ICL)
224 #define JSON_HEDLEY_INTEL_VERSION JSON_HEDLEY_VERSION_ENCODE(__INTEL_COMPILER / 100, __INTEL_COMPILER % 100, __INTEL_COMPILER_UPDATE)
225 #elif defined(__INTEL_COMPILER) && !defined(__ICL)
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_INTEL_CL_VERSION)
239 #undef JSON_HEDLEY_INTEL_CL_VERSION
241 #if defined(__INTEL_COMPILER) && defined(__INTEL_COMPILER_UPDATE) && defined(__ICL)
242 #define JSON_HEDLEY_INTEL_CL_VERSION JSON_HEDLEY_VERSION_ENCODE(__INTEL_COMPILER, __INTEL_COMPILER_UPDATE, 0)
245 #if defined(JSON_HEDLEY_INTEL_CL_VERSION_CHECK)
246 #undef JSON_HEDLEY_INTEL_CL_VERSION_CHECK
248 #if defined(JSON_HEDLEY_INTEL_CL_VERSION)
249 #define JSON_HEDLEY_INTEL_CL_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_INTEL_CL_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
251 #define JSON_HEDLEY_INTEL_CL_VERSION_CHECK(major,minor,patch) (0)
254 #if defined(JSON_HEDLEY_PGI_VERSION)
255 #undef JSON_HEDLEY_PGI_VERSION
257 #if defined(__PGI) && defined(__PGIC__) && defined(__PGIC_MINOR__) && defined(__PGIC_PATCHLEVEL__)
258 #define JSON_HEDLEY_PGI_VERSION JSON_HEDLEY_VERSION_ENCODE(__PGIC__, __PGIC_MINOR__, __PGIC_PATCHLEVEL__)
261 #if defined(JSON_HEDLEY_PGI_VERSION_CHECK)
262 #undef JSON_HEDLEY_PGI_VERSION_CHECK
264 #if defined(JSON_HEDLEY_PGI_VERSION)
265 #define JSON_HEDLEY_PGI_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_PGI_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
267 #define JSON_HEDLEY_PGI_VERSION_CHECK(major,minor,patch) (0)
270 #if defined(JSON_HEDLEY_SUNPRO_VERSION)
271 #undef JSON_HEDLEY_SUNPRO_VERSION
273 #if defined(__SUNPRO_C) && (__SUNPRO_C > 0x1000)
274 #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)
275 #elif defined(__SUNPRO_C)
276 #define JSON_HEDLEY_SUNPRO_VERSION JSON_HEDLEY_VERSION_ENCODE((__SUNPRO_C >> 8) & 0xf, (__SUNPRO_C >> 4) & 0xf, (__SUNPRO_C) & 0xf)
277 #elif defined(__SUNPRO_CC) && (__SUNPRO_CC > 0x1000)
278 #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)
279 #elif defined(__SUNPRO_CC)
280 #define JSON_HEDLEY_SUNPRO_VERSION JSON_HEDLEY_VERSION_ENCODE((__SUNPRO_CC >> 8) & 0xf, (__SUNPRO_CC >> 4) & 0xf, (__SUNPRO_CC) & 0xf)
283 #if defined(JSON_HEDLEY_SUNPRO_VERSION_CHECK)
284 #undef JSON_HEDLEY_SUNPRO_VERSION_CHECK
286 #if defined(JSON_HEDLEY_SUNPRO_VERSION)
287 #define JSON_HEDLEY_SUNPRO_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_SUNPRO_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
289 #define JSON_HEDLEY_SUNPRO_VERSION_CHECK(major,minor,patch) (0)
292 #if defined(JSON_HEDLEY_EMSCRIPTEN_VERSION)
293 #undef JSON_HEDLEY_EMSCRIPTEN_VERSION
295 #if defined(__EMSCRIPTEN__)
296 #define JSON_HEDLEY_EMSCRIPTEN_VERSION JSON_HEDLEY_VERSION_ENCODE(__EMSCRIPTEN_major__, __EMSCRIPTEN_minor__, __EMSCRIPTEN_tiny__)
299 #if defined(JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK)
300 #undef JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK
302 #if defined(JSON_HEDLEY_EMSCRIPTEN_VERSION)
303 #define JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_EMSCRIPTEN_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
305 #define JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK(major,minor,patch) (0)
308 #if defined(JSON_HEDLEY_ARM_VERSION)
309 #undef JSON_HEDLEY_ARM_VERSION
311 #if defined(__CC_ARM) && defined(__ARMCOMPILER_VERSION)
312 #define JSON_HEDLEY_ARM_VERSION JSON_HEDLEY_VERSION_ENCODE(__ARMCOMPILER_VERSION / 1000000, (__ARMCOMPILER_VERSION % 1000000) / 10000, (__ARMCOMPILER_VERSION % 10000) / 100)
313 #elif defined(__CC_ARM) && defined(__ARMCC_VERSION)
314 #define JSON_HEDLEY_ARM_VERSION JSON_HEDLEY_VERSION_ENCODE(__ARMCC_VERSION / 1000000, (__ARMCC_VERSION % 1000000) / 10000, (__ARMCC_VERSION % 10000) / 100)
317 #if defined(JSON_HEDLEY_ARM_VERSION_CHECK)
318 #undef JSON_HEDLEY_ARM_VERSION_CHECK
320 #if defined(JSON_HEDLEY_ARM_VERSION)
321 #define JSON_HEDLEY_ARM_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_ARM_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
323 #define JSON_HEDLEY_ARM_VERSION_CHECK(major,minor,patch) (0)
326 #if defined(JSON_HEDLEY_IBM_VERSION)
327 #undef JSON_HEDLEY_IBM_VERSION
329 #if defined(__ibmxl__)
330 #define JSON_HEDLEY_IBM_VERSION JSON_HEDLEY_VERSION_ENCODE(__ibmxl_version__, __ibmxl_release__, __ibmxl_modification__)
331 #elif defined(__xlC__) && defined(__xlC_ver__)
332 #define JSON_HEDLEY_IBM_VERSION JSON_HEDLEY_VERSION_ENCODE(__xlC__ >> 8, __xlC__ & 0xff, (__xlC_ver__ >> 8) & 0xff)
333 #elif defined(__xlC__)
334 #define JSON_HEDLEY_IBM_VERSION JSON_HEDLEY_VERSION_ENCODE(__xlC__ >> 8, __xlC__ & 0xff, 0)
337 #if defined(JSON_HEDLEY_IBM_VERSION_CHECK)
338 #undef JSON_HEDLEY_IBM_VERSION_CHECK
340 #if defined(JSON_HEDLEY_IBM_VERSION)
341 #define JSON_HEDLEY_IBM_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_IBM_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
343 #define JSON_HEDLEY_IBM_VERSION_CHECK(major,minor,patch) (0)
346 #if defined(JSON_HEDLEY_TI_VERSION)
347 #undef JSON_HEDLEY_TI_VERSION
350 defined(__TI_COMPILER_VERSION__) && \
352 defined(__TMS470__) || defined(__TI_ARM__) || \
353 defined(__MSP430__) || \
354 defined(__TMS320C2000__) \
356 #if (__TI_COMPILER_VERSION__ >= 16000000)
357 #define JSON_HEDLEY_TI_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000))
361 #if defined(JSON_HEDLEY_TI_VERSION_CHECK)
362 #undef JSON_HEDLEY_TI_VERSION_CHECK
364 #if defined(JSON_HEDLEY_TI_VERSION)
365 #define JSON_HEDLEY_TI_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
367 #define JSON_HEDLEY_TI_VERSION_CHECK(major,minor,patch) (0)
370 #if defined(JSON_HEDLEY_TI_CL2000_VERSION)
371 #undef JSON_HEDLEY_TI_CL2000_VERSION
373 #if defined(__TI_COMPILER_VERSION__) && defined(__TMS320C2000__)
374 #define JSON_HEDLEY_TI_CL2000_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000))
377 #if defined(JSON_HEDLEY_TI_CL2000_VERSION_CHECK)
378 #undef JSON_HEDLEY_TI_CL2000_VERSION_CHECK
380 #if defined(JSON_HEDLEY_TI_CL2000_VERSION)
381 #define JSON_HEDLEY_TI_CL2000_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_CL2000_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
383 #define JSON_HEDLEY_TI_CL2000_VERSION_CHECK(major,minor,patch) (0)
386 #if defined(JSON_HEDLEY_TI_CL430_VERSION)
387 #undef JSON_HEDLEY_TI_CL430_VERSION
389 #if defined(__TI_COMPILER_VERSION__) && defined(__MSP430__)
390 #define JSON_HEDLEY_TI_CL430_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000))
393 #if defined(JSON_HEDLEY_TI_CL430_VERSION_CHECK)
394 #undef JSON_HEDLEY_TI_CL430_VERSION_CHECK
396 #if defined(JSON_HEDLEY_TI_CL430_VERSION)
397 #define JSON_HEDLEY_TI_CL430_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_CL430_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
399 #define JSON_HEDLEY_TI_CL430_VERSION_CHECK(major,minor,patch) (0)
402 #if defined(JSON_HEDLEY_TI_ARMCL_VERSION)
403 #undef JSON_HEDLEY_TI_ARMCL_VERSION
405 #if defined(__TI_COMPILER_VERSION__) && (defined(__TMS470__) || defined(__TI_ARM__))
406 #define JSON_HEDLEY_TI_ARMCL_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000))
409 #if defined(JSON_HEDLEY_TI_ARMCL_VERSION_CHECK)
410 #undef JSON_HEDLEY_TI_ARMCL_VERSION_CHECK
412 #if defined(JSON_HEDLEY_TI_ARMCL_VERSION)
413 #define JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_ARMCL_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
415 #define JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(major,minor,patch) (0)
418 #if defined(JSON_HEDLEY_TI_CL6X_VERSION)
419 #undef JSON_HEDLEY_TI_CL6X_VERSION
421 #if defined(__TI_COMPILER_VERSION__) && defined(__TMS320C6X__)
422 #define JSON_HEDLEY_TI_CL6X_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000))
425 #if defined(JSON_HEDLEY_TI_CL6X_VERSION_CHECK)
426 #undef JSON_HEDLEY_TI_CL6X_VERSION_CHECK
428 #if defined(JSON_HEDLEY_TI_CL6X_VERSION)
429 #define JSON_HEDLEY_TI_CL6X_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_CL6X_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
431 #define JSON_HEDLEY_TI_CL6X_VERSION_CHECK(major,minor,patch) (0)
434 #if defined(JSON_HEDLEY_TI_CL7X_VERSION)
435 #undef JSON_HEDLEY_TI_CL7X_VERSION
437 #if defined(__TI_COMPILER_VERSION__) && defined(__C7000__)
438 #define JSON_HEDLEY_TI_CL7X_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000))
441 #if defined(JSON_HEDLEY_TI_CL7X_VERSION_CHECK)
442 #undef JSON_HEDLEY_TI_CL7X_VERSION_CHECK
444 #if defined(JSON_HEDLEY_TI_CL7X_VERSION)
445 #define JSON_HEDLEY_TI_CL7X_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_CL7X_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
447 #define JSON_HEDLEY_TI_CL7X_VERSION_CHECK(major,minor,patch) (0)
450 #if defined(JSON_HEDLEY_TI_CLPRU_VERSION)
451 #undef JSON_HEDLEY_TI_CLPRU_VERSION
453 #if defined(__TI_COMPILER_VERSION__) && defined(__PRU__)
454 #define JSON_HEDLEY_TI_CLPRU_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000))
457 #if defined(JSON_HEDLEY_TI_CLPRU_VERSION_CHECK)
458 #undef JSON_HEDLEY_TI_CLPRU_VERSION_CHECK
460 #if defined(JSON_HEDLEY_TI_CLPRU_VERSION)
461 #define JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_CLPRU_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
463 #define JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(major,minor,patch) (0)
466 #if defined(JSON_HEDLEY_CRAY_VERSION)
467 #undef JSON_HEDLEY_CRAY_VERSION
470 #if defined(_RELEASE_PATCHLEVEL)
471 #define JSON_HEDLEY_CRAY_VERSION JSON_HEDLEY_VERSION_ENCODE(_RELEASE_MAJOR, _RELEASE_MINOR, _RELEASE_PATCHLEVEL)
473 #define JSON_HEDLEY_CRAY_VERSION JSON_HEDLEY_VERSION_ENCODE(_RELEASE_MAJOR, _RELEASE_MINOR, 0)
477 #if defined(JSON_HEDLEY_CRAY_VERSION_CHECK)
478 #undef JSON_HEDLEY_CRAY_VERSION_CHECK
480 #if defined(JSON_HEDLEY_CRAY_VERSION)
481 #define JSON_HEDLEY_CRAY_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_CRAY_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
483 #define JSON_HEDLEY_CRAY_VERSION_CHECK(major,minor,patch) (0)
486 #if defined(JSON_HEDLEY_IAR_VERSION)
487 #undef JSON_HEDLEY_IAR_VERSION
489 #if defined(__IAR_SYSTEMS_ICC__)
491 #define JSON_HEDLEY_IAR_VERSION JSON_HEDLEY_VERSION_ENCODE((__VER__ / 1000000), ((__VER__ / 1000) % 1000), (__VER__ % 1000))
493 #define JSON_HEDLEY_IAR_VERSION JSON_HEDLEY_VERSION_ENCODE(VER / 100, __VER__ % 100, 0)
497 #if defined(JSON_HEDLEY_IAR_VERSION_CHECK)
498 #undef JSON_HEDLEY_IAR_VERSION_CHECK
500 #if defined(JSON_HEDLEY_IAR_VERSION)
501 #define JSON_HEDLEY_IAR_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_IAR_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
503 #define JSON_HEDLEY_IAR_VERSION_CHECK(major,minor,patch) (0)
506 #if defined(JSON_HEDLEY_TINYC_VERSION)
507 #undef JSON_HEDLEY_TINYC_VERSION
509 #if defined(__TINYC__)
510 #define JSON_HEDLEY_TINYC_VERSION JSON_HEDLEY_VERSION_ENCODE(__TINYC__ / 1000, (__TINYC__ / 100) % 10, __TINYC__ % 100)
513 #if defined(JSON_HEDLEY_TINYC_VERSION_CHECK)
514 #undef JSON_HEDLEY_TINYC_VERSION_CHECK
516 #if defined(JSON_HEDLEY_TINYC_VERSION)
517 #define JSON_HEDLEY_TINYC_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TINYC_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
519 #define JSON_HEDLEY_TINYC_VERSION_CHECK(major,minor,patch) (0)
522 #if defined(JSON_HEDLEY_DMC_VERSION)
523 #undef JSON_HEDLEY_DMC_VERSION
526 #define JSON_HEDLEY_DMC_VERSION JSON_HEDLEY_VERSION_ENCODE(__DMC__ >> 8, (__DMC__ >> 4) & 0xf, __DMC__ & 0xf)
529 #if defined(JSON_HEDLEY_DMC_VERSION_CHECK)
530 #undef JSON_HEDLEY_DMC_VERSION_CHECK
532 #if defined(JSON_HEDLEY_DMC_VERSION)
533 #define JSON_HEDLEY_DMC_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_DMC_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
535 #define JSON_HEDLEY_DMC_VERSION_CHECK(major,minor,patch) (0)
538 #if defined(JSON_HEDLEY_COMPCERT_VERSION)
539 #undef JSON_HEDLEY_COMPCERT_VERSION
541 #if defined(__COMPCERT_VERSION__)
542 #define JSON_HEDLEY_COMPCERT_VERSION JSON_HEDLEY_VERSION_ENCODE(__COMPCERT_VERSION__ / 10000, (__COMPCERT_VERSION__ / 100) % 100, __COMPCERT_VERSION__ % 100)
545 #if defined(JSON_HEDLEY_COMPCERT_VERSION_CHECK)
546 #undef JSON_HEDLEY_COMPCERT_VERSION_CHECK
548 #if defined(JSON_HEDLEY_COMPCERT_VERSION)
549 #define JSON_HEDLEY_COMPCERT_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_COMPCERT_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
551 #define JSON_HEDLEY_COMPCERT_VERSION_CHECK(major,minor,patch) (0)
554 #if defined(JSON_HEDLEY_PELLES_VERSION)
555 #undef JSON_HEDLEY_PELLES_VERSION
557 #if defined(__POCC__)
558 #define JSON_HEDLEY_PELLES_VERSION JSON_HEDLEY_VERSION_ENCODE(__POCC__ / 100, __POCC__ % 100, 0)
561 #if defined(JSON_HEDLEY_PELLES_VERSION_CHECK)
562 #undef JSON_HEDLEY_PELLES_VERSION_CHECK
564 #if defined(JSON_HEDLEY_PELLES_VERSION)
565 #define JSON_HEDLEY_PELLES_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_PELLES_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
567 #define JSON_HEDLEY_PELLES_VERSION_CHECK(major,minor,patch) (0)
570 #if defined(JSON_HEDLEY_GCC_VERSION)
571 #undef JSON_HEDLEY_GCC_VERSION
574 defined(JSON_HEDLEY_GNUC_VERSION) && \
575 !defined(__clang__) && \
576 !defined(JSON_HEDLEY_INTEL_VERSION) && \
577 !defined(JSON_HEDLEY_PGI_VERSION) && \
578 !defined(JSON_HEDLEY_ARM_VERSION) && \
579 !defined(JSON_HEDLEY_TI_VERSION) && \
580 !defined(JSON_HEDLEY_TI_ARMCL_VERSION) && \
581 !defined(JSON_HEDLEY_TI_CL430_VERSION) && \
582 !defined(JSON_HEDLEY_TI_CL2000_VERSION) && \
583 !defined(JSON_HEDLEY_TI_CL6X_VERSION) && \
584 !defined(JSON_HEDLEY_TI_CL7X_VERSION) && \
585 !defined(JSON_HEDLEY_TI_CLPRU_VERSION) && \
586 !defined(__COMPCERT__)
587 #define JSON_HEDLEY_GCC_VERSION JSON_HEDLEY_GNUC_VERSION
590 #if defined(JSON_HEDLEY_GCC_VERSION_CHECK)
591 #undef JSON_HEDLEY_GCC_VERSION_CHECK
593 #if defined(JSON_HEDLEY_GCC_VERSION)
594 #define JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_GCC_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
596 #define JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) (0)
599 #if defined(JSON_HEDLEY_HAS_ATTRIBUTE)
600 #undef JSON_HEDLEY_HAS_ATTRIBUTE
602 #if defined(__has_attribute)
603 #define JSON_HEDLEY_HAS_ATTRIBUTE(attribute) __has_attribute(attribute)
605 #define JSON_HEDLEY_HAS_ATTRIBUTE(attribute) (0)
608 #if defined(JSON_HEDLEY_GNUC_HAS_ATTRIBUTE)
609 #undef JSON_HEDLEY_GNUC_HAS_ATTRIBUTE
611 #if defined(__has_attribute)
612 #define JSON_HEDLEY_GNUC_HAS_ATTRIBUTE(attribute,major,minor,patch) __has_attribute(attribute)
614 #define JSON_HEDLEY_GNUC_HAS_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch)
617 #if defined(JSON_HEDLEY_GCC_HAS_ATTRIBUTE)
618 #undef JSON_HEDLEY_GCC_HAS_ATTRIBUTE
620 #if defined(__has_attribute)
621 #define JSON_HEDLEY_GCC_HAS_ATTRIBUTE(attribute,major,minor,patch) __has_attribute(attribute)
623 #define JSON_HEDLEY_GCC_HAS_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch)
626 #if defined(JSON_HEDLEY_HAS_CPP_ATTRIBUTE)
627 #undef JSON_HEDLEY_HAS_CPP_ATTRIBUTE
630 defined(__has_cpp_attribute) && \
631 defined(__cplusplus) && \
632 (!defined(JSON_HEDLEY_SUNPRO_VERSION) || JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,15,0))
633 #define JSON_HEDLEY_HAS_CPP_ATTRIBUTE(attribute) __has_cpp_attribute(attribute)
635 #define JSON_HEDLEY_HAS_CPP_ATTRIBUTE(attribute) (0)
638 #if defined(JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS)
639 #undef JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS
641 #if !defined(__cplusplus) || !defined(__has_cpp_attribute)
642 #define JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS(ns,attribute) (0)
644 !defined(JSON_HEDLEY_PGI_VERSION) && \
645 !defined(JSON_HEDLEY_IAR_VERSION) && \
646 (!defined(JSON_HEDLEY_SUNPRO_VERSION) || JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,15,0)) && \
647 (!defined(JSON_HEDLEY_MSVC_VERSION) || JSON_HEDLEY_MSVC_VERSION_CHECK(19,20,0))
648 #define JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS(ns,attribute) JSON_HEDLEY_HAS_CPP_ATTRIBUTE(ns::attribute)
650 #define JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS(ns,attribute) (0)
653 #if defined(JSON_HEDLEY_GNUC_HAS_CPP_ATTRIBUTE)
654 #undef JSON_HEDLEY_GNUC_HAS_CPP_ATTRIBUTE
656 #if defined(__has_cpp_attribute) && defined(__cplusplus)
657 #define JSON_HEDLEY_GNUC_HAS_CPP_ATTRIBUTE(attribute,major,minor,patch) __has_cpp_attribute(attribute)
659 #define JSON_HEDLEY_GNUC_HAS_CPP_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch)
662 #if defined(JSON_HEDLEY_GCC_HAS_CPP_ATTRIBUTE)
663 #undef JSON_HEDLEY_GCC_HAS_CPP_ATTRIBUTE
665 #if defined(__has_cpp_attribute) && defined(__cplusplus)
666 #define JSON_HEDLEY_GCC_HAS_CPP_ATTRIBUTE(attribute,major,minor,patch) __has_cpp_attribute(attribute)
668 #define JSON_HEDLEY_GCC_HAS_CPP_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch)
671 #if defined(JSON_HEDLEY_HAS_BUILTIN)
672 #undef JSON_HEDLEY_HAS_BUILTIN
674 #if defined(__has_builtin)
675 #define JSON_HEDLEY_HAS_BUILTIN(builtin) __has_builtin(builtin)
677 #define JSON_HEDLEY_HAS_BUILTIN(builtin) (0)
680 #if defined(JSON_HEDLEY_GNUC_HAS_BUILTIN)
681 #undef JSON_HEDLEY_GNUC_HAS_BUILTIN
683 #if defined(__has_builtin)
684 #define JSON_HEDLEY_GNUC_HAS_BUILTIN(builtin,major,minor,patch) __has_builtin(builtin)
686 #define JSON_HEDLEY_GNUC_HAS_BUILTIN(builtin,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch)
689 #if defined(JSON_HEDLEY_GCC_HAS_BUILTIN)
690 #undef JSON_HEDLEY_GCC_HAS_BUILTIN
692 #if defined(__has_builtin)
693 #define JSON_HEDLEY_GCC_HAS_BUILTIN(builtin,major,minor,patch) __has_builtin(builtin)
695 #define JSON_HEDLEY_GCC_HAS_BUILTIN(builtin,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch)
698 #if defined(JSON_HEDLEY_HAS_FEATURE)
699 #undef JSON_HEDLEY_HAS_FEATURE
701 #if defined(__has_feature)
702 #define JSON_HEDLEY_HAS_FEATURE(feature) __has_feature(feature)
704 #define JSON_HEDLEY_HAS_FEATURE(feature) (0)
707 #if defined(JSON_HEDLEY_GNUC_HAS_FEATURE)
708 #undef JSON_HEDLEY_GNUC_HAS_FEATURE
710 #if defined(__has_feature)
711 #define JSON_HEDLEY_GNUC_HAS_FEATURE(feature,major,minor,patch) __has_feature(feature)
713 #define JSON_HEDLEY_GNUC_HAS_FEATURE(feature,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch)
716 #if defined(JSON_HEDLEY_GCC_HAS_FEATURE)
717 #undef JSON_HEDLEY_GCC_HAS_FEATURE
719 #if defined(__has_feature)
720 #define JSON_HEDLEY_GCC_HAS_FEATURE(feature,major,minor,patch) __has_feature(feature)
722 #define JSON_HEDLEY_GCC_HAS_FEATURE(feature,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch)
725 #if defined(JSON_HEDLEY_HAS_EXTENSION)
726 #undef JSON_HEDLEY_HAS_EXTENSION
728 #if defined(__has_extension)
729 #define JSON_HEDLEY_HAS_EXTENSION(extension) __has_extension(extension)
731 #define JSON_HEDLEY_HAS_EXTENSION(extension) (0)
734 #if defined(JSON_HEDLEY_GNUC_HAS_EXTENSION)
735 #undef JSON_HEDLEY_GNUC_HAS_EXTENSION
737 #if defined(__has_extension)
738 #define JSON_HEDLEY_GNUC_HAS_EXTENSION(extension,major,minor,patch) __has_extension(extension)
740 #define JSON_HEDLEY_GNUC_HAS_EXTENSION(extension,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch)
743 #if defined(JSON_HEDLEY_GCC_HAS_EXTENSION)
744 #undef JSON_HEDLEY_GCC_HAS_EXTENSION
746 #if defined(__has_extension)
747 #define JSON_HEDLEY_GCC_HAS_EXTENSION(extension,major,minor,patch) __has_extension(extension)
749 #define JSON_HEDLEY_GCC_HAS_EXTENSION(extension,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch)
752 #if defined(JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE)
753 #undef JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE
755 #if defined(__has_declspec_attribute)
756 #define JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE(attribute) __has_declspec_attribute(attribute)
758 #define JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE(attribute) (0)
761 #if defined(JSON_HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE)
762 #undef JSON_HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE
764 #if defined(__has_declspec_attribute)
765 #define JSON_HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE(attribute,major,minor,patch) __has_declspec_attribute(attribute)
767 #define JSON_HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch)
770 #if defined(JSON_HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE)
771 #undef JSON_HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE
773 #if defined(__has_declspec_attribute)
774 #define JSON_HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE(attribute,major,minor,patch) __has_declspec_attribute(attribute)
776 #define JSON_HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch)
779 #if defined(JSON_HEDLEY_HAS_WARNING)
780 #undef JSON_HEDLEY_HAS_WARNING
782 #if defined(__has_warning)
783 #define JSON_HEDLEY_HAS_WARNING(warning) __has_warning(warning)
785 #define JSON_HEDLEY_HAS_WARNING(warning) (0)
788 #if defined(JSON_HEDLEY_GNUC_HAS_WARNING)
789 #undef JSON_HEDLEY_GNUC_HAS_WARNING
791 #if defined(__has_warning)
792 #define JSON_HEDLEY_GNUC_HAS_WARNING(warning,major,minor,patch) __has_warning(warning)
794 #define JSON_HEDLEY_GNUC_HAS_WARNING(warning,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch)
797 #if defined(JSON_HEDLEY_GCC_HAS_WARNING)
798 #undef JSON_HEDLEY_GCC_HAS_WARNING
800 #if defined(__has_warning)
801 #define JSON_HEDLEY_GCC_HAS_WARNING(warning,major,minor,patch) __has_warning(warning)
803 #define JSON_HEDLEY_GCC_HAS_WARNING(warning,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch)
807 (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)) || \
808 defined(__clang__) || \
809 JSON_HEDLEY_GCC_VERSION_CHECK(3,0,0) || \
810 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
811 JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) || \
812 JSON_HEDLEY_PGI_VERSION_CHECK(18,4,0) || \
813 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
814 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
815 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,7,0) || \
816 JSON_HEDLEY_TI_CL430_VERSION_CHECK(2,0,1) || \
817 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,1,0) || \
818 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,0,0) || \
819 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
820 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
821 JSON_HEDLEY_CRAY_VERSION_CHECK(5,0,0) || \
822 JSON_HEDLEY_TINYC_VERSION_CHECK(0,9,17) || \
823 JSON_HEDLEY_SUNPRO_VERSION_CHECK(8,0,0) || \
824 (JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) && defined(__C99_PRAGMA_OPERATOR))
825 #define JSON_HEDLEY_PRAGMA(value) _Pragma(#value)
826 #elif JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0)
827 #define JSON_HEDLEY_PRAGMA(value) __pragma(value)
829 #define JSON_HEDLEY_PRAGMA(value)
832 #if defined(JSON_HEDLEY_DIAGNOSTIC_PUSH)
833 #undef JSON_HEDLEY_DIAGNOSTIC_PUSH
835 #if defined(JSON_HEDLEY_DIAGNOSTIC_POP)
836 #undef JSON_HEDLEY_DIAGNOSTIC_POP
838 #if defined(__clang__)
839 #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("clang diagnostic push")
840 #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("clang diagnostic pop")
841 #elif JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0)
842 #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("warning(push)")
843 #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("warning(pop)")
844 #elif JSON_HEDLEY_GCC_VERSION_CHECK(4,6,0)
845 #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("GCC diagnostic push")
846 #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("GCC diagnostic pop")
848 JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0) || \
849 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
850 #define JSON_HEDLEY_DIAGNOSTIC_PUSH __pragma(warning(push))
851 #define JSON_HEDLEY_DIAGNOSTIC_POP __pragma(warning(pop))
852 #elif JSON_HEDLEY_ARM_VERSION_CHECK(5,6,0)
853 #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("push")
854 #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("pop")
856 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
857 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
858 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,4,0) || \
859 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,1,0) || \
860 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
861 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0)
862 #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("diag_push")
863 #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("diag_pop")
864 #elif JSON_HEDLEY_PELLES_VERSION_CHECK(2,90,0)
865 #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("warning(push)")
866 #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("warning(pop)")
868 #define JSON_HEDLEY_DIAGNOSTIC_PUSH
869 #define JSON_HEDLEY_DIAGNOSTIC_POP
874 #if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_)
875 #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_
877 #if defined(__cplusplus)
878 # if JSON_HEDLEY_HAS_WARNING("-Wc++98-compat")
879 # if JSON_HEDLEY_HAS_WARNING("-Wc++17-extensions")
880 # if JSON_HEDLEY_HAS_WARNING("-Wc++1z-extensions")
881 # define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(xpr) \
882 JSON_HEDLEY_DIAGNOSTIC_PUSH \
883 _Pragma("clang diagnostic ignored \"-Wc++98-compat\"") \
884 _Pragma("clang diagnostic ignored \"-Wc++17-extensions\"") \
885 _Pragma("clang diagnostic ignored \"-Wc++1z-extensions\"") \
887 JSON_HEDLEY_DIAGNOSTIC_POP
889 # define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(xpr) \
890 JSON_HEDLEY_DIAGNOSTIC_PUSH \
891 _Pragma("clang diagnostic ignored \"-Wc++98-compat\"") \
892 _Pragma("clang diagnostic ignored \"-Wc++17-extensions\"") \
894 JSON_HEDLEY_DIAGNOSTIC_POP
897 # define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(xpr) \
898 JSON_HEDLEY_DIAGNOSTIC_PUSH \
899 _Pragma("clang diagnostic ignored \"-Wc++98-compat\"") \
901 JSON_HEDLEY_DIAGNOSTIC_POP
905 #if !defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_)
906 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(x) x
909 #if defined(JSON_HEDLEY_CONST_CAST)
910 #undef JSON_HEDLEY_CONST_CAST
912 #if defined(__cplusplus)
913 # define JSON_HEDLEY_CONST_CAST(T, expr) (const_cast<T>(expr))
915 JSON_HEDLEY_HAS_WARNING("-Wcast-qual") || \
916 JSON_HEDLEY_GCC_VERSION_CHECK(4,6,0) || \
917 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0)
918 # define JSON_HEDLEY_CONST_CAST(T, expr) (__extension__ ({ \
919 JSON_HEDLEY_DIAGNOSTIC_PUSH \
920 JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL \
922 JSON_HEDLEY_DIAGNOSTIC_POP \
925 # define JSON_HEDLEY_CONST_CAST(T, expr) ((T) (expr))
928 #if defined(JSON_HEDLEY_REINTERPRET_CAST)
929 #undef JSON_HEDLEY_REINTERPRET_CAST
931 #if defined(__cplusplus)
932 #define JSON_HEDLEY_REINTERPRET_CAST(T, expr) (reinterpret_cast<T>(expr))
934 #define JSON_HEDLEY_REINTERPRET_CAST(T, expr) ((T) (expr))
937 #if defined(JSON_HEDLEY_STATIC_CAST)
938 #undef JSON_HEDLEY_STATIC_CAST
940 #if defined(__cplusplus)
941 #define JSON_HEDLEY_STATIC_CAST(T, expr) (static_cast<T>(expr))
943 #define JSON_HEDLEY_STATIC_CAST(T, expr) ((T) (expr))
946 #if defined(JSON_HEDLEY_CPP_CAST)
947 #undef JSON_HEDLEY_CPP_CAST
949 #if defined(__cplusplus)
950 # if JSON_HEDLEY_HAS_WARNING("-Wold-style-cast")
951 # define JSON_HEDLEY_CPP_CAST(T, expr) \
952 JSON_HEDLEY_DIAGNOSTIC_PUSH \
953 _Pragma("clang diagnostic ignored \"-Wold-style-cast\"") \
955 JSON_HEDLEY_DIAGNOSTIC_POP
956 # elif JSON_HEDLEY_IAR_VERSION_CHECK(8,3,0)
957 # define JSON_HEDLEY_CPP_CAST(T, expr) \
958 JSON_HEDLEY_DIAGNOSTIC_PUSH \
959 _Pragma("diag_suppress=Pe137") \
960 JSON_HEDLEY_DIAGNOSTIC_POP
962 # define JSON_HEDLEY_CPP_CAST(T, expr) ((T) (expr))
965 # define JSON_HEDLEY_CPP_CAST(T, expr) (expr)
968 #if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED)
969 #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED
971 #if JSON_HEDLEY_HAS_WARNING("-Wdeprecated-declarations")
972 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("clang diagnostic ignored \"-Wdeprecated-declarations\"")
973 #elif JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0)
974 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("warning(disable:1478 1786)")
975 #elif JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
976 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED __pragma(warning(disable:1478 1786))
977 #elif JSON_HEDLEY_PGI_VERSION_CHECK(20,7,0)
978 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress 1215,1216,1444,1445")
979 #elif JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0)
980 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress 1215,1444")
981 #elif JSON_HEDLEY_GCC_VERSION_CHECK(4,3,0)
982 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"")
983 #elif JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0)
984 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED __pragma(warning(disable:4996))
986 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
987 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
988 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
989 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
990 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
991 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
992 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
993 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
994 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
995 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
996 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0)
997 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress 1291,1718")
998 #elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,13,0) && !defined(__cplusplus)
999 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("error_messages(off,E_DEPRECATED_ATT,E_DEPRECATED_ATT_MESS)")
1000 #elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,13,0) && defined(__cplusplus)
1001 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("error_messages(off,symdeprecated,symdeprecated2)")
1002 #elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
1003 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress=Pe1444,Pe1215")
1004 #elif JSON_HEDLEY_PELLES_VERSION_CHECK(2,90,0)
1005 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("warn(disable:2241)")
1007 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED
1010 #if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS)
1011 #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS
1013 #if JSON_HEDLEY_HAS_WARNING("-Wunknown-pragmas")
1014 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("clang diagnostic ignored \"-Wunknown-pragmas\"")
1015 #elif JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0)
1016 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("warning(disable:161)")
1017 #elif JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1018 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS __pragma(warning(disable:161))
1019 #elif JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0)
1020 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress 1675")
1021 #elif JSON_HEDLEY_GCC_VERSION_CHECK(4,3,0)
1022 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("GCC diagnostic ignored \"-Wunknown-pragmas\"")
1023 #elif JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0)
1024 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS __pragma(warning(disable:4068))
1026 JSON_HEDLEY_TI_VERSION_CHECK(16,9,0) || \
1027 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,0,0) || \
1028 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1029 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,3,0)
1030 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress 163")
1031 #elif JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,0,0)
1032 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress 163")
1033 #elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
1034 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress=Pe161")
1036 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS
1039 #if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES)
1040 #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES
1042 #if JSON_HEDLEY_HAS_WARNING("-Wunknown-attributes")
1043 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("clang diagnostic ignored \"-Wunknown-attributes\"")
1044 #elif JSON_HEDLEY_GCC_VERSION_CHECK(4,6,0)
1045 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"")
1046 #elif JSON_HEDLEY_INTEL_VERSION_CHECK(17,0,0)
1047 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("warning(disable:1292)")
1048 #elif JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1049 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES __pragma(warning(disable:1292))
1050 #elif JSON_HEDLEY_MSVC_VERSION_CHECK(19,0,0)
1051 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES __pragma(warning(disable:5030))
1052 #elif JSON_HEDLEY_PGI_VERSION_CHECK(20,7,0)
1053 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress 1097,1098")
1054 #elif JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0)
1055 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress 1097")
1056 #elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,14,0) && defined(__cplusplus)
1057 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("error_messages(off,attrskipunsup)")
1059 JSON_HEDLEY_TI_VERSION_CHECK(18,1,0) || \
1060 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,3,0) || \
1061 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0)
1062 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress 1173")
1063 #elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
1064 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress=Pe1097")
1066 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES
1069 #if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL)
1070 #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL
1072 #if JSON_HEDLEY_HAS_WARNING("-Wcast-qual")
1073 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL _Pragma("clang diagnostic ignored \"-Wcast-qual\"")
1074 #elif JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0)
1075 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL _Pragma("warning(disable:2203 2331)")
1076 #elif JSON_HEDLEY_GCC_VERSION_CHECK(3,0,0)
1077 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL _Pragma("GCC diagnostic ignored \"-Wcast-qual\"")
1079 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL
1082 #if defined(JSON_HEDLEY_DEPRECATED)
1083 #undef JSON_HEDLEY_DEPRECATED
1085 #if defined(JSON_HEDLEY_DEPRECATED_FOR)
1086 #undef JSON_HEDLEY_DEPRECATED_FOR
1089 JSON_HEDLEY_MSVC_VERSION_CHECK(14,0,0) || \
1090 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1091 #define JSON_HEDLEY_DEPRECATED(since) __declspec(deprecated("Since " # since))
1092 #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) __declspec(deprecated("Since " #since "; use " #replacement))
1094 JSON_HEDLEY_HAS_EXTENSION(attribute_deprecated_with_message) || \
1095 JSON_HEDLEY_GCC_VERSION_CHECK(4,5,0) || \
1096 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1097 JSON_HEDLEY_ARM_VERSION_CHECK(5,6,0) || \
1098 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,13,0) || \
1099 JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) || \
1100 JSON_HEDLEY_TI_VERSION_CHECK(18,1,0) || \
1101 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(18,1,0) || \
1102 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,3,0) || \
1103 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1104 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,3,0)
1105 #define JSON_HEDLEY_DEPRECATED(since) __attribute__((__deprecated__("Since " #since)))
1106 #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) __attribute__((__deprecated__("Since " #since "; use " #replacement)))
1107 #elif defined(__cplusplus) && (__cplusplus >= 201402L)
1108 #define JSON_HEDLEY_DEPRECATED(since) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[deprecated("Since " #since)]])
1109 #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[deprecated("Since " #since "; use " #replacement)]])
1111 JSON_HEDLEY_HAS_ATTRIBUTE(deprecated) || \
1112 JSON_HEDLEY_GCC_VERSION_CHECK(3,1,0) || \
1113 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1114 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1115 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1116 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1117 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1118 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1119 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1120 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1121 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1122 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1123 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1124 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0)
1125 #define JSON_HEDLEY_DEPRECATED(since) __attribute__((__deprecated__))
1126 #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) __attribute__((__deprecated__))
1128 JSON_HEDLEY_MSVC_VERSION_CHECK(13,10,0) || \
1129 JSON_HEDLEY_PELLES_VERSION_CHECK(6,50,0) || \
1130 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1131 #define JSON_HEDLEY_DEPRECATED(since) __declspec(deprecated)
1132 #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) __declspec(deprecated)
1133 #elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
1134 #define JSON_HEDLEY_DEPRECATED(since) _Pragma("deprecated")
1135 #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) _Pragma("deprecated")
1137 #define JSON_HEDLEY_DEPRECATED(since)
1138 #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement)
1141 #if defined(JSON_HEDLEY_UNAVAILABLE)
1142 #undef JSON_HEDLEY_UNAVAILABLE
1145 JSON_HEDLEY_HAS_ATTRIBUTE(warning) || \
1146 JSON_HEDLEY_GCC_VERSION_CHECK(4,3,0) || \
1147 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0)
1148 #define JSON_HEDLEY_UNAVAILABLE(available_since) __attribute__((__warning__("Not available until " #available_since)))
1150 #define JSON_HEDLEY_UNAVAILABLE(available_since)
1153 #if defined(JSON_HEDLEY_WARN_UNUSED_RESULT)
1154 #undef JSON_HEDLEY_WARN_UNUSED_RESULT
1156 #if defined(JSON_HEDLEY_WARN_UNUSED_RESULT_MSG)
1157 #undef JSON_HEDLEY_WARN_UNUSED_RESULT_MSG
1160 JSON_HEDLEY_HAS_ATTRIBUTE(warn_unused_result) || \
1161 JSON_HEDLEY_GCC_VERSION_CHECK(3,4,0) || \
1162 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1163 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1164 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1165 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1166 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1167 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1168 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1169 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1170 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1171 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1172 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1173 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1174 (JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,15,0) && defined(__cplusplus)) || \
1175 JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0)
1176 #define JSON_HEDLEY_WARN_UNUSED_RESULT __attribute__((__warn_unused_result__))
1177 #define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg) __attribute__((__warn_unused_result__))
1178 #elif (JSON_HEDLEY_HAS_CPP_ATTRIBUTE(nodiscard) >= 201907L)
1179 #define JSON_HEDLEY_WARN_UNUSED_RESULT JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[nodiscard]])
1180 #define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[nodiscard(msg)]])
1181 #elif JSON_HEDLEY_HAS_CPP_ATTRIBUTE(nodiscard)
1182 #define JSON_HEDLEY_WARN_UNUSED_RESULT JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[nodiscard]])
1183 #define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[nodiscard]])
1184 #elif defined(_Check_return_)
1185 #define JSON_HEDLEY_WARN_UNUSED_RESULT _Check_return_
1186 #define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg) _Check_return_
1188 #define JSON_HEDLEY_WARN_UNUSED_RESULT
1189 #define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg)
1192 #if defined(JSON_HEDLEY_SENTINEL)
1193 #undef JSON_HEDLEY_SENTINEL
1196 JSON_HEDLEY_HAS_ATTRIBUTE(sentinel) || \
1197 JSON_HEDLEY_GCC_VERSION_CHECK(4,0,0) || \
1198 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1199 JSON_HEDLEY_ARM_VERSION_CHECK(5,4,0)
1200 #define JSON_HEDLEY_SENTINEL(position) __attribute__((__sentinel__(position)))
1202 #define JSON_HEDLEY_SENTINEL(position)
1205 #if defined(JSON_HEDLEY_NO_RETURN)
1206 #undef JSON_HEDLEY_NO_RETURN
1208 #if JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
1209 #define JSON_HEDLEY_NO_RETURN __noreturn
1210 #elif JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0)
1211 #define JSON_HEDLEY_NO_RETURN __attribute__((__noreturn__))
1212 #elif defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L
1213 #define JSON_HEDLEY_NO_RETURN _Noreturn
1214 #elif defined(__cplusplus) && (__cplusplus >= 201103L)
1215 #define JSON_HEDLEY_NO_RETURN JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[noreturn]])
1217 JSON_HEDLEY_HAS_ATTRIBUTE(noreturn) || \
1218 JSON_HEDLEY_GCC_VERSION_CHECK(3,2,0) || \
1219 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \
1220 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1221 JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
1222 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1223 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1224 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1225 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1226 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1227 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1228 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1229 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1230 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1231 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1232 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0)
1233 #define JSON_HEDLEY_NO_RETURN __attribute__((__noreturn__))
1234 #elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0)
1235 #define JSON_HEDLEY_NO_RETURN _Pragma("does_not_return")
1237 JSON_HEDLEY_MSVC_VERSION_CHECK(13,10,0) || \
1238 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1239 #define JSON_HEDLEY_NO_RETURN __declspec(noreturn)
1240 #elif JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6,0,0) && defined(__cplusplus)
1241 #define JSON_HEDLEY_NO_RETURN _Pragma("FUNC_NEVER_RETURNS;")
1242 #elif JSON_HEDLEY_COMPCERT_VERSION_CHECK(3,2,0)
1243 #define JSON_HEDLEY_NO_RETURN __attribute((noreturn))
1244 #elif JSON_HEDLEY_PELLES_VERSION_CHECK(9,0,0)
1245 #define JSON_HEDLEY_NO_RETURN __declspec(noreturn)
1247 #define JSON_HEDLEY_NO_RETURN
1250 #if defined(JSON_HEDLEY_NO_ESCAPE)
1251 #undef JSON_HEDLEY_NO_ESCAPE
1253 #if JSON_HEDLEY_HAS_ATTRIBUTE(noescape)
1254 #define JSON_HEDLEY_NO_ESCAPE __attribute__((__noescape__))
1256 #define JSON_HEDLEY_NO_ESCAPE
1259 #if defined(JSON_HEDLEY_UNREACHABLE)
1260 #undef JSON_HEDLEY_UNREACHABLE
1262 #if defined(JSON_HEDLEY_UNREACHABLE_RETURN)
1263 #undef JSON_HEDLEY_UNREACHABLE_RETURN
1265 #if defined(JSON_HEDLEY_ASSUME)
1266 #undef JSON_HEDLEY_ASSUME
1269 JSON_HEDLEY_MSVC_VERSION_CHECK(13,10,0) || \
1270 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1271 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1272 #define JSON_HEDLEY_ASSUME(expr) __assume(expr)
1273 #elif JSON_HEDLEY_HAS_BUILTIN(__builtin_assume)
1274 #define JSON_HEDLEY_ASSUME(expr) __builtin_assume(expr)
1276 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,2,0) || \
1277 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(4,0,0)
1278 #if defined(__cplusplus)
1279 #define JSON_HEDLEY_ASSUME(expr) std::_nassert(expr)
1281 #define JSON_HEDLEY_ASSUME(expr) _nassert(expr)
1285 (JSON_HEDLEY_HAS_BUILTIN(__builtin_unreachable) && (!defined(JSON_HEDLEY_ARM_VERSION))) || \
1286 JSON_HEDLEY_GCC_VERSION_CHECK(4,5,0) || \
1287 JSON_HEDLEY_PGI_VERSION_CHECK(18,10,0) || \
1288 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1289 JSON_HEDLEY_IBM_VERSION_CHECK(13,1,5)
1290 #define JSON_HEDLEY_UNREACHABLE() __builtin_unreachable()
1291 #elif defined(JSON_HEDLEY_ASSUME)
1292 #define JSON_HEDLEY_UNREACHABLE() JSON_HEDLEY_ASSUME(0)
1294 #if !defined(JSON_HEDLEY_ASSUME)
1295 #if defined(JSON_HEDLEY_UNREACHABLE)
1296 #define JSON_HEDLEY_ASSUME(expr) JSON_HEDLEY_STATIC_CAST(void, ((expr) ? 1 : (JSON_HEDLEY_UNREACHABLE(), 1)))
1298 #define JSON_HEDLEY_ASSUME(expr) JSON_HEDLEY_STATIC_CAST(void, expr)
1301 #if defined(JSON_HEDLEY_UNREACHABLE)
1303 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,2,0) || \
1304 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(4,0,0)
1305 #define JSON_HEDLEY_UNREACHABLE_RETURN(value) return (JSON_HEDLEY_STATIC_CAST(void, JSON_HEDLEY_ASSUME(0)), (value))
1307 #define JSON_HEDLEY_UNREACHABLE_RETURN(value) JSON_HEDLEY_UNREACHABLE()
1310 #define JSON_HEDLEY_UNREACHABLE_RETURN(value) return (value)
1312 #if !defined(JSON_HEDLEY_UNREACHABLE)
1313 #define JSON_HEDLEY_UNREACHABLE() JSON_HEDLEY_ASSUME(0)
1316 JSON_HEDLEY_DIAGNOSTIC_PUSH
1317 #if JSON_HEDLEY_HAS_WARNING("-Wpedantic")
1318 #pragma clang diagnostic ignored "-Wpedantic"
1320 #if JSON_HEDLEY_HAS_WARNING("-Wc++98-compat-pedantic") && defined(__cplusplus)
1321 #pragma clang diagnostic ignored "-Wc++98-compat-pedantic"
1323 #if JSON_HEDLEY_GCC_HAS_WARNING("-Wvariadic-macros",4,0,0)
1324 #if defined(__clang__)
1325 #pragma clang diagnostic ignored "-Wvariadic-macros"
1326 #elif defined(JSON_HEDLEY_GCC_VERSION)
1327 #pragma GCC diagnostic ignored "-Wvariadic-macros"
1330 #if defined(JSON_HEDLEY_NON_NULL)
1331 #undef JSON_HEDLEY_NON_NULL
1334 JSON_HEDLEY_HAS_ATTRIBUTE(nonnull) || \
1335 JSON_HEDLEY_GCC_VERSION_CHECK(3,3,0) || \
1336 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1337 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0)
1338 #define JSON_HEDLEY_NON_NULL(...) __attribute__((__nonnull__(__VA_ARGS__)))
1340 #define JSON_HEDLEY_NON_NULL(...)
1342 JSON_HEDLEY_DIAGNOSTIC_POP
1344 #if defined(JSON_HEDLEY_PRINTF_FORMAT)
1345 #undef JSON_HEDLEY_PRINTF_FORMAT
1347 #if defined(__MINGW32__) && JSON_HEDLEY_GCC_HAS_ATTRIBUTE(format,4,4,0) && !defined(__USE_MINGW_ANSI_STDIO)
1348 #define JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) __attribute__((__format__(ms_printf, string_idx, first_to_check)))
1349 #elif defined(__MINGW32__) && JSON_HEDLEY_GCC_HAS_ATTRIBUTE(format,4,4,0) && defined(__USE_MINGW_ANSI_STDIO)
1350 #define JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) __attribute__((__format__(gnu_printf, string_idx, first_to_check)))
1352 JSON_HEDLEY_HAS_ATTRIBUTE(format) || \
1353 JSON_HEDLEY_GCC_VERSION_CHECK(3,1,0) || \
1354 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1355 JSON_HEDLEY_ARM_VERSION_CHECK(5,6,0) || \
1356 JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
1357 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1358 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1359 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1360 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1361 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1362 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1363 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1364 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1365 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1366 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1367 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0)
1368 #define JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) __attribute__((__format__(__printf__, string_idx, first_to_check)))
1369 #elif JSON_HEDLEY_PELLES_VERSION_CHECK(6,0,0)
1370 #define JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) __declspec(vaformat(printf,string_idx,first_to_check))
1372 #define JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check)
1375 #if defined(JSON_HEDLEY_CONSTEXPR)
1376 #undef JSON_HEDLEY_CONSTEXPR
1378 #if defined(__cplusplus)
1379 #if __cplusplus >= 201103L
1380 #define JSON_HEDLEY_CONSTEXPR JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(constexpr)
1383 #if !defined(JSON_HEDLEY_CONSTEXPR)
1384 #define JSON_HEDLEY_CONSTEXPR
1387 #if defined(JSON_HEDLEY_PREDICT)
1388 #undef JSON_HEDLEY_PREDICT
1390 #if defined(JSON_HEDLEY_LIKELY)
1391 #undef JSON_HEDLEY_LIKELY
1393 #if defined(JSON_HEDLEY_UNLIKELY)
1394 #undef JSON_HEDLEY_UNLIKELY
1396 #if defined(JSON_HEDLEY_UNPREDICTABLE)
1397 #undef JSON_HEDLEY_UNPREDICTABLE
1399 #if JSON_HEDLEY_HAS_BUILTIN(__builtin_unpredictable)
1400 #define JSON_HEDLEY_UNPREDICTABLE(expr) __builtin_unpredictable((expr))
1403 (JSON_HEDLEY_HAS_BUILTIN(__builtin_expect_with_probability) && !defined(JSON_HEDLEY_PGI_VERSION)) || \
1404 JSON_HEDLEY_GCC_VERSION_CHECK(9,0,0)
1405 # define JSON_HEDLEY_PREDICT(expr, value, probability) __builtin_expect_with_probability( (expr), (value), (probability))
1406 # define JSON_HEDLEY_PREDICT_TRUE(expr, probability) __builtin_expect_with_probability(!!(expr), 1 , (probability))
1407 # define JSON_HEDLEY_PREDICT_FALSE(expr, probability) __builtin_expect_with_probability(!!(expr), 0 , (probability))
1408 # define JSON_HEDLEY_LIKELY(expr) __builtin_expect (!!(expr), 1 )
1409 # define JSON_HEDLEY_UNLIKELY(expr) __builtin_expect (!!(expr), 0 )
1411 (JSON_HEDLEY_HAS_BUILTIN(__builtin_expect) && !defined(JSON_HEDLEY_INTEL_CL_VERSION)) || \
1412 JSON_HEDLEY_GCC_VERSION_CHECK(3,0,0) || \
1413 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1414 (JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,15,0) && defined(__cplusplus)) || \
1415 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1416 JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
1417 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1418 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,7,0) || \
1419 JSON_HEDLEY_TI_CL430_VERSION_CHECK(3,1,0) || \
1420 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,1,0) || \
1421 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6,1,0) || \
1422 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1423 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1424 JSON_HEDLEY_TINYC_VERSION_CHECK(0,9,27) || \
1425 JSON_HEDLEY_CRAY_VERSION_CHECK(8,1,0)
1426 # define JSON_HEDLEY_PREDICT(expr, expected, probability) \
1427 (((probability) >= 0.9) ? __builtin_expect((expr), (expected)) : (JSON_HEDLEY_STATIC_CAST(void, expected), (expr)))
1428 # define JSON_HEDLEY_PREDICT_TRUE(expr, probability) \
1430 double hedley_probability_ = (probability); \
1431 ((hedley_probability_ >= 0.9) ? __builtin_expect(!!(expr), 1) : ((hedley_probability_ <= 0.1) ? __builtin_expect(!!(expr), 0) : !!(expr))); \
1433 # define JSON_HEDLEY_PREDICT_FALSE(expr, probability) \
1435 double hedley_probability_ = (probability); \
1436 ((hedley_probability_ >= 0.9) ? __builtin_expect(!!(expr), 0) : ((hedley_probability_ <= 0.1) ? __builtin_expect(!!(expr), 1) : !!(expr))); \
1438 # define JSON_HEDLEY_LIKELY(expr) __builtin_expect(!!(expr), 1)
1439 # define JSON_HEDLEY_UNLIKELY(expr) __builtin_expect(!!(expr), 0)
1441 # define JSON_HEDLEY_PREDICT(expr, expected, probability) (JSON_HEDLEY_STATIC_CAST(void, expected), (expr))
1442 # define JSON_HEDLEY_PREDICT_TRUE(expr, probability) (!!(expr))
1443 # define JSON_HEDLEY_PREDICT_FALSE(expr, probability) (!!(expr))
1444 # define JSON_HEDLEY_LIKELY(expr) (!!(expr))
1445 # define JSON_HEDLEY_UNLIKELY(expr) (!!(expr))
1447 #if !defined(JSON_HEDLEY_UNPREDICTABLE)
1448 #define JSON_HEDLEY_UNPREDICTABLE(expr) JSON_HEDLEY_PREDICT(expr, 1, 0.5)
1451 #if defined(JSON_HEDLEY_MALLOC)
1452 #undef JSON_HEDLEY_MALLOC
1455 JSON_HEDLEY_HAS_ATTRIBUTE(malloc) || \
1456 JSON_HEDLEY_GCC_VERSION_CHECK(3,1,0) || \
1457 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1458 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \
1459 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1460 JSON_HEDLEY_IBM_VERSION_CHECK(12,1,0) || \
1461 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1462 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1463 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1464 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1465 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1466 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1467 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1468 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1469 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1470 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1471 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0)
1472 #define JSON_HEDLEY_MALLOC __attribute__((__malloc__))
1473 #elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0)
1474 #define JSON_HEDLEY_MALLOC _Pragma("returns_new_memory")
1476 JSON_HEDLEY_MSVC_VERSION_CHECK(14,0,0) || \
1477 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1478 #define JSON_HEDLEY_MALLOC __declspec(restrict)
1480 #define JSON_HEDLEY_MALLOC
1483 #if defined(JSON_HEDLEY_PURE)
1484 #undef JSON_HEDLEY_PURE
1487 JSON_HEDLEY_HAS_ATTRIBUTE(pure) || \
1488 JSON_HEDLEY_GCC_VERSION_CHECK(2,96,0) || \
1489 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1490 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \
1491 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1492 JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
1493 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1494 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1495 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1496 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1497 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1498 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1499 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1500 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1501 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1502 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1503 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1504 JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0)
1505 # define JSON_HEDLEY_PURE __attribute__((__pure__))
1506 #elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0)
1507 # define JSON_HEDLEY_PURE _Pragma("does_not_write_global_data")
1508 #elif defined(__cplusplus) && \
1510 JSON_HEDLEY_TI_CL430_VERSION_CHECK(2,0,1) || \
1511 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(4,0,0) || \
1512 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) \
1514 # define JSON_HEDLEY_PURE _Pragma("FUNC_IS_PURE;")
1516 # define JSON_HEDLEY_PURE
1519 #if defined(JSON_HEDLEY_CONST)
1520 #undef JSON_HEDLEY_CONST
1523 JSON_HEDLEY_HAS_ATTRIBUTE(const) || \
1524 JSON_HEDLEY_GCC_VERSION_CHECK(2,5,0) || \
1525 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1526 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \
1527 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1528 JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
1529 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1530 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1531 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1532 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1533 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1534 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1535 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1536 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1537 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1538 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1539 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1540 JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0)
1541 #define JSON_HEDLEY_CONST __attribute__((__const__))
1543 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0)
1544 #define JSON_HEDLEY_CONST _Pragma("no_side_effect")
1546 #define JSON_HEDLEY_CONST JSON_HEDLEY_PURE
1549 #if defined(JSON_HEDLEY_RESTRICT)
1550 #undef JSON_HEDLEY_RESTRICT
1552 #if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) && !defined(__cplusplus)
1553 #define JSON_HEDLEY_RESTRICT restrict
1555 JSON_HEDLEY_GCC_VERSION_CHECK(3,1,0) || \
1556 JSON_HEDLEY_MSVC_VERSION_CHECK(14,0,0) || \
1557 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1558 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) || \
1559 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1560 JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
1561 JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) || \
1562 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1563 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,2,4) || \
1564 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,1,0) || \
1565 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1566 (JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,14,0) && defined(__cplusplus)) || \
1567 JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) || \
1569 #define JSON_HEDLEY_RESTRICT __restrict
1570 #elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,3,0) && !defined(__cplusplus)
1571 #define JSON_HEDLEY_RESTRICT _Restrict
1573 #define JSON_HEDLEY_RESTRICT
1576 #if defined(JSON_HEDLEY_INLINE)
1577 #undef JSON_HEDLEY_INLINE
1580 (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)) || \
1581 (defined(__cplusplus) && (__cplusplus >= 199711L))
1582 #define JSON_HEDLEY_INLINE inline
1584 defined(JSON_HEDLEY_GCC_VERSION) || \
1585 JSON_HEDLEY_ARM_VERSION_CHECK(6,2,0)
1586 #define JSON_HEDLEY_INLINE __inline__
1588 JSON_HEDLEY_MSVC_VERSION_CHECK(12,0,0) || \
1589 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) || \
1590 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1591 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,1,0) || \
1592 JSON_HEDLEY_TI_CL430_VERSION_CHECK(3,1,0) || \
1593 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,2,0) || \
1594 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,0,0) || \
1595 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1596 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0)
1597 #define JSON_HEDLEY_INLINE __inline
1599 #define JSON_HEDLEY_INLINE
1602 #if defined(JSON_HEDLEY_ALWAYS_INLINE)
1603 #undef JSON_HEDLEY_ALWAYS_INLINE
1606 JSON_HEDLEY_HAS_ATTRIBUTE(always_inline) || \
1607 JSON_HEDLEY_GCC_VERSION_CHECK(4,0,0) || \
1608 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1609 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \
1610 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1611 JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
1612 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1613 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1614 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1615 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1616 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1617 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1618 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1619 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1620 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1621 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1622 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0)
1623 # define JSON_HEDLEY_ALWAYS_INLINE __attribute__((__always_inline__)) JSON_HEDLEY_INLINE
1625 JSON_HEDLEY_MSVC_VERSION_CHECK(12,0,0) || \
1626 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1627 # define JSON_HEDLEY_ALWAYS_INLINE __forceinline
1628 #elif defined(__cplusplus) && \
1630 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1631 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1632 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1633 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6,1,0) || \
1634 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1635 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) \
1637 # define JSON_HEDLEY_ALWAYS_INLINE _Pragma("FUNC_ALWAYS_INLINE;")
1638 #elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
1639 # define JSON_HEDLEY_ALWAYS_INLINE _Pragma("inline=forced")
1641 # define JSON_HEDLEY_ALWAYS_INLINE JSON_HEDLEY_INLINE
1644 #if defined(JSON_HEDLEY_NEVER_INLINE)
1645 #undef JSON_HEDLEY_NEVER_INLINE
1648 JSON_HEDLEY_HAS_ATTRIBUTE(noinline) || \
1649 JSON_HEDLEY_GCC_VERSION_CHECK(4,0,0) || \
1650 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1651 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \
1652 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1653 JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
1654 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1655 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1656 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1657 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1658 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1659 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1660 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1661 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1662 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1663 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1664 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0)
1665 #define JSON_HEDLEY_NEVER_INLINE __attribute__((__noinline__))
1667 JSON_HEDLEY_MSVC_VERSION_CHECK(13,10,0) || \
1668 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1669 #define JSON_HEDLEY_NEVER_INLINE __declspec(noinline)
1670 #elif JSON_HEDLEY_PGI_VERSION_CHECK(10,2,0)
1671 #define JSON_HEDLEY_NEVER_INLINE _Pragma("noinline")
1672 #elif JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6,0,0) && defined(__cplusplus)
1673 #define JSON_HEDLEY_NEVER_INLINE _Pragma("FUNC_CANNOT_INLINE;")
1674 #elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
1675 #define JSON_HEDLEY_NEVER_INLINE _Pragma("inline=never")
1676 #elif JSON_HEDLEY_COMPCERT_VERSION_CHECK(3,2,0)
1677 #define JSON_HEDLEY_NEVER_INLINE __attribute((noinline))
1678 #elif JSON_HEDLEY_PELLES_VERSION_CHECK(9,0,0)
1679 #define JSON_HEDLEY_NEVER_INLINE __declspec(noinline)
1681 #define JSON_HEDLEY_NEVER_INLINE
1684 #if defined(JSON_HEDLEY_PRIVATE)
1685 #undef JSON_HEDLEY_PRIVATE
1687 #if defined(JSON_HEDLEY_PUBLIC)
1688 #undef JSON_HEDLEY_PUBLIC
1690 #if defined(JSON_HEDLEY_IMPORT)
1691 #undef JSON_HEDLEY_IMPORT
1693 #if defined(_WIN32) || defined(__CYGWIN__)
1694 # define JSON_HEDLEY_PRIVATE
1695 # define JSON_HEDLEY_PUBLIC __declspec(dllexport)
1696 # define JSON_HEDLEY_IMPORT __declspec(dllimport)
1699 JSON_HEDLEY_HAS_ATTRIBUTE(visibility) || \
1700 JSON_HEDLEY_GCC_VERSION_CHECK(3,3,0) || \
1701 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \
1702 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1703 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1704 JSON_HEDLEY_IBM_VERSION_CHECK(13,1,0) || \
1706 defined(__TI_EABI__) && \
1708 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1709 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) \
1712 # define JSON_HEDLEY_PRIVATE __attribute__((__visibility__("hidden")))
1713 # define JSON_HEDLEY_PUBLIC __attribute__((__visibility__("default")))
1715 # define JSON_HEDLEY_PRIVATE
1716 # define JSON_HEDLEY_PUBLIC
1718 # define JSON_HEDLEY_IMPORT extern
1721 #if defined(JSON_HEDLEY_NO_THROW)
1722 #undef JSON_HEDLEY_NO_THROW
1725 JSON_HEDLEY_HAS_ATTRIBUTE(nothrow) || \
1726 JSON_HEDLEY_GCC_VERSION_CHECK(3,3,0) || \
1727 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0)
1728 #define JSON_HEDLEY_NO_THROW __attribute__((__nothrow__))
1730 JSON_HEDLEY_MSVC_VERSION_CHECK(13,1,0) || \
1731 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) || \
1732 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0)
1733 #define JSON_HEDLEY_NO_THROW __declspec(nothrow)
1735 #define JSON_HEDLEY_NO_THROW
1738 #if defined(JSON_HEDLEY_FALL_THROUGH)
1739 #undef JSON_HEDLEY_FALL_THROUGH
1742 JSON_HEDLEY_HAS_ATTRIBUTE(fallthrough) || \
1743 JSON_HEDLEY_GCC_VERSION_CHECK(7,0,0)
1744 #define JSON_HEDLEY_FALL_THROUGH __attribute__((__fallthrough__))
1745 #elif JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS(clang,fallthrough)
1746 #define JSON_HEDLEY_FALL_THROUGH JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[clang::fallthrough]])
1747 #elif JSON_HEDLEY_HAS_CPP_ATTRIBUTE(fallthrough)
1748 #define JSON_HEDLEY_FALL_THROUGH JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[fallthrough]])
1749 #elif defined(__fallthrough)
1750 #define JSON_HEDLEY_FALL_THROUGH __fallthrough
1752 #define JSON_HEDLEY_FALL_THROUGH
1755 #if defined(JSON_HEDLEY_RETURNS_NON_NULL)
1756 #undef JSON_HEDLEY_RETURNS_NON_NULL
1759 JSON_HEDLEY_HAS_ATTRIBUTE(returns_nonnull) || \
1760 JSON_HEDLEY_GCC_VERSION_CHECK(4,9,0)
1761 #define JSON_HEDLEY_RETURNS_NON_NULL __attribute__((__returns_nonnull__))
1762 #elif defined(_Ret_notnull_)
1763 #define JSON_HEDLEY_RETURNS_NON_NULL _Ret_notnull_
1765 #define JSON_HEDLEY_RETURNS_NON_NULL
1768 #if defined(JSON_HEDLEY_ARRAY_PARAM)
1769 #undef JSON_HEDLEY_ARRAY_PARAM
1772 defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) && \
1773 !defined(__STDC_NO_VLA__) && \
1774 !defined(__cplusplus) && \
1775 !defined(JSON_HEDLEY_PGI_VERSION) && \
1776 !defined(JSON_HEDLEY_TINYC_VERSION)
1777 #define JSON_HEDLEY_ARRAY_PARAM(name) (name)
1779 #define JSON_HEDLEY_ARRAY_PARAM(name)
1782 #if defined(JSON_HEDLEY_IS_CONSTANT)
1783 #undef JSON_HEDLEY_IS_CONSTANT
1785 #if defined(JSON_HEDLEY_REQUIRE_CONSTEXPR)
1786 #undef JSON_HEDLEY_REQUIRE_CONSTEXPR
1790 #if defined(JSON_HEDLEY_IS_CONSTEXPR_)
1791 #undef JSON_HEDLEY_IS_CONSTEXPR_
1794 JSON_HEDLEY_HAS_BUILTIN(__builtin_constant_p) || \
1795 JSON_HEDLEY_GCC_VERSION_CHECK(3,4,0) || \
1796 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1797 JSON_HEDLEY_TINYC_VERSION_CHECK(0,9,19) || \
1798 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1799 JSON_HEDLEY_IBM_VERSION_CHECK(13,1,0) || \
1800 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6,1,0) || \
1801 (JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0) && !defined(__cplusplus)) || \
1802 JSON_HEDLEY_CRAY_VERSION_CHECK(8,1,0)
1803 #define JSON_HEDLEY_IS_CONSTANT(expr) __builtin_constant_p(expr)
1805 #if !defined(__cplusplus)
1807 JSON_HEDLEY_HAS_BUILTIN(__builtin_types_compatible_p) || \
1808 JSON_HEDLEY_GCC_VERSION_CHECK(3,4,0) || \
1809 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1810 JSON_HEDLEY_IBM_VERSION_CHECK(13,1,0) || \
1811 JSON_HEDLEY_CRAY_VERSION_CHECK(8,1,0) || \
1812 JSON_HEDLEY_ARM_VERSION_CHECK(5,4,0) || \
1813 JSON_HEDLEY_TINYC_VERSION_CHECK(0,9,24)
1814 #if defined(__INTPTR_TYPE__)
1815 #define JSON_HEDLEY_IS_CONSTEXPR_(expr) __builtin_types_compatible_p(__typeof__((1 ? (void*) ((__INTPTR_TYPE__) ((expr) * 0)) : (int*) 0)), int*)
1818 #define JSON_HEDLEY_IS_CONSTEXPR_(expr) __builtin_types_compatible_p(__typeof__((1 ? (void*) ((intptr_t) ((expr) * 0)) : (int*) 0)), int*)
1822 defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L) && \
1823 !defined(JSON_HEDLEY_SUNPRO_VERSION) && \
1824 !defined(JSON_HEDLEY_PGI_VERSION) && \
1825 !defined(JSON_HEDLEY_IAR_VERSION)) || \
1826 JSON_HEDLEY_HAS_EXTENSION(c_generic_selections) || \
1827 JSON_HEDLEY_GCC_VERSION_CHECK(4,9,0) || \
1828 JSON_HEDLEY_INTEL_VERSION_CHECK(17,0,0) || \
1829 JSON_HEDLEY_IBM_VERSION_CHECK(12,1,0) || \
1830 JSON_HEDLEY_ARM_VERSION_CHECK(5,3,0)
1831 #if defined(__INTPTR_TYPE__)
1832 #define JSON_HEDLEY_IS_CONSTEXPR_(expr) _Generic((1 ? (void*) ((__INTPTR_TYPE__) ((expr) * 0)) : (int*) 0), int*: 1, void*: 0)
1835 #define JSON_HEDLEY_IS_CONSTEXPR_(expr) _Generic((1 ? (void*) ((intptr_t) * 0) : (int*) 0), int*: 1, void*: 0)
1838 defined(JSON_HEDLEY_GCC_VERSION) || \
1839 defined(JSON_HEDLEY_INTEL_VERSION) || \
1840 defined(JSON_HEDLEY_TINYC_VERSION) || \
1841 defined(JSON_HEDLEY_TI_ARMCL_VERSION) || \
1842 JSON_HEDLEY_TI_CL430_VERSION_CHECK(18,12,0) || \
1843 defined(JSON_HEDLEY_TI_CL2000_VERSION) || \
1844 defined(JSON_HEDLEY_TI_CL6X_VERSION) || \
1845 defined(JSON_HEDLEY_TI_CL7X_VERSION) || \
1846 defined(JSON_HEDLEY_TI_CLPRU_VERSION) || \
1848 # define JSON_HEDLEY_IS_CONSTEXPR_(expr) ( \
1852 ((void*) ((expr) * 0L) ) : \
1853 ((struct { char v[sizeof(void) * 2]; } *) 1) \
1859 #if defined(JSON_HEDLEY_IS_CONSTEXPR_)
1860 #if !defined(JSON_HEDLEY_IS_CONSTANT)
1861 #define JSON_HEDLEY_IS_CONSTANT(expr) JSON_HEDLEY_IS_CONSTEXPR_(expr)
1863 #define JSON_HEDLEY_REQUIRE_CONSTEXPR(expr) (JSON_HEDLEY_IS_CONSTEXPR_(expr) ? (expr) : (-1))
1865 #if !defined(JSON_HEDLEY_IS_CONSTANT)
1866 #define JSON_HEDLEY_IS_CONSTANT(expr) (0)
1868 #define JSON_HEDLEY_REQUIRE_CONSTEXPR(expr) (expr)
1871 #if defined(JSON_HEDLEY_BEGIN_C_DECLS)
1872 #undef JSON_HEDLEY_BEGIN_C_DECLS
1874 #if defined(JSON_HEDLEY_END_C_DECLS)
1875 #undef JSON_HEDLEY_END_C_DECLS
1877 #if defined(JSON_HEDLEY_C_DECL)
1878 #undef JSON_HEDLEY_C_DECL
1880 #if defined(__cplusplus)
1881 #define JSON_HEDLEY_BEGIN_C_DECLS extern "C" {
1882 #define JSON_HEDLEY_END_C_DECLS }
1883 #define JSON_HEDLEY_C_DECL extern "C"
1885 #define JSON_HEDLEY_BEGIN_C_DECLS
1886 #define JSON_HEDLEY_END_C_DECLS
1887 #define JSON_HEDLEY_C_DECL
1890 #if defined(JSON_HEDLEY_STATIC_ASSERT)
1891 #undef JSON_HEDLEY_STATIC_ASSERT
1894 !defined(__cplusplus) && ( \
1895 (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L)) || \
1896 (JSON_HEDLEY_HAS_FEATURE(c_static_assert) && !defined(JSON_HEDLEY_INTEL_CL_VERSION)) || \
1897 JSON_HEDLEY_GCC_VERSION_CHECK(6,0,0) || \
1898 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1899 defined(_Static_assert) \
1901 # define JSON_HEDLEY_STATIC_ASSERT(expr, message) _Static_assert(expr, message)
1903 (defined(__cplusplus) && (__cplusplus >= 201103L)) || \
1904 JSON_HEDLEY_MSVC_VERSION_CHECK(16,0,0) || \
1905 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1906 # define JSON_HEDLEY_STATIC_ASSERT(expr, message) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(static_assert(expr, message))
1908 # define JSON_HEDLEY_STATIC_ASSERT(expr, message)
1911 #if defined(JSON_HEDLEY_NULL)
1912 #undef JSON_HEDLEY_NULL
1914 #if defined(__cplusplus)
1915 #if __cplusplus >= 201103L
1916 #define JSON_HEDLEY_NULL JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(nullptr)
1918 #define JSON_HEDLEY_NULL NULL
1920 #define JSON_HEDLEY_NULL JSON_HEDLEY_STATIC_CAST(void*, 0)
1923 #define JSON_HEDLEY_NULL NULL
1925 #define JSON_HEDLEY_NULL ((void*) 0)
1928 #if defined(JSON_HEDLEY_MESSAGE)
1929 #undef JSON_HEDLEY_MESSAGE
1931 #if JSON_HEDLEY_HAS_WARNING("-Wunknown-pragmas")
1932 # define JSON_HEDLEY_MESSAGE(msg) \
1933 JSON_HEDLEY_DIAGNOSTIC_PUSH \
1934 JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS \
1935 JSON_HEDLEY_PRAGMA(message msg) \
1936 JSON_HEDLEY_DIAGNOSTIC_POP
1938 JSON_HEDLEY_GCC_VERSION_CHECK(4,4,0) || \
1939 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0)
1940 # define JSON_HEDLEY_MESSAGE(msg) JSON_HEDLEY_PRAGMA(message msg)
1941 #elif JSON_HEDLEY_CRAY_VERSION_CHECK(5,0,0)
1942 # define JSON_HEDLEY_MESSAGE(msg) JSON_HEDLEY_PRAGMA(_CRI message msg)
1943 #elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
1944 # define JSON_HEDLEY_MESSAGE(msg) JSON_HEDLEY_PRAGMA(message(msg))
1945 #elif JSON_HEDLEY_PELLES_VERSION_CHECK(2,0,0)
1946 # define JSON_HEDLEY_MESSAGE(msg) JSON_HEDLEY_PRAGMA(message(msg))
1948 # define JSON_HEDLEY_MESSAGE(msg)
1951 #if defined(JSON_HEDLEY_WARNING)
1952 #undef JSON_HEDLEY_WARNING
1954 #if JSON_HEDLEY_HAS_WARNING("-Wunknown-pragmas")
1955 # define JSON_HEDLEY_WARNING(msg) \
1956 JSON_HEDLEY_DIAGNOSTIC_PUSH \
1957 JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS \
1958 JSON_HEDLEY_PRAGMA(clang warning msg) \
1959 JSON_HEDLEY_DIAGNOSTIC_POP
1961 JSON_HEDLEY_GCC_VERSION_CHECK(4,8,0) || \
1962 JSON_HEDLEY_PGI_VERSION_CHECK(18,4,0) || \
1963 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0)
1964 # define JSON_HEDLEY_WARNING(msg) JSON_HEDLEY_PRAGMA(GCC warning msg)
1966 JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0) || \
1967 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1968 # define JSON_HEDLEY_WARNING(msg) JSON_HEDLEY_PRAGMA(message(msg))
1970 # define JSON_HEDLEY_WARNING(msg) JSON_HEDLEY_MESSAGE(msg)
1973 #if defined(JSON_HEDLEY_REQUIRE)
1974 #undef JSON_HEDLEY_REQUIRE
1976 #if defined(JSON_HEDLEY_REQUIRE_MSG)
1977 #undef JSON_HEDLEY_REQUIRE_MSG
1979 #if JSON_HEDLEY_HAS_ATTRIBUTE(diagnose_if)
1980 # if JSON_HEDLEY_HAS_WARNING("-Wgcc-compat")
1981 # define JSON_HEDLEY_REQUIRE(expr) \
1982 JSON_HEDLEY_DIAGNOSTIC_PUSH \
1983 _Pragma("clang diagnostic ignored \"-Wgcc-compat\"") \
1984 __attribute__((diagnose_if(!(expr), #expr, "error"))) \
1985 JSON_HEDLEY_DIAGNOSTIC_POP
1986 # define JSON_HEDLEY_REQUIRE_MSG(expr,msg) \
1987 JSON_HEDLEY_DIAGNOSTIC_PUSH \
1988 _Pragma("clang diagnostic ignored \"-Wgcc-compat\"") \
1989 __attribute__((diagnose_if(!(expr), msg, "error"))) \
1990 JSON_HEDLEY_DIAGNOSTIC_POP
1992 # define JSON_HEDLEY_REQUIRE(expr) __attribute__((diagnose_if(!(expr), #expr, "error")))
1993 # define JSON_HEDLEY_REQUIRE_MSG(expr,msg) __attribute__((diagnose_if(!(expr), msg, "error")))
1996 # define JSON_HEDLEY_REQUIRE(expr)
1997 # define JSON_HEDLEY_REQUIRE_MSG(expr,msg)
2000 #if defined(JSON_HEDLEY_FLAGS)
2001 #undef JSON_HEDLEY_FLAGS
2003 #if JSON_HEDLEY_HAS_ATTRIBUTE(flag_enum)
2004 #define JSON_HEDLEY_FLAGS __attribute__((__flag_enum__))
2006 #define JSON_HEDLEY_FLAGS
2009 #if defined(JSON_HEDLEY_FLAGS_CAST)
2010 #undef JSON_HEDLEY_FLAGS_CAST
2012 #if JSON_HEDLEY_INTEL_VERSION_CHECK(19,0,0)
2013 # define JSON_HEDLEY_FLAGS_CAST(T, expr) (__extension__ ({ \
2014 JSON_HEDLEY_DIAGNOSTIC_PUSH \
2015 _Pragma("warning(disable:188)") \
2017 JSON_HEDLEY_DIAGNOSTIC_POP \
2020 # define JSON_HEDLEY_FLAGS_CAST(T, expr) JSON_HEDLEY_STATIC_CAST(T, expr)
2023 #if defined(JSON_HEDLEY_EMPTY_BASES)
2024 #undef JSON_HEDLEY_EMPTY_BASES
2027 (JSON_HEDLEY_MSVC_VERSION_CHECK(19,0,23918) && !JSON_HEDLEY_MSVC_VERSION_CHECK(20,0,0)) || \
2028 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
2029 #define JSON_HEDLEY_EMPTY_BASES __declspec(empty_bases)
2031 #define JSON_HEDLEY_EMPTY_BASES
2036 #if defined(JSON_HEDLEY_GCC_NOT_CLANG_VERSION_CHECK)
2037 #undef JSON_HEDLEY_GCC_NOT_CLANG_VERSION_CHECK
2039 #if defined(__clang__)
2040 #define JSON_HEDLEY_GCC_NOT_CLANG_VERSION_CHECK(major,minor,patch) (0)
2042 #define JSON_HEDLEY_GCC_NOT_CLANG_VERSION_CHECK(major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch)
2045 #if defined(JSON_HEDLEY_CLANG_HAS_ATTRIBUTE)
2046 #undef JSON_HEDLEY_CLANG_HAS_ATTRIBUTE
2048 #define JSON_HEDLEY_CLANG_HAS_ATTRIBUTE(attribute) JSON_HEDLEY_HAS_ATTRIBUTE(attribute)
2050 #if defined(JSON_HEDLEY_CLANG_HAS_CPP_ATTRIBUTE)
2051 #undef JSON_HEDLEY_CLANG_HAS_CPP_ATTRIBUTE
2053 #define JSON_HEDLEY_CLANG_HAS_CPP_ATTRIBUTE(attribute) JSON_HEDLEY_HAS_CPP_ATTRIBUTE(attribute)
2055 #if defined(JSON_HEDLEY_CLANG_HAS_BUILTIN)
2056 #undef JSON_HEDLEY_CLANG_HAS_BUILTIN
2058 #define JSON_HEDLEY_CLANG_HAS_BUILTIN(builtin) JSON_HEDLEY_HAS_BUILTIN(builtin)
2060 #if defined(JSON_HEDLEY_CLANG_HAS_FEATURE)
2061 #undef JSON_HEDLEY_CLANG_HAS_FEATURE
2063 #define JSON_HEDLEY_CLANG_HAS_FEATURE(feature) JSON_HEDLEY_HAS_FEATURE(feature)
2065 #if defined(JSON_HEDLEY_CLANG_HAS_EXTENSION)
2066 #undef JSON_HEDLEY_CLANG_HAS_EXTENSION
2068 #define JSON_HEDLEY_CLANG_HAS_EXTENSION(extension) JSON_HEDLEY_HAS_EXTENSION(extension)
2070 #if defined(JSON_HEDLEY_CLANG_HAS_DECLSPEC_DECLSPEC_ATTRIBUTE)
2071 #undef JSON_HEDLEY_CLANG_HAS_DECLSPEC_DECLSPEC_ATTRIBUTE
2073 #define JSON_HEDLEY_CLANG_HAS_DECLSPEC_ATTRIBUTE(attribute) JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE(attribute)
2075 #if defined(JSON_HEDLEY_CLANG_HAS_WARNING)
2076 #undef JSON_HEDLEY_CLANG_HAS_WARNING
2078 #define JSON_HEDLEY_CLANG_HAS_WARNING(warning) JSON_HEDLEY_HAS_WARNING(warning)
2087 #if !defined(JSON_SKIP_UNSUPPORTED_COMPILER_CHECK)
2088 #if defined(__clang__)
2089 #if (__clang_major__ * 10000 + __clang_minor__ * 100 + __clang_patchlevel__) < 30400
2090 #error "unsupported Clang version - see https://github.com/nlohmann/json#supported-compilers"
2092 #elif defined(__GNUC__) && !(defined(__ICC) || defined(__INTEL_COMPILER))
2093 #if (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) < 40800
2094 #error "unsupported GCC version - see https://github.com/nlohmann/json#supported-compilers"
2100 #if (defined(__cplusplus) && __cplusplus >= 202002L) || (defined(_MSVC_LANG) && _MSVC_LANG >= 202002L)
2101 #define JSON_HAS_CPP_20
2102 #define JSON_HAS_CPP_17
2103 #define JSON_HAS_CPP_14
2104 #elif (defined(__cplusplus) && __cplusplus >= 201703L) || (defined(_HAS_CXX17) && _HAS_CXX17 == 1) // fix for issue #464
2105 #define JSON_HAS_CPP_17
2106 #define JSON_HAS_CPP_14
2107 #elif (defined(__cplusplus) && __cplusplus >= 201402L) || (defined(_HAS_CXX14) && _HAS_CXX14 == 1)
2108 #define JSON_HAS_CPP_14
2112 #if defined(__clang__) || defined(__GNUC__) || defined(__GNUG__)
2113 #pragma GCC diagnostic push
2114 #pragma GCC diagnostic ignored "-Wfloat-equal"
2118 #if defined(__clang__)
2119 #pragma GCC diagnostic push
2120 #pragma GCC diagnostic ignored "-Wdocumentation"
2124 #if (defined(__cpp_exceptions) || defined(__EXCEPTIONS) || defined(_CPPUNWIND)) && !defined(JSON_NOEXCEPTION)
2125 #define JSON_THROW(exception) throw exception
2126 #define JSON_TRY try
2127 #define JSON_CATCH(exception) catch(exception)
2128 #define JSON_INTERNAL_CATCH(exception) catch(exception)
2131 #define JSON_THROW(exception) std::abort()
2132 #define JSON_TRY if(true)
2133 #define JSON_CATCH(exception) if(false)
2134 #define JSON_INTERNAL_CATCH(exception) if(false)
2138 #if defined(JSON_THROW_USER)
2140 #define JSON_THROW JSON_THROW_USER
2142 #if defined(JSON_TRY_USER)
2144 #define JSON_TRY JSON_TRY_USER
2146 #if defined(JSON_CATCH_USER)
2148 #define JSON_CATCH JSON_CATCH_USER
2149 #undef JSON_INTERNAL_CATCH
2150 #define JSON_INTERNAL_CATCH JSON_CATCH_USER
2152 #if defined(JSON_INTERNAL_CATCH_USER)
2153 #undef JSON_INTERNAL_CATCH
2154 #define JSON_INTERNAL_CATCH JSON_INTERNAL_CATCH_USER
2158 #if !defined(JSON_ASSERT)
2160 #define JSON_ASSERT(x) assert(x)
2164 #if defined(JSON_TESTS_PRIVATE)
2165 #define JSON_PRIVATE_UNLESS_TESTED public
2167 #define JSON_PRIVATE_UNLESS_TESTED private
2175 #define NLOHMANN_JSON_SERIALIZE_ENUM(ENUM_TYPE, ...) \
2176 template<typename BasicJsonType> \
2177 inline void to_json(BasicJsonType& j, const ENUM_TYPE& e) \
2179 static_assert(std::is_enum<ENUM_TYPE>::value, #ENUM_TYPE " must be an enum!"); \
2180 static const std::pair<ENUM_TYPE, BasicJsonType> m[] = __VA_ARGS__; \
2181 auto it = std::find_if(std::begin(m), std::end(m), \
2182 [e](const std::pair<ENUM_TYPE, BasicJsonType>& ej_pair) -> bool \
2184 return ej_pair.first == e; \
2186 j = ((it != std::end(m)) ? it : std::begin(m))->second; \
2188 template<typename BasicJsonType> \
2189 inline void from_json(const BasicJsonType& j, ENUM_TYPE& e) \
2191 static_assert(std::is_enum<ENUM_TYPE>::value, #ENUM_TYPE " must be an enum!"); \
2192 static const std::pair<ENUM_TYPE, BasicJsonType> m[] = __VA_ARGS__; \
2193 auto it = std::find_if(std::begin(m), std::end(m), \
2194 [&j](const std::pair<ENUM_TYPE, BasicJsonType>& ej_pair) -> bool \
2196 return ej_pair.second == j; \
2198 e = ((it != std::end(m)) ? it : std::begin(m))->first; \
2204 #define NLOHMANN_BASIC_JSON_TPL_DECLARATION \
2205 template<template<typename, typename, typename...> class ObjectType, \
2206 template<typename, typename...> class ArrayType, \
2207 class StringType, class BooleanType, class NumberIntegerType, \
2208 class NumberUnsignedType, class NumberFloatType, \
2209 template<typename> class AllocatorType, \
2210 template<typename, typename = void> class JSONSerializer, \
2213 #define NLOHMANN_BASIC_JSON_TPL \
2214 basic_json<ObjectType, ArrayType, StringType, BooleanType, \
2215 NumberIntegerType, NumberUnsignedType, NumberFloatType, \
2216 AllocatorType, JSONSerializer, BinaryType>
2220 #define NLOHMANN_JSON_EXPAND( x ) x
2221 #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
2222 #define NLOHMANN_JSON_PASTE(...) NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_GET_MACRO(__VA_ARGS__, \
2223 NLOHMANN_JSON_PASTE64, \
2224 NLOHMANN_JSON_PASTE63, \
2225 NLOHMANN_JSON_PASTE62, \
2226 NLOHMANN_JSON_PASTE61, \
2227 NLOHMANN_JSON_PASTE60, \
2228 NLOHMANN_JSON_PASTE59, \
2229 NLOHMANN_JSON_PASTE58, \
2230 NLOHMANN_JSON_PASTE57, \
2231 NLOHMANN_JSON_PASTE56, \
2232 NLOHMANN_JSON_PASTE55, \
2233 NLOHMANN_JSON_PASTE54, \
2234 NLOHMANN_JSON_PASTE53, \
2235 NLOHMANN_JSON_PASTE52, \
2236 NLOHMANN_JSON_PASTE51, \
2237 NLOHMANN_JSON_PASTE50, \
2238 NLOHMANN_JSON_PASTE49, \
2239 NLOHMANN_JSON_PASTE48, \
2240 NLOHMANN_JSON_PASTE47, \
2241 NLOHMANN_JSON_PASTE46, \
2242 NLOHMANN_JSON_PASTE45, \
2243 NLOHMANN_JSON_PASTE44, \
2244 NLOHMANN_JSON_PASTE43, \
2245 NLOHMANN_JSON_PASTE42, \
2246 NLOHMANN_JSON_PASTE41, \
2247 NLOHMANN_JSON_PASTE40, \
2248 NLOHMANN_JSON_PASTE39, \
2249 NLOHMANN_JSON_PASTE38, \
2250 NLOHMANN_JSON_PASTE37, \
2251 NLOHMANN_JSON_PASTE36, \
2252 NLOHMANN_JSON_PASTE35, \
2253 NLOHMANN_JSON_PASTE34, \
2254 NLOHMANN_JSON_PASTE33, \
2255 NLOHMANN_JSON_PASTE32, \
2256 NLOHMANN_JSON_PASTE31, \
2257 NLOHMANN_JSON_PASTE30, \
2258 NLOHMANN_JSON_PASTE29, \
2259 NLOHMANN_JSON_PASTE28, \
2260 NLOHMANN_JSON_PASTE27, \
2261 NLOHMANN_JSON_PASTE26, \
2262 NLOHMANN_JSON_PASTE25, \
2263 NLOHMANN_JSON_PASTE24, \
2264 NLOHMANN_JSON_PASTE23, \
2265 NLOHMANN_JSON_PASTE22, \
2266 NLOHMANN_JSON_PASTE21, \
2267 NLOHMANN_JSON_PASTE20, \
2268 NLOHMANN_JSON_PASTE19, \
2269 NLOHMANN_JSON_PASTE18, \
2270 NLOHMANN_JSON_PASTE17, \
2271 NLOHMANN_JSON_PASTE16, \
2272 NLOHMANN_JSON_PASTE15, \
2273 NLOHMANN_JSON_PASTE14, \
2274 NLOHMANN_JSON_PASTE13, \
2275 NLOHMANN_JSON_PASTE12, \
2276 NLOHMANN_JSON_PASTE11, \
2277 NLOHMANN_JSON_PASTE10, \
2278 NLOHMANN_JSON_PASTE9, \
2279 NLOHMANN_JSON_PASTE8, \
2280 NLOHMANN_JSON_PASTE7, \
2281 NLOHMANN_JSON_PASTE6, \
2282 NLOHMANN_JSON_PASTE5, \
2283 NLOHMANN_JSON_PASTE4, \
2284 NLOHMANN_JSON_PASTE3, \
2285 NLOHMANN_JSON_PASTE2, \
2286 NLOHMANN_JSON_PASTE1)(__VA_ARGS__))
2287 #define NLOHMANN_JSON_PASTE2(func, v1) func(v1)
2288 #define NLOHMANN_JSON_PASTE3(func, v1, v2) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE2(func, v2)
2289 #define NLOHMANN_JSON_PASTE4(func, v1, v2, v3) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE3(func, v2, v3)
2290 #define NLOHMANN_JSON_PASTE5(func, v1, v2, v3, v4) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE4(func, v2, v3, v4)
2291 #define NLOHMANN_JSON_PASTE6(func, v1, v2, v3, v4, v5) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE5(func, v2, v3, v4, v5)
2292 #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)
2293 #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)
2294 #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)
2295 #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)
2296 #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)
2297 #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)
2298 #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)
2299 #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)
2300 #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)
2301 #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)
2302 #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)
2303 #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)
2304 #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)
2305 #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)
2306 #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)
2307 #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)
2308 #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)
2309 #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)
2310 #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)
2311 #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)
2312 #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)
2313 #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)
2314 #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)
2315 #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)
2316 #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)
2317 #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)
2318 #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)
2319 #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)
2320 #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)
2321 #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)
2322 #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)
2323 #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)
2324 #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)
2325 #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)
2326 #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)
2327 #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)
2328 #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)
2329 #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)
2330 #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)
2331 #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)
2332 #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)
2333 #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)
2334 #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)
2335 #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)
2336 #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)
2337 #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)
2338 #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)
2339 #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)
2340 #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)
2341 #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)
2342 #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)
2343 #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)
2344 #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)
2345 #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)
2346 #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)
2347 #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)
2348 #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)
2349 #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)
2351 #define NLOHMANN_JSON_TO(v1) nlohmann_json_j[#v1] = nlohmann_json_t.v1;
2352 #define NLOHMANN_JSON_FROM(v1) nlohmann_json_j.at(#v1).get_to(nlohmann_json_t.v1);
2359 #define NLOHMANN_DEFINE_TYPE_INTRUSIVE(Type, ...) \
2360 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__)) } \
2361 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__)) }
2368 #define NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(Type, ...) \
2369 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__)) } \
2370 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__)) }
2372 #ifndef JSON_USE_IMPLICIT_CONVERSIONS
2373 #define JSON_USE_IMPLICIT_CONVERSIONS 1
2376 #if JSON_USE_IMPLICIT_CONVERSIONS
2377 #define JSON_EXPLICIT
2379 #define JSON_EXPLICIT explicit
2423 JSON_HEDLEY_RETURNS_NON_NULL
2424 const char*
what() const noexcept
override
2433 JSON_HEDLEY_NON_NULL(3)
2434 exception(
int id_, const
char* what_arg) :
id(id_), m(what_arg) {}
2436 static std::string name(
const std::string& ename,
int id_)
2438 return "[json.exception." + ename +
"." + std::to_string(id_) +
"] ";
2443 std::runtime_error m;
2505 std::string w = exception::name(
"parse_error", id_) +
"parse error" +
2506 position_string(pos) +
": " + what_arg;
2510 static parse_error create(
int id_, std::size_t byte_,
const std::string& what_arg)
2512 std::string w = exception::name(
"parse_error", id_) +
"parse error" +
2513 (byte_ != 0 ? (
" at byte " + std::to_string(byte_)) :
"") +
2530 parse_error(
int id_, std::size_t byte_,
const char* what_arg)
2533 static std::string position_string(
const position_t& pos)
2535 return " at line " + std::to_string(pos.
lines_read + 1) +
2582 std::string w = exception::name(
"invalid_iterator", id_) + what_arg;
2587 JSON_HEDLEY_NON_NULL(3)
2634 static type_error create(
int id_,
const std::string& what_arg)
2636 std::string w = exception::name(
"type_error", id_) + what_arg;
2641 JSON_HEDLEY_NON_NULL(3)
2681 static out_of_range create(
int id_,
const std::string& what_arg)
2683 std::string w = exception::name(
"out_of_range", id_) + what_arg;
2688 JSON_HEDLEY_NON_NULL(3)
2719 static other_error create(
int id_,
const std::string& what_arg)
2721 std::string w = exception::name(
"other_error", id_) + what_arg;
2726 JSON_HEDLEY_NON_NULL(3)
2738 #include <type_traits>
2745 template<
bool B,
typename T =
void>
2746 using enable_if_t =
typename std::enable_if<B, T>::type;
2748 template<
typename T>
2749 using uncvref_t =
typename std::remove_cv<typename std::remove_reference<T>::type>::type;
2753 template<std::size_t... Ints>
2757 using value_type = std::size_t;
2758 static constexpr std::size_t size() noexcept
2760 return sizeof...(Ints);
2764 template<
class Sequence1,
class Sequence2>
2767 template<std::size_t... I1, std::size_t... I2>
2771 template<std::
size_t N>
2774 typename make_index_sequence < N - N / 2 >::type > {};
2779 template<
typename... Ts>
2787 template<
typename T>
2790 static constexpr T value{};
2793 template<
typename T>
2802 #include <type_traits>
2821 template<
typename ...Ts>
using void_t =
typename make_void<Ts...>::type;
2832 template<
typename It,
typename =
void>
2835 template<
typename It>
2838 void_t<typename It::difference_type, typename It::value_type, typename It::pointer,
2839 typename It::reference, typename It::iterator_category >>
2841 using difference_type =
typename It::difference_type;
2842 using value_type =
typename It::value_type;
2843 using pointer =
typename It::pointer;
2844 using reference =
typename It::reference;
2845 using iterator_category =
typename It::iterator_category;
2850 template<
typename T,
typename =
void>
2855 template<
typename T>
2861 template<
typename T>
2864 using iterator_category = std::random_access_iterator_tag;
2865 using value_type = T;
2866 using difference_type = ptrdiff_t;
2868 using reference = T&;
2880 #include <type_traits>
2896 void operator=(
nonesuch const&) =
delete;
2897 void operator=(
nonesuch&&) =
delete;
2900 template<
class Default,
2902 template<
class...>
class Op,
2906 using value_t = std::false_type;
2907 using type = Default;
2910 template<
class Default,
template<
class...>
class Op,
class... Args>
2911 struct detector<Default, void_t<Op<Args...>>, Op, Args...>
2913 using value_t = std::true_type;
2914 using type = Op<Args...>;
2917 template<
template<
class...>
class Op,
class... Args>
2920 template<
template<
class...>
class Op,
class... Args>
2923 template<
class Default,
template<
class...>
class Op,
class... Args>
2926 template<
class Default,
template<
class...>
class Op,
class... Args>
2927 using detected_or_t =
typename detected_or<Default, Op, Args...>::type;
2929 template<
class Expected,
template<
class...>
class Op,
class... Args>
2930 using is_detected_exact = std::is_same<Expected, detected_t<Op, Args...>>;
2932 template<
class To,
template<
class...>
class Op,
class... Args>
2933 using is_detected_convertible =
2934 std::is_convertible<detected_t<Op, Args...>, To>;
2939 #ifndef INCLUDE_NLOHMANN_JSON_FWD_HPP_
2940 #define INCLUDE_NLOHMANN_JSON_FWD_HPP_
2962 template<
typename T =
void,
typename SFINAE =
void>
2963 struct adl_serializer;
2965 template<
template<
typename U,
typename V,
typename... Args>
class ObjectType =
2967 template<
typename U,
typename... Args>
class ArrayType = std::vector,
2968 class StringType = std::string,
class BooleanType = bool,
2969 class NumberIntegerType = std::int64_t,
2970 class NumberUnsignedType = std::uint64_t,
2971 class NumberFloatType = double,
2972 template<
typename U>
class AllocatorType = std::allocator,
2973 template<
typename T,
typename SFINAE =
void>
class JSONSerializer =
2975 class BinaryType = std::vector<std::uint8_t>>
2989 template<
typename BasicJsonType>
3002 template<
class Key,
class T,
class IgnoredLess,
class Allocator>
3016 #endif // INCLUDE_NLOHMANN_JSON_FWD_HPP_
3046 NLOHMANN_BASIC_JSON_TPL_DECLARATION
3059 template<
typename T>
3066 template<
typename T>
3067 using mapped_type_t =
typename T::mapped_type;
3069 template<
typename T>
3070 using key_type_t =
typename T::key_type;
3072 template<
typename T>
3073 using value_type_t =
typename T::value_type;
3075 template<
typename T>
3076 using difference_type_t =
typename T::difference_type;
3078 template<
typename T>
3079 using pointer_t =
typename T::pointer;
3081 template<
typename T>
3082 using reference_t =
typename T::reference;
3084 template<
typename T>
3085 using iterator_category_t =
typename T::iterator_category;
3087 template<
typename T>
3088 using iterator_t =
typename T::iterator;
3090 template<
typename T,
typename... Args>
3091 using to_json_function = decltype(T::to_json(std::declval<Args>()...));
3093 template<
typename T,
typename... Args>
3094 using from_json_function = decltype(T::from_json(std::declval<Args>()...));
3096 template<
typename T,
typename U>
3097 using get_template_function = decltype(std::declval<T>().
template get<U>());
3100 template<
typename BasicJsonType,
typename T,
typename =
void>
3107 template <
typename BasicJsonType,
typename T>
3110 static constexpr
bool value = is_detected<get_template_function, const BasicJsonType&, T>::value;
3113 template<
typename BasicJsonType,
typename T>
3117 using serializer =
typename BasicJsonType::template json_serializer<T, void>;
3119 static constexpr
bool value =
3120 is_detected_exact<void, from_json_function, serializer,
3121 const BasicJsonType&, T&>::value;
3126 template<
typename BasicJsonType,
typename T,
typename =
void>
3129 template<
typename BasicJsonType,
typename T>
3132 using serializer =
typename BasicJsonType::template json_serializer<T, void>;
3134 static constexpr
bool value =
3135 is_detected_exact<T, from_json_function, serializer,
3136 const BasicJsonType&>::value;
3141 template<
typename BasicJsonType,
typename T,
typename =
void>
3144 template<
typename BasicJsonType,
typename T>
3147 using serializer =
typename BasicJsonType::template json_serializer<T, void>;
3149 static constexpr
bool value =
3150 is_detected_exact<void, to_json_function, serializer, BasicJsonType&,
3159 template<
typename T,
typename =
void>
3162 template<
typename T>
3169 static constexpr
auto value =
3170 is_detected<value_type_t, traits>::value &&
3171 is_detected<difference_type_t, traits>::value &&
3172 is_detected<pointer_t, traits>::value &&
3173 is_detected<iterator_category_t, traits>::value &&
3174 is_detected<reference_t, traits>::value;
3179 template<
typename T,
typename =
void>
3182 template<
typename T>
3185 template<
typename BasicJsonType,
typename CompatibleObjectType,
3189 template<
typename BasicJsonType,
typename CompatibleObjectType>
3191 BasicJsonType, CompatibleObjectType,
3192 enable_if_t < is_detected<mapped_type_t, CompatibleObjectType>::
value&&
3193 is_detected<key_type_t, CompatibleObjectType>::value >>
3196 using object_t =
typename BasicJsonType::object_t;
3199 static constexpr
bool value =
3200 std::is_constructible<
typename object_t::key_type,
3201 typename CompatibleObjectType::key_type>::value &&
3202 std::is_constructible<
typename object_t::mapped_type,
3203 typename CompatibleObjectType::mapped_type>::value;
3206 template<
typename BasicJsonType,
typename CompatibleObjectType>
3210 template<
typename BasicJsonType,
typename ConstructibleObjectType,
3214 template<
typename BasicJsonType,
typename ConstructibleObjectType>
3216 BasicJsonType, ConstructibleObjectType,
3217 enable_if_t < is_detected<mapped_type_t, ConstructibleObjectType>::
value&&
3218 is_detected<key_type_t, ConstructibleObjectType>::value >>
3220 using object_t =
typename BasicJsonType::object_t;
3222 static constexpr
bool value =
3223 (std::is_default_constructible<ConstructibleObjectType>::value &&
3224 (std::is_move_assignable<ConstructibleObjectType>::value ||
3225 std::is_copy_assignable<ConstructibleObjectType>::value) &&
3226 (std::is_constructible<
typename ConstructibleObjectType::key_type,
3227 typename object_t::key_type>::
value &&
3229 typename object_t::mapped_type,
3230 typename ConstructibleObjectType::mapped_type >::
value)) ||
3232 typename ConstructibleObjectType::mapped_type>::
value ||
3235 typename ConstructibleObjectType::mapped_type >::
value);
3238 template<
typename BasicJsonType,
typename ConstructibleObjectType>
3241 ConstructibleObjectType> {};
3243 template<
typename BasicJsonType,
typename CompatibleStringType,
3247 template<
typename BasicJsonType,
typename CompatibleStringType>
3249 BasicJsonType, CompatibleStringType,
3250 enable_if_t<is_detected_exact<typename BasicJsonType::string_t::value_type,
3251 value_type_t, CompatibleStringType>::value >>
3253 static constexpr
auto value =
3254 std::is_constructible<typename BasicJsonType::string_t, CompatibleStringType>::value;
3257 template<
typename BasicJsonType,
typename ConstructibleStringType>
3261 template<
typename BasicJsonType,
typename ConstructibleStringType,
3265 template<
typename BasicJsonType,
typename ConstructibleStringType>
3267 BasicJsonType, ConstructibleStringType,
3268 enable_if_t<is_detected_exact<typename BasicJsonType::string_t::value_type,
3269 value_type_t, ConstructibleStringType>::value >>
3271 static constexpr
auto value =
3272 std::is_constructible<ConstructibleStringType,
3273 typename BasicJsonType::string_t>::value;
3276 template<
typename BasicJsonType,
typename ConstructibleStringType>
3280 template<
typename BasicJsonType,
typename CompatibleArrayType,
typename =
void>
3283 template<
typename BasicJsonType,
typename CompatibleArrayType>
3285 BasicJsonType, CompatibleArrayType,
3286 enable_if_t < is_detected<value_type_t, CompatibleArrayType>::
value&&
3287 is_detected<iterator_t, CompatibleArrayType>::value&&
3292 iterator_traits<CompatibleArrayType >>::value >>
3294 static constexpr
bool value =
3295 std::is_constructible<BasicJsonType,
3296 typename CompatibleArrayType::value_type>::value;
3299 template<
typename BasicJsonType,
typename CompatibleArrayType>
3303 template<
typename BasicJsonType,
typename ConstructibleArrayType,
typename =
void>
3306 template<
typename BasicJsonType,
typename ConstructibleArrayType>
3308 BasicJsonType, ConstructibleArrayType,
3309 enable_if_t<std::is_same<ConstructibleArrayType,
3310 typename BasicJsonType::value_type>::value >>
3311 : std::true_type {};
3313 template<
typename BasicJsonType,
typename ConstructibleArrayType>
3315 BasicJsonType, ConstructibleArrayType,
3316 enable_if_t < !std::is_same<ConstructibleArrayType,
3317 typename BasicJsonType::value_type>::value&&
3318 std::is_default_constructible<ConstructibleArrayType>::value&&
3319 (std::is_move_assignable<ConstructibleArrayType>::value ||
3320 std::is_copy_assignable<ConstructibleArrayType>::value)&&
3321 is_detected<value_type_t, ConstructibleArrayType>::value&&
3322 is_detected<iterator_t, ConstructibleArrayType>::value&&
3324 detected_t<value_type_t, ConstructibleArrayType >>::value >>
3326 static constexpr
bool value =
3334 (std::is_same<
typename ConstructibleArrayType::value_type,
3335 typename BasicJsonType::array_t::value_type>::value ||
3337 typename ConstructibleArrayType::value_type>::value ||
3339 BasicJsonType,
typename ConstructibleArrayType::value_type >::value);
3342 template<
typename BasicJsonType,
typename ConstructibleArrayType>
3346 template<
typename RealIntegerType,
typename CompatibleNumberIntegerType,
3350 template<
typename RealIntegerType,
typename CompatibleNumberIntegerType>
3352 RealIntegerType, CompatibleNumberIntegerType,
3353 enable_if_t < std::is_integral<RealIntegerType>::value&&
3354 std::is_integral<CompatibleNumberIntegerType>::value&&
3355 !std::is_same<bool, CompatibleNumberIntegerType>::value >>
3358 using RealLimits = std::numeric_limits<RealIntegerType>;
3359 using CompatibleLimits = std::numeric_limits<CompatibleNumberIntegerType>;
3361 static constexpr
auto value =
3362 std::is_constructible<RealIntegerType,
3363 CompatibleNumberIntegerType>::value &&
3364 CompatibleLimits::is_integer &&
3365 RealLimits::is_signed == CompatibleLimits::is_signed;
3368 template<
typename RealIntegerType,
typename CompatibleNumberIntegerType>
3371 CompatibleNumberIntegerType> {};
3373 template<
typename BasicJsonType,
typename CompatibleType,
typename =
void>
3376 template<
typename BasicJsonType,
typename CompatibleType>
3378 BasicJsonType, CompatibleType,
3381 static constexpr
bool value =
3385 template<
typename BasicJsonType,
typename CompatibleType>
3392 template<
class B1,
class... Bn>
3394 : std::conditional<bool(B1::value), conjunction<Bn...>, B1>::type {};
3396 template<
typename T1,
typename T2>
3399 template<
typename T1,
typename... Args>
3473 static constexpr std::array<std::uint8_t, 9> order = {{
3480 const auto l_index =
static_cast<std::size_t
>(lhs);
3481 const auto r_index =
static_cast<std::size_t
>(rhs);
3482 return l_index < order.size() && r_index < order.size() && order[l_index] < order[r_index];
3492 template<
typename BasicJsonType>
3493 void from_json(
const BasicJsonType& j,
typename std::nullptr_t& n)
3495 if (JSON_HEDLEY_UNLIKELY(!j.is_null()))
3497 JSON_THROW(type_error::create(302,
"type must be null, but is " + std::string(j.type_name())));
3503 template <
typename BasicJsonType,
typename ArithmeticType,
3504 enable_if_t < std::is_arithmetic<ArithmeticType>::value&&
3505 !std::is_same<ArithmeticType, typename BasicJsonType::boolean_t>::value,
3507 void get_arithmetic_value(
const BasicJsonType& j, ArithmeticType& val)
3509 switch (
static_cast<value_t>(j))
3513 val =
static_cast<ArithmeticType
>(*j.template get_ptr<const typename BasicJsonType::number_unsigned_t*>());
3518 val =
static_cast<ArithmeticType
>(*j.template get_ptr<const typename BasicJsonType::number_integer_t*>());
3523 val =
static_cast<ArithmeticType
>(*j.template get_ptr<const typename BasicJsonType::number_float_t*>());
3528 JSON_THROW(type_error::create(302,
"type must be number, but is " + std::string(j.type_name())));
3532 template<
typename BasicJsonType>
3533 void from_json(
const BasicJsonType& j,
typename BasicJsonType::boolean_t& b)
3535 if (JSON_HEDLEY_UNLIKELY(!j.is_boolean()))
3537 JSON_THROW(type_error::create(302,
"type must be boolean, but is " + std::string(j.type_name())));
3539 b = *j.template get_ptr<const typename BasicJsonType::boolean_t*>();
3542 template<
typename BasicJsonType>
3543 void from_json(
const BasicJsonType& j,
typename BasicJsonType::string_t& s)
3545 if (JSON_HEDLEY_UNLIKELY(!j.is_string()))
3547 JSON_THROW(type_error::create(302,
"type must be string, but is " + std::string(j.type_name())));
3549 s = *j.template get_ptr<const typename BasicJsonType::string_t*>();
3553 typename BasicJsonType,
typename ConstructibleStringType,
3555 is_constructible_string_type<BasicJsonType, ConstructibleStringType>::value&&
3556 !std::is_same<
typename BasicJsonType::string_t,
3557 ConstructibleStringType>::value,
3559 void from_json(
const BasicJsonType& j, ConstructibleStringType& s)
3561 if (JSON_HEDLEY_UNLIKELY(!j.is_string()))
3563 JSON_THROW(type_error::create(302,
"type must be string, but is " + std::string(j.type_name())));
3566 s = *j.template get_ptr<const typename BasicJsonType::string_t*>();
3569 template<
typename BasicJsonType>
3570 void from_json(
const BasicJsonType& j,
typename BasicJsonType::number_float_t& val)
3572 get_arithmetic_value(j, val);
3575 template<
typename BasicJsonType>
3576 void from_json(
const BasicJsonType& j,
typename BasicJsonType::number_unsigned_t& val)
3578 get_arithmetic_value(j, val);
3581 template<
typename BasicJsonType>
3582 void from_json(
const BasicJsonType& j,
typename BasicJsonType::number_integer_t& val)
3584 get_arithmetic_value(j, val);
3587 template<
typename BasicJsonType,
typename EnumType,
3588 enable_if_t<std::is_enum<EnumType>::value,
int> = 0>
3589 void from_json(
const BasicJsonType& j, EnumType& e)
3591 typename std::underlying_type<EnumType>::type val;
3592 get_arithmetic_value(j, val);
3593 e =
static_cast<EnumType
>(val);
3597 template<
typename BasicJsonType,
typename T,
typename Allocator,
3598 enable_if_t<is_getable<BasicJsonType, T>::value,
int> = 0>
3599 void from_json(
const BasicJsonType& j, std::forward_list<T, Allocator>& l)
3601 if (JSON_HEDLEY_UNLIKELY(!j.is_array()))
3603 JSON_THROW(type_error::create(302,
"type must be array, but is " + std::string(j.type_name())));
3606 std::transform(j.rbegin(), j.rend(),
3607 std::front_inserter(l), [](
const BasicJsonType & i)
3609 return i.template get<T>();
3614 template<
typename BasicJsonType,
typename T,
3615 enable_if_t<is_getable<BasicJsonType, T>::value,
int> = 0>
3616 void from_json(
const BasicJsonType& j, std::valarray<T>& l)
3618 if (JSON_HEDLEY_UNLIKELY(!j.is_array()))
3620 JSON_THROW(type_error::create(302,
"type must be array, but is " + std::string(j.type_name())));
3623 std::transform(j.begin(), j.end(), std::begin(l),
3624 [](
const BasicJsonType & elem)
3626 return elem.template get<T>();
3630 template<
typename BasicJsonType,
typename T, std::
size_t N>
3631 auto from_json(
const BasicJsonType& j, T (&arr)[N])
3632 -> decltype(j.template get<T>(),
void())
3634 for (std::size_t i = 0; i < N; ++i)
3636 arr[i] = j.at(i).template get<T>();
3640 template<
typename BasicJsonType>
3641 void from_json_array_impl(
const BasicJsonType& j,
typename BasicJsonType::array_t& arr, priority_tag<3> )
3643 arr = *j.template get_ptr<const typename BasicJsonType::array_t*>();
3646 template<
typename BasicJsonType,
typename T, std::
size_t N>
3647 auto from_json_array_impl(
const BasicJsonType& j, std::array<T, N>& arr,
3649 -> decltype(j.template get<T>(),
void())
3651 for (std::size_t i = 0; i < N; ++i)
3653 arr[i] = j.at(i).template get<T>();
3657 template<
typename BasicJsonType,
typename ConstructibleArrayType>
3658 auto from_json_array_impl(
const BasicJsonType& j, ConstructibleArrayType& arr, priority_tag<1> )
3660 arr.reserve(std::declval<typename ConstructibleArrayType::size_type>()),
3661 j.template get<typename ConstructibleArrayType::value_type>(),
3666 ConstructibleArrayType ret;
3667 ret.reserve(j.size());
3668 std::transform(j.begin(), j.end(),
3669 std::inserter(ret, end(ret)), [](
const BasicJsonType & i)
3673 return i.template get<typename ConstructibleArrayType::value_type>();
3675 arr = std::move(ret);
3678 template<
typename BasicJsonType,
typename ConstructibleArrayType>
3679 void from_json_array_impl(
const BasicJsonType& j, ConstructibleArrayType& arr,
3684 ConstructibleArrayType ret;
3686 j.begin(), j.end(), std::inserter(ret, end(ret)),
3687 [](
const BasicJsonType & i)
3691 return i.template get<typename ConstructibleArrayType::value_type>();
3693 arr = std::move(ret);
3696 template <
typename BasicJsonType,
typename ConstructibleArrayType,
3698 is_constructible_array_type<BasicJsonType, ConstructibleArrayType>::value&&
3699 !is_constructible_object_type<BasicJsonType, ConstructibleArrayType>::value&&
3700 !is_constructible_string_type<BasicJsonType, ConstructibleArrayType>::value&&
3701 !std::is_same<ConstructibleArrayType, typename BasicJsonType::binary_t>::value&&
3702 !is_basic_json<ConstructibleArrayType>::value,
3704 auto from_json(
const BasicJsonType& j, ConstructibleArrayType& arr)
3705 -> decltype(from_json_array_impl(j, arr, priority_tag<3> {}),
3706 j.template get<typename ConstructibleArrayType::value_type>(),
3709 if (JSON_HEDLEY_UNLIKELY(!j.is_array()))
3711 JSON_THROW(type_error::create(302,
"type must be array, but is " +
3712 std::string(j.type_name())));
3715 from_json_array_impl(j, arr, priority_tag<3> {});
3718 template<
typename BasicJsonType>
3719 void from_json(
const BasicJsonType& j,
typename BasicJsonType::binary_t& bin)
3721 if (JSON_HEDLEY_UNLIKELY(!j.is_binary()))
3723 JSON_THROW(type_error::create(302,
"type must be binary, but is " + std::string(j.type_name())));
3726 bin = *j.template get_ptr<const typename BasicJsonType::binary_t*>();
3729 template<
typename BasicJsonType,
typename ConstructibleObjectType,
3730 enable_if_t<is_constructible_object_type<BasicJsonType, ConstructibleObjectType>::value,
int> = 0>
3731 void from_json(
const BasicJsonType& j, ConstructibleObjectType& obj)
3733 if (JSON_HEDLEY_UNLIKELY(!j.is_object()))
3735 JSON_THROW(type_error::create(302,
"type must be object, but is " + std::string(j.type_name())));
3738 ConstructibleObjectType ret;
3739 auto inner_object = j.template get_ptr<const typename BasicJsonType::object_t*>();
3740 using value_type =
typename ConstructibleObjectType::value_type;
3742 inner_object->begin(), inner_object->end(),
3743 std::inserter(ret, ret.begin()),
3744 [](
typename BasicJsonType::object_t::value_type
const & p)
3746 return value_type(p.first, p.second.template get<typename ConstructibleObjectType::mapped_type>());
3748 obj = std::move(ret);
3755 template <
typename BasicJsonType,
typename ArithmeticType,
3757 std::is_arithmetic<ArithmeticType>::value&&
3758 !std::is_same<ArithmeticType, typename BasicJsonType::number_unsigned_t>::value&&
3759 !std::is_same<ArithmeticType, typename BasicJsonType::number_integer_t>::value&&
3760 !std::is_same<ArithmeticType, typename BasicJsonType::number_float_t>::value&&
3761 !std::is_same<ArithmeticType, typename BasicJsonType::boolean_t>::value,
3763 void from_json(
const BasicJsonType& j, ArithmeticType& val)
3765 switch (
static_cast<value_t>(j))
3769 val =
static_cast<ArithmeticType
>(*j.template get_ptr<const typename BasicJsonType::number_unsigned_t*>());
3774 val =
static_cast<ArithmeticType
>(*j.template get_ptr<const typename BasicJsonType::number_integer_t*>());
3779 val =
static_cast<ArithmeticType
>(*j.template get_ptr<const typename BasicJsonType::number_float_t*>());
3784 val =
static_cast<ArithmeticType
>(*j.template get_ptr<const typename BasicJsonType::boolean_t*>());
3789 JSON_THROW(type_error::create(302,
"type must be number, but is " + std::string(j.type_name())));
3793 template<
typename BasicJsonType,
typename A1,
typename A2>
3794 void from_json(
const BasicJsonType& j, std::pair<A1, A2>& p)
3796 p = {j.at(0).template get<A1>(), j.at(1).template get<A2>()};
3799 template<
typename BasicJsonType,
typename Tuple, std::size_t... Idx>
3800 void from_json_tuple_impl(
const BasicJsonType& j, Tuple& t, index_sequence<Idx...> )
3802 t = std::make_tuple(j.at(Idx).template get<
typename std::tuple_element<Idx, Tuple>::type>()...);
3805 template<
typename BasicJsonType,
typename... Args>
3806 void from_json(
const BasicJsonType& j, std::tuple<Args...>& t)
3808 from_json_tuple_impl(j, t, index_sequence_for<Args...> {});
3811 template <
typename BasicJsonType,
typename Key,
typename Value,
typename Compare,
typename Allocator,
3812 typename = enable_if_t < !std::is_constructible <
3813 typename BasicJsonType::string_t, Key >::value >>
3814 void from_json(
const BasicJsonType& j, std::map<Key, Value, Compare, Allocator>& m)
3816 if (JSON_HEDLEY_UNLIKELY(!j.is_array()))
3818 JSON_THROW(type_error::create(302,
"type must be array, but is " + std::string(j.type_name())));
3821 for (
const auto& p : j)
3823 if (JSON_HEDLEY_UNLIKELY(!p.is_array()))
3825 JSON_THROW(type_error::create(302,
"type must be array, but is " + std::string(p.type_name())));
3827 m.emplace(p.at(0).template get<Key>(), p.at(1).template get<Value>());
3831 template <
typename BasicJsonType,
typename Key,
typename Value,
typename Hash,
typename KeyEqual,
typename Allocator,
3832 typename = enable_if_t < !std::is_constructible <
3833 typename BasicJsonType::string_t, Key >::value >>
3834 void from_json(
const BasicJsonType& j, std::unordered_map<Key, Value, Hash, KeyEqual, Allocator>& m)
3836 if (JSON_HEDLEY_UNLIKELY(!j.is_array()))
3838 JSON_THROW(type_error::create(302,
"type must be array, but is " + std::string(j.type_name())));
3841 for (
const auto& p : j)
3843 if (JSON_HEDLEY_UNLIKELY(!p.is_array()))
3845 JSON_THROW(type_error::create(302,
"type must be array, but is " + std::string(p.type_name())));
3847 m.emplace(p.at(0).template get<Key>(), p.at(1).template get<Value>());
3853 template<
typename BasicJsonType,
typename T>
3854 auto operator()(
const BasicJsonType& j, T& val)
const
3855 noexcept(noexcept(from_json(j, val)))
3856 -> decltype(from_json(j, val),
void())
3858 return from_json(j, val);
3875 #include <algorithm>
3879 #include <type_traits>
3901 template<
typename string_type>
3902 void int_to_string( string_type& target, std::size_t value )
3905 using std::to_string;
3911 using difference_type = std::ptrdiff_t;
3915 using iterator_category = std::input_iterator_tag;
3916 using string_type =
typename std::remove_cv< typename std::remove_reference<decltype( std::declval<IteratorType>().
key() ) >::type >::type;
3920 IteratorType anchor;
3922 std::size_t array_index = 0;
3924 mutable std::size_t array_index_last = 0;
3926 mutable string_type array_index_str =
"0";
3928 const string_type empty_str =
"";
3951 return anchor == o.anchor;
3957 return anchor != o.anchor;
3961 const string_type&
key()
const
3963 JSON_ASSERT(anchor.m_object !=
nullptr);
3965 switch (anchor.m_object->type())
3970 if (array_index != array_index_last)
3972 int_to_string( array_index_str, array_index );
3973 array_index_last = array_index;
3975 return array_index_str;
3980 return anchor.key();
3989 typename IteratorType::reference
value()
const
3991 return anchor.value();
4000 typename IteratorType::reference container;
4005 : container(cont) {}
4022 template<std::
size_t N,
typename IteratorType, enable_if_t<N == 0,
int> = 0>
4030 template<std::
size_t N,
typename IteratorType, enable_if_t<N == 1,
int> = 0>
4044 #if defined(__clang__)
4046 #pragma clang diagnostic push
4047 #pragma clang diagnostic ignored "-Wmismatched-tags"
4049 template<
typename IteratorType>
4051 :
public std::integral_constant<std::size_t, 2> {};
4053 template<std::
size_t N,
typename IteratorType>
4057 using type = decltype(
4058 get<N>(std::declval <
4061 #if defined(__clang__)
4062 #pragma clang diagnostic pop
4086 template<
typename BasicJsonType>
4087 static void construct(BasicJsonType& j,
typename BasicJsonType::boolean_t b) noexcept
4091 j.assert_invariant();
4098 template<
typename BasicJsonType>
4099 static void construct(BasicJsonType& j,
const typename BasicJsonType::string_t& s)
4103 j.assert_invariant();
4106 template<
typename BasicJsonType>
4107 static void construct(BasicJsonType& j,
typename BasicJsonType::string_t&& s)
4110 j.m_value = std::move(s);
4111 j.assert_invariant();
4114 template <
typename BasicJsonType,
typename CompatibleStringType,
4115 enable_if_t < !std::is_same<CompatibleStringType, typename BasicJsonType::string_t>::value,
4117 static void construct(BasicJsonType& j,
const CompatibleStringType& str)
4120 j.m_value.string = j.template create<typename BasicJsonType::string_t>(str);
4121 j.assert_invariant();
4128 template<
typename BasicJsonType>
4129 static void construct(BasicJsonType& j,
const typename BasicJsonType::binary_t& b)
4132 typename BasicJsonType::binary_t
value{b};
4134 j.assert_invariant();
4137 template<
typename BasicJsonType>
4138 static void construct(BasicJsonType& j,
typename BasicJsonType::binary_t&& b)
4141 typename BasicJsonType::binary_t
value{std::move(b)};
4143 j.assert_invariant();
4150 template<
typename BasicJsonType>
4151 static void construct(BasicJsonType& j,
typename BasicJsonType::number_float_t val) noexcept
4155 j.assert_invariant();
4162 template<
typename BasicJsonType>
4163 static void construct(BasicJsonType& j,
typename BasicJsonType::number_unsigned_t val) noexcept
4167 j.assert_invariant();
4174 template<
typename BasicJsonType>
4175 static void construct(BasicJsonType& j,
typename BasicJsonType::number_integer_t val) noexcept
4179 j.assert_invariant();
4186 template<
typename BasicJsonType>
4187 static void construct(BasicJsonType& j,
const typename BasicJsonType::array_t& arr)
4191 j.assert_invariant();
4194 template<
typename BasicJsonType>
4195 static void construct(BasicJsonType& j,
typename BasicJsonType::array_t&& arr)
4198 j.m_value = std::move(arr);
4199 j.assert_invariant();
4202 template <
typename BasicJsonType,
typename CompatibleArrayType,
4203 enable_if_t < !std::is_same<CompatibleArrayType, typename BasicJsonType::array_t>::value,
4205 static void construct(BasicJsonType& j,
const CompatibleArrayType& arr)
4210 j.m_value.array = j.template create<typename BasicJsonType::array_t>(begin(arr), end(arr));
4211 j.assert_invariant();
4214 template<
typename BasicJsonType>
4215 static void construct(BasicJsonType& j,
const std::vector<bool>& arr)
4219 j.m_value.array->reserve(arr.size());
4220 for (
const bool x : arr)
4222 j.m_value.array->push_back(x);
4224 j.assert_invariant();
4227 template<
typename BasicJsonType,
typename T,
4228 enable_if_t<std::is_convertible<T, BasicJsonType>::value,
int> = 0>
4229 static void construct(BasicJsonType& j,
const std::valarray<T>& arr)
4233 j.m_value.array->resize(arr.size());
4236 std::copy(std::begin(arr), std::end(arr), j.m_value.array->begin());
4238 j.assert_invariant();
4245 template<
typename BasicJsonType>
4246 static void construct(BasicJsonType& j,
const typename BasicJsonType::object_t& obj)
4250 j.assert_invariant();
4253 template<
typename BasicJsonType>
4254 static void construct(BasicJsonType& j,
typename BasicJsonType::object_t&& obj)
4257 j.m_value = std::move(obj);
4258 j.assert_invariant();
4261 template <
typename BasicJsonType,
typename CompatibleObjectType,
4262 enable_if_t < !std::is_same<CompatibleObjectType, typename BasicJsonType::object_t>::value,
int > = 0 >
4263 static void construct(BasicJsonType& j,
const CompatibleObjectType& obj)
4269 j.m_value.object = j.template create<typename BasicJsonType::object_t>(begin(obj), end(obj));
4270 j.assert_invariant();
4278 template<
typename BasicJsonType,
typename T,
4279 enable_if_t<std::is_same<T, typename BasicJsonType::boolean_t>::value,
int> = 0>
4280 void to_json(BasicJsonType& j, T b) noexcept
4285 template<
typename BasicJsonType,
typename CompatibleString,
4286 enable_if_t<std::is_constructible<typename BasicJsonType::string_t, CompatibleString>::value,
int> = 0>
4287 void to_json(BasicJsonType& j,
const CompatibleString& s)
4289 external_constructor<value_t::string>::construct(j, s);
4292 template<
typename BasicJsonType>
4293 void to_json(BasicJsonType& j,
typename BasicJsonType::string_t&& s)
4295 external_constructor<value_t::string>::construct(j, std::move(s));
4298 template<
typename BasicJsonType,
typename FloatType,
4299 enable_if_t<std::is_floating_point<FloatType>::value,
int> = 0>
4300 void to_json(BasicJsonType& j, FloatType val) noexcept
4302 external_constructor<value_t::number_float>::construct(j,
static_cast<typename BasicJsonType::number_float_t
>(val));
4305 template<
typename BasicJsonType,
typename CompatibleNumberUnsignedType,
4306 enable_if_t<is_compatible_integer_type<typename BasicJsonType::number_unsigned_t, CompatibleNumberUnsignedType>::value,
int> = 0>
4307 void to_json(BasicJsonType& j, CompatibleNumberUnsignedType val) noexcept
4309 external_constructor<value_t::number_unsigned>::construct(j,
static_cast<typename BasicJsonType::number_unsigned_t
>(val));
4312 template<
typename BasicJsonType,
typename CompatibleNumberIntegerType,
4313 enable_if_t<is_compatible_integer_type<typename BasicJsonType::number_integer_t, CompatibleNumberIntegerType>::value,
int> = 0>
4314 void to_json(BasicJsonType& j, CompatibleNumberIntegerType val) noexcept
4316 external_constructor<value_t::number_integer>::construct(j,
static_cast<typename BasicJsonType::number_integer_t
>(val));
4319 template<
typename BasicJsonType,
typename EnumType,
4320 enable_if_t<std::is_enum<EnumType>::value,
int> = 0>
4321 void to_json(BasicJsonType& j, EnumType e) noexcept
4323 using underlying_type =
typename std::underlying_type<EnumType>::type;
4324 external_constructor<value_t::number_integer>::construct(j,
static_cast<underlying_type
>(e));
4327 template<
typename BasicJsonType>
4328 void to_json(BasicJsonType& j,
const std::vector<bool>& e)
4330 external_constructor<value_t::array>::construct(j, e);
4333 template <
typename BasicJsonType,
typename CompatibleArrayType,
4334 enable_if_t < is_compatible_array_type<BasicJsonType,
4335 CompatibleArrayType>::value&&
4336 !is_compatible_object_type<BasicJsonType, CompatibleArrayType>::value&&
4337 !is_compatible_string_type<BasicJsonType, CompatibleArrayType>::value&&
4338 !std::is_same<typename BasicJsonType::binary_t, CompatibleArrayType>::value&&
4339 !is_basic_json<CompatibleArrayType>::value,
4341 void to_json(BasicJsonType& j,
const CompatibleArrayType& arr)
4343 external_constructor<value_t::array>::construct(j, arr);
4346 template<
typename BasicJsonType>
4347 void to_json(BasicJsonType& j,
const typename BasicJsonType::binary_t& bin)
4349 external_constructor<value_t::binary>::construct(j, bin);
4352 template<
typename BasicJsonType,
typename T,
4353 enable_if_t<std::is_convertible<T, BasicJsonType>::value,
int> = 0>
4354 void to_json(BasicJsonType& j,
const std::valarray<T>& arr)
4356 external_constructor<value_t::array>::construct(j, std::move(arr));
4359 template<
typename BasicJsonType>
4360 void to_json(BasicJsonType& j,
typename BasicJsonType::array_t&& arr)
4362 external_constructor<value_t::array>::construct(j, std::move(arr));
4365 template <
typename BasicJsonType,
typename CompatibleObjectType,
4366 enable_if_t < is_compatible_object_type<BasicJsonType, CompatibleObjectType>::value&& !is_basic_json<CompatibleObjectType>::value,
int > = 0 >
4367 void to_json(BasicJsonType& j,
const CompatibleObjectType& obj)
4369 external_constructor<value_t::object>::construct(j, obj);
4372 template<
typename BasicJsonType>
4373 void to_json(BasicJsonType& j,
typename BasicJsonType::object_t&& obj)
4375 external_constructor<value_t::object>::construct(j, std::move(obj));
4379 typename BasicJsonType,
typename T, std::size_t N,
4380 enable_if_t < !std::is_constructible<
typename BasicJsonType::string_t,
4381 const T(&)[N]>::value,
4383 void to_json(BasicJsonType& j,
const T(&arr)[N])
4385 external_constructor<value_t::array>::construct(j, arr);
4388 template < typename BasicJsonType, typename T1, typename T2, enable_if_t < std::is_constructible<BasicJsonType, T1>::value&& std::is_constructible<BasicJsonType, T2>::value,
int > = 0 >
4389 void to_json(BasicJsonType& j,
const std::pair<T1, T2>& p)
4391 j = { p.first, p.second };
4395 template<
typename BasicJsonType,
typename T,
4396 enable_if_t<std::is_same<T, iteration_proxy_value<typename BasicJsonType::iterator>>::value,
int> = 0>
4397 void to_json(BasicJsonType& j,
const T& b)
4399 j = { {b.key(), b.value()} };
4402 template<
typename BasicJsonType,
typename Tuple, std::size_t... Idx>
4403 void to_json_tuple_impl(BasicJsonType& j,
const Tuple& t, index_sequence<Idx...> )
4405 j = { std::get<Idx>(t)... };
4408 template<typename BasicJsonType, typename T, enable_if_t<is_constructible_tuple<BasicJsonType, T>::value,
int > = 0>
4409 void to_json(BasicJsonType& j,
const T& t)
4411 to_json_tuple_impl(j, t, make_index_sequence<std::tuple_size<T>::value> {});
4416 template<
typename BasicJsonType,
typename T>
4417 auto operator()(BasicJsonType& j, T&& val)
const noexcept(noexcept(to_json(j, std::forward<T>(val))))
4418 -> decltype(to_json(j, std::forward<T>(val)),
void())
4420 return to_json(j, std::forward<T>(val));
4436 template<
typename,
typename>
4448 template<
typename BasicJsonType,
typename ValueType>
4449 static auto from_json(BasicJsonType&& j, ValueType& val) noexcept(
4450 noexcept(::nlohmann::from_json(std::forward<BasicJsonType>(j), val)))
4451 -> decltype(::nlohmann::from_json(std::forward<BasicJsonType>(j), val),
void())
4453 ::nlohmann::from_json(std::forward<BasicJsonType>(j), val);
4465 template<
typename BasicJsonType,
typename ValueType>
4466 static auto to_json(BasicJsonType& j, ValueType&& val) noexcept(
4467 noexcept(::nlohmann::to_json(j, std::forward<ValueType>(val))))
4468 -> decltype(::nlohmann::to_json(j, std::forward<ValueType>(val)),
void())
4470 ::nlohmann::to_json(j, std::forward<ValueType>(val));
4499 template<
typename BinaryType>
4521 , m_has_subtype(true)
4527 , m_has_subtype(true)
4530 bool operator==(
const byte_container_with_subtype& rhs)
const
4532 return std::tie(
static_cast<const BinaryType&
>(*
this), m_subtype, m_has_subtype) ==
4533 std::tie(
static_cast<const BinaryType&
>(rhs), rhs.m_subtype, rhs.m_has_subtype);
4536 bool operator!=(
const byte_container_with_subtype& rhs)
const
4538 return !(rhs == *
this);
4562 m_has_subtype =
true;
4609 return m_has_subtype;
4634 m_has_subtype =
false;
4638 std::uint8_t m_subtype = 0;
4639 bool m_has_subtype =
false;
4654 #include <functional>
4662 inline std::size_t combine(std::size_t seed, std::size_t h) noexcept
4664 seed ^= h + 0x9e3779b9 + (seed << 6U) + (seed >> 2U);
4679 template<
typename BasicJsonType>
4680 std::size_t
hash(
const BasicJsonType& j)
4682 using string_t =
typename BasicJsonType::string_t;
4683 using number_integer_t =
typename BasicJsonType::number_integer_t;
4684 using number_unsigned_t =
typename BasicJsonType::number_unsigned_t;
4685 using number_float_t =
typename BasicJsonType::number_float_t;
4687 const auto type =
static_cast<std::size_t
>(j.type());
4690 case BasicJsonType::value_t::null:
4691 case BasicJsonType::value_t::discarded:
4693 return combine(type, 0);
4696 case BasicJsonType::value_t::object:
4698 auto seed = combine(type, j.size());
4699 for (
const auto& element : j.items())
4701 const auto h = std::hash<string_t> {}(element.key());
4702 seed = combine(seed, h);
4703 seed = combine(seed,
hash(element.value()));
4708 case BasicJsonType::value_t::array:
4710 auto seed = combine(type, j.size());
4711 for (
const auto& element : j)
4713 seed = combine(seed,
hash(element));
4718 case BasicJsonType::value_t::string:
4720 const auto h = std::hash<string_t> {}(j.template get_ref<const string_t&>());
4721 return combine(type, h);
4724 case BasicJsonType::value_t::boolean:
4726 const auto h = std::hash<bool> {}(j.template get<bool>());
4727 return combine(type, h);
4730 case BasicJsonType::value_t::number_integer:
4732 const auto h = std::hash<number_integer_t> {}(j.template get<number_integer_t>());
4733 return combine(type, h);
4736 case BasicJsonType::value_t::number_unsigned:
4738 const auto h = std::hash<number_unsigned_t> {}(j.template get<number_unsigned_t>());
4739 return combine(type, h);
4742 case BasicJsonType::value_t::number_float:
4744 const auto h = std::hash<number_float_t> {}(j.template get<number_float_t>());
4745 return combine(type, h);
4748 case BasicJsonType::value_t::binary:
4750 auto seed = combine(type, j.get_binary().size());
4751 const auto h = std::hash<bool> {}(j.get_binary().has_subtype());
4752 seed = combine(seed, h);
4753 seed = combine(seed, j.get_binary().subtype());
4754 for (
const auto byte : j.get_binary())
4756 seed = combine(seed, std::hash<std::uint8_t> {}(byte));
4773 #include <algorithm>
4799 #include <type_traits>
4825 using char_type = char;
4827 JSON_HEDLEY_NON_NULL(2)
4838 std::char_traits<char>::int_type get_character() noexcept
4840 return std::fgetc(m_file);
4861 using char_type = char;
4869 is->clear(is->rdstate() & std::ios::eofbit);
4874 : is(&i), sb(i.rdbuf())
4891 std::char_traits<char>::int_type get_character()
4893 auto res = sb->sbumpc();
4895 if (JSON_HEDLEY_UNLIKELY(res == EOF))
4897 is->clear(is->rdstate() | std::ios::eofbit);
4904 std::istream* is =
nullptr;
4905 std::streambuf* sb =
nullptr;
4910 template<
typename IteratorType>
4914 using char_type =
typename std::iterator_traits<IteratorType>::value_type;
4917 : current(std::move(first)), end(std::move(last)) {}
4919 typename std::char_traits<char_type>::int_type get_character()
4921 if (JSON_HEDLEY_LIKELY(current != end))
4923 auto result = std::char_traits<char_type>::to_int_type(*current);
4924 std::advance(current, 1);
4929 return std::char_traits<char_type>::eof();
4934 IteratorType current;
4937 template<
typename BaseInputAdapter,
size_t T>
4942 return current == end;
4948 template<
typename BaseInputAdapter,
size_t T>
4951 template<
typename BaseInputAdapter>
4955 static void fill_buffer(BaseInputAdapter& input,
4956 std::array<std::char_traits<char>::int_type, 4>& utf8_bytes,
4957 size_t& utf8_bytes_index,
4958 size_t& utf8_bytes_filled)
4960 utf8_bytes_index = 0;
4962 if (JSON_HEDLEY_UNLIKELY(input.empty()))
4964 utf8_bytes[0] = std::char_traits<char>::eof();
4965 utf8_bytes_filled = 1;
4970 const auto wc = input.get_character();
4975 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(wc);
4976 utf8_bytes_filled = 1;
4978 else if (wc <= 0x7FF)
4980 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(0xC0u | ((
static_cast<unsigned int>(wc) >> 6u) & 0x1Fu));
4981 utf8_bytes[1] =
static_cast<std::char_traits<char>::int_type
>(0x80u | (
static_cast<unsigned int>(wc) & 0x3Fu));
4982 utf8_bytes_filled = 2;
4984 else if (wc <= 0xFFFF)
4986 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(0xE0u | ((
static_cast<unsigned int>(wc) >> 12u) & 0x0Fu));
4987 utf8_bytes[1] =
static_cast<std::char_traits<char>::int_type
>(0x80u | ((
static_cast<unsigned int>(wc) >> 6u) & 0x3Fu));
4988 utf8_bytes[2] =
static_cast<std::char_traits<char>::int_type
>(0x80u | (
static_cast<unsigned int>(wc) & 0x3Fu));
4989 utf8_bytes_filled = 3;
4991 else if (wc <= 0x10FFFF)
4993 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(0xF0u | ((
static_cast<unsigned int>(wc) >> 18u) & 0x07u));
4994 utf8_bytes[1] =
static_cast<std::char_traits<char>::int_type
>(0x80u | ((
static_cast<unsigned int>(wc) >> 12u) & 0x3Fu));
4995 utf8_bytes[2] =
static_cast<std::char_traits<char>::int_type
>(0x80u | ((
static_cast<unsigned int>(wc) >> 6u) & 0x3Fu));
4996 utf8_bytes[3] =
static_cast<std::char_traits<char>::int_type
>(0x80u | (
static_cast<unsigned int>(wc) & 0x3Fu));
4997 utf8_bytes_filled = 4;
5002 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(wc);
5003 utf8_bytes_filled = 1;
5009 template<
typename BaseInputAdapter>
5013 static void fill_buffer(BaseInputAdapter& input,
5014 std::array<std::char_traits<char>::int_type, 4>& utf8_bytes,
5015 size_t& utf8_bytes_index,
5016 size_t& utf8_bytes_filled)
5018 utf8_bytes_index = 0;
5020 if (JSON_HEDLEY_UNLIKELY(input.empty()))
5022 utf8_bytes[0] = std::char_traits<char>::eof();
5023 utf8_bytes_filled = 1;
5028 const auto wc = input.get_character();
5033 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(wc);
5034 utf8_bytes_filled = 1;
5036 else if (wc <= 0x7FF)
5038 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(0xC0u | ((
static_cast<unsigned int>(wc) >> 6u)));
5039 utf8_bytes[1] =
static_cast<std::char_traits<char>::int_type
>(0x80u | (
static_cast<unsigned int>(wc) & 0x3Fu));
5040 utf8_bytes_filled = 2;
5042 else if (0xD800 > wc || wc >= 0xE000)
5044 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(0xE0u | ((
static_cast<unsigned int>(wc) >> 12u)));
5045 utf8_bytes[1] =
static_cast<std::char_traits<char>::int_type
>(0x80u | ((
static_cast<unsigned int>(wc) >> 6u) & 0x3Fu));
5046 utf8_bytes[2] =
static_cast<std::char_traits<char>::int_type
>(0x80u | (
static_cast<unsigned int>(wc) & 0x3Fu));
5047 utf8_bytes_filled = 3;
5051 if (JSON_HEDLEY_UNLIKELY(!input.empty()))
5053 const auto wc2 =
static_cast<unsigned int>(input.get_character());
5054 const auto charcode = 0x10000u + (((
static_cast<unsigned int>(wc) & 0x3FFu) << 10u) | (wc2 & 0x3FFu));
5055 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(0xF0u | (charcode >> 18u));
5056 utf8_bytes[1] =
static_cast<std::char_traits<char>::int_type
>(0x80u | ((charcode >> 12u) & 0x3Fu));
5057 utf8_bytes[2] =
static_cast<std::char_traits<char>::int_type
>(0x80u | ((charcode >> 6u) & 0x3Fu));
5058 utf8_bytes[3] =
static_cast<std::char_traits<char>::int_type
>(0x80u | (charcode & 0x3Fu));
5059 utf8_bytes_filled = 4;
5063 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(wc);
5064 utf8_bytes_filled = 1;
5072 template<
typename BaseInputAdapter,
typename W
ideCharType>
5076 using char_type = char;
5079 : base_adapter(base) {}
5081 typename std::char_traits<char>::int_type get_character() noexcept
5084 if (utf8_bytes_index == utf8_bytes_filled)
5086 fill_buffer<sizeof(WideCharType)>();
5088 JSON_ASSERT(utf8_bytes_filled > 0);
5089 JSON_ASSERT(utf8_bytes_index == 0);
5093 JSON_ASSERT(utf8_bytes_filled > 0);
5094 JSON_ASSERT(utf8_bytes_index < utf8_bytes_filled);
5095 return utf8_bytes[utf8_bytes_index++];
5099 BaseInputAdapter base_adapter;
5108 std::array<std::char_traits<char>::int_type, 4> utf8_bytes = {{0, 0, 0, 0}};
5111 std::size_t utf8_bytes_index = 0;
5113 std::size_t utf8_bytes_filled = 0;
5117 template<
typename IteratorType,
typename Enable =
void>
5120 using iterator_type = IteratorType;
5121 using char_type =
typename std::iterator_traits<iterator_type>::value_type;
5124 static adapter_type create(IteratorType first, IteratorType last)
5126 return adapter_type(std::move(first), std::move(last));
5130 template<
typename T>
5133 using value_type =
typename std::iterator_traits<T>::value_type;
5136 value =
sizeof(value_type) > 1
5140 template<
typename IteratorType>
5143 using iterator_type = IteratorType;
5144 using char_type =
typename std::iterator_traits<iterator_type>::value_type;
5148 static adapter_type create(IteratorType first, IteratorType last)
5155 template<
typename IteratorType>
5159 return factory_type::create(first, last);
5163 template<
typename ContainerType>
5164 auto input_adapter(
const ContainerType& container) -> decltype(input_adapter(begin(container), end(container)))
5170 return input_adapter(begin(container), end(container));
5174 inline file_input_adapter input_adapter(std::FILE* file)
5176 return file_input_adapter(file);
5179 inline input_stream_adapter input_adapter(std::istream& stream)
5181 return input_stream_adapter(stream);
5184 inline input_stream_adapter input_adapter(std::istream&& stream)
5186 return input_stream_adapter(stream);
5189 using contiguous_bytes_input_adapter = decltype(input_adapter(std::declval<const char*>(), std::declval<const char*>()));
5192 template <
typename CharT,
5193 typename std::enable_if <
5194 std::is_pointer<CharT>::value&&
5195 !std::is_array<CharT>::value&&
5196 std::is_integral<typename std::remove_pointer<CharT>::type>::value&&
5197 sizeof(
typename std::remove_pointer<CharT>::type) == 1,
5199 contiguous_bytes_input_adapter input_adapter(CharT b)
5201 auto length = std::strlen(
reinterpret_cast<const char*
>(b));
5202 const auto* ptr =
reinterpret_cast<const char*
>(b);
5203 return input_adapter(ptr, ptr + length);
5206 template<
typename T, std::
size_t N>
5207 auto input_adapter(T (&array)[N]) -> decltype(input_adapter(array, array + N))
5209 return input_adapter(array, array + N);
5218 template <
typename CharT,
5219 typename std::enable_if <
5220 std::is_pointer<CharT>::value&&
5221 std::is_integral<typename std::remove_pointer<CharT>::type>::value&&
5222 sizeof(
typename std::remove_pointer<CharT>::type) == 1,
5225 : ia(
reinterpret_cast<const char*
>(b),
reinterpret_cast<const char*
>(b) + l) {}
5227 template<
class IteratorType,
5228 typename std::enable_if<
5229 std::is_same<typename iterator_traits<IteratorType>::iterator_category, std::random_access_iterator_tag>::value,
5232 : ia(input_adapter(first, last)) {}
5234 contiguous_bytes_input_adapter&& get()
5236 return std::move(ia);
5240 contiguous_bytes_input_adapter ia;
5269 template<
typename BasicJsonType>
5272 using number_integer_t =
typename BasicJsonType::number_integer_t;
5273 using number_unsigned_t =
typename BasicJsonType::number_unsigned_t;
5274 using number_float_t =
typename BasicJsonType::number_float_t;
5275 using string_t =
typename BasicJsonType::string_t;
5276 using binary_t =
typename BasicJsonType::binary_t;
5282 virtual bool null() = 0;
5343 virtual bool key(string_t& val) = 0;
5373 const std::string& last_token,
5395 template<
typename BasicJsonType>
5399 using number_integer_t =
typename BasicJsonType::number_integer_t;
5400 using number_unsigned_t =
typename BasicJsonType::number_unsigned_t;
5401 using number_float_t =
typename BasicJsonType::number_float_t;
5402 using string_t =
typename BasicJsonType::string_t;
5403 using binary_t =
typename BasicJsonType::binary_t;
5411 : root(r), allow_exceptions(allow_exceptions_)
5423 handle_value(
nullptr);
5427 bool boolean(
bool val)
5433 bool number_integer(number_integer_t val)
5439 bool number_unsigned(number_unsigned_t val)
5445 bool number_float(number_float_t val,
const string_t& )
5451 bool string(string_t& val)
5457 bool binary(binary_t& val)
5459 handle_value(std::move(val));
5463 bool start_object(std::size_t len)
5465 ref_stack.push_back(handle_value(BasicJsonType::value_t::object));
5467 if (JSON_HEDLEY_UNLIKELY(len != std::size_t(-1) && len > ref_stack.back()->max_size()))
5469 JSON_THROW(out_of_range::create(408,
5470 "excessive object size: " + std::to_string(len)));
5476 bool key(string_t& val)
5479 object_element = &(ref_stack.back()->m_value.object->operator[](val));
5485 ref_stack.pop_back();
5489 bool start_array(std::size_t len)
5491 ref_stack.push_back(handle_value(BasicJsonType::value_t::array));
5493 if (JSON_HEDLEY_UNLIKELY(len != std::size_t(-1) && len > ref_stack.back()->max_size()))
5495 JSON_THROW(out_of_range::create(408,
5496 "excessive array size: " + std::to_string(len)));
5504 ref_stack.pop_back();
5508 template<
class Exception>
5509 bool parse_error(std::size_t ,
const std::string& ,
5510 const Exception& ex)
5513 static_cast<void>(ex);
5514 if (allow_exceptions)
5521 constexpr
bool is_errored()
const
5533 template<
typename Value>
5534 JSON_HEDLEY_RETURNS_NON_NULL
5535 BasicJsonType* handle_value(Value&& v)
5537 if (ref_stack.empty())
5539 root = BasicJsonType(std::forward<Value>(v));
5543 JSON_ASSERT(ref_stack.back()->is_array() || ref_stack.back()->is_object());
5545 if (ref_stack.back()->is_array())
5547 ref_stack.back()->m_value.array->emplace_back(std::forward<Value>(v));
5548 return &(ref_stack.back()->m_value.array->back());
5551 JSON_ASSERT(ref_stack.back()->is_object());
5552 JSON_ASSERT(object_element);
5553 *object_element = BasicJsonType(std::forward<Value>(v));
5554 return object_element;
5558 BasicJsonType& root;
5560 std::vector<BasicJsonType*> ref_stack {};
5562 BasicJsonType* object_element =
nullptr;
5564 bool errored =
false;
5566 const bool allow_exceptions =
true;
5569 template<
typename BasicJsonType>
5573 using number_integer_t =
typename BasicJsonType::number_integer_t;
5574 using number_unsigned_t =
typename BasicJsonType::number_unsigned_t;
5575 using number_float_t =
typename BasicJsonType::number_float_t;
5576 using string_t =
typename BasicJsonType::string_t;
5577 using binary_t =
typename BasicJsonType::binary_t;
5578 using parser_callback_t =
typename BasicJsonType::parser_callback_t;
5579 using parse_event_t =
typename BasicJsonType::parse_event_t;
5582 const parser_callback_t cb,
5583 const bool allow_exceptions_ =
true)
5584 : root(r), callback(cb), allow_exceptions(allow_exceptions_)
5586 keep_stack.push_back(
true);
5598 handle_value(
nullptr);
5602 bool boolean(
bool val)
5608 bool number_integer(number_integer_t val)
5614 bool number_unsigned(number_unsigned_t val)
5620 bool number_float(number_float_t val,
const string_t& )
5626 bool string(string_t& val)
5632 bool binary(binary_t& val)
5634 handle_value(std::move(val));
5638 bool start_object(std::size_t len)
5641 const bool keep = callback(
static_cast<int>(ref_stack.size()), parse_event_t::object_start, discarded);
5642 keep_stack.push_back(keep);
5644 auto val = handle_value(BasicJsonType::value_t::object,
true);
5645 ref_stack.push_back(val.second);
5648 if (ref_stack.back() && JSON_HEDLEY_UNLIKELY(len != std::size_t(-1) && len > ref_stack.back()->max_size()))
5650 JSON_THROW(out_of_range::create(408,
"excessive object size: " + std::to_string(len)));
5656 bool key(string_t& val)
5658 BasicJsonType k = BasicJsonType(val);
5661 const bool keep = callback(
static_cast<int>(ref_stack.size()),
parse_event_t::key, k);
5662 key_keep_stack.push_back(keep);
5665 if (keep && ref_stack.back())
5667 object_element = &(ref_stack.back()->m_value.object->operator[](val) = discarded);
5675 if (ref_stack.back() && !callback(
static_cast<int>(ref_stack.size()) - 1, parse_event_t::object_end, *ref_stack.back()))
5678 *ref_stack.back() = discarded;
5681 JSON_ASSERT(!ref_stack.empty());
5682 JSON_ASSERT(!keep_stack.empty());
5683 ref_stack.pop_back();
5684 keep_stack.pop_back();
5686 if (!ref_stack.empty() && ref_stack.back() && ref_stack.back()->is_structured())
5689 for (
auto it = ref_stack.back()->begin(); it != ref_stack.back()->end(); ++it)
5691 if (it->is_discarded())
5693 ref_stack.back()->erase(it);
5702 bool start_array(std::size_t len)
5704 const bool keep = callback(
static_cast<int>(ref_stack.size()), parse_event_t::array_start, discarded);
5705 keep_stack.push_back(keep);
5707 auto val = handle_value(BasicJsonType::value_t::array,
true);
5708 ref_stack.push_back(val.second);
5711 if (ref_stack.back() && JSON_HEDLEY_UNLIKELY(len != std::size_t(-1) && len > ref_stack.back()->max_size()))
5713 JSON_THROW(out_of_range::create(408,
"excessive array size: " + std::to_string(len)));
5723 if (ref_stack.back())
5725 keep = callback(
static_cast<int>(ref_stack.size()) - 1, parse_event_t::array_end, *ref_stack.back());
5729 *ref_stack.back() = discarded;
5733 JSON_ASSERT(!ref_stack.empty());
5734 JSON_ASSERT(!keep_stack.empty());
5735 ref_stack.pop_back();
5736 keep_stack.pop_back();
5739 if (!keep && !ref_stack.empty() && ref_stack.back()->is_array())
5741 ref_stack.back()->m_value.array->pop_back();
5747 template<
class Exception>
5748 bool parse_error(std::size_t ,
const std::string& ,
5749 const Exception& ex)
5752 static_cast<void>(ex);
5753 if (allow_exceptions)
5760 constexpr
bool is_errored()
const
5781 template<
typename Value>
5782 std::pair<bool, BasicJsonType*> handle_value(Value&& v,
const bool skip_callback =
false)
5784 JSON_ASSERT(!keep_stack.empty());
5788 if (!keep_stack.back())
5790 return {
false,
nullptr};
5794 auto value = BasicJsonType(std::forward<Value>(v));
5802 return {
false,
nullptr};
5805 if (ref_stack.empty())
5807 root = std::move(
value);
5808 return {
true, &root};
5813 if (!ref_stack.back())
5815 return {
false,
nullptr};
5819 JSON_ASSERT(ref_stack.back()->is_array() || ref_stack.back()->is_object());
5822 if (ref_stack.back()->is_array())
5824 ref_stack.back()->m_value.array->push_back(std::move(
value));
5825 return {
true, &(ref_stack.back()->m_value.array->back())};
5829 JSON_ASSERT(ref_stack.back()->is_object());
5831 JSON_ASSERT(!key_keep_stack.empty());
5832 const bool store_element = key_keep_stack.back();
5833 key_keep_stack.pop_back();
5837 return {
false,
nullptr};
5840 JSON_ASSERT(object_element);
5841 *object_element = std::move(
value);
5842 return {
true, object_element};
5846 BasicJsonType& root;
5848 std::vector<BasicJsonType*> ref_stack {};
5850 std::vector<bool> keep_stack {};
5852 std::vector<bool> key_keep_stack {};
5854 BasicJsonType* object_element =
nullptr;
5856 bool errored =
false;
5858 const parser_callback_t callback =
nullptr;
5860 const bool allow_exceptions =
true;
5862 BasicJsonType discarded = BasicJsonType::value_t::discarded;
5865 template<
typename BasicJsonType>
5869 using number_integer_t =
typename BasicJsonType::number_integer_t;
5870 using number_unsigned_t =
typename BasicJsonType::number_unsigned_t;
5871 using number_float_t =
typename BasicJsonType::number_float_t;
5872 using string_t =
typename BasicJsonType::string_t;
5873 using binary_t =
typename BasicJsonType::binary_t;
5885 bool number_integer(number_integer_t )
5890 bool number_unsigned(number_unsigned_t )
5895 bool number_float(number_float_t ,
const string_t& )
5900 bool string(string_t& )
5905 bool binary(binary_t& )
5910 bool start_object(std::size_t = std::size_t(-1))
5915 bool key(string_t& )
5925 bool start_array(std::size_t = std::size_t(-1))
5952 #include <initializer_list>
5972 template<
typename BasicJsonType>
5999 JSON_HEDLEY_RETURNS_NON_NULL
6006 return "<uninitialized>";
6008 return "true literal";
6010 return "false literal";
6012 return "null literal";
6014 return "string literal";
6018 return "number literal";
6032 return "<parse error>";
6034 return "end of input";
6036 return "'[', '{', or a literal";
6039 return "unknown token";
6049 template<
typename BasicJsonType,
typename InputAdapterType>
6052 using number_integer_t =
typename BasicJsonType::number_integer_t;
6053 using number_unsigned_t =
typename BasicJsonType::number_unsigned_t;
6054 using number_float_t =
typename BasicJsonType::number_float_t;
6055 using string_t =
typename BasicJsonType::string_t;
6056 using char_type =
typename InputAdapterType::char_type;
6057 using char_int_type =
typename std::char_traits<char_type>::int_type;
6062 explicit lexer(InputAdapterType&& adapter,
bool ignore_comments_ =
false)
6063 : ia(std::move(adapter))
6064 , ignore_comments(ignore_comments_)
6065 , decimal_point_char(
static_cast<char_int_type
>(get_decimal_point()))
6082 static char get_decimal_point() noexcept
6084 const auto* loc = localeconv();
6085 JSON_ASSERT(loc !=
nullptr);
6086 return (loc->decimal_point ==
nullptr) ?
'.' : *(loc->decimal_point);
6111 JSON_ASSERT(current ==
'u');
6114 const auto factors = { 12u, 8u, 4u, 0u };
6115 for (
const auto factor : factors)
6119 if (current >=
'0' && current <=
'9')
6121 codepoint +=
static_cast<int>((
static_cast<unsigned int>(current) - 0x30u) << factor);
6123 else if (current >=
'A' && current <=
'F')
6125 codepoint +=
static_cast<int>((
static_cast<unsigned int>(current) - 0x37u) << factor);
6127 else if (current >=
'a' && current <=
'f')
6129 codepoint +=
static_cast<int>((
static_cast<unsigned int>(current) - 0x57u) << factor);
6137 JSON_ASSERT(0x0000 <= codepoint && codepoint <= 0xFFFF);
6156 bool next_byte_in_range(std::initializer_list<char_int_type> ranges)
6158 JSON_ASSERT(ranges.size() == 2 || ranges.size() == 4 || ranges.size() == 6);
6161 for (
auto range = ranges.begin(); range != ranges.end(); ++range)
6164 if (JSON_HEDLEY_LIKELY(*range <= current && current <= *(++range)))
6170 error_message =
"invalid string: ill-formed UTF-8 byte";
6199 JSON_ASSERT(current ==
'\"');
6207 case std::char_traits<char_type>::eof():
6209 error_message =
"invalid string: missing closing quote";
6210 return token_type::parse_error;
6216 return token_type::value_string;
6260 const int codepoint1 = get_codepoint();
6261 int codepoint = codepoint1;
6263 if (JSON_HEDLEY_UNLIKELY(codepoint1 == -1))
6265 error_message =
"invalid string: '\\u' must be followed by 4 hex digits";
6266 return token_type::parse_error;
6270 if (0xD800 <= codepoint1 && codepoint1 <= 0xDBFF)
6273 if (JSON_HEDLEY_LIKELY(get() ==
'\\' && get() ==
'u'))
6275 const int codepoint2 = get_codepoint();
6277 if (JSON_HEDLEY_UNLIKELY(codepoint2 == -1))
6279 error_message =
"invalid string: '\\u' must be followed by 4 hex digits";
6280 return token_type::parse_error;
6284 if (JSON_HEDLEY_LIKELY(0xDC00 <= codepoint2 && codepoint2 <= 0xDFFF))
6287 codepoint =
static_cast<int>(
6289 (
static_cast<unsigned int>(codepoint1) << 10u)
6291 +
static_cast<unsigned int>(codepoint2)
6299 error_message =
"invalid string: surrogate U+D800..U+DBFF must be followed by U+DC00..U+DFFF";
6300 return token_type::parse_error;
6305 error_message =
"invalid string: surrogate U+D800..U+DBFF must be followed by U+DC00..U+DFFF";
6306 return token_type::parse_error;
6311 if (JSON_HEDLEY_UNLIKELY(0xDC00 <= codepoint1 && codepoint1 <= 0xDFFF))
6313 error_message =
"invalid string: surrogate U+DC00..U+DFFF must follow U+D800..U+DBFF";
6314 return token_type::parse_error;
6319 JSON_ASSERT(0x00 <= codepoint && codepoint <= 0x10FFFF);
6322 if (codepoint < 0x80)
6325 add(
static_cast<char_int_type
>(codepoint));
6327 else if (codepoint <= 0x7FF)
6330 add(
static_cast<char_int_type
>(0xC0u | (
static_cast<unsigned int>(codepoint) >> 6u)));
6331 add(
static_cast<char_int_type
>(0x80u | (
static_cast<unsigned int>(codepoint) & 0x3Fu)));
6333 else if (codepoint <= 0xFFFF)
6336 add(
static_cast<char_int_type
>(0xE0u | (
static_cast<unsigned int>(codepoint) >> 12u)));
6337 add(
static_cast<char_int_type
>(0x80u | ((
static_cast<unsigned int>(codepoint) >> 6u) & 0x3Fu)));
6338 add(
static_cast<char_int_type
>(0x80u | (
static_cast<unsigned int>(codepoint) & 0x3Fu)));
6343 add(
static_cast<char_int_type
>(0xF0u | (
static_cast<unsigned int>(codepoint) >> 18u)));
6344 add(
static_cast<char_int_type
>(0x80u | ((
static_cast<unsigned int>(codepoint) >> 12u) & 0x3Fu)));
6345 add(
static_cast<char_int_type
>(0x80u | ((
static_cast<unsigned int>(codepoint) >> 6u) & 0x3Fu)));
6346 add(
static_cast<char_int_type
>(0x80u | (
static_cast<unsigned int>(codepoint) & 0x3Fu)));
6354 error_message =
"invalid string: forbidden character after backslash";
6355 return token_type::parse_error;
6364 error_message =
"invalid string: control character U+0000 (NUL) must be escaped to \\u0000";
6365 return token_type::parse_error;
6370 error_message =
"invalid string: control character U+0001 (SOH) must be escaped to \\u0001";
6371 return token_type::parse_error;
6376 error_message =
"invalid string: control character U+0002 (STX) must be escaped to \\u0002";
6377 return token_type::parse_error;
6382 error_message =
"invalid string: control character U+0003 (ETX) must be escaped to \\u0003";
6383 return token_type::parse_error;
6388 error_message =
"invalid string: control character U+0004 (EOT) must be escaped to \\u0004";
6389 return token_type::parse_error;
6394 error_message =
"invalid string: control character U+0005 (ENQ) must be escaped to \\u0005";
6395 return token_type::parse_error;
6400 error_message =
"invalid string: control character U+0006 (ACK) must be escaped to \\u0006";
6401 return token_type::parse_error;
6406 error_message =
"invalid string: control character U+0007 (BEL) must be escaped to \\u0007";
6407 return token_type::parse_error;
6412 error_message =
"invalid string: control character U+0008 (BS) must be escaped to \\u0008 or \\b";
6413 return token_type::parse_error;
6418 error_message =
"invalid string: control character U+0009 (HT) must be escaped to \\u0009 or \\t";
6419 return token_type::parse_error;
6424 error_message =
"invalid string: control character U+000A (LF) must be escaped to \\u000A or \\n";
6425 return token_type::parse_error;
6430 error_message =
"invalid string: control character U+000B (VT) must be escaped to \\u000B";
6431 return token_type::parse_error;
6436 error_message =
"invalid string: control character U+000C (FF) must be escaped to \\u000C or \\f";
6437 return token_type::parse_error;
6442 error_message =
"invalid string: control character U+000D (CR) must be escaped to \\u000D or \\r";
6443 return token_type::parse_error;
6448 error_message =
"invalid string: control character U+000E (SO) must be escaped to \\u000E";
6449 return token_type::parse_error;
6454 error_message =
"invalid string: control character U+000F (SI) must be escaped to \\u000F";
6455 return token_type::parse_error;
6460 error_message =
"invalid string: control character U+0010 (DLE) must be escaped to \\u0010";
6461 return token_type::parse_error;
6466 error_message =
"invalid string: control character U+0011 (DC1) must be escaped to \\u0011";
6467 return token_type::parse_error;
6472 error_message =
"invalid string: control character U+0012 (DC2) must be escaped to \\u0012";
6473 return token_type::parse_error;
6478 error_message =
"invalid string: control character U+0013 (DC3) must be escaped to \\u0013";
6479 return token_type::parse_error;
6484 error_message =
"invalid string: control character U+0014 (DC4) must be escaped to \\u0014";
6485 return token_type::parse_error;
6490 error_message =
"invalid string: control character U+0015 (NAK) must be escaped to \\u0015";
6491 return token_type::parse_error;
6496 error_message =
"invalid string: control character U+0016 (SYN) must be escaped to \\u0016";
6497 return token_type::parse_error;
6502 error_message =
"invalid string: control character U+0017 (ETB) must be escaped to \\u0017";
6503 return token_type::parse_error;
6508 error_message =
"invalid string: control character U+0018 (CAN) must be escaped to \\u0018";
6509 return token_type::parse_error;
6514 error_message =
"invalid string: control character U+0019 (EM) must be escaped to \\u0019";
6515 return token_type::parse_error;
6520 error_message =
"invalid string: control character U+001A (SUB) must be escaped to \\u001A";
6521 return token_type::parse_error;
6526 error_message =
"invalid string: control character U+001B (ESC) must be escaped to \\u001B";
6527 return token_type::parse_error;
6532 error_message =
"invalid string: control character U+001C (FS) must be escaped to \\u001C";
6533 return token_type::parse_error;
6538 error_message =
"invalid string: control character U+001D (GS) must be escaped to \\u001D";
6539 return token_type::parse_error;
6544 error_message =
"invalid string: control character U+001E (RS) must be escaped to \\u001E";
6545 return token_type::parse_error;
6550 error_message =
"invalid string: control character U+001F (US) must be escaped to \\u001F";
6551 return token_type::parse_error;
6686 if (JSON_HEDLEY_UNLIKELY(!next_byte_in_range({0x80, 0xBF})))
6688 return token_type::parse_error;
6696 if (JSON_HEDLEY_UNLIKELY(!(next_byte_in_range({0xA0, 0xBF, 0x80, 0xBF}))))
6698 return token_type::parse_error;
6720 if (JSON_HEDLEY_UNLIKELY(!(next_byte_in_range({0x80, 0xBF, 0x80, 0xBF}))))
6722 return token_type::parse_error;
6730 if (JSON_HEDLEY_UNLIKELY(!(next_byte_in_range({0x80, 0x9F, 0x80, 0xBF}))))
6732 return token_type::parse_error;
6740 if (JSON_HEDLEY_UNLIKELY(!(next_byte_in_range({0x90, 0xBF, 0x80, 0xBF, 0x80, 0xBF}))))
6742 return token_type::parse_error;
6752 if (JSON_HEDLEY_UNLIKELY(!(next_byte_in_range({0x80, 0xBF, 0x80, 0xBF, 0x80, 0xBF}))))
6754 return token_type::parse_error;
6762 if (JSON_HEDLEY_UNLIKELY(!(next_byte_in_range({0x80, 0x8F, 0x80, 0xBF, 0x80, 0xBF}))))
6764 return token_type::parse_error;
6772 error_message =
"invalid string: ill-formed UTF-8 byte";
6773 return token_type::parse_error;
6796 case std::char_traits<char_type>::eof():
6813 case std::char_traits<char_type>::eof():
6816 error_message =
"invalid comment; missing closing '*/'";
6844 error_message =
"invalid comment; expecting '/' or '*' after '/'";
6850 JSON_HEDLEY_NON_NULL(2)
6851 static void strtof(
float& f,
const char* str,
char** endptr) noexcept
6853 f = std::strtof(str, endptr);
6856 JSON_HEDLEY_NON_NULL(2)
6857 static void strtof(
double& f,
const char* str,
char** endptr) noexcept
6859 f = std::strtod(str, endptr);
6862 JSON_HEDLEY_NON_NULL(2)
6863 static void strtof(
long double& f,
const char* str,
char** endptr) noexcept
6865 f = std::strtold(str, endptr);
6915 token_type number_type = token_type::value_unsigned;
6923 goto scan_number_minus;
6929 goto scan_number_zero;
6943 goto scan_number_any1;
6953 number_type = token_type::value_integer;
6959 goto scan_number_zero;
6973 goto scan_number_any1;
6978 error_message =
"invalid number; expected digit after '-'";
6979 return token_type::parse_error;
6989 add(decimal_point_char);
6990 goto scan_number_decimal1;
6997 goto scan_number_exponent;
7001 goto scan_number_done;
7020 goto scan_number_any1;
7025 add(decimal_point_char);
7026 goto scan_number_decimal1;
7033 goto scan_number_exponent;
7037 goto scan_number_done;
7040 scan_number_decimal1:
7042 number_type = token_type::value_float;
7057 goto scan_number_decimal2;
7062 error_message =
"invalid number; expected digit after '.'";
7063 return token_type::parse_error;
7067 scan_number_decimal2:
7083 goto scan_number_decimal2;
7090 goto scan_number_exponent;
7094 goto scan_number_done;
7097 scan_number_exponent:
7099 number_type = token_type::value_float;
7106 goto scan_number_sign;
7121 goto scan_number_any2;
7127 "invalid number; expected '+', '-', or digit after exponent";
7128 return token_type::parse_error;
7148 goto scan_number_any2;
7153 error_message =
"invalid number; expected digit after exponent sign";
7154 return token_type::parse_error;
7174 goto scan_number_any2;
7178 goto scan_number_done;
7186 char* endptr =
nullptr;
7190 if (number_type == token_type::value_unsigned)
7192 const auto x = std::strtoull(token_buffer.data(), &endptr, 10);
7195 JSON_ASSERT(endptr == token_buffer.data() + token_buffer.size());
7199 value_unsigned =
static_cast<number_unsigned_t
>(x);
7200 if (value_unsigned == x)
7202 return token_type::value_unsigned;
7206 else if (number_type == token_type::value_integer)
7208 const auto x = std::strtoll(token_buffer.data(), &endptr, 10);
7211 JSON_ASSERT(endptr == token_buffer.data() + token_buffer.size());
7215 value_integer =
static_cast<number_integer_t
>(x);
7216 if (value_integer == x)
7218 return token_type::value_integer;
7225 strtof(value_float, token_buffer.data(), &endptr);
7228 JSON_ASSERT(endptr == token_buffer.data() + token_buffer.size());
7230 return token_type::value_float;
7238 JSON_HEDLEY_NON_NULL(2)
7239 token_type scan_literal(
const char_type* literal_text,
const std::size_t length,
7242 JSON_ASSERT(std::char_traits<char_type>::to_char_type(current) == literal_text[0]);
7243 for (std::size_t i = 1; i < length; ++i)
7245 if (JSON_HEDLEY_UNLIKELY(std::char_traits<char_type>::to_char_type(get()) != literal_text[i]))
7247 error_message =
"invalid literal";
7248 return token_type::parse_error;
7259 void reset() noexcept
7261 token_buffer.clear();
7262 token_string.clear();
7263 token_string.push_back(std::char_traits<char_type>::to_char_type(current));
7288 current = ia.get_character();
7291 if (JSON_HEDLEY_LIKELY(current != std::char_traits<char_type>::eof()))
7293 token_string.push_back(std::char_traits<char_type>::to_char_type(current));
7296 if (current ==
'\n')
7332 if (JSON_HEDLEY_LIKELY(current != std::char_traits<char_type>::eof()))
7334 JSON_ASSERT(!token_string.empty());
7335 token_string.pop_back();
7340 void add(char_int_type c)
7342 token_buffer.push_back(
static_cast<typename string_t::value_type
>(c));
7353 return value_integer;
7359 return value_unsigned;
7371 return token_buffer;
7391 for (
const auto c : token_string)
7393 if (
static_cast<unsigned char>(c) <=
'\x1F')
7396 std::array<char, 9> cs{{}};
7397 (std::snprintf)(cs.data(), cs.size(),
"<U+%.4X>",
static_cast<unsigned char>(c));
7398 result += cs.data();
7403 result.push_back(
static_cast<std::string::value_type
>(c));
7411 JSON_HEDLEY_RETURNS_NON_NULL
7414 return error_message;
7430 return get() == 0xBB && get() == 0xBF;
7439 void skip_whitespace()
7445 while (current ==
' ' || current ==
'\t' || current ==
'\n' || current ==
'\r');
7453 error_message =
"invalid BOM; must be 0xEF 0xBB 0xBF if given";
7454 return token_type::parse_error;
7461 while (ignore_comments && current ==
'/')
7463 if (!scan_comment())
7465 return token_type::parse_error;
7476 return token_type::begin_array;
7478 return token_type::end_array;
7480 return token_type::begin_object;
7482 return token_type::end_object;
7484 return token_type::name_separator;
7486 return token_type::value_separator;
7491 std::array<char_type, 4> true_literal = {{
't',
'r',
'u',
'e'}};
7492 return scan_literal(true_literal.data(), true_literal.size(), token_type::literal_true);
7496 std::array<char_type, 5> false_literal = {{
'f',
'a',
'l',
's',
'e'}};
7497 return scan_literal(false_literal.data(), false_literal.size(), token_type::literal_false);
7501 std::array<char_type, 4> null_literal = {{
'n',
'u',
'l',
'l'}};
7502 return scan_literal(null_literal.data(), null_literal.size(), token_type::literal_null);
7507 return scan_string();
7521 return scan_number();
7526 case std::char_traits<char_type>::eof():
7527 return token_type::end_of_input;
7531 error_message =
"invalid literal";
7532 return token_type::parse_error;
7538 InputAdapterType ia;
7541 const bool ignore_comments =
false;
7544 char_int_type current = std::char_traits<char_type>::eof();
7547 bool next_unget =
false;
7550 position_t position {};
7553 std::vector<char_type> token_string {};
7556 string_t token_buffer {};
7559 const char* error_message =
"";
7562 number_integer_t value_integer = 0;
7563 number_unsigned_t value_unsigned = 0;
7564 number_float_t value_float = 0;
7567 const char_int_type decimal_point_char =
'.';
7590 template<
typename T>
7591 using null_function_t = decltype(std::declval<T&>().
null());
7593 template<
typename T>
7594 using boolean_function_t =
7595 decltype(std::declval<T&>().
boolean(std::declval<bool>()));
7597 template<
typename T,
typename Integer>
7598 using number_integer_function_t =
7599 decltype(std::declval<T&>().number_integer(std::declval<Integer>()));
7601 template<
typename T,
typename Un
signed>
7602 using number_unsigned_function_t =
7603 decltype(std::declval<T&>().number_unsigned(std::declval<Unsigned>()));
7605 template<
typename T,
typename Float,
typename String>
7606 using number_float_function_t = decltype(std::declval<T&>().number_float(
7607 std::declval<Float>(), std::declval<const String&>()));
7609 template<
typename T,
typename String>
7610 using string_function_t =
7611 decltype(std::declval<T&>().
string(std::declval<String&>()));
7613 template<
typename T,
typename Binary>
7614 using binary_function_t =
7615 decltype(std::declval<T&>().binary(std::declval<Binary&>()));
7617 template<
typename T>
7618 using start_object_function_t =
7619 decltype(std::declval<T&>().start_object(std::declval<std::size_t>()));
7621 template<
typename T,
typename String>
7622 using key_function_t =
7623 decltype(std::declval<T&>().key(std::declval<String&>()));
7625 template<
typename T>
7626 using end_object_function_t = decltype(std::declval<T&>().end_object());
7628 template<
typename T>
7629 using start_array_function_t =
7630 decltype(std::declval<T&>().start_array(std::declval<std::size_t>()));
7632 template<
typename T>
7633 using end_array_function_t = decltype(std::declval<T&>().end_array());
7635 template<
typename T,
typename Exception>
7636 using parse_error_function_t = decltype(std::declval<T&>().parse_error(
7637 std::declval<std::size_t>(), std::declval<const std::string&>(),
7638 std::declval<const Exception&>()));
7640 template<
typename SAX,
typename BasicJsonType>
7645 "BasicJsonType must be of type basic_json<...>");
7647 using number_integer_t =
typename BasicJsonType::number_integer_t;
7648 using number_unsigned_t =
typename BasicJsonType::number_unsigned_t;
7649 using number_float_t =
typename BasicJsonType::number_float_t;
7650 using string_t =
typename BasicJsonType::string_t;
7651 using binary_t =
typename BasicJsonType::binary_t;
7652 using exception_t =
typename BasicJsonType::exception;
7655 static constexpr
bool value =
7656 is_detected_exact<bool, null_function_t, SAX>::value &&
7657 is_detected_exact<bool, boolean_function_t, SAX>::value &&
7658 is_detected_exact<bool, number_integer_function_t, SAX, number_integer_t>::value &&
7659 is_detected_exact<bool, number_unsigned_function_t, SAX, number_unsigned_t>::value &&
7660 is_detected_exact<bool, number_float_function_t, SAX, number_float_t, string_t>::value &&
7661 is_detected_exact<bool, string_function_t, SAX, string_t>::value &&
7662 is_detected_exact<bool, binary_function_t, SAX, binary_t>::value &&
7663 is_detected_exact<bool, start_object_function_t, SAX>::value &&
7664 is_detected_exact<bool, key_function_t, SAX, string_t>::value &&
7665 is_detected_exact<bool, end_object_function_t, SAX>::value &&
7666 is_detected_exact<bool, start_array_function_t, SAX>::value &&
7667 is_detected_exact<bool, end_array_function_t, SAX>::value &&
7668 is_detected_exact<bool, parse_error_function_t, SAX, exception_t>::value;
7671 template<
typename SAX,
typename BasicJsonType>
7676 "BasicJsonType must be of type basic_json<...>");
7678 using number_integer_t =
typename BasicJsonType::number_integer_t;
7679 using number_unsigned_t =
typename BasicJsonType::number_unsigned_t;
7680 using number_float_t =
typename BasicJsonType::number_float_t;
7681 using string_t =
typename BasicJsonType::string_t;
7682 using binary_t =
typename BasicJsonType::binary_t;
7683 using exception_t =
typename BasicJsonType::exception;
7686 static_assert(is_detected_exact<bool, null_function_t, SAX>::value,
7687 "Missing/invalid function: bool null()");
7688 static_assert(is_detected_exact<bool, boolean_function_t, SAX>::value,
7689 "Missing/invalid function: bool boolean(bool)");
7690 static_assert(is_detected_exact<bool, boolean_function_t, SAX>::value,
7691 "Missing/invalid function: bool boolean(bool)");
7693 is_detected_exact<
bool, number_integer_function_t, SAX,
7694 number_integer_t>::
value,
7695 "Missing/invalid function: bool number_integer(number_integer_t)");
7697 is_detected_exact<
bool, number_unsigned_function_t, SAX,
7698 number_unsigned_t>::
value,
7699 "Missing/invalid function: bool number_unsigned(number_unsigned_t)");
7700 static_assert(is_detected_exact<
bool, number_float_function_t, SAX,
7701 number_float_t, string_t>::
value,
7702 "Missing/invalid function: bool number_float(number_float_t, const string_t&)");
7704 is_detected_exact<bool, string_function_t, SAX, string_t>::value,
7705 "Missing/invalid function: bool string(string_t&)");
7707 is_detected_exact<bool, binary_function_t, SAX, binary_t>::value,
7708 "Missing/invalid function: bool binary(binary_t&)");
7709 static_assert(is_detected_exact<bool, start_object_function_t, SAX>::value,
7710 "Missing/invalid function: bool start_object(std::size_t)");
7711 static_assert(is_detected_exact<bool, key_function_t, SAX, string_t>::value,
7712 "Missing/invalid function: bool key(string_t&)");
7713 static_assert(is_detected_exact<bool, end_object_function_t, SAX>::value,
7714 "Missing/invalid function: bool end_object()");
7715 static_assert(is_detected_exact<bool, start_array_function_t, SAX>::value,
7716 "Missing/invalid function: bool start_array(std::size_t)");
7717 static_assert(is_detected_exact<bool, end_array_function_t, SAX>::value,
7718 "Missing/invalid function: bool end_array()");
7720 is_detected_exact<bool, parse_error_function_t, SAX, exception_t>::value,
7721 "Missing/invalid function: bool parse_error(std::size_t, const "
7722 "std::string&, const exception&)");
7749 static inline bool little_endianess(
int num = 1) noexcept
7751 return *
reinterpret_cast<char*
>(&num) == 1;
7762 template<
typename BasicJsonType,
typename InputAdapterType,
typename SAX = json_sax_dom_parser<BasicJsonType>>
7765 using number_integer_t =
typename BasicJsonType::number_integer_t;
7766 using number_unsigned_t =
typename BasicJsonType::number_unsigned_t;
7767 using number_float_t =
typename BasicJsonType::number_float_t;
7768 using string_t =
typename BasicJsonType::string_t;
7769 using binary_t =
typename BasicJsonType::binary_t;
7770 using json_sax_t = SAX;
7771 using char_type =
typename InputAdapterType::char_type;
7772 using char_int_type =
typename std::char_traits<char_type>::int_type;
7800 JSON_HEDLEY_NON_NULL(3)
7803 const
bool strict = true,
7807 bool result =
false;
7811 case input_format_t::bson:
7812 result = parse_bson_internal();
7815 case input_format_t::cbor:
7816 result = parse_cbor_internal(
true, tag_handler);
7819 case input_format_t::msgpack:
7820 result = parse_msgpack_internal();
7823 case input_format_t::ubjson:
7824 result = parse_ubjson_internal();
7832 if (result && strict)
7834 if (format == input_format_t::ubjson)
7843 if (JSON_HEDLEY_UNLIKELY(current != std::char_traits<char_type>::eof()))
7845 return sax->parse_error(chars_read, get_token_string(),
7846 parse_error::create(110, chars_read, exception_message(format,
"expected end of input; last byte: 0x" + get_token_string(),
"value")));
7862 bool parse_bson_internal()
7864 std::int32_t document_size{};
7865 get_number<std::int32_t, true>(input_format_t::bson, document_size);
7867 if (JSON_HEDLEY_UNLIKELY(!sax->start_object(std::size_t(-1))))
7872 if (JSON_HEDLEY_UNLIKELY(!parse_bson_element_list(
false)))
7877 return sax->end_object();
7887 bool get_bson_cstr(string_t& result)
7889 auto out = std::back_inserter(result);
7893 if (JSON_HEDLEY_UNLIKELY(!unexpect_eof(input_format_t::bson,
"cstring")))
7897 if (current == 0x00)
7901 *out++ =
static_cast<typename string_t::value_type
>(current);
7916 template<
typename NumberType>
7917 bool get_bson_string(
const NumberType len, string_t& result)
7919 if (JSON_HEDLEY_UNLIKELY(len < 1))
7921 auto last_token = get_token_string();
7922 return sax->parse_error(chars_read, last_token,
parse_error::create(112, chars_read, exception_message(input_format_t::bson,
"string length must be at least 1, is " + std::to_string(len),
"string")));
7925 return get_string(input_format_t::bson, len -
static_cast<NumberType
>(1), result) && get() != std::char_traits<char_type>::eof();
7937 template<
typename NumberType>
7938 bool get_bson_binary(
const NumberType len, binary_t& result)
7940 if (JSON_HEDLEY_UNLIKELY(len < 0))
7942 auto last_token = get_token_string();
7943 return sax->parse_error(chars_read, last_token,
parse_error::create(112, chars_read, exception_message(input_format_t::bson,
"byte array length cannot be negative, is " + std::to_string(len),
"binary")));
7947 std::uint8_t subtype{};
7948 get_number<std::uint8_t>(input_format_t::bson, subtype);
7949 result.set_subtype(subtype);
7951 return get_binary(input_format_t::bson, len, result);
7964 bool parse_bson_element_internal(
const char_int_type element_type,
7965 const std::size_t element_type_parse_position)
7967 switch (element_type)
7972 return get_number<double, true>(input_format_t::bson, number) && sax->number_float(
static_cast<number_float_t
>(number),
"");
7979 return get_number<std::int32_t, true>(input_format_t::bson, len) && get_bson_string(len, value) && sax->string(value);
7984 return parse_bson_internal();
7989 return parse_bson_array();
7996 return get_number<std::int32_t, true>(input_format_t::bson, len) && get_bson_binary(len, value) && sax->binary(value);
8001 return sax->boolean(get() != 0);
8011 std::int32_t
value{};
8012 return get_number<std::int32_t, true>(input_format_t::bson, value) && sax->number_integer(value);
8017 std::int64_t
value{};
8018 return get_number<std::int64_t, true>(input_format_t::bson, value) && sax->number_integer(value);
8023 std::array<char, 3> cr{{}};
8024 (std::snprintf)(cr.data(), cr.size(),
"%.2hhX",
static_cast<unsigned char>(element_type));
8025 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())));
8042 bool parse_bson_element_list(
const bool is_array)
8046 while (
auto element_type = get())
8048 if (JSON_HEDLEY_UNLIKELY(!unexpect_eof(input_format_t::bson,
"element list")))
8053 const std::size_t element_type_parse_position = chars_read;
8054 if (JSON_HEDLEY_UNLIKELY(!get_bson_cstr(key)))
8059 if (!is_array && !sax->key(key))
8064 if (JSON_HEDLEY_UNLIKELY(!parse_bson_element_internal(element_type, element_type_parse_position)))
8080 bool parse_bson_array()
8082 std::int32_t document_size{};
8083 get_number<std::int32_t, true>(input_format_t::bson, document_size);
8085 if (JSON_HEDLEY_UNLIKELY(!sax->start_array(std::size_t(-1))))
8090 if (JSON_HEDLEY_UNLIKELY(!parse_bson_element_list(
true)))
8095 return sax->end_array();
8110 bool parse_cbor_internal(
const bool get_char,
8113 switch (get_char ? get() : current)
8116 case std::char_traits<char_type>::eof():
8144 return sax->number_unsigned(
static_cast<number_unsigned_t
>(current));
8148 std::uint8_t number{};
8149 return get_number(input_format_t::cbor, number) && sax->number_unsigned(number);
8154 std::uint16_t number{};
8155 return get_number(input_format_t::cbor, number) && sax->number_unsigned(number);
8160 std::uint32_t number{};
8161 return get_number(input_format_t::cbor, number) && sax->number_unsigned(number);
8166 std::uint64_t number{};
8167 return get_number(input_format_t::cbor, number) && sax->number_unsigned(number);
8195 return sax->number_integer(
static_cast<std::int8_t
>(0x20 - 1 - current));
8199 std::uint8_t number{};
8200 return get_number(input_format_t::cbor, number) && sax->number_integer(
static_cast<number_integer_t
>(-1) - number);
8205 std::uint16_t number{};
8206 return get_number(input_format_t::cbor, number) && sax->number_integer(
static_cast<number_integer_t
>(-1) - number);
8211 std::uint32_t number{};
8212 return get_number(input_format_t::cbor, number) && sax->number_integer(
static_cast<number_integer_t
>(-1) - number);
8217 std::uint64_t number{};
8218 return get_number(input_format_t::cbor, number) && sax->number_integer(
static_cast<number_integer_t
>(-1)
8219 -
static_cast<number_integer_t
>(number));
8254 return get_cbor_binary(b) && sax->binary(b);
8289 return get_cbor_string(s) && sax->string(s);
8317 return get_cbor_array(
static_cast<std::size_t
>(
static_cast<unsigned int>(current) & 0x1Fu), tag_handler);
8322 return get_number(input_format_t::cbor, len) && get_cbor_array(
static_cast<std::size_t
>(len), tag_handler);
8327 std::uint16_t len{};
8328 return get_number(input_format_t::cbor, len) && get_cbor_array(
static_cast<std::size_t
>(len), tag_handler);
8333 std::uint32_t len{};
8334 return get_number(input_format_t::cbor, len) && get_cbor_array(
static_cast<std::size_t
>(len), tag_handler);
8339 std::uint64_t len{};
8340 return get_number(input_format_t::cbor, len) && get_cbor_array(
static_cast<std::size_t
>(len), tag_handler);
8344 return get_cbor_array(std::size_t(-1), tag_handler);
8371 return get_cbor_object(
static_cast<std::size_t
>(
static_cast<unsigned int>(current) & 0x1Fu), tag_handler);
8376 return get_number(input_format_t::cbor, len) && get_cbor_object(
static_cast<std::size_t
>(len), tag_handler);
8381 std::uint16_t len{};
8382 return get_number(input_format_t::cbor, len) && get_cbor_object(
static_cast<std::size_t
>(len), tag_handler);
8387 std::uint32_t len{};
8388 return get_number(input_format_t::cbor, len) && get_cbor_object(
static_cast<std::size_t
>(len), tag_handler);
8393 std::uint64_t len{};
8394 return get_number(input_format_t::cbor, len) && get_cbor_object(
static_cast<std::size_t
>(len), tag_handler);
8398 return get_cbor_object(std::size_t(-1), tag_handler);
8420 switch (tag_handler)
8424 auto last_token = get_token_string();
8425 return sax->parse_error(chars_read, last_token,
parse_error::create(112, chars_read, exception_message(input_format_t::cbor,
"invalid byte: 0x" + last_token,
"value")));
8435 get_number(input_format_t::cbor, len);
8440 std::uint16_t len{};
8441 get_number(input_format_t::cbor, len);
8446 std::uint32_t len{};
8447 get_number(input_format_t::cbor, len);
8452 std::uint64_t len{};
8453 get_number(input_format_t::cbor, len);
8459 return parse_cbor_internal(
true, tag_handler);
8469 return sax->boolean(
false);
8472 return sax->boolean(
true);
8479 const auto byte1_raw = get();
8480 if (JSON_HEDLEY_UNLIKELY(!unexpect_eof(input_format_t::cbor,
"number")))
8484 const auto byte2_raw = get();
8485 if (JSON_HEDLEY_UNLIKELY(!unexpect_eof(input_format_t::cbor,
"number")))
8490 const auto byte1 =
static_cast<unsigned char>(byte1_raw);
8491 const auto byte2 =
static_cast<unsigned char>(byte2_raw);
8501 const auto half =
static_cast<unsigned int>((byte1 << 8u) + byte2);
8502 const double val = [&half]
8504 const int exp = (half >> 10u) & 0x1Fu;
8505 const unsigned int mant = half & 0x3FFu;
8506 JSON_ASSERT(0 <= exp&& exp <= 32);
8507 JSON_ASSERT(mant <= 1024);
8511 return std::ldexp(mant, -24);
8514 ? std::numeric_limits<double>::infinity()
8515 : std::numeric_limits<double>::quiet_NaN();
8517 return std::ldexp(mant + 1024, exp - 25);
8520 return sax->number_float((half & 0x8000u) != 0
8521 ?
static_cast<number_float_t
>(-val)
8522 :
static_cast<number_float_t
>(val),
"");
8528 return get_number(input_format_t::cbor, number) && sax->number_float(
static_cast<number_float_t
>(number),
"");
8534 return get_number(input_format_t::cbor, number) && sax->number_float(
static_cast<number_float_t
>(number),
"");
8539 auto last_token = get_token_string();
8540 return sax->parse_error(chars_read, last_token,
parse_error::create(112, chars_read, exception_message(input_format_t::cbor,
"invalid byte: 0x" + last_token,
"value")));
8556 bool get_cbor_string(string_t& result)
8558 if (JSON_HEDLEY_UNLIKELY(!unexpect_eof(input_format_t::cbor,
"string")))
8591 return get_string(input_format_t::cbor,
static_cast<unsigned int>(current) & 0x1Fu, result);
8597 return get_number(input_format_t::cbor, len) && get_string(input_format_t::cbor, len, result);
8602 std::uint16_t len{};
8603 return get_number(input_format_t::cbor, len) && get_string(input_format_t::cbor, len, result);
8608 std::uint32_t len{};
8609 return get_number(input_format_t::cbor, len) && get_string(input_format_t::cbor, len, result);
8614 std::uint64_t len{};
8615 return get_number(input_format_t::cbor, len) && get_string(input_format_t::cbor, len, result);
8620 while (get() != 0xFF)
8623 if (!get_cbor_string(chunk))
8627 result.append(chunk);
8634 auto last_token = get_token_string();
8635 return sax->parse_error(chars_read, last_token,
parse_error::create(113, chars_read, exception_message(input_format_t::cbor,
"expected length specification (0x60-0x7B) or indefinite string type (0x7F); last byte: 0x" + last_token,
"string")));
8651 bool get_cbor_binary(binary_t& result)
8653 if (JSON_HEDLEY_UNLIKELY(!unexpect_eof(input_format_t::cbor,
"binary")))
8686 return get_binary(input_format_t::cbor,
static_cast<unsigned int>(current) & 0x1Fu, result);
8692 return get_number(input_format_t::cbor, len) &&
8693 get_binary(input_format_t::cbor, len, result);
8698 std::uint16_t len{};
8699 return get_number(input_format_t::cbor, len) &&
8700 get_binary(input_format_t::cbor, len, result);
8705 std::uint32_t len{};
8706 return get_number(input_format_t::cbor, len) &&
8707 get_binary(input_format_t::cbor, len, result);
8712 std::uint64_t len{};
8713 return get_number(input_format_t::cbor, len) &&
8714 get_binary(input_format_t::cbor, len, result);
8719 while (get() != 0xFF)
8722 if (!get_cbor_binary(chunk))
8726 result.insert(result.end(), chunk.begin(), chunk.end());
8733 auto last_token = get_token_string();
8734 return sax->parse_error(chars_read, last_token,
parse_error::create(113, chars_read, exception_message(input_format_t::cbor,
"expected length specification (0x40-0x5B) or indefinite binary array type (0x5F); last byte: 0x" + last_token,
"binary")));
8745 bool get_cbor_array(
const std::size_t len,
8748 if (JSON_HEDLEY_UNLIKELY(!sax->start_array(len)))
8753 if (len != std::size_t(-1))
8755 for (std::size_t i = 0; i < len; ++i)
8757 if (JSON_HEDLEY_UNLIKELY(!parse_cbor_internal(
true, tag_handler)))
8765 while (get() != 0xFF)
8767 if (JSON_HEDLEY_UNLIKELY(!parse_cbor_internal(
false, tag_handler)))
8774 return sax->end_array();
8783 bool get_cbor_object(
const std::size_t len,
8786 if (JSON_HEDLEY_UNLIKELY(!sax->start_object(len)))
8792 if (len != std::size_t(-1))
8794 for (std::size_t i = 0; i < len; ++i)
8797 if (JSON_HEDLEY_UNLIKELY(!get_cbor_string(key) || !sax->key(key)))
8802 if (JSON_HEDLEY_UNLIKELY(!parse_cbor_internal(
true, tag_handler)))
8811 while (get() != 0xFF)
8813 if (JSON_HEDLEY_UNLIKELY(!get_cbor_string(key) || !sax->key(key)))
8818 if (JSON_HEDLEY_UNLIKELY(!parse_cbor_internal(
true, tag_handler)))
8826 return sax->end_object();
8836 bool parse_msgpack_internal()
8841 case std::char_traits<char_type>::eof():
8973 return sax->number_unsigned(
static_cast<number_unsigned_t
>(current));
8992 return get_msgpack_object(
static_cast<std::size_t
>(
static_cast<unsigned int>(current) & 0x0Fu));
9011 return get_msgpack_array(
static_cast<std::size_t
>(
static_cast<unsigned int>(current) & 0x0Fu));
9051 return get_msgpack_string(s) && sax->string(s);
9058 return sax->boolean(
false);
9061 return sax->boolean(
true);
9076 return get_msgpack_binary(b) && sax->binary(b);
9082 return get_number(input_format_t::msgpack, number) && sax->number_float(
static_cast<number_float_t
>(number),
"");
9088 return get_number(input_format_t::msgpack, number) && sax->number_float(
static_cast<number_float_t
>(number),
"");
9093 std::uint8_t number{};
9094 return get_number(input_format_t::msgpack, number) && sax->number_unsigned(number);
9099 std::uint16_t number{};
9100 return get_number(input_format_t::msgpack, number) && sax->number_unsigned(number);
9105 std::uint32_t number{};
9106 return get_number(input_format_t::msgpack, number) && sax->number_unsigned(number);
9111 std::uint64_t number{};
9112 return get_number(input_format_t::msgpack, number) && sax->number_unsigned(number);
9117 std::int8_t number{};
9118 return get_number(input_format_t::msgpack, number) && sax->number_integer(number);
9123 std::int16_t number{};
9124 return get_number(input_format_t::msgpack, number) && sax->number_integer(number);
9129 std::int32_t number{};
9130 return get_number(input_format_t::msgpack, number) && sax->number_integer(number);
9135 std::int64_t number{};
9136 return get_number(input_format_t::msgpack, number) && sax->number_integer(number);
9141 std::uint16_t len{};
9142 return get_number(input_format_t::msgpack, len) && get_msgpack_array(
static_cast<std::size_t
>(len));
9147 std::uint32_t len{};
9148 return get_number(input_format_t::msgpack, len) && get_msgpack_array(
static_cast<std::size_t
>(len));
9153 std::uint16_t len{};
9154 return get_number(input_format_t::msgpack, len) && get_msgpack_object(
static_cast<std::size_t
>(len));
9159 std::uint32_t len{};
9160 return get_number(input_format_t::msgpack, len) && get_msgpack_object(
static_cast<std::size_t
>(len));
9196 return sax->number_integer(
static_cast<std::int8_t
>(current));
9200 auto last_token = get_token_string();
9201 return sax->parse_error(chars_read, last_token,
parse_error::create(112, chars_read, exception_message(input_format_t::msgpack,
"invalid byte: 0x" + last_token,
"value")));
9216 bool get_msgpack_string(string_t& result)
9218 if (JSON_HEDLEY_UNLIKELY(!unexpect_eof(input_format_t::msgpack,
"string")))
9259 return get_string(input_format_t::msgpack,
static_cast<unsigned int>(current) & 0x1Fu, result);
9265 return get_number(input_format_t::msgpack, len) && get_string(input_format_t::msgpack, len, result);
9270 std::uint16_t len{};
9271 return get_number(input_format_t::msgpack, len) && get_string(input_format_t::msgpack, len, result);
9276 std::uint32_t len{};
9277 return get_number(input_format_t::msgpack, len) && get_string(input_format_t::msgpack, len, result);
9282 auto last_token = get_token_string();
9283 return sax->parse_error(chars_read, last_token,
parse_error::create(113, chars_read, exception_message(input_format_t::msgpack,
"expected length specification (0xA0-0xBF, 0xD9-0xDB); last byte: 0x" + last_token,
"string")));
9298 bool get_msgpack_binary(binary_t& result)
9301 auto assign_and_return_true = [&result](std::int8_t subtype)
9303 result.set_subtype(
static_cast<std::uint8_t
>(subtype));
9312 return get_number(input_format_t::msgpack, len) &&
9313 get_binary(input_format_t::msgpack, len, result);
9318 std::uint16_t len{};
9319 return get_number(input_format_t::msgpack, len) &&
9320 get_binary(input_format_t::msgpack, len, result);
9325 std::uint32_t len{};
9326 return get_number(input_format_t::msgpack, len) &&
9327 get_binary(input_format_t::msgpack, len, result);
9333 std::int8_t subtype{};
9334 return get_number(input_format_t::msgpack, len) &&
9335 get_number(input_format_t::msgpack, subtype) &&
9336 get_binary(input_format_t::msgpack, len, result) &&
9337 assign_and_return_true(subtype);
9342 std::uint16_t len{};
9343 std::int8_t subtype{};
9344 return get_number(input_format_t::msgpack, len) &&
9345 get_number(input_format_t::msgpack, subtype) &&
9346 get_binary(input_format_t::msgpack, len, result) &&
9347 assign_and_return_true(subtype);
9352 std::uint32_t len{};
9353 std::int8_t subtype{};
9354 return get_number(input_format_t::msgpack, len) &&
9355 get_number(input_format_t::msgpack, subtype) &&
9356 get_binary(input_format_t::msgpack, len, result) &&
9357 assign_and_return_true(subtype);
9362 std::int8_t subtype{};
9363 return get_number(input_format_t::msgpack, subtype) &&
9364 get_binary(input_format_t::msgpack, 1, result) &&
9365 assign_and_return_true(subtype);
9370 std::int8_t subtype{};
9371 return get_number(input_format_t::msgpack, subtype) &&
9372 get_binary(input_format_t::msgpack, 2, result) &&
9373 assign_and_return_true(subtype);
9378 std::int8_t subtype{};
9379 return get_number(input_format_t::msgpack, subtype) &&
9380 get_binary(input_format_t::msgpack, 4, result) &&
9381 assign_and_return_true(subtype);
9386 std::int8_t subtype{};
9387 return get_number(input_format_t::msgpack, subtype) &&
9388 get_binary(input_format_t::msgpack, 8, result) &&
9389 assign_and_return_true(subtype);
9394 std::int8_t subtype{};
9395 return get_number(input_format_t::msgpack, subtype) &&
9396 get_binary(input_format_t::msgpack, 16, result) &&
9397 assign_and_return_true(subtype);
9409 bool get_msgpack_array(
const std::size_t len)
9411 if (JSON_HEDLEY_UNLIKELY(!sax->start_array(len)))
9416 for (std::size_t i = 0; i < len; ++i)
9418 if (JSON_HEDLEY_UNLIKELY(!parse_msgpack_internal()))
9424 return sax->end_array();
9431 bool get_msgpack_object(
const std::size_t len)
9433 if (JSON_HEDLEY_UNLIKELY(!sax->start_object(len)))
9439 for (std::size_t i = 0; i < len; ++i)
9442 if (JSON_HEDLEY_UNLIKELY(!get_msgpack_string(key) || !sax->key(key)))
9447 if (JSON_HEDLEY_UNLIKELY(!parse_msgpack_internal()))
9454 return sax->end_object();
9468 bool parse_ubjson_internal(
const bool get_char =
true)
9470 return get_ubjson_value(get_char ? get_ignore_noop() : current);
9487 bool get_ubjson_string(string_t& result,
const bool get_char =
true)
9494 if (JSON_HEDLEY_UNLIKELY(!unexpect_eof(input_format_t::ubjson,
"value")))
9504 return get_number(input_format_t::ubjson, len) && get_string(input_format_t::ubjson, len, result);
9510 return get_number(input_format_t::ubjson, len) && get_string(input_format_t::ubjson, len, result);
9516 return get_number(input_format_t::ubjson, len) && get_string(input_format_t::ubjson, len, result);
9522 return get_number(input_format_t::ubjson, len) && get_string(input_format_t::ubjson, len, result);
9528 return get_number(input_format_t::ubjson, len) && get_string(input_format_t::ubjson, len, result);
9532 auto last_token = get_token_string();
9533 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")));
9541 bool get_ubjson_size_value(std::size_t& result)
9543 switch (get_ignore_noop())
9547 std::uint8_t number{};
9548 if (JSON_HEDLEY_UNLIKELY(!get_number(input_format_t::ubjson, number)))
9552 result =
static_cast<std::size_t
>(number);
9558 std::int8_t number{};
9559 if (JSON_HEDLEY_UNLIKELY(!get_number(input_format_t::ubjson, number)))
9563 result =
static_cast<std::size_t
>(number);
9569 std::int16_t number{};
9570 if (JSON_HEDLEY_UNLIKELY(!get_number(input_format_t::ubjson, number)))
9574 result =
static_cast<std::size_t
>(number);
9580 std::int32_t number{};
9581 if (JSON_HEDLEY_UNLIKELY(!get_number(input_format_t::ubjson, number)))
9585 result =
static_cast<std::size_t
>(number);
9591 std::int64_t number{};
9592 if (JSON_HEDLEY_UNLIKELY(!get_number(input_format_t::ubjson, number)))
9596 result =
static_cast<std::size_t
>(number);
9602 auto last_token = get_token_string();
9603 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")));
9618 bool get_ubjson_size_type(std::pair<std::size_t, char_int_type>& result)
9620 result.first = string_t::npos;
9627 result.second = get();
9628 if (JSON_HEDLEY_UNLIKELY(!unexpect_eof(input_format_t::ubjson,
"type")))
9634 if (JSON_HEDLEY_UNLIKELY(current !=
'#'))
9636 if (JSON_HEDLEY_UNLIKELY(!unexpect_eof(input_format_t::ubjson,
"value")))
9640 auto last_token = get_token_string();
9641 return sax->parse_error(chars_read, last_token,
parse_error::create(112, chars_read, exception_message(input_format_t::ubjson,
"expected '#' after type information; last byte: 0x" + last_token,
"size")));
9644 return get_ubjson_size_value(result.first);
9649 return get_ubjson_size_value(result.first);
9659 bool get_ubjson_value(
const char_int_type prefix)
9663 case std::char_traits<char_type>::eof():
9667 return sax->boolean(
true);
9669 return sax->boolean(
false);
9676 std::uint8_t number{};
9677 return get_number(input_format_t::ubjson, number) && sax->number_unsigned(number);
9682 std::int8_t number{};
9683 return get_number(input_format_t::ubjson, number) && sax->number_integer(number);
9688 std::int16_t number{};
9689 return get_number(input_format_t::ubjson, number) && sax->number_integer(number);
9694 std::int32_t number{};
9695 return get_number(input_format_t::ubjson, number) && sax->number_integer(number);
9700 std::int64_t number{};
9701 return get_number(input_format_t::ubjson, number) && sax->number_integer(number);
9707 return get_number(input_format_t::ubjson, number) && sax->number_float(
static_cast<number_float_t
>(number),
"");
9713 return get_number(input_format_t::ubjson, number) && sax->number_float(
static_cast<number_float_t
>(number),
"");
9718 return get_ubjson_high_precision_number();
9724 if (JSON_HEDLEY_UNLIKELY(!unexpect_eof(input_format_t::ubjson,
"char")))
9728 if (JSON_HEDLEY_UNLIKELY(current > 127))
9730 auto last_token = get_token_string();
9731 return sax->parse_error(chars_read, last_token,
parse_error::create(113, chars_read, exception_message(input_format_t::ubjson,
"byte after 'C' must be in range 0x00..0x7F; last byte: 0x" + last_token,
"char")));
9733 string_t s(1,
static_cast<typename string_t::value_type
>(current));
9734 return sax->string(s);
9740 return get_ubjson_string(s) && sax->string(s);
9744 return get_ubjson_array();
9747 return get_ubjson_object();
9751 auto last_token = get_token_string();
9752 return sax->parse_error(chars_read, last_token,
parse_error::create(112, chars_read, exception_message(input_format_t::ubjson,
"invalid byte: 0x" + last_token,
"value")));
9760 bool get_ubjson_array()
9762 std::pair<std::size_t, char_int_type> size_and_type;
9763 if (JSON_HEDLEY_UNLIKELY(!get_ubjson_size_type(size_and_type)))
9768 if (size_and_type.first != string_t::npos)
9770 if (JSON_HEDLEY_UNLIKELY(!sax->start_array(size_and_type.first)))
9775 if (size_and_type.second != 0)
9777 if (size_and_type.second !=
'N')
9779 for (std::size_t i = 0; i < size_and_type.first; ++i)
9781 if (JSON_HEDLEY_UNLIKELY(!get_ubjson_value(size_and_type.second)))
9790 for (std::size_t i = 0; i < size_and_type.first; ++i)
9792 if (JSON_HEDLEY_UNLIKELY(!parse_ubjson_internal()))
9801 if (JSON_HEDLEY_UNLIKELY(!sax->start_array(std::size_t(-1))))
9806 while (current !=
']')
9808 if (JSON_HEDLEY_UNLIKELY(!parse_ubjson_internal(
false)))
9816 return sax->end_array();
9822 bool get_ubjson_object()
9824 std::pair<std::size_t, char_int_type> size_and_type;
9825 if (JSON_HEDLEY_UNLIKELY(!get_ubjson_size_type(size_and_type)))
9831 if (size_and_type.first != string_t::npos)
9833 if (JSON_HEDLEY_UNLIKELY(!sax->start_object(size_and_type.first)))
9838 if (size_and_type.second != 0)
9840 for (std::size_t i = 0; i < size_and_type.first; ++i)
9842 if (JSON_HEDLEY_UNLIKELY(!get_ubjson_string(key) || !sax->key(key)))
9846 if (JSON_HEDLEY_UNLIKELY(!get_ubjson_value(size_and_type.second)))
9855 for (std::size_t i = 0; i < size_and_type.first; ++i)
9857 if (JSON_HEDLEY_UNLIKELY(!get_ubjson_string(key) || !sax->key(key)))
9861 if (JSON_HEDLEY_UNLIKELY(!parse_ubjson_internal()))
9871 if (JSON_HEDLEY_UNLIKELY(!sax->start_object(std::size_t(-1))))
9876 while (current !=
'}')
9878 if (JSON_HEDLEY_UNLIKELY(!get_ubjson_string(key,
false) || !sax->key(key)))
9882 if (JSON_HEDLEY_UNLIKELY(!parse_ubjson_internal()))
9891 return sax->end_object();
9897 bool get_ubjson_high_precision_number()
9901 auto res = get_ubjson_size_value(size);
9902 if (JSON_HEDLEY_UNLIKELY(!res))
9908 std::vector<char> number_vector;
9909 for (std::size_t i = 0; i < size; ++i)
9912 if (JSON_HEDLEY_UNLIKELY(!unexpect_eof(input_format_t::ubjson,
"number")))
9916 number_vector.push_back(
static_cast<char>(current));
9920 auto number_ia = detail::input_adapter(std::forward<decltype(number_vector)>(number_vector));
9921 auto number_lexer = detail::lexer<BasicJsonType, decltype(number_ia)>(std::move(number_ia),
false);
9922 const auto result_number = number_lexer.scan();
9923 const auto number_string = number_lexer.get_token_string();
9924 const auto result_remainder = number_lexer.scan();
9928 if (JSON_HEDLEY_UNLIKELY(result_remainder != token_type::end_of_input))
9930 return sax->parse_error(chars_read, number_string,
parse_error::create(115, chars_read, exception_message(input_format_t::ubjson,
"invalid number text: " + number_lexer.get_token_string(),
"high-precision number")));
9933 switch (result_number)
9935 case token_type::value_integer:
9936 return sax->number_integer(number_lexer.get_number_integer());
9937 case token_type::value_unsigned:
9938 return sax->number_unsigned(number_lexer.get_number_unsigned());
9939 case token_type::value_float:
9940 return sax->number_float(number_lexer.get_number_float(), std::move(number_string));
9942 return sax->parse_error(chars_read, number_string,
parse_error::create(115, chars_read, exception_message(input_format_t::ubjson,
"invalid number text: " + number_lexer.get_token_string(),
"high-precision number")));
9962 return current = ia.get_character();
9968 char_int_type get_ignore_noop()
9974 while (current ==
'N');
9992 template<
typename NumberType,
bool InputIsLittleEndian = false>
9996 std::array<std::uint8_t,
sizeof(NumberType)> vec;
9997 for (std::size_t i = 0; i <
sizeof(NumberType); ++i)
10000 if (JSON_HEDLEY_UNLIKELY(!unexpect_eof(format,
"number")))
10006 if (is_little_endian != InputIsLittleEndian)
10008 vec[
sizeof(NumberType) - i - 1] =
static_cast<std::uint8_t
>(current);
10012 vec[i] =
static_cast<std::uint8_t
>(current);
10017 std::memcpy(&result, vec.data(),
sizeof(NumberType));
10035 template<
typename NumberType>
10037 const NumberType len,
10040 bool success =
true;
10041 for (NumberType i = 0; i < len; i++)
10044 if (JSON_HEDLEY_UNLIKELY(!unexpect_eof(format,
"string")))
10049 result.push_back(
static_cast<typename string_t::value_type
>(current));
10068 template<
typename NumberType>
10070 const NumberType len,
10073 bool success =
true;
10074 for (NumberType i = 0; i < len; i++)
10077 if (JSON_HEDLEY_UNLIKELY(!unexpect_eof(format,
"binary")))
10082 result.push_back(
static_cast<std::uint8_t
>(current));
10092 JSON_HEDLEY_NON_NULL(3)
10093 bool unexpect_eof(const
input_format_t format, const
char* context)
const
10095 if (JSON_HEDLEY_UNLIKELY(current == std::char_traits<char_type>::eof()))
10097 return sax->parse_error(chars_read,
"<end of file>",
10098 parse_error::create(110, chars_read, exception_message(format,
"unexpected end of input", context)));
10106 std::string get_token_string()
const
10108 std::array<char, 3> cr{{}};
10109 (std::snprintf)(cr.data(), cr.size(),
"%.2hhX",
static_cast<unsigned char>(current));
10110 return std::string{cr.data()};
10120 const std::string& detail,
10121 const std::string& context)
const
10123 std::string error_msg =
"syntax error while parsing ";
10127 case input_format_t::cbor:
10128 error_msg +=
"CBOR";
10131 case input_format_t::msgpack:
10132 error_msg +=
"MessagePack";
10135 case input_format_t::ubjson:
10136 error_msg +=
"UBJSON";
10139 case input_format_t::bson:
10140 error_msg +=
"BSON";
10144 JSON_ASSERT(
false);
10147 return error_msg +
" " + context +
": " + detail;
10152 InputAdapterType ia;
10155 char_int_type current = std::char_traits<char_type>::eof();
10158 std::size_t chars_read = 0;
10161 const bool is_little_endian = little_endianess();
10164 json_sax_t* sax =
nullptr;
10178 #include <functional>
10222 template<
typename BasicJsonType>
10223 using parser_callback_t =
10224 std::function<bool(
int depth,
parse_event_t event, BasicJsonType& parsed)>;
10231 template<
typename BasicJsonType,
typename InputAdapterType>
10234 using number_integer_t =
typename BasicJsonType::number_integer_t;
10235 using number_unsigned_t =
typename BasicJsonType::number_unsigned_t;
10236 using number_float_t =
typename BasicJsonType::number_float_t;
10237 using string_t =
typename BasicJsonType::string_t;
10239 using token_type =
typename lexer_t::token_type;
10244 const parser_callback_t<BasicJsonType> cb =
nullptr,
10245 const bool allow_exceptions_ =
true,
10246 const bool skip_comments =
false)
10248 , m_lexer(std::move(adapter), skip_comments)
10249 , allow_exceptions(allow_exceptions_)
10265 void parse(
const bool strict, BasicJsonType& result)
10270 sax_parse_internal(&sdp);
10271 result.assert_invariant();
10274 if (strict && (get_token() != token_type::end_of_input))
10279 exception_message(token_type::end_of_input,
"value")));
10283 if (sdp.is_errored())
10291 if (result.is_discarded())
10299 sax_parse_internal(&sdp);
10300 result.assert_invariant();
10303 if (strict && (get_token() != token_type::end_of_input))
10308 exception_message(token_type::end_of_input,
"value")));
10312 if (sdp.is_errored())
10329 return sax_parse(&sax_acceptor, strict);
10332 template<
typename SAX>
10333 JSON_HEDLEY_NON_NULL(2)
10334 bool sax_parse(SAX* sax, const
bool strict = true)
10337 const bool result = sax_parse_internal(sax);
10340 if (result && strict && (get_token() != token_type::end_of_input))
10345 exception_message(token_type::end_of_input,
"value")));
10352 template<
typename SAX>
10353 JSON_HEDLEY_NON_NULL(2)
10354 bool sax_parse_internal(SAX* sax)
10358 std::vector<bool> states;
10360 bool skip_to_state_evaluation =
false;
10364 if (!skip_to_state_evaluation)
10367 switch (last_token)
10369 case token_type::begin_object:
10371 if (JSON_HEDLEY_UNLIKELY(!sax->start_object(std::size_t(-1))))
10377 if (get_token() == token_type::end_object)
10379 if (JSON_HEDLEY_UNLIKELY(!sax->end_object()))
10387 if (JSON_HEDLEY_UNLIKELY(last_token != token_type::value_string))
10392 exception_message(token_type::value_string,
"object key")));
10394 if (JSON_HEDLEY_UNLIKELY(!sax->key(m_lexer.
get_string())))
10400 if (JSON_HEDLEY_UNLIKELY(get_token() != token_type::name_separator))
10405 exception_message(token_type::name_separator,
"object separator")));
10409 states.push_back(
false);
10416 case token_type::begin_array:
10418 if (JSON_HEDLEY_UNLIKELY(!sax->start_array(std::size_t(-1))))
10424 if (get_token() == token_type::end_array)
10426 if (JSON_HEDLEY_UNLIKELY(!sax->end_array()))
10434 states.push_back(
true);
10440 case token_type::value_float:
10444 if (JSON_HEDLEY_UNLIKELY(!std::isfinite(res)))
10448 out_of_range::create(406,
"number overflow parsing '" + m_lexer.
get_token_string() +
"'"));
10451 if (JSON_HEDLEY_UNLIKELY(!sax->number_float(res, m_lexer.
get_string())))
10459 case token_type::literal_false:
10461 if (JSON_HEDLEY_UNLIKELY(!sax->boolean(
false)))
10468 case token_type::literal_null:
10470 if (JSON_HEDLEY_UNLIKELY(!sax->null()))
10477 case token_type::literal_true:
10479 if (JSON_HEDLEY_UNLIKELY(!sax->boolean(
true)))
10486 case token_type::value_integer:
10495 case token_type::value_string:
10497 if (JSON_HEDLEY_UNLIKELY(!sax->string(m_lexer.
get_string())))
10504 case token_type::value_unsigned:
10513 case token_type::parse_error:
10519 exception_message(token_type::uninitialized,
"value")));
10527 exception_message(token_type::literal_or_value,
"value")));
10533 skip_to_state_evaluation =
false;
10537 if (states.empty())
10546 if (get_token() == token_type::value_separator)
10554 if (JSON_HEDLEY_LIKELY(last_token == token_type::end_array))
10556 if (JSON_HEDLEY_UNLIKELY(!sax->end_array()))
10565 JSON_ASSERT(!states.empty());
10567 skip_to_state_evaluation =
true;
10574 exception_message(token_type::end_array,
"array")));
10579 if (get_token() == token_type::value_separator)
10582 if (JSON_HEDLEY_UNLIKELY(get_token() != token_type::value_string))
10587 exception_message(token_type::value_string,
"object key")));
10590 if (JSON_HEDLEY_UNLIKELY(!sax->key(m_lexer.
get_string())))
10596 if (JSON_HEDLEY_UNLIKELY(get_token() != token_type::name_separator))
10601 exception_message(token_type::name_separator,
"object separator")));
10610 if (JSON_HEDLEY_LIKELY(last_token == token_type::end_object))
10612 if (JSON_HEDLEY_UNLIKELY(!sax->end_object()))
10621 JSON_ASSERT(!states.empty());
10623 skip_to_state_evaluation =
true;
10630 exception_message(token_type::end_object,
"object")));
10636 token_type get_token()
10638 return last_token = m_lexer.scan();
10641 std::string exception_message(
const token_type expected,
const std::string& context)
10643 std::string error_msg =
"syntax error ";
10645 if (!context.empty())
10647 error_msg +=
"while parsing " + context +
" ";
10652 if (last_token == token_type::parse_error)
10662 if (expected != token_type::uninitialized)
10672 const parser_callback_t<BasicJsonType> callback =
nullptr;
10674 token_type last_token = token_type::uninitialized;
10678 const bool allow_exceptions =
true;
10708 using difference_type = std::ptrdiff_t;
10709 static constexpr difference_type begin_value = 0;
10710 static constexpr difference_type end_value = begin_value + 1;
10712 JSON_PRIVATE_UNLESS_TESTED:
10714 difference_type m_it = (std::numeric_limits<std::ptrdiff_t>::min)();
10717 constexpr difference_type get_value()
const noexcept
10725 m_it = begin_value;
10737 return m_it == begin_value;
10743 return m_it == end_value;
10748 return lhs.m_it == rhs.m_it;
10751 friend constexpr
bool operator<(primitive_iterator_t lhs, primitive_iterator_t rhs) noexcept
10753 return lhs.m_it < rhs.m_it;
10756 primitive_iterator_t operator+(difference_type n) noexcept
10758 auto result = *
this;
10763 friend constexpr difference_type operator-(primitive_iterator_t lhs, primitive_iterator_t rhs) noexcept
10765 return lhs.m_it - rhs.m_it;
10768 primitive_iterator_t& operator++() noexcept
10774 primitive_iterator_t
const operator++(
int) noexcept
10776 auto result = *
this;
10781 primitive_iterator_t& operator--() noexcept
10787 primitive_iterator_t
const operator--(
int) noexcept
10789 auto result = *
this;
10794 primitive_iterator_t& operator+=(difference_type n) noexcept
10800 primitive_iterator_t& operator-=(difference_type n) noexcept
10835 #include <iterator>
10836 #include <type_traits>
10858 template<
typename IteratorType>
class iteration_proxy;
10859 template<
typename IteratorType>
class iteration_proxy_value;
10877 template<
typename BasicJsonType>
10882 friend BasicJsonType;
10886 using object_t =
typename BasicJsonType::object_t;
10887 using array_t =
typename BasicJsonType::array_t;
10889 static_assert(
is_basic_json<
typename std::remove_const<BasicJsonType>::type>::
value,
10890 "iter_impl only accepts (const) basic_json");
10906 using pointer =
typename std::conditional<std::is_const<BasicJsonType>::value,
10907 typename BasicJsonType::const_pointer,
10908 typename BasicJsonType::pointer>::type;
10911 typename std::conditional<std::is_const<BasicJsonType>::value,
10912 typename BasicJsonType::const_reference,
10913 typename BasicJsonType::reference>::type;
10926 JSON_ASSERT(m_object !=
nullptr);
10928 switch (m_object->m_type)
10967 : m_object(other.m_object),
m_it(other.m_it)
10978 m_object = other.m_object;
10989 : m_object(other.m_object),
m_it(other.m_it)
11000 m_object = other.m_object;
11005 JSON_PRIVATE_UNLESS_TESTED:
11010 void set_begin() noexcept
11012 JSON_ASSERT(m_object !=
nullptr);
11014 switch (m_object->m_type)
11049 JSON_ASSERT(m_object !=
nullptr);
11051 switch (m_object->m_type)
11080 JSON_ASSERT(m_object !=
nullptr);
11082 switch (m_object->m_type)
11097 JSON_THROW(invalid_iterator::create(214,
"cannot get value"));
11106 JSON_THROW(invalid_iterator::create(214,
"cannot get value"));
11117 JSON_ASSERT(m_object !=
nullptr);
11119 switch (m_object->m_type)
11140 JSON_THROW(invalid_iterator::create(214,
"cannot get value"));
11151 auto result = *
this;
11162 JSON_ASSERT(m_object !=
nullptr);
11164 switch (m_object->m_type)
11194 auto result = *
this;
11205 JSON_ASSERT(m_object !=
nullptr);
11207 switch (m_object->m_type)
11238 if (JSON_HEDLEY_UNLIKELY(m_object != other.m_object))
11240 JSON_THROW(invalid_iterator::create(212,
"cannot compare iterators of different containers"));
11243 JSON_ASSERT(m_object !=
nullptr);
11245 switch (m_object->m_type)
11274 if (JSON_HEDLEY_UNLIKELY(m_object != other.m_object))
11276 JSON_THROW(invalid_iterator::create(212,
"cannot compare iterators of different containers"));
11279 JSON_ASSERT(m_object !=
nullptr);
11281 switch (m_object->m_type)
11284 JSON_THROW(invalid_iterator::create(213,
"cannot compare order of object iterators"));
11300 return !other.operator < (*this);
11327 JSON_ASSERT(m_object !=
nullptr);
11329 switch (m_object->m_type)
11332 JSON_THROW(invalid_iterator::create(209,
"cannot use offsets with object iterators"));
11365 auto result = *
this;
11387 auto result = *
this;
11398 JSON_ASSERT(m_object !=
nullptr);
11400 switch (m_object->m_type)
11403 JSON_THROW(invalid_iterator::create(209,
"cannot use offsets with object iterators"));
11419 JSON_ASSERT(m_object !=
nullptr);
11421 switch (m_object->m_type)
11424 JSON_THROW(invalid_iterator::create(208,
"cannot use operator[] for object iterators"));
11430 JSON_THROW(invalid_iterator::create(214,
"cannot get value"));
11439 JSON_THROW(invalid_iterator::create(214,
"cannot get value"));
11448 const typename object_t::key_type&
key()
const
11450 JSON_ASSERT(m_object !=
nullptr);
11452 if (JSON_HEDLEY_LIKELY(m_object->is_object()))
11457 JSON_THROW(invalid_iterator::create(207,
"cannot use key() for non-object iterators"));
11469 JSON_PRIVATE_UNLESS_TESTED:
11484 #include <iterator>
11513 template<
typename Base>
11517 using difference_type = std::ptrdiff_t;
11585 auto key() const -> decltype(std::declval<Base>().
key())
11587 auto it = --this->base();
11594 auto it = --this->base();
11595 return it.operator * ();
11606 #include <algorithm>
11623 template<
typename BasicJsonType>
11627 NLOHMANN_BASIC_JSON_TPL_DECLARATION
11653 : reference_tokens(split(s))
11672 return std::accumulate(reference_tokens.begin(), reference_tokens.end(),
11674 [](
const std::string & a,
const std::string & b)
11676 return a +
"/" + escape(b);
11681 operator std::string()
const
11704 reference_tokens.insert(reference_tokens.end(),
11705 ptr.reference_tokens.begin(),
11706 ptr.reference_tokens.end());
11750 return *
this /= std::to_string(array_idx);
11854 if (JSON_HEDLEY_UNLIKELY(
empty()))
11856 JSON_THROW(detail::out_of_range::create(405,
"JSON pointer has no parent"));
11859 reference_tokens.pop_back();
11878 if (JSON_HEDLEY_UNLIKELY(
empty()))
11880 JSON_THROW(detail::out_of_range::create(405,
"JSON pointer has no parent"));
11883 return reference_tokens.back();
11900 reference_tokens.push_back(token);
11906 reference_tokens.push_back(std::move(token));
11925 return reference_tokens.empty();
11939 static typename BasicJsonType::size_type array_index(
const std::string& s)
11941 using size_type =
typename BasicJsonType::size_type;
11944 if (JSON_HEDLEY_UNLIKELY(s.size() > 1 && s[0] ==
'0'))
11947 "array index '" + s +
11948 "' must not begin with '0'"));
11952 if (JSON_HEDLEY_UNLIKELY(s.size() > 1 && !(s[0] >=
'1' && s[0] <=
'9')))
11957 std::size_t processed_chars = 0;
11958 unsigned long long res = 0;
11961 res = std::stoull(s, &processed_chars);
11963 JSON_CATCH(std::out_of_range&)
11965 JSON_THROW(detail::out_of_range::create(404,
"unresolved reference token '" + s +
"'"));
11969 if (JSON_HEDLEY_UNLIKELY(processed_chars != s.size()))
11971 JSON_THROW(detail::out_of_range::create(404,
"unresolved reference token '" + s +
"'"));
11976 if (res >=
static_cast<unsigned long long>((std::numeric_limits<size_type>::max)()))
11978 JSON_THROW(detail::out_of_range::create(410,
"array index " + s +
" exceeds size_type"));
11981 return static_cast<size_type
>(res);
11984 JSON_PRIVATE_UNLESS_TESTED:
11987 if (JSON_HEDLEY_UNLIKELY(
empty()))
11989 JSON_THROW(detail::out_of_range::create(405,
"JSON pointer has no parent"));
11993 result.reference_tokens = {reference_tokens[0]};
12006 BasicJsonType& get_and_create(BasicJsonType& j)
const
12012 for (
const auto& reference_token : reference_tokens)
12014 switch (result->type())
12018 if (reference_token ==
"0")
12021 result = &result->operator[](0);
12026 result = &result->operator[](reference_token);
12034 result = &result->operator[](reference_token);
12041 result = &result->operator[](array_index(reference_token));
12052 JSON_THROW(detail::type_error::create(313,
"invalid value to unflatten"));
12078 BasicJsonType& get_unchecked(BasicJsonType* ptr)
const
12080 for (
const auto& reference_token : reference_tokens)
12083 if (ptr->is_null())
12087 std::all_of(reference_token.begin(), reference_token.end(),
12088 [](
const unsigned char x)
12090 return std::isdigit(x);
12094 *ptr = (nums || reference_token ==
"-")
12099 switch (ptr->type())
12104 ptr = &ptr->operator[](reference_token);
12110 if (reference_token ==
"-")
12113 ptr = &ptr->operator[](ptr->m_value.array->size());
12118 ptr = &ptr->operator[](array_index(reference_token));
12124 JSON_THROW(detail::out_of_range::create(404,
"unresolved reference token '" + reference_token +
"'"));
12137 BasicJsonType& get_checked(BasicJsonType* ptr)
const
12139 for (
const auto& reference_token : reference_tokens)
12141 switch (ptr->type())
12146 ptr = &ptr->at(reference_token);
12152 if (JSON_HEDLEY_UNLIKELY(reference_token ==
"-"))
12155 JSON_THROW(detail::out_of_range::create(402,
12156 "array index '-' (" + std::to_string(ptr->m_value.array->size()) +
12157 ") is out of range"));
12161 ptr = &ptr->at(array_index(reference_token));
12166 JSON_THROW(detail::out_of_range::create(404,
"unresolved reference token '" + reference_token +
"'"));
12186 const BasicJsonType& get_unchecked(
const BasicJsonType* ptr)
const
12188 for (
const auto& reference_token : reference_tokens)
12190 switch (ptr->type())
12195 ptr = &ptr->operator[](reference_token);
12201 if (JSON_HEDLEY_UNLIKELY(reference_token ==
"-"))
12204 JSON_THROW(detail::out_of_range::create(402,
12205 "array index '-' (" + std::to_string(ptr->m_value.array->size()) +
12206 ") is out of range"));
12210 ptr = &ptr->operator[](array_index(reference_token));
12215 JSON_THROW(detail::out_of_range::create(404,
"unresolved reference token '" + reference_token +
"'"));
12228 const BasicJsonType& get_checked(
const BasicJsonType* ptr)
const
12230 for (
const auto& reference_token : reference_tokens)
12232 switch (ptr->type())
12237 ptr = &ptr->at(reference_token);
12243 if (JSON_HEDLEY_UNLIKELY(reference_token ==
"-"))
12246 JSON_THROW(detail::out_of_range::create(402,
12247 "array index '-' (" + std::to_string(ptr->m_value.array->size()) +
12248 ") is out of range"));
12252 ptr = &ptr->at(array_index(reference_token));
12257 JSON_THROW(detail::out_of_range::create(404,
"unresolved reference token '" + reference_token +
"'"));
12268 bool contains(
const BasicJsonType* ptr)
const
12270 for (
const auto& reference_token : reference_tokens)
12272 switch (ptr->type())
12276 if (!ptr->contains(reference_token))
12282 ptr = &ptr->operator[](reference_token);
12288 if (JSON_HEDLEY_UNLIKELY(reference_token ==
"-"))
12293 if (JSON_HEDLEY_UNLIKELY(reference_token.size() == 1 && !(
"0" <= reference_token && reference_token <=
"9")))
12298 if (JSON_HEDLEY_UNLIKELY(reference_token.size() > 1))
12300 if (JSON_HEDLEY_UNLIKELY(!(
'1' <= reference_token[0] && reference_token[0] <=
'9')))
12305 for (std::size_t i = 1; i < reference_token.size(); i++)
12307 if (JSON_HEDLEY_UNLIKELY(!(
'0' <= reference_token[i] && reference_token[i] <=
'9')))
12315 const auto idx = array_index(reference_token);
12316 if (idx >= ptr->size())
12322 ptr = &ptr->operator[](idx);
12348 static std::vector<std::string> split(
const std::string& reference_string)
12350 std::vector<std::string> result;
12353 if (reference_string.empty())
12359 if (JSON_HEDLEY_UNLIKELY(reference_string[0] !=
'/'))
12362 "JSON pointer must be empty or begin with '/' - was: '" +
12363 reference_string +
"'"));
12371 std::size_t slash = reference_string.find_first_of(
'/', 1),
12378 start = (slash == std::string::npos) ? 0 : slash + 1,
12380 slash = reference_string.find_first_of(
'/', start))
12384 auto reference_token = reference_string.substr(start, slash - start);
12387 for (std::size_t pos = reference_token.find_first_of(
'~');
12388 pos != std::string::npos;
12389 pos = reference_token.find_first_of(
'~', pos + 1))
12391 JSON_ASSERT(reference_token[pos] ==
'~');
12394 if (JSON_HEDLEY_UNLIKELY(pos == reference_token.size() - 1 ||
12395 (reference_token[pos + 1] !=
'0' &&
12396 reference_token[pos + 1] !=
'1')))
12403 unescape(reference_token);
12404 result.push_back(reference_token);
12423 static void replace_substring(std::string& s,
const std::string& f,
12424 const std::string& t)
12426 JSON_ASSERT(!f.empty());
12427 for (
auto pos = s.find(f);
12428 pos != std::string::npos;
12429 s.replace(pos, f.size(), t),
12430 pos = s.find(f, pos + t.size()))
12434 JSON_PRIVATE_UNLESS_TESTED:
12436 static std::string escape(std::string s)
12438 replace_substring(s,
"~",
"~0");
12439 replace_substring(s,
"/",
"~1");
12444 static void unescape(std::string& s)
12446 replace_substring(s,
"~1",
"/");
12447 replace_substring(s,
"~0",
"~");
12458 static void flatten(
const std::string& reference_string,
12459 const BasicJsonType& value,
12460 BasicJsonType& result)
12462 switch (
value.type())
12466 if (
value.m_value.array->empty())
12469 result[reference_string] =
nullptr;
12474 for (std::size_t i = 0; i <
value.m_value.array->size(); ++i)
12476 flatten(reference_string +
"/" + std::to_string(i),
12477 value.m_value.array->operator[](i), result);
12485 if (
value.m_value.object->empty())
12488 result[reference_string] =
nullptr;
12493 for (
const auto& element : *
value.m_value.object)
12495 flatten(reference_string +
"/" + escape(element.first), element.second, result);
12504 result[reference_string] =
value;
12520 static BasicJsonType
12521 unflatten(
const BasicJsonType& value)
12523 if (JSON_HEDLEY_UNLIKELY(!
value.is_object()))
12525 JSON_THROW(detail::type_error::create(314,
"only objects can be unflattened"));
12528 BasicJsonType result;
12531 for (
const auto& element : *
value.m_value.object)
12533 if (JSON_HEDLEY_UNLIKELY(!element.second.is_primitive()))
12535 JSON_THROW(detail::type_error::create(315,
"values in object must be primitive"));
12542 json_pointer(element.first).get_and_create(result) = element.second;
12562 return lhs.reference_tokens == rhs.reference_tokens;
12579 return !(lhs == rhs);
12583 std::vector<std::string> reference_tokens;
12590 #include <initializer_list>
12600 template<
typename BasicJsonType>
12604 using value_type = BasicJsonType;
12607 : owned_value(std::move(
value))
12608 , value_ref(&owned_value)
12613 : value_ref(
const_cast<value_type*
>(&
value))
12617 json_ref(std::initializer_list<json_ref> init)
12618 : owned_value(init)
12619 , value_ref(&owned_value)
12625 enable_if_t<std::is_constructible<value_type, Args...>::value,
int> = 0 >
12627 : owned_value(std::forward<Args>(args)...)
12628 , value_ref(&owned_value)
12639 value_type moved_or_copied()
const
12643 return std::move(*value_ref);
12648 value_type
const& operator*()
const
12650 return *
static_cast<value_type const*
>(value_ref);
12653 value_type
const* operator->()
const
12655 return static_cast<value_type const*
>(value_ref);
12659 mutable value_type owned_value =
nullptr;
12660 value_type* value_ref =
nullptr;
12661 const bool is_rvalue =
true;
12675 #include <algorithm>
12690 #include <algorithm>
12693 #include <iterator>
12708 virtual void write_character(CharType c) = 0;
12709 virtual void write_characters(
const CharType* s, std::size_t length) = 0;
12714 template<
typename CharType>
12718 template<
typename CharType>
12726 void write_character(CharType c)
override
12731 JSON_HEDLEY_NON_NULL(2)
12732 void write_characters(
const CharType* s, std::size_t length)
override
12734 std::copy(s, s + length, std::back_inserter(v));
12738 std::vector<CharType>& v;
12742 template<
typename CharType>
12750 void write_character(CharType c)
override
12755 JSON_HEDLEY_NON_NULL(2)
12756 void write_characters(
const CharType* s, std::size_t length)
override
12758 stream.write(s,
static_cast<std::streamsize
>(length));
12762 std::basic_ostream<CharType>& stream;
12766 template<
typename CharType,
typename StringType = std::basic_
string<CharType>>
12774 void write_character(CharType c)
override
12779 JSON_HEDLEY_NON_NULL(2)
12780 void write_characters(
const CharType* s, std::size_t length)
override
12782 str.append(s, length);
12789 template<
typename CharType,
typename StringType = std::basic_
string<CharType>>
12825 template<
typename BasicJsonType,
typename CharType>
12828 using string_t =
typename BasicJsonType::string_t;
12829 using binary_t =
typename BasicJsonType::binary_t;
12830 using number_float_t =
typename BasicJsonType::number_float_t;
12853 write_bson_object(*j.m_value.object);
12859 JSON_THROW(type_error::create(317,
"to serialize to BSON, top-level type must be object, but is " + std::string(j.type_name())));
12873 oa->write_character(to_char_type(0xF6));
12879 oa->write_character(j.m_value.boolean
12880 ? to_char_type(0xF5)
12881 : to_char_type(0xF4));
12887 if (j.m_value.number_integer >= 0)
12892 if (j.m_value.number_integer <= 0x17)
12894 write_number(
static_cast<std::uint8_t
>(j.m_value.number_integer));
12896 else if (j.m_value.number_integer <= (std::numeric_limits<std::uint8_t>::max)())
12898 oa->write_character(to_char_type(0x18));
12899 write_number(
static_cast<std::uint8_t
>(j.m_value.number_integer));
12901 else if (j.m_value.number_integer <= (std::numeric_limits<std::uint16_t>::max)())
12903 oa->write_character(to_char_type(0x19));
12904 write_number(
static_cast<std::uint16_t
>(j.m_value.number_integer));
12906 else if (j.m_value.number_integer <= (std::numeric_limits<std::uint32_t>::max)())
12908 oa->write_character(to_char_type(0x1A));
12909 write_number(
static_cast<std::uint32_t
>(j.m_value.number_integer));
12913 oa->write_character(to_char_type(0x1B));
12914 write_number(
static_cast<std::uint64_t
>(j.m_value.number_integer));
12921 const auto positive_number = -1 - j.m_value.number_integer;
12922 if (j.m_value.number_integer >= -24)
12924 write_number(
static_cast<std::uint8_t
>(0x20 + positive_number));
12926 else if (positive_number <= (std::numeric_limits<std::uint8_t>::max)())
12928 oa->write_character(to_char_type(0x38));
12929 write_number(
static_cast<std::uint8_t
>(positive_number));
12931 else if (positive_number <= (std::numeric_limits<std::uint16_t>::max)())
12933 oa->write_character(to_char_type(0x39));
12934 write_number(
static_cast<std::uint16_t
>(positive_number));
12936 else if (positive_number <= (std::numeric_limits<std::uint32_t>::max)())
12938 oa->write_character(to_char_type(0x3A));
12939 write_number(
static_cast<std::uint32_t
>(positive_number));
12943 oa->write_character(to_char_type(0x3B));
12944 write_number(
static_cast<std::uint64_t
>(positive_number));
12952 if (j.m_value.number_unsigned <= 0x17)
12954 write_number(
static_cast<std::uint8_t
>(j.m_value.number_unsigned));
12956 else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint8_t>::max)())
12958 oa->write_character(to_char_type(0x18));
12959 write_number(
static_cast<std::uint8_t
>(j.m_value.number_unsigned));
12961 else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint16_t>::max)())
12963 oa->write_character(to_char_type(0x19));
12964 write_number(
static_cast<std::uint16_t
>(j.m_value.number_unsigned));
12966 else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint32_t>::max)())
12968 oa->write_character(to_char_type(0x1A));
12969 write_number(
static_cast<std::uint32_t
>(j.m_value.number_unsigned));
12973 oa->write_character(to_char_type(0x1B));
12974 write_number(
static_cast<std::uint64_t
>(j.m_value.number_unsigned));
12981 if (std::isnan(j.m_value.number_float))
12984 oa->write_character(to_char_type(0xF9));
12985 oa->write_character(to_char_type(0x7E));
12986 oa->write_character(to_char_type(0x00));
12988 else if (std::isinf(j.m_value.number_float))
12991 oa->write_character(to_char_type(0xf9));
12992 oa->write_character(j.m_value.number_float > 0 ? to_char_type(0x7C) : to_char_type(0xFC));
12993 oa->write_character(to_char_type(0x00));
12997 write_compact_float(j.m_value.number_float, detail::input_format_t::cbor);
13005 const auto N = j.m_value.string->size();
13008 write_number(
static_cast<std::uint8_t
>(0x60 + N));
13010 else if (N <= (std::numeric_limits<std::uint8_t>::max)())
13012 oa->write_character(to_char_type(0x78));
13013 write_number(
static_cast<std::uint8_t
>(N));
13015 else if (N <= (std::numeric_limits<std::uint16_t>::max)())
13017 oa->write_character(to_char_type(0x79));
13018 write_number(
static_cast<std::uint16_t
>(N));
13020 else if (N <= (std::numeric_limits<std::uint32_t>::max)())
13022 oa->write_character(to_char_type(0x7A));
13023 write_number(
static_cast<std::uint32_t
>(N));
13026 else if (N <= (std::numeric_limits<std::uint64_t>::max)())
13028 oa->write_character(to_char_type(0x7B));
13029 write_number(
static_cast<std::uint64_t
>(N));
13034 oa->write_characters(
13035 reinterpret_cast<const CharType*
>(j.m_value.string->c_str()),
13036 j.m_value.string->size());
13043 const auto N = j.m_value.array->size();
13046 write_number(
static_cast<std::uint8_t
>(0x80 + N));
13048 else if (N <= (std::numeric_limits<std::uint8_t>::max)())
13050 oa->write_character(to_char_type(0x98));
13051 write_number(
static_cast<std::uint8_t
>(N));
13053 else if (N <= (std::numeric_limits<std::uint16_t>::max)())
13055 oa->write_character(to_char_type(0x99));
13056 write_number(
static_cast<std::uint16_t
>(N));
13058 else if (N <= (std::numeric_limits<std::uint32_t>::max)())
13060 oa->write_character(to_char_type(0x9A));
13061 write_number(
static_cast<std::uint32_t
>(N));
13064 else if (N <= (std::numeric_limits<std::uint64_t>::max)())
13066 oa->write_character(to_char_type(0x9B));
13067 write_number(
static_cast<std::uint64_t
>(N));
13072 for (
const auto& el : *j.m_value.array)
13081 if (j.m_value.binary->has_subtype())
13083 write_number(
static_cast<std::uint8_t
>(0xd8));
13084 write_number(j.m_value.binary->subtype());
13088 const auto N = j.m_value.binary->size();
13091 write_number(
static_cast<std::uint8_t
>(0x40 + N));
13093 else if (N <= (std::numeric_limits<std::uint8_t>::max)())
13095 oa->write_character(to_char_type(0x58));
13096 write_number(
static_cast<std::uint8_t
>(N));
13098 else if (N <= (std::numeric_limits<std::uint16_t>::max)())
13100 oa->write_character(to_char_type(0x59));
13101 write_number(
static_cast<std::uint16_t
>(N));
13103 else if (N <= (std::numeric_limits<std::uint32_t>::max)())
13105 oa->write_character(to_char_type(0x5A));
13106 write_number(
static_cast<std::uint32_t
>(N));
13109 else if (N <= (std::numeric_limits<std::uint64_t>::max)())
13111 oa->write_character(to_char_type(0x5B));
13112 write_number(
static_cast<std::uint64_t
>(N));
13117 oa->write_characters(
13118 reinterpret_cast<const CharType*
>(j.m_value.binary->data()),
13127 const auto N = j.m_value.object->size();
13130 write_number(
static_cast<std::uint8_t
>(0xA0 + N));
13132 else if (N <= (std::numeric_limits<std::uint8_t>::max)())
13134 oa->write_character(to_char_type(0xB8));
13135 write_number(
static_cast<std::uint8_t
>(N));
13137 else if (N <= (std::numeric_limits<std::uint16_t>::max)())
13139 oa->write_character(to_char_type(0xB9));
13140 write_number(
static_cast<std::uint16_t
>(N));
13142 else if (N <= (std::numeric_limits<std::uint32_t>::max)())
13144 oa->write_character(to_char_type(0xBA));
13145 write_number(
static_cast<std::uint32_t
>(N));
13148 else if (N <= (std::numeric_limits<std::uint64_t>::max)())
13150 oa->write_character(to_char_type(0xBB));
13151 write_number(
static_cast<std::uint64_t
>(N));
13156 for (
const auto& el : *j.m_value.object)
13178 oa->write_character(to_char_type(0xC0));
13184 oa->write_character(j.m_value.boolean
13185 ? to_char_type(0xC3)
13186 : to_char_type(0xC2));
13192 if (j.m_value.number_integer >= 0)
13197 if (j.m_value.number_unsigned < 128)
13200 write_number(
static_cast<std::uint8_t
>(j.m_value.number_integer));
13202 else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint8_t>::max)())
13205 oa->write_character(to_char_type(0xCC));
13206 write_number(
static_cast<std::uint8_t
>(j.m_value.number_integer));
13208 else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint16_t>::max)())
13211 oa->write_character(to_char_type(0xCD));
13212 write_number(
static_cast<std::uint16_t
>(j.m_value.number_integer));
13214 else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint32_t>::max)())
13217 oa->write_character(to_char_type(0xCE));
13218 write_number(
static_cast<std::uint32_t
>(j.m_value.number_integer));
13220 else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint64_t>::max)())
13223 oa->write_character(to_char_type(0xCF));
13224 write_number(
static_cast<std::uint64_t
>(j.m_value.number_integer));
13229 if (j.m_value.number_integer >= -32)
13232 write_number(
static_cast<std::int8_t
>(j.m_value.number_integer));
13234 else if (j.m_value.number_integer >= (std::numeric_limits<std::int8_t>::min)() &&
13235 j.m_value.number_integer <= (std::numeric_limits<std::int8_t>::max)())
13238 oa->write_character(to_char_type(0xD0));
13239 write_number(
static_cast<std::int8_t
>(j.m_value.number_integer));
13241 else if (j.m_value.number_integer >= (std::numeric_limits<std::int16_t>::min)() &&
13242 j.m_value.number_integer <= (std::numeric_limits<std::int16_t>::max)())
13245 oa->write_character(to_char_type(0xD1));
13246 write_number(
static_cast<std::int16_t
>(j.m_value.number_integer));
13248 else if (j.m_value.number_integer >= (std::numeric_limits<std::int32_t>::min)() &&
13249 j.m_value.number_integer <= (std::numeric_limits<std::int32_t>::max)())
13252 oa->write_character(to_char_type(0xD2));
13253 write_number(
static_cast<std::int32_t
>(j.m_value.number_integer));
13255 else if (j.m_value.number_integer >= (std::numeric_limits<std::int64_t>::min)() &&
13256 j.m_value.number_integer <= (std::numeric_limits<std::int64_t>::max)())
13259 oa->write_character(to_char_type(0xD3));
13260 write_number(
static_cast<std::int64_t
>(j.m_value.number_integer));
13268 if (j.m_value.number_unsigned < 128)
13271 write_number(
static_cast<std::uint8_t
>(j.m_value.number_integer));
13273 else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint8_t>::max)())
13276 oa->write_character(to_char_type(0xCC));
13277 write_number(
static_cast<std::uint8_t
>(j.m_value.number_integer));
13279 else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint16_t>::max)())
13282 oa->write_character(to_char_type(0xCD));
13283 write_number(
static_cast<std::uint16_t
>(j.m_value.number_integer));
13285 else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint32_t>::max)())
13288 oa->write_character(to_char_type(0xCE));
13289 write_number(
static_cast<std::uint32_t
>(j.m_value.number_integer));
13291 else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint64_t>::max)())
13294 oa->write_character(to_char_type(0xCF));
13295 write_number(
static_cast<std::uint64_t
>(j.m_value.number_integer));
13302 write_compact_float(j.m_value.number_float, detail::input_format_t::msgpack);
13309 const auto N = j.m_value.string->size();
13313 write_number(
static_cast<std::uint8_t
>(0xA0 | N));
13315 else if (N <= (std::numeric_limits<std::uint8_t>::max)())
13318 oa->write_character(to_char_type(0xD9));
13319 write_number(
static_cast<std::uint8_t
>(N));
13321 else if (N <= (std::numeric_limits<std::uint16_t>::max)())
13324 oa->write_character(to_char_type(0xDA));
13325 write_number(
static_cast<std::uint16_t
>(N));
13327 else if (N <= (std::numeric_limits<std::uint32_t>::max)())
13330 oa->write_character(to_char_type(0xDB));
13331 write_number(
static_cast<std::uint32_t
>(N));
13335 oa->write_characters(
13336 reinterpret_cast<const CharType*
>(j.m_value.string->c_str()),
13337 j.m_value.string->size());
13344 const auto N = j.m_value.array->size();
13348 write_number(
static_cast<std::uint8_t
>(0x90 | N));
13350 else if (N <= (std::numeric_limits<std::uint16_t>::max)())
13353 oa->write_character(to_char_type(0xDC));
13354 write_number(
static_cast<std::uint16_t
>(N));
13356 else if (N <= (std::numeric_limits<std::uint32_t>::max)())
13359 oa->write_character(to_char_type(0xDD));
13360 write_number(
static_cast<std::uint32_t
>(N));
13364 for (
const auto& el : *j.m_value.array)
13375 const bool use_ext = j.m_value.binary->has_subtype();
13378 const auto N = j.m_value.binary->size();
13379 if (N <= (std::numeric_limits<std::uint8_t>::max)())
13381 std::uint8_t output_type{};
13388 output_type = 0xD4;
13391 output_type = 0xD5;
13394 output_type = 0xD6;
13397 output_type = 0xD7;
13400 output_type = 0xD8;
13403 output_type = 0xC7;
13411 output_type = 0xC4;
13415 oa->write_character(to_char_type(output_type));
13418 write_number(
static_cast<std::uint8_t
>(N));
13421 else if (N <= (std::numeric_limits<std::uint16_t>::max)())
13423 std::uint8_t output_type = use_ext
13427 oa->write_character(to_char_type(output_type));
13428 write_number(
static_cast<std::uint16_t
>(N));
13430 else if (N <= (std::numeric_limits<std::uint32_t>::max)())
13432 std::uint8_t output_type = use_ext
13436 oa->write_character(to_char_type(output_type));
13437 write_number(
static_cast<std::uint32_t
>(N));
13443 write_number(
static_cast<std::int8_t
>(j.m_value.binary->subtype()));
13447 oa->write_characters(
13448 reinterpret_cast<const CharType*
>(j.m_value.binary->data()),
13457 const auto N = j.m_value.object->size();
13461 write_number(
static_cast<std::uint8_t
>(0x80 | (N & 0xF)));
13463 else if (N <= (std::numeric_limits<std::uint16_t>::max)())
13466 oa->write_character(to_char_type(0xDE));
13467 write_number(
static_cast<std::uint16_t
>(N));
13469 else if (N <= (std::numeric_limits<std::uint32_t>::max)())
13472 oa->write_character(to_char_type(0xDF));
13473 write_number(
static_cast<std::uint32_t
>(N));
13477 for (
const auto& el : *j.m_value.object)
13497 const bool use_type,
const bool add_prefix =
true)
13505 oa->write_character(to_char_type(
'Z'));
13514 oa->write_character(j.m_value.boolean
13515 ? to_char_type(
'T')
13516 : to_char_type(
'F'));
13523 write_number_with_ubjson_prefix(j.m_value.number_integer, add_prefix);
13529 write_number_with_ubjson_prefix(j.m_value.number_unsigned, add_prefix);
13535 write_number_with_ubjson_prefix(j.m_value.number_float, add_prefix);
13543 oa->write_character(to_char_type(
'S'));
13545 write_number_with_ubjson_prefix(j.m_value.string->size(),
true);
13546 oa->write_characters(
13547 reinterpret_cast<const CharType*
>(j.m_value.string->c_str()),
13548 j.m_value.string->size());
13556 oa->write_character(to_char_type(
'['));
13559 bool prefix_required =
true;
13560 if (use_type && !j.m_value.array->empty())
13562 JSON_ASSERT(use_count);
13563 const CharType first_prefix = ubjson_prefix(j.front());
13564 const bool same_prefix = std::all_of(j.begin() + 1, j.end(),
13565 [
this, first_prefix](
const BasicJsonType & v)
13567 return ubjson_prefix(v) == first_prefix;
13572 prefix_required =
false;
13573 oa->write_character(to_char_type(
'$'));
13574 oa->write_character(first_prefix);
13580 oa->write_character(to_char_type(
'#'));
13581 write_number_with_ubjson_prefix(j.m_value.array->size(),
true);
13584 for (
const auto& el : *j.m_value.array)
13586 write_ubjson(el, use_count, use_type, prefix_required);
13591 oa->write_character(to_char_type(
']'));
13601 oa->write_character(to_char_type(
'['));
13604 if (use_type && !j.m_value.binary->empty())
13606 JSON_ASSERT(use_count);
13607 oa->write_character(to_char_type(
'$'));
13608 oa->write_character(
'U');
13613 oa->write_character(to_char_type(
'#'));
13614 write_number_with_ubjson_prefix(j.m_value.binary->size(),
true);
13619 oa->write_characters(
13620 reinterpret_cast<const CharType*
>(j.m_value.binary->data()),
13621 j.m_value.binary->size());
13625 for (
size_t i = 0; i < j.m_value.binary->size(); ++i)
13627 oa->write_character(to_char_type(
'U'));
13628 oa->write_character(j.m_value.binary->data()[i]);
13634 oa->write_character(to_char_type(
']'));
13644 oa->write_character(to_char_type(
'{'));
13647 bool prefix_required =
true;
13648 if (use_type && !j.m_value.object->empty())
13650 JSON_ASSERT(use_count);
13651 const CharType first_prefix = ubjson_prefix(j.front());
13652 const bool same_prefix = std::all_of(j.begin(), j.end(),
13653 [
this, first_prefix](
const BasicJsonType & v)
13655 return ubjson_prefix(v) == first_prefix;
13660 prefix_required =
false;
13661 oa->write_character(to_char_type(
'$'));
13662 oa->write_character(first_prefix);
13668 oa->write_character(to_char_type(
'#'));
13669 write_number_with_ubjson_prefix(j.m_value.object->size(),
true);
13672 for (
const auto& el : *j.m_value.object)
13674 write_number_with_ubjson_prefix(el.first.size(),
true);
13675 oa->write_characters(
13676 reinterpret_cast<const CharType*
>(el.first.c_str()),
13678 write_ubjson(el.second, use_count, use_type, prefix_required);
13683 oa->write_character(to_char_type(
'}'));
13703 static std::size_t calc_bson_entry_header_size(
const string_t& name)
13705 const auto it = name.find(
static_cast<typename string_t::value_type
>(0));
13706 if (JSON_HEDLEY_UNLIKELY(it != BasicJsonType::string_t::npos))
13708 JSON_THROW(out_of_range::create(409,
13709 "BSON key cannot contain code point U+0000 (at byte " + std::to_string(it) +
")"));
13712 return 1ul + name.size() + 1u;
13718 void write_bson_entry_header(
const string_t& name,
13719 const std::uint8_t element_type)
13721 oa->write_character(to_char_type(element_type));
13722 oa->write_characters(
13723 reinterpret_cast<const CharType*
>(name.c_str()),
13730 void write_bson_boolean(
const string_t& name,
13733 write_bson_entry_header(name, 0x08);
13734 oa->write_character(value ? to_char_type(0x01) : to_char_type(0x00));
13740 void write_bson_double(
const string_t& name,
13741 const double value)
13743 write_bson_entry_header(name, 0x01);
13744 write_number<double, true>(value);
13750 static std::size_t calc_bson_string_size(
const string_t& value)
13752 return sizeof(std::int32_t) +
value.size() + 1ul;
13758 void write_bson_string(
const string_t& name,
13759 const string_t& value)
13761 write_bson_entry_header(name, 0x02);
13763 write_number<std::int32_t, true>(
static_cast<std::int32_t
>(
value.size() + 1ul));
13764 oa->write_characters(
13765 reinterpret_cast<const CharType*
>(
value.c_str()),
13772 void write_bson_null(
const string_t& name)
13774 write_bson_entry_header(name, 0x0A);
13780 static std::size_t calc_bson_integer_size(
const std::int64_t value)
13782 return (std::numeric_limits<std::int32_t>::min)() <= value && value <= (std::numeric_limits<std::int32_t>::max)()
13783 ?
sizeof(std::int32_t)
13784 :
sizeof(std::int64_t);
13790 void write_bson_integer(
const string_t& name,
13791 const std::int64_t value)
13793 if ((std::numeric_limits<std::int32_t>::min)() <= value && value <= (std::numeric_limits<std::int32_t>::max)())
13795 write_bson_entry_header(name, 0x10);
13796 write_number<std::int32_t, true>(
static_cast<std::int32_t
>(value));
13800 write_bson_entry_header(name, 0x12);
13801 write_number<std::int64_t, true>(
static_cast<std::int64_t
>(value));
13808 static constexpr std::size_t calc_bson_unsigned_size(
const std::uint64_t value) noexcept
13810 return (value <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int32_t>::max)()))
13811 ?
sizeof(std::int32_t)
13812 :
sizeof(std::int64_t);
13818 void write_bson_unsigned(
const string_t& name,
13819 const std::uint64_t value)
13821 if (value <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int32_t>::max)()))
13823 write_bson_entry_header(name, 0x10 );
13824 write_number<std::int32_t, true>(
static_cast<std::int32_t
>(value));
13826 else if (value <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int64_t>::max)()))
13828 write_bson_entry_header(name, 0x12 );
13829 write_number<std::int64_t, true>(
static_cast<std::int64_t
>(value));
13833 JSON_THROW(out_of_range::create(407,
"integer number " + std::to_string(value) +
" cannot be represented by BSON as it does not fit int64"));
13840 void write_bson_object_entry(
const string_t& name,
13841 const typename BasicJsonType::object_t& value)
13843 write_bson_entry_header(name, 0x03);
13844 write_bson_object(value);
13850 static std::size_t calc_bson_array_size(
const typename BasicJsonType::array_t& value)
13852 std::size_t array_index = 0ul;
13854 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)
13856 return result + calc_bson_element_size(std::to_string(array_index++), el);
13859 return sizeof(std::int32_t) + embedded_document_size + 1ul;
13865 static std::size_t calc_bson_binary_size(
const typename BasicJsonType::binary_t& value)
13867 return sizeof(std::int32_t) +
value.size() + 1ul;
13873 void write_bson_array(
const string_t& name,
13874 const typename BasicJsonType::array_t& value)
13876 write_bson_entry_header(name, 0x04);
13877 write_number<std::int32_t, true>(
static_cast<std::int32_t
>(calc_bson_array_size(value)));
13879 std::size_t array_index = 0ul;
13881 for (
const auto& el : value)
13883 write_bson_element(std::to_string(array_index++), el);
13886 oa->write_character(to_char_type(0x00));
13892 void write_bson_binary(
const string_t& name,
13893 const binary_t& value)
13895 write_bson_entry_header(name, 0x05);
13897 write_number<std::int32_t, true>(
static_cast<std::int32_t
>(
value.size()));
13898 write_number(
value.has_subtype() ?
value.subtype() : std::uint8_t(0x00));
13900 oa->write_characters(
reinterpret_cast<const CharType*
>(
value.data()),
value.size());
13907 static std::size_t calc_bson_element_size(
const string_t& name,
13908 const BasicJsonType& j)
13910 const auto header_size = calc_bson_entry_header_size(name);
13914 return header_size + calc_bson_object_size(*j.m_value.object);
13917 return header_size + calc_bson_array_size(*j.m_value.array);
13920 return header_size + calc_bson_binary_size(*j.m_value.binary);
13923 return header_size + 1ul;
13926 return header_size + 8ul;
13929 return header_size + calc_bson_integer_size(j.m_value.number_integer);
13932 return header_size + calc_bson_unsigned_size(j.m_value.number_unsigned);
13935 return header_size + calc_bson_string_size(*j.m_value.string);
13938 return header_size + 0ul;
13942 JSON_ASSERT(
false);
13955 void write_bson_element(
const string_t& name,
13956 const BasicJsonType& j)
13961 return write_bson_object_entry(name, *j.m_value.object);
13964 return write_bson_array(name, *j.m_value.array);
13967 return write_bson_binary(name, *j.m_value.binary);
13970 return write_bson_boolean(name, j.m_value.boolean);
13973 return write_bson_double(name, j.m_value.number_float);
13976 return write_bson_integer(name, j.m_value.number_integer);
13979 return write_bson_unsigned(name, j.m_value.number_unsigned);
13982 return write_bson_string(name, *j.m_value.string);
13985 return write_bson_null(name);
13989 JSON_ASSERT(
false);
14001 static std::size_t calc_bson_object_size(
const typename BasicJsonType::object_t& value)
14003 std::size_t document_size = std::accumulate(
value.begin(),
value.end(), std::size_t(0),
14004 [](
size_t result,
const typename BasicJsonType::object_t::value_type & el)
14006 return result += calc_bson_element_size(el.first, el.second);
14009 return sizeof(std::int32_t) + document_size + 1ul;
14016 void write_bson_object(
const typename BasicJsonType::object_t& value)
14018 write_number<std::int32_t, true>(
static_cast<std::int32_t
>(calc_bson_object_size(value)));
14020 for (
const auto& el : value)
14022 write_bson_element(el.first, el.second);
14025 oa->write_character(to_char_type(0x00));
14032 static constexpr CharType get_cbor_float_prefix(
float )
14034 return to_char_type(0xFA);
14037 static constexpr CharType get_cbor_float_prefix(
double )
14039 return to_char_type(0xFB);
14046 static constexpr CharType get_msgpack_float_prefix(
float )
14048 return to_char_type(0xCA);
14051 static constexpr CharType get_msgpack_float_prefix(
double )
14053 return to_char_type(0xCB);
14061 template<
typename NumberType,
typename std::enable_if<
14062 std::is_floating_point<NumberType>::value,
int>::type = 0>
14063 void write_number_with_ubjson_prefix(
const NumberType n,
14064 const bool add_prefix)
14068 oa->write_character(get_ubjson_float_prefix(n));
14074 template<
typename NumberType,
typename std::enable_if<
14075 std::is_unsigned<NumberType>::value,
int>::type = 0>
14076 void write_number_with_ubjson_prefix(
const NumberType n,
14077 const bool add_prefix)
14079 if (n <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int8_t>::max)()))
14083 oa->write_character(to_char_type(
'i'));
14085 write_number(
static_cast<std::uint8_t
>(n));
14087 else if (n <= (std::numeric_limits<std::uint8_t>::max)())
14091 oa->write_character(to_char_type(
'U'));
14093 write_number(
static_cast<std::uint8_t
>(n));
14095 else if (n <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int16_t>::max)()))
14099 oa->write_character(to_char_type(
'I'));
14101 write_number(
static_cast<std::int16_t
>(n));
14103 else if (n <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int32_t>::max)()))
14107 oa->write_character(to_char_type(
'l'));
14109 write_number(
static_cast<std::int32_t
>(n));
14111 else if (n <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int64_t>::max)()))
14115 oa->write_character(to_char_type(
'L'));
14117 write_number(
static_cast<std::int64_t
>(n));
14123 oa->write_character(to_char_type(
'H'));
14126 const auto number = BasicJsonType(n).dump();
14127 write_number_with_ubjson_prefix(number.size(),
true);
14128 for (std::size_t i = 0; i < number.size(); ++i)
14130 oa->write_character(to_char_type(
static_cast<std::uint8_t
>(number[i])));
14136 template <
typename NumberType,
typename std::enable_if <
14137 std::is_signed<NumberType>::value&&
14138 !std::is_floating_point<NumberType>::value,
int >::type = 0 >
14139 void write_number_with_ubjson_prefix(
const NumberType n,
14140 const bool add_prefix)
14142 if ((std::numeric_limits<std::int8_t>::min)() <= n && n <= (std::numeric_limits<std::int8_t>::max)())
14146 oa->write_character(to_char_type(
'i'));
14148 write_number(
static_cast<std::int8_t
>(n));
14150 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)()))
14154 oa->write_character(to_char_type(
'U'));
14156 write_number(
static_cast<std::uint8_t
>(n));
14158 else if ((std::numeric_limits<std::int16_t>::min)() <= n && n <= (std::numeric_limits<std::int16_t>::max)())
14162 oa->write_character(to_char_type(
'I'));
14164 write_number(
static_cast<std::int16_t
>(n));
14166 else if ((std::numeric_limits<std::int32_t>::min)() <= n && n <= (std::numeric_limits<std::int32_t>::max)())
14170 oa->write_character(to_char_type(
'l'));
14172 write_number(
static_cast<std::int32_t
>(n));
14174 else if ((std::numeric_limits<std::int64_t>::min)() <= n && n <= (std::numeric_limits<std::int64_t>::max)())
14178 oa->write_character(to_char_type(
'L'));
14180 write_number(
static_cast<std::int64_t
>(n));
14187 oa->write_character(to_char_type(
'H'));
14190 const auto number = BasicJsonType(n).dump();
14191 write_number_with_ubjson_prefix(number.size(),
true);
14192 for (std::size_t i = 0; i < number.size(); ++i)
14194 oa->write_character(to_char_type(
static_cast<std::uint8_t
>(number[i])));
14203 CharType ubjson_prefix(
const BasicJsonType& j)
const noexcept
14211 return j.m_value.boolean ?
'T' :
'F';
14215 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)())
14219 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)())
14223 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)())
14227 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)())
14231 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)())
14241 if (j.m_value.number_unsigned <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int8_t>::max)()))
14245 if (j.m_value.number_unsigned <=
static_cast<std::uint64_t
>((std::numeric_limits<std::uint8_t>::max)()))
14249 if (j.m_value.number_unsigned <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int16_t>::max)()))
14253 if (j.m_value.number_unsigned <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int32_t>::max)()))
14257 if (j.m_value.number_unsigned <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int64_t>::max)()))
14266 return get_ubjson_float_prefix(j.m_value.number_float);
14283 static constexpr CharType get_ubjson_float_prefix(
float )
14288 static constexpr CharType get_ubjson_float_prefix(
double )
14308 template<
typename NumberType,
bool OutputIsLittleEndian = false>
14309 void write_number(
const NumberType n)
14312 std::array<CharType,
sizeof(NumberType)> vec;
14313 std::memcpy(vec.data(), &n,
sizeof(NumberType));
14316 if (is_little_endian != OutputIsLittleEndian)
14319 std::reverse(vec.begin(), vec.end());
14322 oa->write_characters(vec.data(),
sizeof(NumberType));
14327 if (
static_cast<double>(n) >=
static_cast<double>(std::numeric_limits<float>::lowest()) &&
14328 static_cast<double>(n) <=
static_cast<double>((std::numeric_limits<float>::max)()) &&
14329 static_cast<double>(
static_cast<float>(n)) ==
static_cast<double>(n))
14331 oa->write_character(format == detail::input_format_t::cbor
14332 ? get_cbor_float_prefix(
static_cast<float>(n))
14333 : get_msgpack_float_prefix(
static_cast<float>(n)));
14334 write_number(
static_cast<float>(n));
14338 oa->write_character(format == detail::input_format_t::cbor
14339 ? get_cbor_float_prefix(n)
14340 : get_msgpack_float_prefix(n));
14350 template <
typename C = CharType,
14351 enable_if_t < std::is_signed<C>::value && std::is_signed<char>::value > * =
nullptr >
14352 static constexpr CharType to_char_type(std::uint8_t x) noexcept
14354 return *
reinterpret_cast<char*
>(&x);
14357 template <
typename C = CharType,
14358 enable_if_t < std::is_signed<C>::value && std::is_unsigned<char>::value > * =
nullptr >
14359 static CharType to_char_type(std::uint8_t x) noexcept
14361 static_assert(
sizeof(std::uint8_t) ==
sizeof(CharType),
"size of CharType must be equal to std::uint8_t");
14362 static_assert(std::is_trivial<CharType>::value,
"CharType must be trivial");
14364 std::memcpy(&result, &x,
sizeof(x));
14368 template<
typename C = CharType,
14369 enable_if_t<std::is_unsigned<C>::value>* =
nullptr>
14370 static constexpr CharType to_char_type(std::uint8_t x) noexcept
14375 template <
typename InputCharType,
typename C = CharType,
14377 std::is_signed<C>::value &&
14378 std::is_signed<char>::value &&
14379 std::is_same<char, typename std::remove_cv<InputCharType>::type>::value
14381 static constexpr CharType to_char_type(InputCharType x) noexcept
14388 const bool is_little_endian = little_endianess();
14391 output_adapter_t<CharType> oa =
nullptr;
14401 #include <algorithm>
14410 #include <type_traits>
14421 #include <type_traits>
14450 namespace dtoa_impl
14453 template<
typename Target,
typename Source>
14454 Target reinterpret_bits(
const Source source)
14456 static_assert(
sizeof(Target) ==
sizeof(Source),
"size mismatch");
14459 std::memcpy(&target, &source,
sizeof(Source));
14465 static constexpr
int kPrecision = 64;
14467 std::uint64_t f = 0;
14470 constexpr
diyfp(std::uint64_t f_,
int e_) noexcept : f(f_), e(e_) {}
14478 JSON_ASSERT(x.e == y.e);
14479 JSON_ASSERT(x.f >= y.f);
14481 return {x.f - y.f, x.e};
14490 static_assert(kPrecision == 64,
"internal error");
14515 const std::uint64_t u_lo = x.f & 0xFFFFFFFFu;
14516 const std::uint64_t u_hi = x.f >> 32u;
14517 const std::uint64_t v_lo = y.f & 0xFFFFFFFFu;
14518 const std::uint64_t v_hi = y.f >> 32u;
14520 const std::uint64_t p0 = u_lo * v_lo;
14521 const std::uint64_t p1 = u_lo * v_hi;
14522 const std::uint64_t p2 = u_hi * v_lo;
14523 const std::uint64_t p3 = u_hi * v_hi;
14525 const std::uint64_t p0_hi = p0 >> 32u;
14526 const std::uint64_t p1_lo = p1 & 0xFFFFFFFFu;
14527 const std::uint64_t p1_hi = p1 >> 32u;
14528 const std::uint64_t p2_lo = p2 & 0xFFFFFFFFu;
14529 const std::uint64_t p2_hi = p2 >> 32u;
14531 std::uint64_t Q = p0_hi + p1_lo + p2_lo;
14542 Q += std::uint64_t{1} << (64u - 32u - 1u);
14544 const std::uint64_t h = p3 + p2_hi + p1_hi + (Q >> 32u);
14546 return {h, x.e + y.e + 64};
14555 JSON_ASSERT(x.f != 0);
14557 while ((x.f >> 63u) == 0)
14572 const int delta = x.e - target_exponent;
14574 JSON_ASSERT(delta >= 0);
14575 JSON_ASSERT(((x.f << delta) >> delta) == x.f);
14577 return {x.f << delta, target_exponent};
14594 template<
typename FloatType>
14597 JSON_ASSERT(std::isfinite(
value));
14598 JSON_ASSERT(
value > 0);
14607 static_assert(std::numeric_limits<FloatType>::is_iec559,
14608 "internal error: dtoa_short requires an IEEE-754 floating-point implementation");
14610 constexpr
int kPrecision = std::numeric_limits<FloatType>::digits;
14611 constexpr
int kBias = std::numeric_limits<FloatType>::max_exponent - 1 + (kPrecision - 1);
14612 constexpr
int kMinExp = 1 - kBias;
14613 constexpr std::uint64_t kHiddenBit = std::uint64_t{1} << (kPrecision - 1);
14615 using bits_type =
typename std::conditional<kPrecision == 24, std::uint32_t, std::uint64_t >::type;
14617 const std::uint64_t bits = reinterpret_bits<bits_type>(
value);
14618 const std::uint64_t E = bits >> (kPrecision - 1);
14619 const std::uint64_t F = bits & (kHiddenBit - 1);
14621 const bool is_denormal = E == 0;
14622 const diyfp v = is_denormal
14623 ?
diyfp(F, kMinExp)
14624 :
diyfp(F + kHiddenBit,
static_cast<int>(E) - kBias);
14647 const bool lower_boundary_is_closer = F == 0 && E > 1;
14648 const diyfp m_plus =
diyfp(2 * v.f + 1, v.e - 1);
14649 const diyfp m_minus = lower_boundary_is_closer
14650 ?
diyfp(4 * v.f - 1, v.e - 2)
14651 :
diyfp(2 * v.f - 1, v.e - 1);
14717 constexpr
int kAlpha = -60;
14718 constexpr
int kGamma = -32;
14786 constexpr
int kCachedPowersMinDecExp = -300;
14787 constexpr
int kCachedPowersDecStep = 8;
14789 static constexpr std::array<cached_power, 79> kCachedPowers =
14792 { 0xAB70FE17C79AC6CA, -1060, -300 },
14793 { 0xFF77B1FCBEBCDC4F, -1034, -292 },
14794 { 0xBE5691EF416BD60C, -1007, -284 },
14795 { 0x8DD01FAD907FFC3C, -980, -276 },
14796 { 0xD3515C2831559A83, -954, -268 },
14797 { 0x9D71AC8FADA6C9B5, -927, -260 },
14798 { 0xEA9C227723EE8BCB, -901, -252 },
14799 { 0xAECC49914078536D, -874, -244 },
14800 { 0x823C12795DB6CE57, -847, -236 },
14801 { 0xC21094364DFB5637, -821, -228 },
14802 { 0x9096EA6F3848984F, -794, -220 },
14803 { 0xD77485CB25823AC7, -768, -212 },
14804 { 0xA086CFCD97BF97F4, -741, -204 },
14805 { 0xEF340A98172AACE5, -715, -196 },
14806 { 0xB23867FB2A35B28E, -688, -188 },
14807 { 0x84C8D4DFD2C63F3B, -661, -180 },
14808 { 0xC5DD44271AD3CDBA, -635, -172 },
14809 { 0x936B9FCEBB25C996, -608, -164 },
14810 { 0xDBAC6C247D62A584, -582, -156 },
14811 { 0xA3AB66580D5FDAF6, -555, -148 },
14812 { 0xF3E2F893DEC3F126, -529, -140 },
14813 { 0xB5B5ADA8AAFF80B8, -502, -132 },
14814 { 0x87625F056C7C4A8B, -475, -124 },
14815 { 0xC9BCFF6034C13053, -449, -116 },
14816 { 0x964E858C91BA2655, -422, -108 },
14817 { 0xDFF9772470297EBD, -396, -100 },
14818 { 0xA6DFBD9FB8E5B88F, -369, -92 },
14819 { 0xF8A95FCF88747D94, -343, -84 },
14820 { 0xB94470938FA89BCF, -316, -76 },
14821 { 0x8A08F0F8BF0F156B, -289, -68 },
14822 { 0xCDB02555653131B6, -263, -60 },
14823 { 0x993FE2C6D07B7FAC, -236, -52 },
14824 { 0xE45C10C42A2B3B06, -210, -44 },
14825 { 0xAA242499697392D3, -183, -36 },
14826 { 0xFD87B5F28300CA0E, -157, -28 },
14827 { 0xBCE5086492111AEB, -130, -20 },
14828 { 0x8CBCCC096F5088CC, -103, -12 },
14829 { 0xD1B71758E219652C, -77, -4 },
14830 { 0x9C40000000000000, -50, 4 },
14831 { 0xE8D4A51000000000, -24, 12 },
14832 { 0xAD78EBC5AC620000, 3, 20 },
14833 { 0x813F3978F8940984, 30, 28 },
14834 { 0xC097CE7BC90715B3, 56, 36 },
14835 { 0x8F7E32CE7BEA5C70, 83, 44 },
14836 { 0xD5D238A4ABE98068, 109, 52 },
14837 { 0x9F4F2726179A2245, 136, 60 },
14838 { 0xED63A231D4C4FB27, 162, 68 },
14839 { 0xB0DE65388CC8ADA8, 189, 76 },
14840 { 0x83C7088E1AAB65DB, 216, 84 },
14841 { 0xC45D1DF942711D9A, 242, 92 },
14842 { 0x924D692CA61BE758, 269, 100 },
14843 { 0xDA01EE641A708DEA, 295, 108 },
14844 { 0xA26DA3999AEF774A, 322, 116 },
14845 { 0xF209787BB47D6B85, 348, 124 },
14846 { 0xB454E4A179DD1877, 375, 132 },
14847 { 0x865B86925B9BC5C2, 402, 140 },
14848 { 0xC83553C5C8965D3D, 428, 148 },
14849 { 0x952AB45CFA97A0B3, 455, 156 },
14850 { 0xDE469FBD99A05FE3, 481, 164 },
14851 { 0xA59BC234DB398C25, 508, 172 },
14852 { 0xF6C69A72A3989F5C, 534, 180 },
14853 { 0xB7DCBF5354E9BECE, 561, 188 },
14854 { 0x88FCF317F22241E2, 588, 196 },
14855 { 0xCC20CE9BD35C78A5, 614, 204 },
14856 { 0x98165AF37B2153DF, 641, 212 },
14857 { 0xE2A0B5DC971F303A, 667, 220 },
14858 { 0xA8D9D1535CE3B396, 694, 228 },
14859 { 0xFB9B7CD9A4A7443C, 720, 236 },
14860 { 0xBB764C4CA7A44410, 747, 244 },
14861 { 0x8BAB8EEFB6409C1A, 774, 252 },
14862 { 0xD01FEF10A657842C, 800, 260 },
14863 { 0x9B10A4E5E9913129, 827, 268 },
14864 { 0xE7109BFBA19C0C9D, 853, 276 },
14865 { 0xAC2820D9623BF429, 880, 284 },
14866 { 0x80444B5E7AA7CF85, 907, 292 },
14867 { 0xBF21E44003ACDD2D, 933, 300 },
14868 { 0x8E679C2F5E44FF8F, 960, 308 },
14869 { 0xD433179D9C8CB841, 986, 316 },
14870 { 0x9E19DB92B4E31BA9, 1013, 324 },
14878 JSON_ASSERT(e >= -1500);
14879 JSON_ASSERT(e <= 1500);
14880 const int f = kAlpha - e - 1;
14881 const int k = (f * 78913) / (1 << 18) +
static_cast<int>(f > 0);
14883 const int index = (-kCachedPowersMinDecExp + k + (kCachedPowersDecStep - 1)) / kCachedPowersDecStep;
14884 JSON_ASSERT(index >= 0);
14885 JSON_ASSERT(
static_cast<std::size_t
>(index) < kCachedPowers.size());
14887 const cached_power cached = kCachedPowers[
static_cast<std::size_t
>(index)];
14888 JSON_ASSERT(kAlpha <= cached.e + e + 64);
14889 JSON_ASSERT(kGamma >= cached.e + e + 64);
14901 if (n >= 1000000000)
14903 pow10 = 1000000000;
14907 else if (n >= 100000000)
14912 else if (n >= 10000000)
14917 else if (n >= 1000000)
14922 else if (n >= 100000)
14927 else if (n >= 10000)
14932 else if (n >= 1000)
14954 inline void grisu2_round(
char* buf,
int len, std::uint64_t dist, std::uint64_t delta,
14955 std::uint64_t rest, std::uint64_t ten_k)
14957 JSON_ASSERT(len >= 1);
14958 JSON_ASSERT(dist <= delta);
14959 JSON_ASSERT(rest <= delta);
14960 JSON_ASSERT(ten_k > 0);
14982 && delta - rest >= ten_k
14983 && (rest + ten_k < dist || dist - rest > rest + ten_k - dist))
14985 JSON_ASSERT(buf[len - 1] !=
'0');
14998 static_assert(kAlpha >= -60,
"internal error");
14999 static_assert(kGamma <= -32,
"internal error");
15013 JSON_ASSERT(M_plus.e >= kAlpha);
15014 JSON_ASSERT(M_plus.e <= kGamma);
15016 std::uint64_t delta =
diyfp::sub(M_plus, M_minus).f;
15017 std::uint64_t dist =
diyfp::sub(M_plus, w ).f;
15026 const diyfp one(std::uint64_t{1} << -M_plus.e, M_plus.e);
15028 auto p1 =
static_cast<std::uint32_t
>(M_plus.f >> -one.e);
15029 std::uint64_t p2 = M_plus.f & (one.f - 1);
15035 JSON_ASSERT(p1 > 0);
15037 std::uint32_t pow10;
15065 const std::uint32_t d = p1 / pow10;
15066 const std::uint32_t r = p1 % pow10;
15071 JSON_ASSERT(d <= 9);
15072 buffer[length++] =
static_cast<char>(
'0' + d);
15091 const std::uint64_t rest = (std::uint64_t{p1} << -one.e) + p2;
15096 decimal_exponent += n;
15107 const std::uint64_t ten_n = std::uint64_t{pow10} << -one.e;
15108 grisu2_round(buffer, length, dist, delta, rest, ten_n);
15158 JSON_ASSERT(p2 > delta);
15169 JSON_ASSERT(p2 <= (std::numeric_limits<std::uint64_t>::max)() / 10);
15171 const std::uint64_t d = p2 >> -one.e;
15172 const std::uint64_t r = p2 & (one.f - 1);
15178 JSON_ASSERT(d <= 9);
15179 buffer[length++] =
static_cast<char>(
'0' + d);
15204 decimal_exponent -= m;
15212 const std::uint64_t ten_m = one.f;
15213 grisu2_round(buffer, length, dist, delta, p2, ten_m);
15235 JSON_HEDLEY_NON_NULL(1)
15236 inline
void grisu2(
char* buf,
int& len,
int& decimal_exponent,
15239 JSON_ASSERT(m_plus.e == m_minus.e);
15240 JSON_ASSERT(m_plus.e == v.e);
15253 const diyfp c_minus_k(cached.f, cached.e);
15281 const diyfp M_minus(w_minus.f + 1, w_minus.e);
15282 const diyfp M_plus (w_plus.f - 1, w_plus.e );
15284 decimal_exponent = -cached.k;
15294 template<
typename FloatType>
15295 JSON_HEDLEY_NON_NULL(1)
15296 void
grisu2(
char* buf,
int& len,
int& decimal_exponent, FloatType value)
15298 static_assert(diyfp::kPrecision >= std::numeric_limits<FloatType>::digits + 3,
15299 "internal error: not enough precision");
15301 JSON_ASSERT(std::isfinite(
value));
15302 JSON_ASSERT(
value > 0);
15326 grisu2(buf, len, decimal_exponent, w.minus, w.w, w.plus);
15334 JSON_HEDLEY_NON_NULL(1)
15335 JSON_HEDLEY_RETURNS_NON_NULL
15338 JSON_ASSERT(e > -1000);
15339 JSON_ASSERT(e < 1000);
15351 auto k =
static_cast<std::uint32_t
>(e);
15357 *buf++ =
static_cast<char>(
'0' + k);
15361 *buf++ =
static_cast<char>(
'0' + k / 10);
15363 *buf++ =
static_cast<char>(
'0' + k);
15367 *buf++ =
static_cast<char>(
'0' + k / 100);
15369 *buf++ =
static_cast<char>(
'0' + k / 10);
15371 *buf++ =
static_cast<char>(
'0' + k);
15386 JSON_HEDLEY_NON_NULL(1)
15387 JSON_HEDLEY_RETURNS_NON_NULL
15389 int min_exp,
int max_exp)
15391 JSON_ASSERT(min_exp < 0);
15392 JSON_ASSERT(max_exp > 0);
15395 const int n = len + decimal_exponent;
15401 if (k <= n && n <= max_exp)
15406 std::memset(buf + k,
'0',
static_cast<size_t>(n) -
static_cast<size_t>(k));
15410 return buf + (
static_cast<size_t>(n) + 2);
15413 if (0 < n && n <= max_exp)
15418 JSON_ASSERT(k > n);
15420 std::memmove(buf + (
static_cast<size_t>(n) + 1), buf + n,
static_cast<size_t>(k) -
static_cast<size_t>(n));
15422 return buf + (
static_cast<size_t>(k) + 1U);
15425 if (min_exp < n && n <= 0)
15430 std::memmove(buf + (2 +
static_cast<size_t>(-n)), buf,
static_cast<size_t>(k));
15433 std::memset(buf + 2,
'0',
static_cast<size_t>(-n));
15434 return buf + (2U +
static_cast<size_t>(-n) +
static_cast<size_t>(k));
15449 std::memmove(buf + 2, buf + 1,
static_cast<size_t>(k) - 1);
15451 buf += 1 +
static_cast<size_t>(k);
15470 template<
typename FloatType>
15471 JSON_HEDLEY_NON_NULL(1, 2)
15472 JSON_HEDLEY_RETURNS_NON_NULL
15473 char*
to_chars(
char* first, const
char* last, FloatType value)
15475 static_cast<void>(last);
15476 JSON_ASSERT(std::isfinite(
value));
15479 if (std::signbit(
value))
15494 JSON_ASSERT(last - first >= std::numeric_limits<FloatType>::max_digits10);
15501 int decimal_exponent = 0;
15504 JSON_ASSERT(len <= std::numeric_limits<FloatType>::max_digits10);
15507 constexpr
int kMinExp = -4;
15509 constexpr
int kMaxExp = std::numeric_limits<FloatType>::digits10;
15511 JSON_ASSERT(last - first >= kMaxExp + 2);
15512 JSON_ASSERT(last - first >= 2 + (-kMinExp - 1) + std::numeric_limits<FloatType>::max_digits10);
15513 JSON_ASSERT(last - first >= std::numeric_limits<FloatType>::max_digits10 + 6);
15550 template<
typename BasicJsonType>
15553 using string_t =
typename BasicJsonType::string_t;
15554 using number_float_t =
typename BasicJsonType::number_float_t;
15555 using number_integer_t =
typename BasicJsonType::number_integer_t;
15556 using number_unsigned_t =
typename BasicJsonType::number_unsigned_t;
15557 using binary_char_t =
typename BasicJsonType::binary_t::value_type;
15558 static constexpr std::uint8_t UTF8_ACCEPT = 0;
15559 static constexpr std::uint8_t UTF8_REJECT = 1;
15570 ,
loc(std::localeconv())
15608 const bool pretty_print,
15609 const bool ensure_ascii,
15610 const unsigned int indent_step,
15611 const unsigned int current_indent = 0)
15613 switch (val.m_type)
15617 if (val.m_value.object->empty())
15619 o->write_characters(
"{}", 2);
15625 o->write_characters(
"{\n", 2);
15628 const auto new_indent = current_indent + indent_step;
15629 if (JSON_HEDLEY_UNLIKELY(
indent_string.size() < new_indent))
15635 auto i = val.m_value.object->cbegin();
15636 for (std::size_t cnt = 0; cnt < val.m_value.object->size() - 1; ++cnt, ++i)
15639 o->write_character(
'\"');
15640 dump_escaped(i->first, ensure_ascii);
15641 o->write_characters(
"\": ", 3);
15642 dump(i->second,
true, ensure_ascii, indent_step, new_indent);
15643 o->write_characters(
",\n", 2);
15647 JSON_ASSERT(i != val.m_value.object->cend());
15648 JSON_ASSERT(std::next(i) == val.m_value.object->cend());
15650 o->write_character(
'\"');
15651 dump_escaped(i->first, ensure_ascii);
15652 o->write_characters(
"\": ", 3);
15653 dump(i->second,
true, ensure_ascii, indent_step, new_indent);
15655 o->write_character(
'\n');
15656 o->write_characters(
indent_string.c_str(), current_indent);
15657 o->write_character(
'}');
15661 o->write_character(
'{');
15664 auto i = val.m_value.object->cbegin();
15665 for (std::size_t cnt = 0; cnt < val.m_value.object->size() - 1; ++cnt, ++i)
15667 o->write_character(
'\"');
15668 dump_escaped(i->first, ensure_ascii);
15669 o->write_characters(
"\":", 2);
15670 dump(i->second,
false, ensure_ascii, indent_step, current_indent);
15671 o->write_character(
',');
15675 JSON_ASSERT(i != val.m_value.object->cend());
15676 JSON_ASSERT(std::next(i) == val.m_value.object->cend());
15677 o->write_character(
'\"');
15678 dump_escaped(i->first, ensure_ascii);
15679 o->write_characters(
"\":", 2);
15680 dump(i->second,
false, ensure_ascii, indent_step, current_indent);
15682 o->write_character(
'}');
15690 if (val.m_value.array->empty())
15692 o->write_characters(
"[]", 2);
15698 o->write_characters(
"[\n", 2);
15701 const auto new_indent = current_indent + indent_step;
15702 if (JSON_HEDLEY_UNLIKELY(
indent_string.size() < new_indent))
15708 for (
auto i = val.m_value.array->cbegin();
15709 i != val.m_value.array->cend() - 1; ++i)
15712 dump(*i,
true, ensure_ascii, indent_step, new_indent);
15713 o->write_characters(
",\n", 2);
15717 JSON_ASSERT(!val.m_value.array->empty());
15719 dump(val.m_value.array->back(),
true, ensure_ascii, indent_step, new_indent);
15721 o->write_character(
'\n');
15722 o->write_characters(
indent_string.c_str(), current_indent);
15723 o->write_character(
']');
15727 o->write_character(
'[');
15730 for (
auto i = val.m_value.array->cbegin();
15731 i != val.m_value.array->cend() - 1; ++i)
15733 dump(*i,
false, ensure_ascii, indent_step, current_indent);
15734 o->write_character(
',');
15738 JSON_ASSERT(!val.m_value.array->empty());
15739 dump(val.m_value.array->back(),
false, ensure_ascii, indent_step, current_indent);
15741 o->write_character(
']');
15749 o->write_character(
'\"');
15750 dump_escaped(*val.m_value.string, ensure_ascii);
15751 o->write_character(
'\"');
15759 o->write_characters(
"{\n", 2);
15762 const auto new_indent = current_indent + indent_step;
15763 if (JSON_HEDLEY_UNLIKELY(
indent_string.size() < new_indent))
15770 o->write_characters(
"\"bytes\": [", 10);
15772 if (!val.m_value.binary->empty())
15774 for (
auto i = val.m_value.binary->cbegin();
15775 i != val.m_value.binary->cend() - 1; ++i)
15778 o->write_characters(
", ", 2);
15780 dump_integer(val.m_value.binary->back());
15783 o->write_characters(
"],\n", 3);
15786 o->write_characters(
"\"subtype\": ", 11);
15787 if (val.m_value.binary->has_subtype())
15789 dump_integer(val.m_value.binary->subtype());
15793 o->write_characters(
"null", 4);
15795 o->write_character(
'\n');
15796 o->write_characters(
indent_string.c_str(), current_indent);
15797 o->write_character(
'}');
15801 o->write_characters(
"{\"bytes\":[", 10);
15803 if (!val.m_value.binary->empty())
15805 for (
auto i = val.m_value.binary->cbegin();
15806 i != val.m_value.binary->cend() - 1; ++i)
15809 o->write_character(
',');
15811 dump_integer(val.m_value.binary->back());
15814 o->write_characters(
"],\"subtype\":", 12);
15815 if (val.m_value.binary->has_subtype())
15817 dump_integer(val.m_value.binary->subtype());
15818 o->write_character(
'}');
15822 o->write_characters(
"null}", 5);
15830 if (val.m_value.boolean)
15832 o->write_characters(
"true", 4);
15836 o->write_characters(
"false", 5);
15843 dump_integer(val.m_value.number_integer);
15849 dump_integer(val.m_value.number_unsigned);
15855 dump_float(val.m_value.number_float);
15861 o->write_characters(
"<discarded>", 11);
15867 o->write_characters(
"null", 4);
15872 JSON_ASSERT(
false);
15876 JSON_PRIVATE_UNLESS_TESTED:
15891 void dump_escaped(
const string_t& s,
const bool ensure_ascii)
15893 std::uint32_t codepoint;
15894 std::uint8_t state = UTF8_ACCEPT;
15895 std::size_t bytes = 0;
15898 std::size_t bytes_after_last_accept = 0;
15899 std::size_t undumped_chars = 0;
15901 for (std::size_t i = 0; i < s.size(); ++i)
15903 const auto byte =
static_cast<uint8_t
>(s[i]);
15905 switch (decode(state, codepoint,
byte))
15964 if ((codepoint <= 0x1F) || (ensure_ascii && (codepoint >= 0x7F)))
15966 if (codepoint <= 0xFFFF)
15968 (std::snprintf)(
string_buffer.data() + bytes, 7,
"\\u%04x",
15969 static_cast<std::uint16_t
>(codepoint));
15974 (std::snprintf)(
string_buffer.data() + bytes, 13,
"\\u%04x\\u%04x",
15975 static_cast<std::uint16_t
>(0xD7C0u + (codepoint >> 10u)),
15976 static_cast<std::uint16_t
>(0xDC00u + (codepoint & 0x3FFu)));
16000 bytes_after_last_accept = bytes;
16001 undumped_chars = 0;
16009 case error_handler_t::strict:
16011 std::string sn(3,
'\0');
16012 (std::snprintf)(&sn[0], sn.size(),
"%.2X", byte);
16013 JSON_THROW(type_error::create(316,
"invalid UTF-8 byte at index " + std::to_string(i) +
": 0x" + sn));
16017 case error_handler_t::replace:
16023 if (undumped_chars > 0)
16030 bytes = bytes_after_last_accept;
16046 string_buffer[bytes++] = detail::binary_writer<BasicJsonType, char>::to_char_type(
'\xEF');
16047 string_buffer[bytes++] = detail::binary_writer<BasicJsonType, char>::to_char_type(
'\xBF');
16048 string_buffer[bytes++] = detail::binary_writer<BasicJsonType, char>::to_char_type(
'\xBD');
16060 bytes_after_last_accept = bytes;
16063 undumped_chars = 0;
16066 state = UTF8_ACCEPT;
16071 JSON_ASSERT(
false);
16090 if (JSON_HEDLEY_LIKELY(state == UTF8_ACCEPT))
16103 case error_handler_t::strict:
16105 std::string sn(3,
'\0');
16106 (std::snprintf)(&sn[0], sn.size(),
"%.2X",
static_cast<std::uint8_t
>(s.back()));
16107 JSON_THROW(type_error::create(316,
"incomplete UTF-8 string; last byte: 0x" + sn));
16113 o->write_characters(
string_buffer.data(), bytes_after_last_accept);
16117 case error_handler_t::replace:
16120 o->write_characters(
string_buffer.data(), bytes_after_last_accept);
16124 o->write_characters(
"\\ufffd", 6);
16128 o->write_characters(
"\xEF\xBF\xBD", 3);
16134 JSON_ASSERT(
false);
16148 inline unsigned int count_digits(number_unsigned_t x) noexcept
16150 unsigned int n_digits = 1;
16159 return n_digits + 1;
16163 return n_digits + 2;
16167 return n_digits + 3;
16183 template <
typename NumberType, detail::enable_if_t <
16184 std::is_same<NumberType, number_unsigned_t>::value ||
16185 std::is_same<NumberType, number_integer_t>::value ||
16186 std::is_same<NumberType, binary_char_t>::value,
16188 void dump_integer(NumberType x)
16190 static constexpr std::array<std::array<char, 2>, 100> digits_to_99
16193 {{
'0',
'0'}}, {{
'0',
'1'}}, {{
'0',
'2'}}, {{
'0',
'3'}}, {{
'0',
'4'}}, {{
'0',
'5'}}, {{
'0',
'6'}}, {{
'0',
'7'}}, {{
'0',
'8'}}, {{
'0',
'9'}},
16194 {{
'1',
'0'}}, {{
'1',
'1'}}, {{
'1',
'2'}}, {{
'1',
'3'}}, {{
'1',
'4'}}, {{
'1',
'5'}}, {{
'1',
'6'}}, {{
'1',
'7'}}, {{
'1',
'8'}}, {{
'1',
'9'}},
16195 {{
'2',
'0'}}, {{
'2',
'1'}}, {{
'2',
'2'}}, {{
'2',
'3'}}, {{
'2',
'4'}}, {{
'2',
'5'}}, {{
'2',
'6'}}, {{
'2',
'7'}}, {{
'2',
'8'}}, {{
'2',
'9'}},
16196 {{
'3',
'0'}}, {{
'3',
'1'}}, {{
'3',
'2'}}, {{
'3',
'3'}}, {{
'3',
'4'}}, {{
'3',
'5'}}, {{
'3',
'6'}}, {{
'3',
'7'}}, {{
'3',
'8'}}, {{
'3',
'9'}},
16197 {{
'4',
'0'}}, {{
'4',
'1'}}, {{
'4',
'2'}}, {{
'4',
'3'}}, {{
'4',
'4'}}, {{
'4',
'5'}}, {{
'4',
'6'}}, {{
'4',
'7'}}, {{
'4',
'8'}}, {{
'4',
'9'}},
16198 {{
'5',
'0'}}, {{
'5',
'1'}}, {{
'5',
'2'}}, {{
'5',
'3'}}, {{
'5',
'4'}}, {{
'5',
'5'}}, {{
'5',
'6'}}, {{
'5',
'7'}}, {{
'5',
'8'}}, {{
'5',
'9'}},
16199 {{
'6',
'0'}}, {{
'6',
'1'}}, {{
'6',
'2'}}, {{
'6',
'3'}}, {{
'6',
'4'}}, {{
'6',
'5'}}, {{
'6',
'6'}}, {{
'6',
'7'}}, {{
'6',
'8'}}, {{
'6',
'9'}},
16200 {{
'7',
'0'}}, {{
'7',
'1'}}, {{
'7',
'2'}}, {{
'7',
'3'}}, {{
'7',
'4'}}, {{
'7',
'5'}}, {{
'7',
'6'}}, {{
'7',
'7'}}, {{
'7',
'8'}}, {{
'7',
'9'}},
16201 {{
'8',
'0'}}, {{
'8',
'1'}}, {{
'8',
'2'}}, {{
'8',
'3'}}, {{
'8',
'4'}}, {{
'8',
'5'}}, {{
'8',
'6'}}, {{
'8',
'7'}}, {{
'8',
'8'}}, {{
'8',
'9'}},
16202 {{
'9',
'0'}}, {{
'9',
'1'}}, {{
'9',
'2'}}, {{
'9',
'3'}}, {{
'9',
'4'}}, {{
'9',
'5'}}, {{
'9',
'6'}}, {{
'9',
'7'}}, {{
'9',
'8'}}, {{
'9',
'9'}},
16209 o->write_character(
'0');
16216 const bool is_negative = std::is_same<NumberType, number_integer_t>::value && !(x >= 0);
16217 number_unsigned_t abs_value;
16219 unsigned int n_chars;
16224 abs_value = remove_sign(
static_cast<number_integer_t
>(x));
16227 n_chars = 1 + count_digits(abs_value);
16231 abs_value =
static_cast<number_unsigned_t
>(x);
16232 n_chars = count_digits(abs_value);
16240 buffer_ptr += n_chars;
16244 while (abs_value >= 100)
16246 const auto digits_index =
static_cast<unsigned>((abs_value % 100));
16248 *(--buffer_ptr) = digits_to_99[digits_index][1];
16249 *(--buffer_ptr) = digits_to_99[digits_index][0];
16252 if (abs_value >= 10)
16254 const auto digits_index =
static_cast<unsigned>(abs_value);
16255 *(--buffer_ptr) = digits_to_99[digits_index][1];
16256 *(--buffer_ptr) = digits_to_99[digits_index][0];
16260 *(--buffer_ptr) =
static_cast<char>(
'0' + abs_value);
16274 void dump_float(number_float_t x)
16277 if (!std::isfinite(x))
16279 o->write_characters(
"null", 4);
16288 static constexpr
bool is_ieee_single_or_double
16289 = (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) ||
16290 (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);
16292 dump_float(x, std::integral_constant<bool, is_ieee_single_or_double>());
16295 void dump_float(number_float_t x, std::true_type )
16298 char* end = ::nlohmann::detail::to_chars(begin, begin +
number_buffer.size(), x);
16300 o->write_characters(begin,
static_cast<size_t>(end - begin));
16303 void dump_float(number_float_t x, std::false_type )
16306 static constexpr
auto d = std::numeric_limits<number_float_t>::max_digits10;
16312 JSON_ASSERT(len > 0);
16314 JSON_ASSERT(
static_cast<std::size_t
>(len) <
number_buffer.size());
16336 o->write_characters(
number_buffer.data(),
static_cast<std::size_t
>(len));
16339 const bool value_is_int_like =
16343 return c ==
'.' || c ==
'e';
16346 if (value_is_int_like)
16348 o->write_characters(
".0", 2);
16373 static std::uint8_t decode(std::uint8_t& state, std::uint32_t& codep,
const std::uint8_t
byte) noexcept
16375 static const std::array<std::uint8_t, 400> utf8d =
16378 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,
16379 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,
16380 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,
16381 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,
16382 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,
16383 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,
16384 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,
16385 0xA, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x4, 0x3, 0x3,
16386 0xB, 0x6, 0x6, 0x6, 0x5, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8,
16387 0x0, 0x1, 0x2, 0x3, 0x5, 0x8, 0x7, 0x1, 0x1, 0x1, 0x4, 0x6, 0x1, 0x1, 0x1, 0x1,
16388 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,
16389 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,
16390 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,
16391 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
16395 const std::uint8_t type = utf8d[byte];
16397 codep = (state != UTF8_ACCEPT)
16398 ? (
byte & 0x3fu) | (codep << 6u)
16399 : (0xFFu >> type) & (byte);
16401 std::size_t index = 256u +
static_cast<size_t>(state) * 16u +
static_cast<size_t>(type);
16402 JSON_ASSERT(index < 400);
16403 state = utf8d[index];
16412 number_unsigned_t remove_sign(number_unsigned_t x)
16414 JSON_ASSERT(
false);
16427 inline number_unsigned_t remove_sign(number_integer_t x) noexcept
16429 JSON_ASSERT(x < 0 && x < (std::numeric_limits<number_integer_t>::max)());
16430 return static_cast<number_unsigned_t
>(-(x + 1)) + 1;
16435 output_adapter_t<char> o =
nullptr;
16468 #include <functional>
16481 template <
class Key,
class T,
class IgnoredLess = std::less<Key>,
16482 class Allocator = std::allocator<std::pair<const Key, T>>>
16485 using key_type = Key;
16486 using mapped_type = T;
16487 using Container = std::vector<std::pair<const Key, T>, Allocator>;
16488 using typename Container::iterator;
16489 using typename Container::const_iterator;
16490 using typename Container::size_type;
16491 using typename Container::value_type;
16495 ordered_map(
const Allocator& alloc = Allocator()) : Container{alloc} {}
16496 template <
class It>
16497 ordered_map(It first, It last,
const Allocator& alloc = Allocator())
16498 : Container{first, last, alloc} {}
16499 ordered_map(std::initializer_list<T> init,
const Allocator& alloc = Allocator() )
16500 : Container{init, alloc} {}
16502 std::pair<iterator, bool> emplace(
const key_type& key, T&& t)
16504 for (
auto it = this->begin(); it != this->end(); ++it)
16506 if (it->first == key)
16508 return {it,
false};
16511 Container::emplace_back(key, t);
16512 return {--this->end(),
true};
16515 T& operator[](
const Key& key)
16517 return emplace(key, T{}).first->second;
16520 const T& operator[](
const Key& key)
const
16525 T& at(
const Key& key)
16527 for (
auto it = this->begin(); it != this->end(); ++it)
16529 if (it->first == key)
16535 JSON_THROW(std::out_of_range(
"key not found"));
16538 const T& at(
const Key& key)
const
16540 for (
auto it = this->begin(); it != this->end(); ++it)
16542 if (it->first == key)
16548 JSON_THROW(std::out_of_range(
"key not found"));
16551 size_type erase(
const Key& key)
16553 for (
auto it = this->begin(); it != this->end(); ++it)
16555 if (it->first == key)
16558 for (
auto next = it; ++next != this->end(); ++it)
16561 new (&*it) value_type{std::move(*next)};
16563 Container::pop_back();
16570 iterator erase(iterator pos)
16575 for (
auto next = it; ++next != this->end(); ++it)
16578 new (&*it) value_type{std::move(*next)};
16580 Container::pop_back();
16584 size_type count(
const Key& key)
const
16586 for (
auto it = this->begin(); it != this->end(); ++it)
16588 if (it->first == key)
16596 iterator find(
const Key& key)
16598 for (
auto it = this->begin(); it != this->end(); ++it)
16600 if (it->first == key)
16605 return Container::end();
16608 const_iterator find(
const Key& key)
const
16610 for (
auto it = this->begin(); it != this->end(); ++it)
16612 if (it->first == key)
16617 return Container::end();
16620 std::pair<iterator, bool> insert( value_type&& value )
16622 return emplace(value.first, std::move(value.second));
16625 std::pair<iterator, bool> insert(
const value_type& value )
16627 for (
auto it = this->begin(); it != this->end(); ++it)
16629 if (it->first == value.first)
16631 return {it,
false};
16634 Container::push_back(value);
16635 return {--this->end(),
true};
16734 NLOHMANN_BASIC_JSON_TPL_DECLARATION
16739 friend ::nlohmann::json_pointer<basic_json>;
16741 template<
typename BasicJsonType,
typename InputType>
16742 friend class ::nlohmann::detail::parser;
16743 friend ::nlohmann::detail::serializer<basic_json>;
16744 template<
typename BasicJsonType>
16745 friend class ::nlohmann::detail::iter_impl;
16746 template<
typename BasicJsonType,
typename CharType>
16747 friend class ::nlohmann::detail::binary_writer;
16748 template<
typename BasicJsonType,
typename InputType,
typename SAX>
16749 friend class ::nlohmann::detail::binary_reader;
16750 template<
typename BasicJsonType>
16751 friend class ::nlohmann::detail::json_sax_dom_parser;
16752 template<
typename BasicJsonType>
16753 friend class ::nlohmann::detail::json_sax_dom_callback_parser;
16756 using basic_json_t = NLOHMANN_BASIC_JSON_TPL;
16758 JSON_PRIVATE_UNLESS_TESTED:
16762 template<
typename InputAdapterType>
16763 static ::nlohmann::detail::parser<basic_json, InputAdapterType> parser(
16764 InputAdapterType adapter,
16765 detail::parser_callback_t<basic_json>cb =
nullptr,
16766 const bool allow_exceptions =
true,
16767 const bool ignore_comments =
false
16770 return ::nlohmann::detail::parser<basic_json, InputAdapterType>(std::move(adapter),
16771 std::move(cb), allow_exceptions, ignore_comments);
16776 template<
typename BasicJsonType>
16778 template<
typename BasicJsonType>
16780 template<
typename Iterator>
16784 template<
typename CharType>
16787 template<
typename InputType>
16791 JSON_PRIVATE_UNLESS_TESTED:
16798 template<
typename T,
typename SFINAE>
16799 using json_serializer = JSONSerializer<T, SFINAE>;
16861 using pointer =
typename std::allocator_traits<allocator_type>::pointer;
16863 using const_pointer =
typename std::allocator_traits<allocator_type>::const_pointer;
16911 JSON_HEDLEY_WARN_UNUSED_RESULT
16916 result[
"copyright"] =
"(C) 2013-2020 Niels Lohmann";
16917 result[
"name"] =
"JSON for Modern C++";
16918 result[
"url"] =
"https://github.com/nlohmann/json";
16919 result[
"version"][
"string"] =
16920 std::to_string(NLOHMANN_JSON_VERSION_MAJOR) +
"." +
16921 std::to_string(NLOHMANN_JSON_VERSION_MINOR) +
"." +
16922 std::to_string(NLOHMANN_JSON_VERSION_PATCH);
16923 result[
"version"][
"major"] = NLOHMANN_JSON_VERSION_MAJOR;
16924 result[
"version"][
"minor"] = NLOHMANN_JSON_VERSION_MINOR;
16925 result[
"version"][
"patch"] = NLOHMANN_JSON_VERSION_PATCH;
16928 result[
"platform"] =
"win32";
16929 #elif defined __linux__
16930 result[
"platform"] =
"linux";
16931 #elif defined __APPLE__
16932 result[
"platform"] =
"apple";
16933 #elif defined __unix__
16934 result[
"platform"] =
"unix";
16936 result[
"platform"] =
"unknown";
16939 #if defined(__ICC) || defined(__INTEL_COMPILER)
16940 result[
"compiler"] = {{
"family",
"icc"}, {
"version", __INTEL_COMPILER}};
16941 #elif defined(__clang__)
16942 result[
"compiler"] = {{
"family",
"clang"}, {
"version", __clang_version__}};
16943 #elif defined(__GNUC__) || defined(__GNUG__)
16944 result[
"compiler"] = {{
"family",
"gcc"}, {
"version", std::to_string(__GNUC__) +
"." + std::to_string(__GNUC_MINOR__) +
"." + std::to_string(__GNUC_PATCHLEVEL__)}};
16945 #elif defined(__HP_cc) || defined(__HP_aCC)
16946 result[
"compiler"] =
"hp"
16947 #elif defined(__IBMCPP__)
16948 result[
"compiler"] = {{
"family",
"ilecpp"}, {
"version", __IBMCPP__}};
16949 #elif defined(_MSC_VER)
16950 result[
"compiler"] = {{
"family",
"msvc"}, {
"version", _MSC_VER}};
16951 #elif defined(__PGI)
16952 result[
"compiler"] = {{
"family",
"pgcpp"}, {
"version", __PGI}};
16953 #elif defined(__SUNPRO_CC)
16954 result[
"compiler"] = {{
"family",
"sunpro"}, {
"version", __SUNPRO_CC}};
16956 result[
"compiler"] = {{
"family",
"unknown"}, {
"version",
"unknown"}};
16960 result[
"compiler"][
"c++"] = std::to_string(__cplusplus);
16962 result[
"compiler"][
"c++"] =
"unknown";
16977 #if defined(JSON_HAS_CPP_14)
16980 using object_comparator_t = std::less<>;
16982 using object_comparator_t = std::less<StringType>;
17070 object_comparator_t,
17071 AllocatorType<std::pair<
const StringType,
17118 using array_t = ArrayType<basic_json, AllocatorType<basic_json>>;
17485 template<
typename T,
typename... Args>
17486 JSON_HEDLEY_RETURNS_NON_NULL
17487 static T* create(Args&& ... args)
17489 AllocatorType<T> alloc;
17490 using AllocatorTraits = std::allocator_traits<AllocatorType<T>>;
17492 auto deleter = [&](T *
object)
17494 AllocatorTraits::deallocate(alloc,
object, 1);
17496 std::unique_ptr<T, decltype(deleter)>
object(AllocatorTraits::allocate(alloc, 1), deleter);
17497 AllocatorTraits::construct(alloc,
object.
get(), std::forward<Args>(args)...);
17498 JSON_ASSERT(
object !=
nullptr);
17499 return object.release();
17506 JSON_PRIVATE_UNLESS_TESTED:
17552 json_value() =
default;
17554 json_value(
boolean_t v) noexcept : boolean(v) {}
17562 json_value(value_t t)
17568 object = create<object_t>();
17574 array = create<array_t>();
17580 string = create<string_t>(
"");
17586 binary = create<binary_t>();
17625 JSON_THROW(other_error::create(500,
"961c151d2e87f2686a955a9be24d316f1362bf21 3.9.1"));
17635 string = create<string_t>(
value);
17641 string = create<string_t>(std::move(
value));
17647 object = create<object_t>(
value);
17653 object = create<object_t>(std::move(
value));
17659 array = create<array_t>(
value);
17665 array = create<array_t>(std::move(
value));
17671 binary = create<binary_t>(
value);
17677 binary = create<binary_t>(std::move(
value));
17683 binary = create<binary_t>(
value);
17689 binary = create<binary_t>(std::move(
value));
17692 void destroy(value_t t) noexcept
17695 std::vector<basic_json> stack;
17700 stack.reserve(array->size());
17701 std::move(array->begin(), array->end(), std::back_inserter(stack));
17706 for (
auto&& it : *
object)
17708 stack.push_back(std::move(it.second));
17712 while (!stack.empty())
17715 basic_json current_item(std::move(stack.back()));
17720 if (current_item.is_array())
17722 std::move(current_item.m_value.array->begin(), current_item.m_value.array->end(),
17723 std::back_inserter(stack));
17725 current_item.m_value.array->clear();
17727 else if (current_item.is_object())
17729 for (
auto&& it : *current_item.m_value.object)
17731 stack.push_back(std::move(it.second));
17734 current_item.m_value.object->clear();
17745 AllocatorType<object_t> alloc;
17746 std::allocator_traits<decltype(alloc)>::destroy(alloc,
object);
17747 std::allocator_traits<decltype(alloc)>::deallocate(alloc,
object, 1);
17753 AllocatorType<array_t> alloc;
17754 std::allocator_traits<decltype(alloc)>::destroy(alloc, array);
17755 std::allocator_traits<decltype(alloc)>::deallocate(alloc, array, 1);
17761 AllocatorType<string_t> alloc;
17762 std::allocator_traits<decltype(alloc)>::destroy(alloc,
string);
17763 std::allocator_traits<decltype(alloc)>::deallocate(alloc,
string, 1);
17769 AllocatorType<binary_t> alloc;
17770 std::allocator_traits<decltype(alloc)>::destroy(alloc, binary);
17771 std::allocator_traits<decltype(alloc)>::deallocate(alloc, binary, 1);
17793 void assert_invariant() const noexcept
17916 assert_invariant();
17940 assert_invariant();
18006 template <
typename CompatibleType,
18007 typename U = detail::uncvref_t<CompatibleType>,
18008 detail::enable_if_t <
18011 JSONSerializer<U>::to_json(std::declval<basic_json_t&>(),
18012 std::forward<CompatibleType>(val))))
18014 JSONSerializer<U>::to_json(*
this, std::forward<CompatibleType>(val));
18015 assert_invariant();
18044 template <
typename BasicJsonType,
18045 detail::enable_if_t <
18049 using other_boolean_t =
typename BasicJsonType::boolean_t;
18050 using other_number_float_t =
typename BasicJsonType::number_float_t;
18051 using other_number_integer_t =
typename BasicJsonType::number_integer_t;
18052 using other_number_unsigned_t =
typename BasicJsonType::number_unsigned_t;
18053 using other_string_t =
typename BasicJsonType::string_t;
18054 using other_object_t =
typename BasicJsonType::object_t;
18055 using other_array_t =
typename BasicJsonType::array_t;
18056 using other_binary_t =
typename BasicJsonType::binary_t;
18058 switch (val.type())
18061 JSONSerializer<other_boolean_t>::to_json(*
this, val.template get<other_boolean_t>());
18064 JSONSerializer<other_number_float_t>::to_json(*
this, val.template get<other_number_float_t>());
18067 JSONSerializer<other_number_integer_t>::to_json(*
this, val.template get<other_number_integer_t>());
18070 JSONSerializer<other_number_unsigned_t>::to_json(*
this, val.template get<other_number_unsigned_t>());
18073 JSONSerializer<other_string_t>::to_json(*
this, val.template get_ref<const other_string_t&>());
18076 JSONSerializer<other_object_t>::to_json(*
this, val.template get_ref<const other_object_t&>());
18079 JSONSerializer<other_array_t>::to_json(*
this, val.template get_ref<const other_array_t&>());
18082 JSONSerializer<other_binary_t>::to_json(*
this, val.template get_ref<const other_binary_t&>());
18091 JSON_ASSERT(
false);
18093 assert_invariant();
18171 bool type_deduction =
true,
18176 bool is_an_object = std::all_of(init.begin(), init.end(),
18179 return element_ref->is_array() && element_ref->size() == 2 && (*element_ref)[0].is_string();
18183 if (!type_deduction)
18188 is_an_object =
false;
18192 if (JSON_HEDLEY_UNLIKELY(manual_type ==
value_t::object && !is_an_object))
18194 JSON_THROW(type_error::create(301,
"cannot create object from initializer list"));
18206 auto element = element_ref.moved_or_copied();
18207 m_value.object->emplace(
18208 std::move(*((*element.m_value.array)[0].m_value.string)),
18209 std::move((*element.m_value.array)[1]));
18216 m_value.array = create<array_t>(init.begin(), init.end());
18219 assert_invariant();
18249 JSON_HEDLEY_WARN_UNUSED_RESULT
18254 res.m_value = init;
18286 JSON_HEDLEY_WARN_UNUSED_RESULT
18291 res.m_value =
binary_t(init, subtype);
18296 JSON_HEDLEY_WARN_UNUSED_RESULT
18301 res.m_value = std::move(init);
18306 JSON_HEDLEY_WARN_UNUSED_RESULT
18311 res.m_value =
binary_t(std::move(init), subtype);
18352 JSON_HEDLEY_WARN_UNUSED_RESULT
18396 JSON_HEDLEY_WARN_UNUSED_RESULT
18427 m_value.array = create<array_t>(cnt, val);
18428 assert_invariant();
18486 template <
class InputIT,
typename std::enable_if <
18487 std::is_same<InputIT, typename basic_json_t::iterator>::value ||
18488 std::is_same<InputIT, typename basic_json_t::const_iterator>::value,
int >
::type = 0 >
18491 JSON_ASSERT(first.m_object !=
nullptr);
18492 JSON_ASSERT(last.m_object !=
nullptr);
18495 if (JSON_HEDLEY_UNLIKELY(first.m_object != last.m_object))
18497 JSON_THROW(invalid_iterator::create(201,
"iterators are not compatible"));
18501 m_type = first.m_object->m_type;
18512 if (JSON_HEDLEY_UNLIKELY(!first.m_it.primitive_iterator.is_begin()
18513 || !last.m_it.primitive_iterator.is_end()))
18515 JSON_THROW(invalid_iterator::create(204,
"iterators out of range"));
18528 m_value.number_integer = first.m_object->m_value.number_integer;
18534 m_value.number_unsigned = first.m_object->m_value.number_unsigned;
18540 m_value.number_float = first.m_object->m_value.number_float;
18546 m_value.boolean = first.m_object->m_value.boolean;
18552 m_value = *first.m_object->m_value.string;
18558 m_value.object = create<object_t>(first.m_it.object_iterator,
18559 last.m_it.object_iterator);
18565 m_value.array = create<array_t>(first.m_it.array_iterator,
18566 last.m_it.array_iterator);
18572 m_value = *first.m_object->m_value.binary;
18577 JSON_THROW(invalid_iterator::create(206,
"cannot construct with iterators from " +
18578 std::string(first.m_object->type_name())));
18581 assert_invariant();
18589 template<
typename JsonRef,
18590 detail::enable_if_t<detail::conjunction<detail::is_json_ref<JsonRef>,
18591 std::is_same<typename JsonRef::value_type, basic_json>>
::value,
int> = 0 >
18620 : m_type(other.m_type)
18623 other.assert_invariant();
18679 assert_invariant();
18709 : m_type(std::move(other.m_type)),
18710 m_value(std::move(other.m_value))
18713 other.assert_invariant();
18717 other.m_value = {};
18719 assert_invariant();
18746 std::is_nothrow_move_constructible<value_t>::value&&
18747 std::is_nothrow_move_assignable<value_t>::value&&
18748 std::is_nothrow_move_constructible<json_value>::value&&
18749 std::is_nothrow_move_assignable<json_value>::value
18753 other.assert_invariant();
18756 swap(m_type, other.m_type);
18759 assert_invariant();
18780 assert_invariant();
18843 const char indent_char =
' ',
18844 const bool ensure_ascii =
false,
18852 s.dump(*
this,
true, ensure_ascii,
static_cast<unsigned int>(indent));
18856 s.dump(*
this,
false, ensure_ascii, 0);
19273 JSON_THROW(type_error::create(302,
"type must be boolean, but is " + std::string(
type_name())));
19295 constexpr
const array_t* get_impl_ptr(
const array_t* )
const noexcept
19383 template<
typename ReferenceType,
typename ThisType>
19384 static ReferenceType get_ref_impl(ThisType& obj)
19387 auto ptr = obj.template get_ptr<typename std::add_pointer<ReferenceType>::type>();
19389 if (JSON_HEDLEY_LIKELY(ptr !=
nullptr))
19394 JSON_THROW(type_error::create(303,
"incompatible ReferenceType for get_ref, actual type is " + std::string(obj.type_name())));
19416 template<
typename BasicJsonType, detail::enable_if_t<
19417 std::is_same<typename std::remove_const<BasicJsonType>::type, basic_json_t>
::value,
19439 template <
typename BasicJsonType, detail::enable_if_t <
19440 !std::is_same<BasicJsonType, basic_json>::value&&
19486 template <
typename ValueTypeCV,
typename ValueType = detail::uncvref_t<ValueTypeCV>,
19487 detail::enable_if_t <
19488 !detail::is_basic_json<ValueType>::value &&
19489 detail::has_from_json<basic_json_t, ValueType>::value &&
19490 !detail::has_non_default_from_json<basic_json_t, ValueType>::value,
19492 ValueType
get() const noexcept(noexcept(
19493 JSONSerializer<ValueType>::from_json(std::declval<const basic_json_t&>(), std::declval<ValueType&>())))
19498 static_assert(!std::is_reference<ValueTypeCV>::value,
19499 "get() cannot be used with reference types, you might want to use get_ref()");
19500 static_assert(std::is_default_constructible<ValueType>::value,
19501 "types must be DefaultConstructible when used with get()");
19504 JSONSerializer<ValueType>::from_json(*
this, ret);
19539 template <
typename ValueTypeCV,
typename ValueType = detail::uncvref_t<ValueTypeCV>,
19540 detail::enable_if_t < !std::is_same<basic_json_t, ValueType>::value &&
19541 detail::has_non_default_from_json<basic_json_t, ValueType>::value,
19543 ValueType
get() const noexcept(noexcept(
19544 JSONSerializer<ValueType>::from_json(std::declval<const basic_json_t&>())))
19546 static_assert(!std::is_reference<ValueTypeCV>::value,
19547 "get() cannot be used with reference types, you might want to use get_ref()");
19548 return JSONSerializer<ValueType>::from_json(*
this);
19584 template <
typename ValueType,
19585 detail::enable_if_t <
19589 ValueType &
get_to(ValueType& v)
const noexcept(noexcept(
19590 JSONSerializer<ValueType>::from_json(std::declval<const basic_json_t&>(), v)))
19592 JSONSerializer<ValueType>::from_json(*
this, v);
19598 template<
typename ValueType,
19599 detail::enable_if_t <
19602 ValueType &
get_to(ValueType& v)
const
19609 typename T, std::size_t N,
19610 typename Array = T (&)[N],
19611 detail::enable_if_t <
19612 detail::has_from_json<basic_json_t, Array>::value,
int > = 0 >
19613 Array
get_to(T (&v)[N])
const
19614 noexcept(noexcept(JSONSerializer<Array>::from_json(
19615 std::declval<const basic_json_t&>(), v)))
19617 JSONSerializer<Array>::from_json(*
this, v);
19648 template<
typename PointerType,
typename std::enable_if<
19649 std::is_pointer<PointerType>::value,
int>
::type = 0>
19650 auto get_ptr() noexcept -> decltype(std::declval<basic_json_t&>().get_impl_ptr(std::declval<PointerType>()))
19653 return get_impl_ptr(
static_cast<PointerType
>(
nullptr));
19660 template <
typename PointerType,
typename std::enable_if <
19661 std::is_pointer<PointerType>::value&&
19662 std::is_const<typename std::remove_pointer<PointerType>::type>
::value,
int >
::type = 0 >
19663 constexpr
auto get_ptr() const noexcept -> decltype(std::declval<const basic_json_t&>().get_impl_ptr(std::declval<PointerType>()))
19666 return get_impl_ptr(
static_cast<PointerType
>(
nullptr));
19696 template<
typename PointerType,
typename std::enable_if<
19697 std::is_pointer<PointerType>::value,
int>
::type = 0>
19698 auto get() noexcept -> decltype(std::declval<basic_json_t&>().template
get_ptr<PointerType>())
19701 return get_ptr<PointerType>();
19708 template<
typename PointerType,
typename std::enable_if<
19709 std::is_pointer<PointerType>::value,
int>
::type = 0>
19710 constexpr
auto get() const noexcept -> decltype(std::declval<const basic_json_t&>().template
get_ptr<PointerType>())
19713 return get_ptr<PointerType>();
19742 template<
typename ReferenceType,
typename std::enable_if<
19743 std::is_reference<ReferenceType>::value,
int>
::type = 0>
19747 return get_ref_impl<ReferenceType>(*
this);
19754 template <
typename ReferenceType,
typename std::enable_if <
19755 std::is_reference<ReferenceType>::value&&
19756 std::is_const<typename std::remove_reference<ReferenceType>::type>
::value,
int >
::type = 0 >
19760 return get_ref_impl<ReferenceType>(*
this);
19792 template <
typename ValueType,
typename std::enable_if <
19793 !std::is_pointer<ValueType>::value&&
19794 !std::is_same<ValueType, detail::json_ref<basic_json>>
::value&&
19795 !std::is_same<ValueType, typename string_t::value_type>::value&&
19797 && !std::is_same<ValueType, std::initializer_list<typename string_t::value_type>>
::value
19798 #if defined(JSON_HAS_CPP_17) && (defined(__GNUC__) || (defined(_MSC_VER) && _MSC_VER >= 1910 && _MSC_VER <= 1914))
19799 && !std::is_same<ValueType, typename std::string_view>::value
19801 && detail::is_detected<detail::get_template_function, const basic_json_t&, ValueType>::value
19803 JSON_EXPLICIT
operator ValueType()
const
19806 return get<ValueType>();
19822 JSON_THROW(type_error::create(302,
"type must be binary, but is " + std::string(
type_name())));
19825 return *get_ptr<binary_t*>();
19833 JSON_THROW(type_error::create(302,
"type must be binary, but is " + std::string(
type_name())));
19836 return *get_ptr<const binary_t*>();
19879 if (JSON_HEDLEY_LIKELY(
is_array()))
19883 return m_value.array->at(idx);
19885 JSON_CATCH (std::out_of_range&)
19888 JSON_THROW(out_of_range::create(401,
"array index " + std::to_string(idx) +
" is out of range"));
19893 JSON_THROW(type_error::create(304,
"cannot use at() with " + std::string(
type_name())));
19926 if (JSON_HEDLEY_LIKELY(
is_array()))
19930 return m_value.array->at(idx);
19932 JSON_CATCH (std::out_of_range&)
19935 JSON_THROW(out_of_range::create(401,
"array index " + std::to_string(idx) +
" is out of range"));
19940 JSON_THROW(type_error::create(304,
"cannot use at() with " + std::string(
type_name())));
19981 return m_value.object->at(key);
19983 JSON_CATCH (std::out_of_range&)
19986 JSON_THROW(out_of_range::create(403,
"key '" + key +
"' not found"));
19991 JSON_THROW(type_error::create(304,
"cannot use at() with " + std::string(
type_name())));
20032 return m_value.object->at(key);
20034 JSON_CATCH (std::out_of_range&)
20037 JSON_THROW(out_of_range::create(403,
"key '" + key +
"' not found"));
20042 JSON_THROW(type_error::create(304,
"cannot use at() with " + std::string(
type_name())));
20077 m_value.array = create<array_t>();
20078 assert_invariant();
20082 if (JSON_HEDLEY_LIKELY(
is_array()))
20085 if (idx >=
m_value.array->size())
20088 idx -
m_value.array->size() + 1,
20092 return m_value.array->operator[](idx);
20095 JSON_THROW(type_error::create(305,
"cannot use operator[] with a numeric argument with " + std::string(
type_name())));
20120 if (JSON_HEDLEY_LIKELY(
is_array()))
20122 return m_value.array->operator[](idx);
20125 JSON_THROW(type_error::create(305,
"cannot use operator[] with a numeric argument with " + std::string(
type_name())));
20161 m_value.object = create<object_t>();
20162 assert_invariant();
20168 return m_value.object->operator[](key);
20171 JSON_THROW(type_error::create(305,
"cannot use operator[] with a string argument with " + std::string(
type_name())));
20209 JSON_ASSERT(
m_value.object->find(key) !=
m_value.object->end());
20210 return m_value.object->find(key)->second;
20213 JSON_THROW(type_error::create(305,
"cannot use operator[] with a string argument with " + std::string(
type_name())));
20243 template<
typename T>
20244 JSON_HEDLEY_NON_NULL(2)
20252 assert_invariant();
20258 return m_value.object->operator[](key);
20261 JSON_THROW(type_error::create(305,
"cannot use operator[] with a string argument with " + std::string(
type_name())));
20294 template<
typename T>
20295 JSON_HEDLEY_NON_NULL(2)
20301 JSON_ASSERT(
m_value.object->find(key) !=
m_value.object->end());
20302 return m_value.object->find(key)->second;
20305 JSON_THROW(type_error::create(305,
"cannot use operator[] with a string argument with " + std::string(
type_name())));
20359 template <
class ValueType,
typename std::enable_if <
20361 && !std::is_same<value_t, ValueType>::value,
int >
::type = 0 >
20362 ValueType
value(
const typename object_t::key_type& key,
const ValueType& default_value)
const
20368 const auto it =
find(key);
20371 return it->template get<ValueType>();
20374 return default_value;
20377 JSON_THROW(type_error::create(306,
"cannot use value() with " + std::string(
type_name())));
20384 string_t value(
const typename object_t::key_type& key,
const char* default_value)
const
20432 template<
class ValueType,
typename std::enable_if<
20442 return ptr.get_checked(
this).template get<ValueType>();
20446 return default_value;
20450 JSON_THROW(type_error::create(306,
"cannot use value() with " + std::string(
type_name())));
20457 JSON_HEDLEY_NON_NULL(3)
20595 template <
class IteratorType,
typename std::enable_if <
20596 std::is_same<IteratorType, typename basic_json_t::iterator>::value ||
20597 std::is_same<IteratorType, typename basic_json_t::const_iterator>::value,
int >
::type
20602 if (JSON_HEDLEY_UNLIKELY(
this != pos.m_object))
20604 JSON_THROW(invalid_iterator::create(202,
"iterator does not fit current value"));
20607 IteratorType result =
end();
20618 if (JSON_HEDLEY_UNLIKELY(!pos.m_it.primitive_iterator.is_begin()))
20620 JSON_THROW(invalid_iterator::create(205,
"iterator out of range"));
20625 AllocatorType<string_t> alloc;
20626 std::allocator_traits<decltype(alloc)>::destroy(alloc,
m_value.string);
20627 std::allocator_traits<decltype(alloc)>::deallocate(alloc,
m_value.string, 1);
20632 AllocatorType<binary_t> alloc;
20633 std::allocator_traits<decltype(alloc)>::destroy(alloc,
m_value.binary);
20634 std::allocator_traits<decltype(alloc)>::deallocate(alloc,
m_value.binary, 1);
20639 assert_invariant();
20645 result.m_it.object_iterator =
m_value.object->erase(pos.m_it.object_iterator);
20651 result.m_it.array_iterator =
m_value.array->erase(pos.m_it.array_iterator);
20656 JSON_THROW(type_error::create(307,
"cannot use erase() with " + std::string(
type_name())));
20708 template <
class IteratorType,
typename std::enable_if <
20709 std::is_same<IteratorType, typename basic_json_t::iterator>::value ||
20710 std::is_same<IteratorType, typename basic_json_t::const_iterator>::value,
int >
::type
20712 IteratorType
erase(IteratorType first, IteratorType last)
20715 if (JSON_HEDLEY_UNLIKELY(
this != first.m_object ||
this != last.m_object))
20717 JSON_THROW(invalid_iterator::create(203,
"iterators do not fit current value"));
20720 IteratorType result =
end();
20731 if (JSON_HEDLEY_LIKELY(!first.m_it.primitive_iterator.is_begin()
20732 || !last.m_it.primitive_iterator.is_end()))
20734 JSON_THROW(invalid_iterator::create(204,
"iterators out of range"));
20739 AllocatorType<string_t> alloc;
20740 std::allocator_traits<decltype(alloc)>::destroy(alloc,
m_value.string);
20741 std::allocator_traits<decltype(alloc)>::deallocate(alloc,
m_value.string, 1);
20746 AllocatorType<binary_t> alloc;
20747 std::allocator_traits<decltype(alloc)>::destroy(alloc,
m_value.binary);
20748 std::allocator_traits<decltype(alloc)>::deallocate(alloc,
m_value.binary, 1);
20753 assert_invariant();
20759 result.m_it.object_iterator =
m_value.object->erase(first.m_it.object_iterator,
20760 last.m_it.object_iterator);
20766 result.m_it.array_iterator =
m_value.array->erase(first.m_it.array_iterator,
20767 last.m_it.array_iterator);
20772 JSON_THROW(type_error::create(307,
"cannot use erase() with " + std::string(
type_name())));
20812 return m_value.object->erase(key);
20815 JSON_THROW(type_error::create(307,
"cannot use erase() with " + std::string(
type_name())));
20845 if (JSON_HEDLEY_LIKELY(
is_array()))
20847 if (JSON_HEDLEY_UNLIKELY(idx >=
size()))
20849 JSON_THROW(out_of_range::create(401,
"array index " + std::to_string(idx) +
" is out of range"));
20856 JSON_THROW(type_error::create(307,
"cannot use erase() with " + std::string(
type_name())));
20894 template<
typename KeyT>
20897 auto result =
end();
20901 result.m_it.object_iterator =
m_value.object->find(std::forward<KeyT>(key));
20911 template<
typename KeyT>
20914 auto result =
cend();
20918 result.m_it.object_iterator =
m_value.object->find(std::forward<KeyT>(key));
20945 template<
typename KeyT>
20977 template <
typename KeyT,
typename std::enable_if <
21012 return ptr.contains(
this);
21052 result.set_begin();
21092 result.set_begin();
21356 JSON_HEDLEY_DEPRECATED_FOR(3.1.0,
items())
21359 return ref.items();
21365 JSON_HEDLEY_DEPRECATED_FOR(3.1.0,
items())
21368 return ref.items();
21517 return m_value.array->empty();
21523 return m_value.object->empty();
21590 return m_value.array->size();
21596 return m_value.object->size();
21655 return m_value.array->max_size();
21661 return m_value.object->max_size();
21801 JSON_THROW(type_error::create(308,
"cannot use push_back() with " + std::string(
type_name())));
21809 assert_invariant();
21813 m_value.array->push_back(std::move(val));
21836 JSON_THROW(type_error::create(308,
"cannot use push_back() with " + std::string(
type_name())));
21844 assert_invariant();
21848 m_value.array->push_back(val);
21886 JSON_THROW(type_error::create(308,
"cannot use push_back() with " + std::string(
type_name())));
21894 assert_invariant();
21938 if (
is_object() && init.size() == 2 && (*init.begin())->is_string())
21941 push_back(
typename object_t::value_type(
21942 std::move(key.
get_ref<
string_t&>()), (init.begin() + 1)->moved_or_copied()));
21983 template<
class... Args>
21989 JSON_THROW(type_error::create(311,
"cannot use emplace_back() with " + std::string(
type_name())));
21997 assert_invariant();
22001 #ifdef JSON_HAS_CPP_17
22002 return m_value.array->emplace_back(std::forward<Args>(args)...);
22004 m_value.array->emplace_back(std::forward<Args>(args)...);
22005 return m_value.array->back();
22036 template<
class... Args>
22042 JSON_THROW(type_error::create(311,
"cannot use emplace() with " + std::string(
type_name())));
22050 assert_invariant();
22054 auto res =
m_value.object->emplace(std::forward<Args>(args)...);
22057 it.m_it.object_iterator = res.first;
22060 return {it, res.second};
22066 template<
typename... Args>
22070 JSON_ASSERT(
m_value.array !=
nullptr);
22108 if (JSON_HEDLEY_LIKELY(
is_array()))
22111 if (JSON_HEDLEY_UNLIKELY(pos.m_object !=
this))
22113 JSON_THROW(invalid_iterator::create(202,
"iterator does not fit current value"));
22120 JSON_THROW(type_error::create(309,
"cannot use insert() with " + std::string(
type_name())));
22129 return insert(pos, val);
22159 if (JSON_HEDLEY_LIKELY(
is_array()))
22162 if (JSON_HEDLEY_UNLIKELY(pos.m_object !=
this))
22164 JSON_THROW(invalid_iterator::create(202,
"iterator does not fit current value"));
22171 JSON_THROW(type_error::create(309,
"cannot use insert() with " + std::string(
type_name())));
22207 if (JSON_HEDLEY_UNLIKELY(!
is_array()))
22209 JSON_THROW(type_error::create(309,
"cannot use insert() with " + std::string(
type_name())));
22213 if (JSON_HEDLEY_UNLIKELY(pos.m_object !=
this))
22215 JSON_THROW(invalid_iterator::create(202,
"iterator does not fit current value"));
22219 if (JSON_HEDLEY_UNLIKELY(first.m_object != last.m_object))
22221 JSON_THROW(invalid_iterator::create(210,
"iterators do not fit"));
22224 if (JSON_HEDLEY_UNLIKELY(first.m_object ==
this))
22226 JSON_THROW(invalid_iterator::create(211,
"passed iterators may not belong to container"));
22260 if (JSON_HEDLEY_UNLIKELY(!
is_array()))
22262 JSON_THROW(type_error::create(309,
"cannot use insert() with " + std::string(
type_name())));
22266 if (JSON_HEDLEY_UNLIKELY(pos.m_object !=
this))
22268 JSON_THROW(invalid_iterator::create(202,
"iterator does not fit current value"));
22301 if (JSON_HEDLEY_UNLIKELY(!
is_object()))
22303 JSON_THROW(type_error::create(309,
"cannot use insert() with " + std::string(
type_name())));
22307 if (JSON_HEDLEY_UNLIKELY(first.m_object != last.m_object))
22309 JSON_THROW(invalid_iterator::create(210,
"iterators do not fit"));
22313 if (JSON_HEDLEY_UNLIKELY(!first.m_object->is_object()))
22315 JSON_THROW(invalid_iterator::create(202,
"iterators first and last must point to objects"));
22346 m_value.object = create<object_t>();
22347 assert_invariant();
22350 if (JSON_HEDLEY_UNLIKELY(!
is_object()))
22352 JSON_THROW(type_error::create(312,
"cannot use update() with " + std::string(
type_name())));
22354 if (JSON_HEDLEY_UNLIKELY(!j.
is_object()))
22356 JSON_THROW(type_error::create(312,
"cannot use update() with " + std::string(j.
type_name())));
22359 for (
auto it = j.
cbegin(); it != j.
cend(); ++it)
22361 m_value.object->operator[](it.key()) = it.value();
22397 m_value.object = create<object_t>();
22398 assert_invariant();
22401 if (JSON_HEDLEY_UNLIKELY(!
is_object()))
22403 JSON_THROW(type_error::create(312,
"cannot use update() with " + std::string(
type_name())));
22407 if (JSON_HEDLEY_UNLIKELY(first.m_object != last.m_object))
22409 JSON_THROW(invalid_iterator::create(210,
"iterators do not fit"));
22413 if (JSON_HEDLEY_UNLIKELY(!first.m_object->is_object()
22414 || !last.m_object->is_object()))
22416 JSON_THROW(invalid_iterator::create(202,
"iterators first and last must point to objects"));
22419 for (
auto it = first; it != last; ++it)
22421 m_value.object->operator[](it.key()) = it.value();
22443 std::is_nothrow_move_constructible<value_t>::value&&
22444 std::is_nothrow_move_assignable<value_t>::value&&
22445 std::is_nothrow_move_constructible<json_value>::value&&
22446 std::is_nothrow_move_assignable<json_value>::value
22449 std::swap(m_type, other.m_type);
22450 std::swap(
m_value, other.m_value);
22451 assert_invariant();
22473 std::is_nothrow_move_constructible<value_t>::value&&
22474 std::is_nothrow_move_assignable<value_t>::value&&
22475 std::is_nothrow_move_constructible<json_value>::value&&
22476 std::is_nothrow_move_assignable<json_value>::value
22505 if (JSON_HEDLEY_LIKELY(
is_array()))
22507 std::swap(*(
m_value.array), other);
22511 JSON_THROW(type_error::create(310,
"cannot use swap() with " + std::string(
type_name())));
22540 std::swap(*(
m_value.object), other);
22544 JSON_THROW(type_error::create(310,
"cannot use swap() with " + std::string(
type_name())));
22573 std::swap(*(
m_value.string), other);
22577 JSON_THROW(type_error::create(310,
"cannot use swap() with " + std::string(
type_name())));
22606 std::swap(*(
m_value.binary), other);
22610 JSON_THROW(type_error::create(310,
"cannot use swap() with " + std::string(
type_name())));
22620 std::swap(*(
m_value.binary), other);
22624 JSON_THROW(type_error::create(310,
"cannot use swap() with " + std::string(
type_name())));
22695 const auto lhs_type = lhs.type();
22696 const auto rhs_type = rhs.type();
22698 if (lhs_type == rhs_type)
22703 return *lhs.m_value.array == *rhs.m_value.array;
22706 return *lhs.m_value.object == *rhs.m_value.object;
22712 return *lhs.m_value.string == *rhs.m_value.string;
22715 return lhs.m_value.boolean == rhs.m_value.boolean;
22718 return lhs.m_value.number_integer == rhs.m_value.number_integer;
22721 return lhs.m_value.number_unsigned == rhs.m_value.number_unsigned;
22724 return lhs.m_value.number_float == rhs.m_value.number_float;
22727 return *lhs.m_value.binary == *rhs.m_value.binary;
22735 return static_cast<number_float_t>(lhs.m_value.number_integer) == rhs.m_value.number_float;
22739 return lhs.m_value.number_float ==
static_cast<number_float_t>(rhs.m_value.number_integer);
22743 return static_cast<number_float_t>(lhs.m_value.number_unsigned) == rhs.m_value.number_float;
22747 return lhs.m_value.number_float ==
static_cast<number_float_t>(rhs.m_value.number_unsigned);
22751 return static_cast<number_integer_t>(lhs.m_value.number_unsigned) == rhs.m_value.number_integer;
22755 return lhs.m_value.number_integer ==
static_cast<number_integer_t>(rhs.m_value.number_unsigned);
22765 template<
typename ScalarType,
typename std::enable_if<
22766 std::is_scalar<ScalarType>::value,
int>
::type = 0>
22776 template<
typename ScalarType,
typename std::enable_if<
22777 std::is_scalar<ScalarType>::value,
int>
::type = 0>
22803 return !(lhs == rhs);
22810 template<
typename ScalarType,
typename std::enable_if<
22811 std::is_scalar<ScalarType>::value,
int>
::type = 0>
22821 template<
typename ScalarType,
typename std::enable_if<
22822 std::is_scalar<ScalarType>::value,
int>
::type = 0>
22856 const auto lhs_type = lhs.type();
22857 const auto rhs_type = rhs.type();
22859 if (lhs_type == rhs_type)
22866 return (*lhs.m_value.array) < (*rhs.m_value.array);
22869 return (*lhs.m_value.object) < (*rhs.m_value.object);
22875 return (*lhs.m_value.string) < (*rhs.m_value.string);
22878 return (lhs.m_value.boolean) < (rhs.m_value.boolean);
22881 return (lhs.m_value.number_integer) < (rhs.m_value.number_integer);
22884 return (lhs.m_value.number_unsigned) < (rhs.m_value.number_unsigned);
22887 return (lhs.m_value.number_float) < (rhs.m_value.number_float);
22890 return (*lhs.m_value.binary) < (*rhs.m_value.binary);
22898 return static_cast<number_float_t>(lhs.m_value.number_integer) < rhs.m_value.number_float;
22902 return lhs.m_value.number_float <
static_cast<number_float_t>(rhs.m_value.number_integer);
22906 return static_cast<number_float_t>(lhs.m_value.number_unsigned) < rhs.m_value.number_float;
22910 return lhs.m_value.number_float <
static_cast<number_float_t>(rhs.m_value.number_unsigned);
22914 return lhs.m_value.number_integer <
static_cast<number_integer_t>(rhs.m_value.number_unsigned);
22918 return static_cast<number_integer_t>(lhs.m_value.number_unsigned) < rhs.m_value.number_integer;
22931 template<
typename ScalarType,
typename std::enable_if<
22932 std::is_scalar<ScalarType>::value,
int>
::type = 0>
22942 template<
typename ScalarType,
typename std::enable_if<
22943 std::is_scalar<ScalarType>::value,
int>
::type = 0>
22970 return !(rhs < lhs);
22977 template<
typename ScalarType,
typename std::enable_if<
22978 std::is_scalar<ScalarType>::value,
int>
::type = 0>
22988 template<
typename ScalarType,
typename std::enable_if<
22989 std::is_scalar<ScalarType>::value,
int>
::type = 0>
23016 return !(lhs <= rhs);
23023 template<
typename ScalarType,
typename std::enable_if<
23024 std::is_scalar<ScalarType>::value,
int>
::type = 0>
23034 template<
typename ScalarType,
typename std::enable_if<
23035 std::is_scalar<ScalarType>::value,
int>
::type = 0>
23062 return !(lhs < rhs);
23069 template<
typename ScalarType,
typename std::enable_if<
23070 std::is_scalar<ScalarType>::value,
int>
::type = 0>
23080 template<
typename ScalarType,
typename std::enable_if<
23081 std::is_scalar<ScalarType>::value,
int>
::type = 0>
23130 const bool pretty_print = o.width() > 0;
23131 const auto indentation = pretty_print ? o.width() : 0;
23138 s.dump(j, pretty_print,
false,
static_cast<unsigned int>(indentation));
23150 JSON_HEDLEY_DEPRECATED_FOR(3.0.0,
operator<<(std::ostream&,
const basic_json&))
23151 friend std::ostream& operator>>(const
basic_json& j, std::ostream& o)
23217 template<
typename InputType>
23218 JSON_HEDLEY_WARN_UNUSED_RESULT
23221 const bool allow_exceptions =
true,
23222 const bool ignore_comments =
false)
23225 parser(detail::input_adapter(std::forward<InputType>(i)), cb, allow_exceptions, ignore_comments).parse(
true, result);
23255 template<
typename IteratorType>
23256 JSON_HEDLEY_WARN_UNUSED_RESULT
23260 const bool allow_exceptions =
true,
23261 const bool ignore_comments =
false)
23264 parser(detail::input_adapter(std::move(first), std::move(last)), cb, allow_exceptions, ignore_comments).parse(
true, result);
23268 JSON_HEDLEY_WARN_UNUSED_RESULT
23269 JSON_HEDLEY_DEPRECATED_FOR(3.8.0,
parse(ptr, ptr + len))
23272 const bool allow_exceptions =
true,
23273 const bool ignore_comments =
false)
23276 parser(i.get(), cb, allow_exceptions, ignore_comments).parse(
true, result);
23310 template<
typename InputType>
23312 const bool ignore_comments =
false)
23314 return parser(detail::input_adapter(std::forward<InputType>(i)),
nullptr,
false, ignore_comments).accept(
true);
23317 template<
typename IteratorType>
23318 static bool accept(IteratorType first, IteratorType last,
23319 const bool ignore_comments =
false)
23321 return parser(detail::input_adapter(std::move(first), std::move(last)),
nullptr,
false, ignore_comments).accept(
true);
23324 JSON_HEDLEY_WARN_UNUSED_RESULT
23325 JSON_HEDLEY_DEPRECATED_FOR(3.8.0,
accept(ptr, ptr + len))
23326 static bool accept(detail::span_input_adapter&& i,
23327 const bool ignore_comments =
false)
23329 return parser(i.get(),
nullptr,
false, ignore_comments).accept(
true);
23372 template <
typename InputType,
typename SAX>
23373 JSON_HEDLEY_NON_NULL(2)
23376 const
bool strict = true,
23377 const
bool ignore_comments = false)
23379 auto ia = detail::input_adapter(std::forward<InputType>(i));
23380 return format == input_format_t::json
23381 ? parser(std::move(ia),
nullptr,
true, ignore_comments).sax_parse(sax, strict)
23385 template<
class IteratorType,
class SAX>
23386 JSON_HEDLEY_NON_NULL(3)
23387 static
bool sax_parse(IteratorType first, IteratorType last, SAX* sax,
23388 input_format_t format = input_format_t::
json,
23389 const
bool strict = true,
23390 const
bool ignore_comments = false)
23392 auto ia = detail::input_adapter(std::move(first), std::move(last));
23393 return format == input_format_t::json
23394 ? parser(std::move(ia),
nullptr,
true, ignore_comments).sax_parse(sax, strict)
23398 template <
typename SAX>
23399 JSON_HEDLEY_DEPRECATED_FOR(3.8.0,
sax_parse(ptr, ptr + len, ...))
23400 JSON_HEDLEY_NON_NULL(2)
23401 static
bool sax_parse(detail::span_input_adapter&& i, SAX* sax,
23402 input_format_t format = input_format_t::
json,
23403 const
bool strict = true,
23404 const
bool ignore_comments = false)
23407 return format == input_format_t::json
23408 ? parser(std::move(ia),
nullptr,
true, ignore_comments).sax_parse(sax, strict)
23409 : detail::binary_reader<basic_json, decltype(ia), SAX>(std::move(ia)).sax_parse(format, sax, strict);
23420 JSON_HEDLEY_DEPRECATED_FOR(3.0.0,
operator>>(std::istream&,
basic_json&))
23453 parser(detail::input_adapter(i)).parse(
false, j);
23494 JSON_HEDLEY_RETURNS_NON_NULL
23513 return "discarded";
23521 JSON_PRIVATE_UNLESS_TESTED:
23636 std::vector<uint8_t> result;
23643 binary_writer<uint8_t>(o).write_cbor(j);
23648 binary_writer<char>(o).write_cbor(j);
23731 std::vector<uint8_t> result;
23738 binary_writer<uint8_t>(o).write_msgpack(j);
23743 binary_writer<char>(o).write_msgpack(j);
23833 const bool use_size =
false,
23834 const bool use_type =
false)
23836 std::vector<uint8_t> result;
23837 to_ubjson(j, result, use_size, use_type);
23842 const bool use_size =
false,
const bool use_type =
false)
23844 binary_writer<uint8_t>(o).write_ubjson(j, use_size, use_type);
23848 const bool use_size =
false,
const bool use_type =
false)
23850 binary_writer<char>(o).write_ubjson(j, use_size, use_type);
23912 std::vector<uint8_t> result;
24041 template<
typename InputType>
24042 JSON_HEDLEY_WARN_UNUSED_RESULT
24044 const bool strict =
true,
24045 const bool allow_exceptions =
true,
24050 auto ia = detail::input_adapter(std::forward<InputType>(i));
24058 template<
typename IteratorType>
24059 JSON_HEDLEY_WARN_UNUSED_RESULT
24061 const bool strict =
true,
24062 const bool allow_exceptions =
true,
24067 auto ia = detail::input_adapter(std::move(first), std::move(last));
24072 template<
typename T>
24073 JSON_HEDLEY_WARN_UNUSED_RESULT
24074 JSON_HEDLEY_DEPRECATED_FOR(3.8.0,
from_cbor(ptr, ptr + len))
24076 const bool strict =
true,
24077 const bool allow_exceptions =
true,
24080 return from_cbor(ptr, ptr + len, strict, allow_exceptions, tag_handler);
24084 JSON_HEDLEY_WARN_UNUSED_RESULT
24085 JSON_HEDLEY_DEPRECATED_FOR(3.8.0,
from_cbor(ptr, ptr + len))
24087 const bool strict =
true,
24088 const bool allow_exceptions =
true,
24092 detail::json_sax_dom_parser<basic_json> sdp(result, allow_exceptions);
24094 const bool res = binary_reader<decltype(ia)>(std::move(ia)).sax_parse(input_format_t::cbor, &sdp, strict, tag_handler);
24184 template<
typename InputType>
24185 JSON_HEDLEY_WARN_UNUSED_RESULT
24187 const bool strict =
true,
24188 const bool allow_exceptions =
true)
24192 auto ia = detail::input_adapter(std::forward<InputType>(i));
24200 template<
typename IteratorType>
24201 JSON_HEDLEY_WARN_UNUSED_RESULT
24203 const bool strict =
true,
24204 const bool allow_exceptions =
true)
24208 auto ia = detail::input_adapter(std::move(first), std::move(last));
24214 template<
typename T>
24215 JSON_HEDLEY_WARN_UNUSED_RESULT
24216 JSON_HEDLEY_DEPRECATED_FOR(3.8.0,
from_msgpack(ptr, ptr + len))
24218 const bool strict =
true,
24219 const bool allow_exceptions =
true)
24221 return from_msgpack(ptr, ptr + len, strict, allow_exceptions);
24224 JSON_HEDLEY_WARN_UNUSED_RESULT
24225 JSON_HEDLEY_DEPRECATED_FOR(3.8.0,
from_msgpack(ptr, ptr + len))
24227 const bool strict =
true,
24228 const bool allow_exceptions =
true)
24231 detail::json_sax_dom_parser<basic_json> sdp(result, allow_exceptions);
24233 const bool res = binary_reader<decltype(ia)>(std::move(ia)).sax_parse(input_format_t::msgpack, &sdp, strict);
24300 template<
typename InputType>
24301 JSON_HEDLEY_WARN_UNUSED_RESULT
24303 const bool strict =
true,
24304 const bool allow_exceptions =
true)
24308 auto ia = detail::input_adapter(std::forward<InputType>(i));
24316 template<
typename IteratorType>
24317 JSON_HEDLEY_WARN_UNUSED_RESULT
24319 const bool strict =
true,
24320 const bool allow_exceptions =
true)
24324 auto ia = detail::input_adapter(std::move(first), std::move(last));
24329 template<
typename T>
24330 JSON_HEDLEY_WARN_UNUSED_RESULT
24331 JSON_HEDLEY_DEPRECATED_FOR(3.8.0,
from_ubjson(ptr, ptr + len))
24333 const bool strict =
true,
24334 const bool allow_exceptions =
true)
24336 return from_ubjson(ptr, ptr + len, strict, allow_exceptions);
24339 JSON_HEDLEY_WARN_UNUSED_RESULT
24340 JSON_HEDLEY_DEPRECATED_FOR(3.8.0,
from_ubjson(ptr, ptr + len))
24342 const bool strict =
true,
24343 const bool allow_exceptions =
true)
24346 detail::json_sax_dom_parser<basic_json> sdp(result, allow_exceptions);
24348 const bool res = binary_reader<decltype(ia)>(std::move(ia)).sax_parse(input_format_t::ubjson, &sdp, strict);
24413 template<
typename InputType>
24414 JSON_HEDLEY_WARN_UNUSED_RESULT
24416 const bool strict =
true,
24417 const bool allow_exceptions =
true)
24421 auto ia = detail::input_adapter(std::forward<InputType>(i));
24429 template<
typename IteratorType>
24430 JSON_HEDLEY_WARN_UNUSED_RESULT
24432 const bool strict =
true,
24433 const bool allow_exceptions =
true)
24437 auto ia = detail::input_adapter(std::move(first), std::move(last));
24442 template<
typename T>
24443 JSON_HEDLEY_WARN_UNUSED_RESULT
24444 JSON_HEDLEY_DEPRECATED_FOR(3.8.0,
from_bson(ptr, ptr + len))
24446 const bool strict =
true,
24447 const bool allow_exceptions =
true)
24449 return from_bson(ptr, ptr + len, strict, allow_exceptions);
24452 JSON_HEDLEY_WARN_UNUSED_RESULT
24453 JSON_HEDLEY_DEPRECATED_FOR(3.8.0,
from_bson(ptr, ptr + len))
24455 const bool strict =
true,
24456 const bool allow_exceptions =
true)
24459 detail::json_sax_dom_parser<basic_json> sdp(result, allow_exceptions);
24461 const bool res = binary_reader<decltype(ia)>(std::move(ia)).sax_parse(input_format_t::bson, &sdp, strict);
24508 return ptr.get_unchecked(
this);
24536 return ptr.get_unchecked(
this);
24579 return ptr.get_checked(
this);
24622 return ptr.get_checked(
this);
24650 json_pointer::flatten(
"", *
this, result);
24686 return json_pointer::unflatten(*
this);
24751 enum class patch_operations {add, remove, replace, move, copy, test, invalid};
24753 const auto get_op = [](
const std::string & op)
24757 return patch_operations::add;
24759 if (op ==
"remove")
24761 return patch_operations::remove;
24763 if (op ==
"replace")
24765 return patch_operations::replace;
24769 return patch_operations::move;
24773 return patch_operations::copy;
24777 return patch_operations::test;
24780 return patch_operations::invalid;
24795 if (top_pointer != ptr)
24797 result.
at(top_pointer);
24801 const auto last_path = ptr.
back();
24805 switch (parent.m_type)
24811 parent[last_path] = val;
24817 if (last_path ==
"-")
24824 const auto idx = json_pointer::array_index(last_path);
24825 if (JSON_HEDLEY_UNLIKELY(idx > parent.
size()))
24828 JSON_THROW(out_of_range::create(401,
"array index " + std::to_string(idx) +
" is out of range"));
24839 JSON_ASSERT(
false);
24844 const auto operation_remove = [&result](
json_pointer & ptr)
24847 const auto last_path = ptr.
back();
24855 auto it = parent.
find(last_path);
24856 if (JSON_HEDLEY_LIKELY(it != parent.
end()))
24862 JSON_THROW(out_of_range::create(403,
"key '" + last_path +
"' not found"));
24868 parent.
erase(json_pointer::array_index(last_path));
24873 if (JSON_HEDLEY_UNLIKELY(!json_patch.
is_array()))
24879 for (
const auto& val : json_patch)
24882 const auto get_value = [&val](
const std::string & op,
24883 const std::string & member,
24887 auto it = val.
m_value.object->find(member);
24890 const auto error_msg = (op ==
"op") ?
"operation" :
"operation '" + op +
"'";
24893 if (JSON_HEDLEY_UNLIKELY(it == val.m_value.object->end()))
24895 JSON_THROW(
parse_error::create(105, 0, error_msg +
" must have member '" + member +
"'"));
24899 if (JSON_HEDLEY_UNLIKELY(string_type && !it->second.is_string()))
24901 JSON_THROW(
parse_error::create(105, 0, error_msg +
" must have string member '" + member +
"'"));
24909 if (JSON_HEDLEY_UNLIKELY(!val.is_object()))
24915 const auto op = get_value(
"op",
"op",
true).template get<std::string>();
24916 const auto path = get_value(op,
"path",
true).template get<std::string>();
24919 switch (get_op(op))
24921 case patch_operations::add:
24923 operation_add(ptr, get_value(
"add",
"value",
false));
24927 case patch_operations::remove:
24929 operation_remove(ptr);
24933 case patch_operations::replace:
24936 result.
at(ptr) = get_value(
"replace",
"value",
false);
24940 case patch_operations::move:
24942 const auto from_path = get_value(
"move",
"from",
true).template get<std::string>();
24952 operation_remove(from_ptr);
24953 operation_add(ptr, v);
24957 case patch_operations::copy:
24959 const auto from_path = get_value(
"copy",
"from",
true).template get<std::string>();
24968 operation_add(ptr, v);
24972 case patch_operations::test:
24974 bool success =
false;
24979 success = (result.
at(ptr) == get_value(
"test",
"value",
false));
24987 if (JSON_HEDLEY_UNLIKELY(!success))
24989 JSON_THROW(other_error::create(501,
"unsuccessful: " + val.dump()));
25040 JSON_HEDLEY_WARN_UNUSED_RESULT
25042 const std::string& path =
"")
25048 if (source == target)
25053 if (source.
type() != target.
type())
25058 {
"op",
"replace"}, {
"path", path}, {
"value", target}
25063 switch (source.
type())
25069 while (i < source.
size() && i < target.
size())
25072 auto temp_diff =
diff(source[i], target[i], path +
"/" + std::to_string(i));
25073 result.
insert(result.
end(), temp_diff.begin(), temp_diff.end());
25082 while (i < source.
size())
25089 {
"path", path +
"/" + std::to_string(i)}
25095 while (i < target.
size())
25100 {
"path", path +
"/-"},
25101 {
"value", target[i]}
25112 for (
auto it = source.
cbegin(); it != source.
cend(); ++it)
25115 const auto key = json_pointer::escape(it.key());
25117 if (target.
find(it.key()) != target.
end())
25120 auto temp_diff =
diff(it.value(), target[it.key()], path +
"/" + key);
25121 result.
insert(result.
end(), temp_diff.begin(), temp_diff.end());
25128 {
"op",
"remove"}, {
"path", path +
"/" + key}
25134 for (
auto it = target.
cbegin(); it != target.
cend(); ++it)
25136 if (source.
find(it.key()) == source.
end())
25139 const auto key = json_pointer::escape(it.key());
25142 {
"op",
"add"}, {
"path", path +
"/" + key},
25143 {
"value", it.value()}
25156 {
"op",
"replace"}, {
"path", path}, {
"value", target}
25224 for (
auto it = apply_patch.
begin(); it != apply_patch.
end(); ++it)
25226 if (it.value().is_null())
25238 *
this = apply_patch;
25254 NLOHMANN_BASIC_JSON_TPL_DECLARATION
25302 #ifndef JSON_HAS_CPP_20
25311 is_nothrow_move_constructible<nlohmann::json>::value&&
25312 is_nothrow_move_assignable<nlohmann::json>::value
25335 JSON_HEDLEY_NON_NULL(1)
25336 inline
nlohmann::
json operator "" _json(const
char* s, std::
size_t n)
25354 JSON_HEDLEY_NON_NULL(1)
25355 inline
nlohmann::
json::json_pointer operator "" _json_pointer(const
char* s, std::
size_t n)
25364 #if defined(__clang__) || defined(__GNUC__) || defined(__GNUG__)
25365 #pragma GCC diagnostic pop
25367 #if defined(__clang__)
25368 #pragma GCC diagnostic pop
25373 #undef JSON_INTERNAL_CATCH
25377 #undef JSON_PRIVATE_UNLESS_TESTED
25378 #undef JSON_HAS_CPP_14
25379 #undef JSON_HAS_CPP_17
25380 #undef NLOHMANN_BASIC_JSON_TPL_DECLARATION
25381 #undef NLOHMANN_BASIC_JSON_TPL
25382 #undef JSON_EXPLICIT
25385 #undef JSON_HEDLEY_ALWAYS_INLINE
25386 #undef JSON_HEDLEY_ARM_VERSION
25387 #undef JSON_HEDLEY_ARM_VERSION_CHECK
25388 #undef JSON_HEDLEY_ARRAY_PARAM
25389 #undef JSON_HEDLEY_ASSUME
25390 #undef JSON_HEDLEY_BEGIN_C_DECLS
25391 #undef JSON_HEDLEY_CLANG_HAS_ATTRIBUTE
25392 #undef JSON_HEDLEY_CLANG_HAS_BUILTIN
25393 #undef JSON_HEDLEY_CLANG_HAS_CPP_ATTRIBUTE
25394 #undef JSON_HEDLEY_CLANG_HAS_DECLSPEC_DECLSPEC_ATTRIBUTE
25395 #undef JSON_HEDLEY_CLANG_HAS_EXTENSION
25396 #undef JSON_HEDLEY_CLANG_HAS_FEATURE
25397 #undef JSON_HEDLEY_CLANG_HAS_WARNING
25398 #undef JSON_HEDLEY_COMPCERT_VERSION
25399 #undef JSON_HEDLEY_COMPCERT_VERSION_CHECK
25400 #undef JSON_HEDLEY_CONCAT
25401 #undef JSON_HEDLEY_CONCAT3
25402 #undef JSON_HEDLEY_CONCAT3_EX
25403 #undef JSON_HEDLEY_CONCAT_EX
25404 #undef JSON_HEDLEY_CONST
25405 #undef JSON_HEDLEY_CONSTEXPR
25406 #undef JSON_HEDLEY_CONST_CAST
25407 #undef JSON_HEDLEY_CPP_CAST
25408 #undef JSON_HEDLEY_CRAY_VERSION
25409 #undef JSON_HEDLEY_CRAY_VERSION_CHECK
25410 #undef JSON_HEDLEY_C_DECL
25411 #undef JSON_HEDLEY_DEPRECATED
25412 #undef JSON_HEDLEY_DEPRECATED_FOR
25413 #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL
25414 #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_
25415 #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED
25416 #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES
25417 #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS
25418 #undef JSON_HEDLEY_DIAGNOSTIC_POP
25419 #undef JSON_HEDLEY_DIAGNOSTIC_PUSH
25420 #undef JSON_HEDLEY_DMC_VERSION
25421 #undef JSON_HEDLEY_DMC_VERSION_CHECK
25422 #undef JSON_HEDLEY_EMPTY_BASES
25423 #undef JSON_HEDLEY_EMSCRIPTEN_VERSION
25424 #undef JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK
25425 #undef JSON_HEDLEY_END_C_DECLS
25426 #undef JSON_HEDLEY_FLAGS
25427 #undef JSON_HEDLEY_FLAGS_CAST
25428 #undef JSON_HEDLEY_GCC_HAS_ATTRIBUTE
25429 #undef JSON_HEDLEY_GCC_HAS_BUILTIN
25430 #undef JSON_HEDLEY_GCC_HAS_CPP_ATTRIBUTE
25431 #undef JSON_HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE
25432 #undef JSON_HEDLEY_GCC_HAS_EXTENSION
25433 #undef JSON_HEDLEY_GCC_HAS_FEATURE
25434 #undef JSON_HEDLEY_GCC_HAS_WARNING
25435 #undef JSON_HEDLEY_GCC_NOT_CLANG_VERSION_CHECK
25436 #undef JSON_HEDLEY_GCC_VERSION
25437 #undef JSON_HEDLEY_GCC_VERSION_CHECK
25438 #undef JSON_HEDLEY_GNUC_HAS_ATTRIBUTE
25439 #undef JSON_HEDLEY_GNUC_HAS_BUILTIN
25440 #undef JSON_HEDLEY_GNUC_HAS_CPP_ATTRIBUTE
25441 #undef JSON_HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE
25442 #undef JSON_HEDLEY_GNUC_HAS_EXTENSION
25443 #undef JSON_HEDLEY_GNUC_HAS_FEATURE
25444 #undef JSON_HEDLEY_GNUC_HAS_WARNING
25445 #undef JSON_HEDLEY_GNUC_VERSION
25446 #undef JSON_HEDLEY_GNUC_VERSION_CHECK
25447 #undef JSON_HEDLEY_HAS_ATTRIBUTE
25448 #undef JSON_HEDLEY_HAS_BUILTIN
25449 #undef JSON_HEDLEY_HAS_CPP_ATTRIBUTE
25450 #undef JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS
25451 #undef JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE
25452 #undef JSON_HEDLEY_HAS_EXTENSION
25453 #undef JSON_HEDLEY_HAS_FEATURE
25454 #undef JSON_HEDLEY_HAS_WARNING
25455 #undef JSON_HEDLEY_IAR_VERSION
25456 #undef JSON_HEDLEY_IAR_VERSION_CHECK
25457 #undef JSON_HEDLEY_IBM_VERSION
25458 #undef JSON_HEDLEY_IBM_VERSION_CHECK
25459 #undef JSON_HEDLEY_IMPORT
25460 #undef JSON_HEDLEY_INLINE
25461 #undef JSON_HEDLEY_INTEL_CL_VERSION
25462 #undef JSON_HEDLEY_INTEL_CL_VERSION_CHECK
25463 #undef JSON_HEDLEY_INTEL_VERSION
25464 #undef JSON_HEDLEY_INTEL_VERSION_CHECK
25465 #undef JSON_HEDLEY_IS_CONSTANT
25466 #undef JSON_HEDLEY_IS_CONSTEXPR_
25467 #undef JSON_HEDLEY_LIKELY
25468 #undef JSON_HEDLEY_MALLOC
25469 #undef JSON_HEDLEY_MESSAGE
25470 #undef JSON_HEDLEY_MSVC_VERSION
25471 #undef JSON_HEDLEY_MSVC_VERSION_CHECK
25472 #undef JSON_HEDLEY_NEVER_INLINE
25473 #undef JSON_HEDLEY_NON_NULL
25474 #undef JSON_HEDLEY_NO_ESCAPE
25475 #undef JSON_HEDLEY_NO_RETURN
25476 #undef JSON_HEDLEY_NO_THROW
25477 #undef JSON_HEDLEY_NULL
25478 #undef JSON_HEDLEY_PELLES_VERSION
25479 #undef JSON_HEDLEY_PELLES_VERSION_CHECK
25480 #undef JSON_HEDLEY_PGI_VERSION
25481 #undef JSON_HEDLEY_PGI_VERSION_CHECK
25482 #undef JSON_HEDLEY_PREDICT
25483 #undef JSON_HEDLEY_PRINTF_FORMAT
25484 #undef JSON_HEDLEY_PRIVATE
25485 #undef JSON_HEDLEY_PUBLIC
25486 #undef JSON_HEDLEY_PURE
25487 #undef JSON_HEDLEY_REINTERPRET_CAST
25488 #undef JSON_HEDLEY_REQUIRE
25489 #undef JSON_HEDLEY_REQUIRE_CONSTEXPR
25490 #undef JSON_HEDLEY_REQUIRE_MSG
25491 #undef JSON_HEDLEY_RESTRICT
25492 #undef JSON_HEDLEY_RETURNS_NON_NULL
25493 #undef JSON_HEDLEY_SENTINEL
25494 #undef JSON_HEDLEY_STATIC_ASSERT
25495 #undef JSON_HEDLEY_STATIC_CAST
25496 #undef JSON_HEDLEY_STRINGIFY
25497 #undef JSON_HEDLEY_STRINGIFY_EX
25498 #undef JSON_HEDLEY_SUNPRO_VERSION
25499 #undef JSON_HEDLEY_SUNPRO_VERSION_CHECK
25500 #undef JSON_HEDLEY_TINYC_VERSION
25501 #undef JSON_HEDLEY_TINYC_VERSION_CHECK
25502 #undef JSON_HEDLEY_TI_ARMCL_VERSION
25503 #undef JSON_HEDLEY_TI_ARMCL_VERSION_CHECK
25504 #undef JSON_HEDLEY_TI_CL2000_VERSION
25505 #undef JSON_HEDLEY_TI_CL2000_VERSION_CHECK
25506 #undef JSON_HEDLEY_TI_CL430_VERSION
25507 #undef JSON_HEDLEY_TI_CL430_VERSION_CHECK
25508 #undef JSON_HEDLEY_TI_CL6X_VERSION
25509 #undef JSON_HEDLEY_TI_CL6X_VERSION_CHECK
25510 #undef JSON_HEDLEY_TI_CL7X_VERSION
25511 #undef JSON_HEDLEY_TI_CL7X_VERSION_CHECK
25512 #undef JSON_HEDLEY_TI_CLPRU_VERSION
25513 #undef JSON_HEDLEY_TI_CLPRU_VERSION_CHECK
25514 #undef JSON_HEDLEY_TI_VERSION
25515 #undef JSON_HEDLEY_TI_VERSION_CHECK
25516 #undef JSON_HEDLEY_UNAVAILABLE
25517 #undef JSON_HEDLEY_UNLIKELY
25518 #undef JSON_HEDLEY_UNPREDICTABLE
25519 #undef JSON_HEDLEY_UNREACHABLE
25520 #undef JSON_HEDLEY_UNREACHABLE_RETURN
25521 #undef JSON_HEDLEY_VERSION
25522 #undef JSON_HEDLEY_VERSION_DECODE_MAJOR
25523 #undef JSON_HEDLEY_VERSION_DECODE_MINOR
25524 #undef JSON_HEDLEY_VERSION_DECODE_REVISION
25525 #undef JSON_HEDLEY_VERSION_ENCODE
25526 #undef JSON_HEDLEY_WARNING
25527 #undef JSON_HEDLEY_WARN_UNUSED_RESULT
25528 #undef JSON_HEDLEY_WARN_UNUSED_RESULT_MSG
25529 #undef JSON_HEDLEY_FALL_THROUGH
25533 #endif // INCLUDE_NLOHMANN_JSON_HPP_