39#ifndef INCLUDE_NLOHMANN_JSON_HPP_
40#define INCLUDE_NLOHMANN_JSON_HPP_
42#ifndef JSON_SKIP_LIBRARY_VERSION_CHECK
43 #if defined(NLOHMANN_JSON_VERSION_MAJOR) && defined(NLOHMANN_JSON_VERSION_MINOR) && defined(NLOHMANN_JSON_VERSION_PATCH)
44 #if NLOHMANN_JSON_VERSION_MAJOR != 3 || NLOHMANN_JSON_VERSION_MINOR != 10 || NLOHMANN_JSON_VERSION_PATCH != 5
45 #warning "Already included a different version of the library!"
50#define NLOHMANN_JSON_VERSION_MAJOR 3
51#define NLOHMANN_JSON_VERSION_MINOR 10
52#define NLOHMANN_JSON_VERSION_PATCH 5
57#include <initializer_list>
79#include <forward_list>
85#include <unordered_map>
125#if !defined(JSON_HEDLEY_VERSION) || (JSON_HEDLEY_VERSION < 15)
126#if defined(JSON_HEDLEY_VERSION)
127 #undef JSON_HEDLEY_VERSION
129#define JSON_HEDLEY_VERSION 15
131#if defined(JSON_HEDLEY_STRINGIFY_EX)
132 #undef JSON_HEDLEY_STRINGIFY_EX
134#define JSON_HEDLEY_STRINGIFY_EX(x) #x
136#if defined(JSON_HEDLEY_STRINGIFY)
137 #undef JSON_HEDLEY_STRINGIFY
139#define JSON_HEDLEY_STRINGIFY(x) JSON_HEDLEY_STRINGIFY_EX(x)
141#if defined(JSON_HEDLEY_CONCAT_EX)
142 #undef JSON_HEDLEY_CONCAT_EX
144#define JSON_HEDLEY_CONCAT_EX(a,b) a##b
146#if defined(JSON_HEDLEY_CONCAT)
147 #undef JSON_HEDLEY_CONCAT
149#define JSON_HEDLEY_CONCAT(a,b) JSON_HEDLEY_CONCAT_EX(a,b)
151#if defined(JSON_HEDLEY_CONCAT3_EX)
152 #undef JSON_HEDLEY_CONCAT3_EX
154#define JSON_HEDLEY_CONCAT3_EX(a,b,c) a##b##c
156#if defined(JSON_HEDLEY_CONCAT3)
157 #undef JSON_HEDLEY_CONCAT3
159#define JSON_HEDLEY_CONCAT3(a,b,c) JSON_HEDLEY_CONCAT3_EX(a,b,c)
161#if defined(JSON_HEDLEY_VERSION_ENCODE)
162 #undef JSON_HEDLEY_VERSION_ENCODE
164#define JSON_HEDLEY_VERSION_ENCODE(major,minor,revision) (((major) * 1000000) + ((minor) * 1000) + (revision))
166#if defined(JSON_HEDLEY_VERSION_DECODE_MAJOR)
167 #undef JSON_HEDLEY_VERSION_DECODE_MAJOR
169#define JSON_HEDLEY_VERSION_DECODE_MAJOR(version) ((version) / 1000000)
171#if defined(JSON_HEDLEY_VERSION_DECODE_MINOR)
172 #undef JSON_HEDLEY_VERSION_DECODE_MINOR
174#define JSON_HEDLEY_VERSION_DECODE_MINOR(version) (((version) % 1000000) / 1000)
176#if defined(JSON_HEDLEY_VERSION_DECODE_REVISION)
177 #undef JSON_HEDLEY_VERSION_DECODE_REVISION
179#define JSON_HEDLEY_VERSION_DECODE_REVISION(version) ((version) % 1000)
181#if defined(JSON_HEDLEY_GNUC_VERSION)
182 #undef JSON_HEDLEY_GNUC_VERSION
184#if defined(__GNUC__) && defined(__GNUC_PATCHLEVEL__)
185 #define JSON_HEDLEY_GNUC_VERSION JSON_HEDLEY_VERSION_ENCODE(__GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__)
186#elif defined(__GNUC__)
187 #define JSON_HEDLEY_GNUC_VERSION JSON_HEDLEY_VERSION_ENCODE(__GNUC__, __GNUC_MINOR__, 0)
190#if defined(JSON_HEDLEY_GNUC_VERSION_CHECK)
191 #undef JSON_HEDLEY_GNUC_VERSION_CHECK
193#if defined(JSON_HEDLEY_GNUC_VERSION)
194 #define JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_GNUC_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
196 #define JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) (0)
199#if defined(JSON_HEDLEY_MSVC_VERSION)
200 #undef JSON_HEDLEY_MSVC_VERSION
202#if defined(_MSC_FULL_VER) && (_MSC_FULL_VER >= 140000000) && !defined(__ICL)
203 #define JSON_HEDLEY_MSVC_VERSION JSON_HEDLEY_VERSION_ENCODE(_MSC_FULL_VER / 10000000, (_MSC_FULL_VER % 10000000) / 100000, (_MSC_FULL_VER % 100000) / 100)
204#elif defined(_MSC_FULL_VER) && !defined(__ICL)
205 #define JSON_HEDLEY_MSVC_VERSION JSON_HEDLEY_VERSION_ENCODE(_MSC_FULL_VER / 1000000, (_MSC_FULL_VER % 1000000) / 10000, (_MSC_FULL_VER % 10000) / 10)
206#elif defined(_MSC_VER) && !defined(__ICL)
207 #define JSON_HEDLEY_MSVC_VERSION JSON_HEDLEY_VERSION_ENCODE(_MSC_VER / 100, _MSC_VER % 100, 0)
210#if defined(JSON_HEDLEY_MSVC_VERSION_CHECK)
211 #undef JSON_HEDLEY_MSVC_VERSION_CHECK
213#if !defined(JSON_HEDLEY_MSVC_VERSION)
214 #define JSON_HEDLEY_MSVC_VERSION_CHECK(major,minor,patch) (0)
215#elif defined(_MSC_VER) && (_MSC_VER >= 1400)
216 #define JSON_HEDLEY_MSVC_VERSION_CHECK(major,minor,patch) (_MSC_FULL_VER >= ((major * 10000000) + (minor * 100000) + (patch)))
217#elif defined(_MSC_VER) && (_MSC_VER >= 1200)
218 #define JSON_HEDLEY_MSVC_VERSION_CHECK(major,minor,patch) (_MSC_FULL_VER >= ((major * 1000000) + (minor * 10000) + (patch)))
220 #define JSON_HEDLEY_MSVC_VERSION_CHECK(major,minor,patch) (_MSC_VER >= ((major * 100) + (minor)))
223#if defined(JSON_HEDLEY_INTEL_VERSION)
224 #undef JSON_HEDLEY_INTEL_VERSION
226#if defined(__INTEL_COMPILER) && defined(__INTEL_COMPILER_UPDATE) && !defined(__ICL)
227 #define JSON_HEDLEY_INTEL_VERSION JSON_HEDLEY_VERSION_ENCODE(__INTEL_COMPILER / 100, __INTEL_COMPILER % 100, __INTEL_COMPILER_UPDATE)
228#elif defined(__INTEL_COMPILER) && !defined(__ICL)
229 #define JSON_HEDLEY_INTEL_VERSION JSON_HEDLEY_VERSION_ENCODE(__INTEL_COMPILER / 100, __INTEL_COMPILER % 100, 0)
232#if defined(JSON_HEDLEY_INTEL_VERSION_CHECK)
233 #undef JSON_HEDLEY_INTEL_VERSION_CHECK
235#if defined(JSON_HEDLEY_INTEL_VERSION)
236 #define JSON_HEDLEY_INTEL_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_INTEL_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
238 #define JSON_HEDLEY_INTEL_VERSION_CHECK(major,minor,patch) (0)
241#if defined(JSON_HEDLEY_INTEL_CL_VERSION)
242 #undef JSON_HEDLEY_INTEL_CL_VERSION
244#if defined(__INTEL_COMPILER) && defined(__INTEL_COMPILER_UPDATE) && defined(__ICL)
245 #define JSON_HEDLEY_INTEL_CL_VERSION JSON_HEDLEY_VERSION_ENCODE(__INTEL_COMPILER, __INTEL_COMPILER_UPDATE, 0)
248#if defined(JSON_HEDLEY_INTEL_CL_VERSION_CHECK)
249 #undef JSON_HEDLEY_INTEL_CL_VERSION_CHECK
251#if defined(JSON_HEDLEY_INTEL_CL_VERSION)
252 #define JSON_HEDLEY_INTEL_CL_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_INTEL_CL_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
254 #define JSON_HEDLEY_INTEL_CL_VERSION_CHECK(major,minor,patch) (0)
257#if defined(JSON_HEDLEY_PGI_VERSION)
258 #undef JSON_HEDLEY_PGI_VERSION
260#if defined(__PGI) && defined(__PGIC__) && defined(__PGIC_MINOR__) && defined(__PGIC_PATCHLEVEL__)
261 #define JSON_HEDLEY_PGI_VERSION JSON_HEDLEY_VERSION_ENCODE(__PGIC__, __PGIC_MINOR__, __PGIC_PATCHLEVEL__)
264#if defined(JSON_HEDLEY_PGI_VERSION_CHECK)
265 #undef JSON_HEDLEY_PGI_VERSION_CHECK
267#if defined(JSON_HEDLEY_PGI_VERSION)
268 #define JSON_HEDLEY_PGI_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_PGI_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
270 #define JSON_HEDLEY_PGI_VERSION_CHECK(major,minor,patch) (0)
273#if defined(JSON_HEDLEY_SUNPRO_VERSION)
274 #undef JSON_HEDLEY_SUNPRO_VERSION
276#if defined(__SUNPRO_C) && (__SUNPRO_C > 0x1000)
277 #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)
278#elif defined(__SUNPRO_C)
279 #define JSON_HEDLEY_SUNPRO_VERSION JSON_HEDLEY_VERSION_ENCODE((__SUNPRO_C >> 8) & 0xf, (__SUNPRO_C >> 4) & 0xf, (__SUNPRO_C) & 0xf)
280#elif defined(__SUNPRO_CC) && (__SUNPRO_CC > 0x1000)
281 #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)
282#elif defined(__SUNPRO_CC)
283 #define JSON_HEDLEY_SUNPRO_VERSION JSON_HEDLEY_VERSION_ENCODE((__SUNPRO_CC >> 8) & 0xf, (__SUNPRO_CC >> 4) & 0xf, (__SUNPRO_CC) & 0xf)
286#if defined(JSON_HEDLEY_SUNPRO_VERSION_CHECK)
287 #undef JSON_HEDLEY_SUNPRO_VERSION_CHECK
289#if defined(JSON_HEDLEY_SUNPRO_VERSION)
290 #define JSON_HEDLEY_SUNPRO_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_SUNPRO_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
292 #define JSON_HEDLEY_SUNPRO_VERSION_CHECK(major,minor,patch) (0)
295#if defined(JSON_HEDLEY_EMSCRIPTEN_VERSION)
296 #undef JSON_HEDLEY_EMSCRIPTEN_VERSION
298#if defined(__EMSCRIPTEN__)
299 #define JSON_HEDLEY_EMSCRIPTEN_VERSION JSON_HEDLEY_VERSION_ENCODE(__EMSCRIPTEN_major__, __EMSCRIPTEN_minor__, __EMSCRIPTEN_tiny__)
302#if defined(JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK)
303 #undef JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK
305#if defined(JSON_HEDLEY_EMSCRIPTEN_VERSION)
306 #define JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_EMSCRIPTEN_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
308 #define JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK(major,minor,patch) (0)
311#if defined(JSON_HEDLEY_ARM_VERSION)
312 #undef JSON_HEDLEY_ARM_VERSION
314#if defined(__CC_ARM) && defined(__ARMCOMPILER_VERSION)
315 #define JSON_HEDLEY_ARM_VERSION JSON_HEDLEY_VERSION_ENCODE(__ARMCOMPILER_VERSION / 1000000, (__ARMCOMPILER_VERSION % 1000000) / 10000, (__ARMCOMPILER_VERSION % 10000) / 100)
316#elif defined(__CC_ARM) && defined(__ARMCC_VERSION)
317 #define JSON_HEDLEY_ARM_VERSION JSON_HEDLEY_VERSION_ENCODE(__ARMCC_VERSION / 1000000, (__ARMCC_VERSION % 1000000) / 10000, (__ARMCC_VERSION % 10000) / 100)
320#if defined(JSON_HEDLEY_ARM_VERSION_CHECK)
321 #undef JSON_HEDLEY_ARM_VERSION_CHECK
323#if defined(JSON_HEDLEY_ARM_VERSION)
324 #define JSON_HEDLEY_ARM_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_ARM_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
326 #define JSON_HEDLEY_ARM_VERSION_CHECK(major,minor,patch) (0)
329#if defined(JSON_HEDLEY_IBM_VERSION)
330 #undef JSON_HEDLEY_IBM_VERSION
332#if defined(__ibmxl__)
333 #define JSON_HEDLEY_IBM_VERSION JSON_HEDLEY_VERSION_ENCODE(__ibmxl_version__, __ibmxl_release__, __ibmxl_modification__)
334#elif defined(__xlC__) && defined(__xlC_ver__)
335 #define JSON_HEDLEY_IBM_VERSION JSON_HEDLEY_VERSION_ENCODE(__xlC__ >> 8, __xlC__ & 0xff, (__xlC_ver__ >> 8) & 0xff)
336#elif defined(__xlC__)
337 #define JSON_HEDLEY_IBM_VERSION JSON_HEDLEY_VERSION_ENCODE(__xlC__ >> 8, __xlC__ & 0xff, 0)
340#if defined(JSON_HEDLEY_IBM_VERSION_CHECK)
341 #undef JSON_HEDLEY_IBM_VERSION_CHECK
343#if defined(JSON_HEDLEY_IBM_VERSION)
344 #define JSON_HEDLEY_IBM_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_IBM_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
346 #define JSON_HEDLEY_IBM_VERSION_CHECK(major,minor,patch) (0)
349#if defined(JSON_HEDLEY_TI_VERSION)
350 #undef JSON_HEDLEY_TI_VERSION
353 defined(__TI_COMPILER_VERSION__) && \
355 defined(__TMS470__) || defined(__TI_ARM__) || \
356 defined(__MSP430__) || \
357 defined(__TMS320C2000__) \
359#if (__TI_COMPILER_VERSION__ >= 16000000)
360 #define JSON_HEDLEY_TI_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000))
364#if defined(JSON_HEDLEY_TI_VERSION_CHECK)
365 #undef JSON_HEDLEY_TI_VERSION_CHECK
367#if defined(JSON_HEDLEY_TI_VERSION)
368 #define JSON_HEDLEY_TI_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
370 #define JSON_HEDLEY_TI_VERSION_CHECK(major,minor,patch) (0)
373#if defined(JSON_HEDLEY_TI_CL2000_VERSION)
374 #undef JSON_HEDLEY_TI_CL2000_VERSION
376#if defined(__TI_COMPILER_VERSION__) && defined(__TMS320C2000__)
377 #define JSON_HEDLEY_TI_CL2000_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000))
380#if defined(JSON_HEDLEY_TI_CL2000_VERSION_CHECK)
381 #undef JSON_HEDLEY_TI_CL2000_VERSION_CHECK
383#if defined(JSON_HEDLEY_TI_CL2000_VERSION)
384 #define JSON_HEDLEY_TI_CL2000_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_CL2000_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
386 #define JSON_HEDLEY_TI_CL2000_VERSION_CHECK(major,minor,patch) (0)
389#if defined(JSON_HEDLEY_TI_CL430_VERSION)
390 #undef JSON_HEDLEY_TI_CL430_VERSION
392#if defined(__TI_COMPILER_VERSION__) && defined(__MSP430__)
393 #define JSON_HEDLEY_TI_CL430_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000))
396#if defined(JSON_HEDLEY_TI_CL430_VERSION_CHECK)
397 #undef JSON_HEDLEY_TI_CL430_VERSION_CHECK
399#if defined(JSON_HEDLEY_TI_CL430_VERSION)
400 #define JSON_HEDLEY_TI_CL430_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_CL430_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
402 #define JSON_HEDLEY_TI_CL430_VERSION_CHECK(major,minor,patch) (0)
405#if defined(JSON_HEDLEY_TI_ARMCL_VERSION)
406 #undef JSON_HEDLEY_TI_ARMCL_VERSION
408#if defined(__TI_COMPILER_VERSION__) && (defined(__TMS470__) || defined(__TI_ARM__))
409 #define JSON_HEDLEY_TI_ARMCL_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000))
412#if defined(JSON_HEDLEY_TI_ARMCL_VERSION_CHECK)
413 #undef JSON_HEDLEY_TI_ARMCL_VERSION_CHECK
415#if defined(JSON_HEDLEY_TI_ARMCL_VERSION)
416 #define JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_ARMCL_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
418 #define JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(major,minor,patch) (0)
421#if defined(JSON_HEDLEY_TI_CL6X_VERSION)
422 #undef JSON_HEDLEY_TI_CL6X_VERSION
424#if defined(__TI_COMPILER_VERSION__) && defined(__TMS320C6X__)
425 #define JSON_HEDLEY_TI_CL6X_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000))
428#if defined(JSON_HEDLEY_TI_CL6X_VERSION_CHECK)
429 #undef JSON_HEDLEY_TI_CL6X_VERSION_CHECK
431#if defined(JSON_HEDLEY_TI_CL6X_VERSION)
432 #define JSON_HEDLEY_TI_CL6X_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_CL6X_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
434 #define JSON_HEDLEY_TI_CL6X_VERSION_CHECK(major,minor,patch) (0)
437#if defined(JSON_HEDLEY_TI_CL7X_VERSION)
438 #undef JSON_HEDLEY_TI_CL7X_VERSION
440#if defined(__TI_COMPILER_VERSION__) && defined(__C7000__)
441 #define JSON_HEDLEY_TI_CL7X_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000))
444#if defined(JSON_HEDLEY_TI_CL7X_VERSION_CHECK)
445 #undef JSON_HEDLEY_TI_CL7X_VERSION_CHECK
447#if defined(JSON_HEDLEY_TI_CL7X_VERSION)
448 #define JSON_HEDLEY_TI_CL7X_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_CL7X_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
450 #define JSON_HEDLEY_TI_CL7X_VERSION_CHECK(major,minor,patch) (0)
453#if defined(JSON_HEDLEY_TI_CLPRU_VERSION)
454 #undef JSON_HEDLEY_TI_CLPRU_VERSION
456#if defined(__TI_COMPILER_VERSION__) && defined(__PRU__)
457 #define JSON_HEDLEY_TI_CLPRU_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000))
460#if defined(JSON_HEDLEY_TI_CLPRU_VERSION_CHECK)
461 #undef JSON_HEDLEY_TI_CLPRU_VERSION_CHECK
463#if defined(JSON_HEDLEY_TI_CLPRU_VERSION)
464 #define JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_CLPRU_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
466 #define JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(major,minor,patch) (0)
469#if defined(JSON_HEDLEY_CRAY_VERSION)
470 #undef JSON_HEDLEY_CRAY_VERSION
473 #if defined(_RELEASE_PATCHLEVEL)
474 #define JSON_HEDLEY_CRAY_VERSION JSON_HEDLEY_VERSION_ENCODE(_RELEASE_MAJOR, _RELEASE_MINOR, _RELEASE_PATCHLEVEL)
476 #define JSON_HEDLEY_CRAY_VERSION JSON_HEDLEY_VERSION_ENCODE(_RELEASE_MAJOR, _RELEASE_MINOR, 0)
480#if defined(JSON_HEDLEY_CRAY_VERSION_CHECK)
481 #undef JSON_HEDLEY_CRAY_VERSION_CHECK
483#if defined(JSON_HEDLEY_CRAY_VERSION)
484 #define JSON_HEDLEY_CRAY_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_CRAY_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
486 #define JSON_HEDLEY_CRAY_VERSION_CHECK(major,minor,patch) (0)
489#if defined(JSON_HEDLEY_IAR_VERSION)
490 #undef JSON_HEDLEY_IAR_VERSION
492#if defined(__IAR_SYSTEMS_ICC__)
494 #define JSON_HEDLEY_IAR_VERSION JSON_HEDLEY_VERSION_ENCODE((__VER__ / 1000000), ((__VER__ / 1000) % 1000), (__VER__ % 1000))
496 #define JSON_HEDLEY_IAR_VERSION JSON_HEDLEY_VERSION_ENCODE(__VER__ / 100, __VER__ % 100, 0)
500#if defined(JSON_HEDLEY_IAR_VERSION_CHECK)
501 #undef JSON_HEDLEY_IAR_VERSION_CHECK
503#if defined(JSON_HEDLEY_IAR_VERSION)
504 #define JSON_HEDLEY_IAR_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_IAR_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
506 #define JSON_HEDLEY_IAR_VERSION_CHECK(major,minor,patch) (0)
509#if defined(JSON_HEDLEY_TINYC_VERSION)
510 #undef JSON_HEDLEY_TINYC_VERSION
512#if defined(__TINYC__)
513 #define JSON_HEDLEY_TINYC_VERSION JSON_HEDLEY_VERSION_ENCODE(__TINYC__ / 1000, (__TINYC__ / 100) % 10, __TINYC__ % 100)
516#if defined(JSON_HEDLEY_TINYC_VERSION_CHECK)
517 #undef JSON_HEDLEY_TINYC_VERSION_CHECK
519#if defined(JSON_HEDLEY_TINYC_VERSION)
520 #define JSON_HEDLEY_TINYC_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TINYC_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
522 #define JSON_HEDLEY_TINYC_VERSION_CHECK(major,minor,patch) (0)
525#if defined(JSON_HEDLEY_DMC_VERSION)
526 #undef JSON_HEDLEY_DMC_VERSION
529 #define JSON_HEDLEY_DMC_VERSION JSON_HEDLEY_VERSION_ENCODE(__DMC__ >> 8, (__DMC__ >> 4) & 0xf, __DMC__ & 0xf)
532#if defined(JSON_HEDLEY_DMC_VERSION_CHECK)
533 #undef JSON_HEDLEY_DMC_VERSION_CHECK
535#if defined(JSON_HEDLEY_DMC_VERSION)
536 #define JSON_HEDLEY_DMC_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_DMC_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
538 #define JSON_HEDLEY_DMC_VERSION_CHECK(major,minor,patch) (0)
541#if defined(JSON_HEDLEY_COMPCERT_VERSION)
542 #undef JSON_HEDLEY_COMPCERT_VERSION
544#if defined(__COMPCERT_VERSION__)
545 #define JSON_HEDLEY_COMPCERT_VERSION JSON_HEDLEY_VERSION_ENCODE(__COMPCERT_VERSION__ / 10000, (__COMPCERT_VERSION__ / 100) % 100, __COMPCERT_VERSION__ % 100)
548#if defined(JSON_HEDLEY_COMPCERT_VERSION_CHECK)
549 #undef JSON_HEDLEY_COMPCERT_VERSION_CHECK
551#if defined(JSON_HEDLEY_COMPCERT_VERSION)
552 #define JSON_HEDLEY_COMPCERT_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_COMPCERT_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
554 #define JSON_HEDLEY_COMPCERT_VERSION_CHECK(major,minor,patch) (0)
557#if defined(JSON_HEDLEY_PELLES_VERSION)
558 #undef JSON_HEDLEY_PELLES_VERSION
561 #define JSON_HEDLEY_PELLES_VERSION JSON_HEDLEY_VERSION_ENCODE(__POCC__ / 100, __POCC__ % 100, 0)
564#if defined(JSON_HEDLEY_PELLES_VERSION_CHECK)
565 #undef JSON_HEDLEY_PELLES_VERSION_CHECK
567#if defined(JSON_HEDLEY_PELLES_VERSION)
568 #define JSON_HEDLEY_PELLES_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_PELLES_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
570 #define JSON_HEDLEY_PELLES_VERSION_CHECK(major,minor,patch) (0)
573#if defined(JSON_HEDLEY_MCST_LCC_VERSION)
574 #undef JSON_HEDLEY_MCST_LCC_VERSION
576#if defined(__LCC__) && defined(__LCC_MINOR__)
577 #define JSON_HEDLEY_MCST_LCC_VERSION JSON_HEDLEY_VERSION_ENCODE(__LCC__ / 100, __LCC__ % 100, __LCC_MINOR__)
580#if defined(JSON_HEDLEY_MCST_LCC_VERSION_CHECK)
581 #undef JSON_HEDLEY_MCST_LCC_VERSION_CHECK
583#if defined(JSON_HEDLEY_MCST_LCC_VERSION)
584 #define JSON_HEDLEY_MCST_LCC_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_MCST_LCC_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
586 #define JSON_HEDLEY_MCST_LCC_VERSION_CHECK(major,minor,patch) (0)
589#if defined(JSON_HEDLEY_GCC_VERSION)
590 #undef JSON_HEDLEY_GCC_VERSION
593 defined(JSON_HEDLEY_GNUC_VERSION) && \
594 !defined(__clang__) && \
595 !defined(JSON_HEDLEY_INTEL_VERSION) && \
596 !defined(JSON_HEDLEY_PGI_VERSION) && \
597 !defined(JSON_HEDLEY_ARM_VERSION) && \
598 !defined(JSON_HEDLEY_CRAY_VERSION) && \
599 !defined(JSON_HEDLEY_TI_VERSION) && \
600 !defined(JSON_HEDLEY_TI_ARMCL_VERSION) && \
601 !defined(JSON_HEDLEY_TI_CL430_VERSION) && \
602 !defined(JSON_HEDLEY_TI_CL2000_VERSION) && \
603 !defined(JSON_HEDLEY_TI_CL6X_VERSION) && \
604 !defined(JSON_HEDLEY_TI_CL7X_VERSION) && \
605 !defined(JSON_HEDLEY_TI_CLPRU_VERSION) && \
606 !defined(__COMPCERT__) && \
607 !defined(JSON_HEDLEY_MCST_LCC_VERSION)
608 #define JSON_HEDLEY_GCC_VERSION JSON_HEDLEY_GNUC_VERSION
611#if defined(JSON_HEDLEY_GCC_VERSION_CHECK)
612 #undef JSON_HEDLEY_GCC_VERSION_CHECK
614#if defined(JSON_HEDLEY_GCC_VERSION)
615 #define JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_GCC_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
617 #define JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) (0)
620#if defined(JSON_HEDLEY_HAS_ATTRIBUTE)
621 #undef JSON_HEDLEY_HAS_ATTRIBUTE
624 defined(__has_attribute) && \
626 (!defined(JSON_HEDLEY_IAR_VERSION) || JSON_HEDLEY_IAR_VERSION_CHECK(8,5,9)) \
628# define JSON_HEDLEY_HAS_ATTRIBUTE(attribute) __has_attribute(attribute)
630# define JSON_HEDLEY_HAS_ATTRIBUTE(attribute) (0)
633#if defined(JSON_HEDLEY_GNUC_HAS_ATTRIBUTE)
634 #undef JSON_HEDLEY_GNUC_HAS_ATTRIBUTE
636#if defined(__has_attribute)
637 #define JSON_HEDLEY_GNUC_HAS_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_HAS_ATTRIBUTE(attribute)
639 #define JSON_HEDLEY_GNUC_HAS_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch)
642#if defined(JSON_HEDLEY_GCC_HAS_ATTRIBUTE)
643 #undef JSON_HEDLEY_GCC_HAS_ATTRIBUTE
645#if defined(__has_attribute)
646 #define JSON_HEDLEY_GCC_HAS_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_HAS_ATTRIBUTE(attribute)
648 #define JSON_HEDLEY_GCC_HAS_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch)
651#if defined(JSON_HEDLEY_HAS_CPP_ATTRIBUTE)
652 #undef JSON_HEDLEY_HAS_CPP_ATTRIBUTE
655 defined(__has_cpp_attribute) && \
656 defined(__cplusplus) && \
657 (!defined(JSON_HEDLEY_SUNPRO_VERSION) || JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,15,0))
658 #define JSON_HEDLEY_HAS_CPP_ATTRIBUTE(attribute) __has_cpp_attribute(attribute)
660 #define JSON_HEDLEY_HAS_CPP_ATTRIBUTE(attribute) (0)
663#if defined(JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS)
664 #undef JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS
666#if !defined(__cplusplus) || !defined(__has_cpp_attribute)
667 #define JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS(ns,attribute) (0)
669 !defined(JSON_HEDLEY_PGI_VERSION) && \
670 !defined(JSON_HEDLEY_IAR_VERSION) && \
671 (!defined(JSON_HEDLEY_SUNPRO_VERSION) || JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,15,0)) && \
672 (!defined(JSON_HEDLEY_MSVC_VERSION) || JSON_HEDLEY_MSVC_VERSION_CHECK(19,20,0))
673 #define JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS(ns,attribute) JSON_HEDLEY_HAS_CPP_ATTRIBUTE(ns::attribute)
675 #define JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS(ns,attribute) (0)
678#if defined(JSON_HEDLEY_GNUC_HAS_CPP_ATTRIBUTE)
679 #undef JSON_HEDLEY_GNUC_HAS_CPP_ATTRIBUTE
681#if defined(__has_cpp_attribute) && defined(__cplusplus)
682 #define JSON_HEDLEY_GNUC_HAS_CPP_ATTRIBUTE(attribute,major,minor,patch) __has_cpp_attribute(attribute)
684 #define JSON_HEDLEY_GNUC_HAS_CPP_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch)
687#if defined(JSON_HEDLEY_GCC_HAS_CPP_ATTRIBUTE)
688 #undef JSON_HEDLEY_GCC_HAS_CPP_ATTRIBUTE
690#if defined(__has_cpp_attribute) && defined(__cplusplus)
691 #define JSON_HEDLEY_GCC_HAS_CPP_ATTRIBUTE(attribute,major,minor,patch) __has_cpp_attribute(attribute)
693 #define JSON_HEDLEY_GCC_HAS_CPP_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch)
696#if defined(JSON_HEDLEY_HAS_BUILTIN)
697 #undef JSON_HEDLEY_HAS_BUILTIN
699#if defined(__has_builtin)
700 #define JSON_HEDLEY_HAS_BUILTIN(builtin) __has_builtin(builtin)
702 #define JSON_HEDLEY_HAS_BUILTIN(builtin) (0)
705#if defined(JSON_HEDLEY_GNUC_HAS_BUILTIN)
706 #undef JSON_HEDLEY_GNUC_HAS_BUILTIN
708#if defined(__has_builtin)
709 #define JSON_HEDLEY_GNUC_HAS_BUILTIN(builtin,major,minor,patch) __has_builtin(builtin)
711 #define JSON_HEDLEY_GNUC_HAS_BUILTIN(builtin,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch)
714#if defined(JSON_HEDLEY_GCC_HAS_BUILTIN)
715 #undef JSON_HEDLEY_GCC_HAS_BUILTIN
717#if defined(__has_builtin)
718 #define JSON_HEDLEY_GCC_HAS_BUILTIN(builtin,major,minor,patch) __has_builtin(builtin)
720 #define JSON_HEDLEY_GCC_HAS_BUILTIN(builtin,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch)
723#if defined(JSON_HEDLEY_HAS_FEATURE)
724 #undef JSON_HEDLEY_HAS_FEATURE
726#if defined(__has_feature)
727 #define JSON_HEDLEY_HAS_FEATURE(feature) __has_feature(feature)
729 #define JSON_HEDLEY_HAS_FEATURE(feature) (0)
732#if defined(JSON_HEDLEY_GNUC_HAS_FEATURE)
733 #undef JSON_HEDLEY_GNUC_HAS_FEATURE
735#if defined(__has_feature)
736 #define JSON_HEDLEY_GNUC_HAS_FEATURE(feature,major,minor,patch) __has_feature(feature)
738 #define JSON_HEDLEY_GNUC_HAS_FEATURE(feature,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch)
741#if defined(JSON_HEDLEY_GCC_HAS_FEATURE)
742 #undef JSON_HEDLEY_GCC_HAS_FEATURE
744#if defined(__has_feature)
745 #define JSON_HEDLEY_GCC_HAS_FEATURE(feature,major,minor,patch) __has_feature(feature)
747 #define JSON_HEDLEY_GCC_HAS_FEATURE(feature,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch)
750#if defined(JSON_HEDLEY_HAS_EXTENSION)
751 #undef JSON_HEDLEY_HAS_EXTENSION
753#if defined(__has_extension)
754 #define JSON_HEDLEY_HAS_EXTENSION(extension) __has_extension(extension)
756 #define JSON_HEDLEY_HAS_EXTENSION(extension) (0)
759#if defined(JSON_HEDLEY_GNUC_HAS_EXTENSION)
760 #undef JSON_HEDLEY_GNUC_HAS_EXTENSION
762#if defined(__has_extension)
763 #define JSON_HEDLEY_GNUC_HAS_EXTENSION(extension,major,minor,patch) __has_extension(extension)
765 #define JSON_HEDLEY_GNUC_HAS_EXTENSION(extension,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch)
768#if defined(JSON_HEDLEY_GCC_HAS_EXTENSION)
769 #undef JSON_HEDLEY_GCC_HAS_EXTENSION
771#if defined(__has_extension)
772 #define JSON_HEDLEY_GCC_HAS_EXTENSION(extension,major,minor,patch) __has_extension(extension)
774 #define JSON_HEDLEY_GCC_HAS_EXTENSION(extension,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch)
777#if defined(JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE)
778 #undef JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE
780#if defined(__has_declspec_attribute)
781 #define JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE(attribute) __has_declspec_attribute(attribute)
783 #define JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE(attribute) (0)
786#if defined(JSON_HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE)
787 #undef JSON_HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE
789#if defined(__has_declspec_attribute)
790 #define JSON_HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE(attribute,major,minor,patch) __has_declspec_attribute(attribute)
792 #define JSON_HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch)
795#if defined(JSON_HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE)
796 #undef JSON_HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE
798#if defined(__has_declspec_attribute)
799 #define JSON_HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE(attribute,major,minor,patch) __has_declspec_attribute(attribute)
801 #define JSON_HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch)
804#if defined(JSON_HEDLEY_HAS_WARNING)
805 #undef JSON_HEDLEY_HAS_WARNING
807#if defined(__has_warning)
808 #define JSON_HEDLEY_HAS_WARNING(warning) __has_warning(warning)
810 #define JSON_HEDLEY_HAS_WARNING(warning) (0)
813#if defined(JSON_HEDLEY_GNUC_HAS_WARNING)
814 #undef JSON_HEDLEY_GNUC_HAS_WARNING
816#if defined(__has_warning)
817 #define JSON_HEDLEY_GNUC_HAS_WARNING(warning,major,minor,patch) __has_warning(warning)
819 #define JSON_HEDLEY_GNUC_HAS_WARNING(warning,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch)
822#if defined(JSON_HEDLEY_GCC_HAS_WARNING)
823 #undef JSON_HEDLEY_GCC_HAS_WARNING
825#if defined(__has_warning)
826 #define JSON_HEDLEY_GCC_HAS_WARNING(warning,major,minor,patch) __has_warning(warning)
828 #define JSON_HEDLEY_GCC_HAS_WARNING(warning,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch)
832 (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)) || \
833 defined(__clang__) || \
834 JSON_HEDLEY_GCC_VERSION_CHECK(3,0,0) || \
835 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
836 JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) || \
837 JSON_HEDLEY_PGI_VERSION_CHECK(18,4,0) || \
838 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
839 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
840 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,7,0) || \
841 JSON_HEDLEY_TI_CL430_VERSION_CHECK(2,0,1) || \
842 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,1,0) || \
843 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,0,0) || \
844 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
845 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
846 JSON_HEDLEY_CRAY_VERSION_CHECK(5,0,0) || \
847 JSON_HEDLEY_TINYC_VERSION_CHECK(0,9,17) || \
848 JSON_HEDLEY_SUNPRO_VERSION_CHECK(8,0,0) || \
849 (JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) && defined(__C99_PRAGMA_OPERATOR))
850 #define JSON_HEDLEY_PRAGMA(value) _Pragma(#value)
851#elif JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0)
852 #define JSON_HEDLEY_PRAGMA(value) __pragma(value)
854 #define JSON_HEDLEY_PRAGMA(value)
857#if defined(JSON_HEDLEY_DIAGNOSTIC_PUSH)
858 #undef JSON_HEDLEY_DIAGNOSTIC_PUSH
860#if defined(JSON_HEDLEY_DIAGNOSTIC_POP)
861 #undef JSON_HEDLEY_DIAGNOSTIC_POP
863#if defined(__clang__)
864 #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("clang diagnostic push")
865 #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("clang diagnostic pop")
866#elif JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0)
867 #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("warning(push)")
868 #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("warning(pop)")
869#elif JSON_HEDLEY_GCC_VERSION_CHECK(4,6,0)
870 #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("GCC diagnostic push")
871 #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("GCC diagnostic pop")
873 JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0) || \
874 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
875 #define JSON_HEDLEY_DIAGNOSTIC_PUSH __pragma(warning(push))
876 #define JSON_HEDLEY_DIAGNOSTIC_POP __pragma(warning(pop))
877#elif JSON_HEDLEY_ARM_VERSION_CHECK(5,6,0)
878 #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("push")
879 #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("pop")
881 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
882 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
883 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,4,0) || \
884 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,1,0) || \
885 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
886 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0)
887 #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("diag_push")
888 #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("diag_pop")
889#elif JSON_HEDLEY_PELLES_VERSION_CHECK(2,90,0)
890 #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("warning(push)")
891 #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("warning(pop)")
893 #define JSON_HEDLEY_DIAGNOSTIC_PUSH
894 #define JSON_HEDLEY_DIAGNOSTIC_POP
899#if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_)
900 #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_
902#if defined(__cplusplus)
903# if JSON_HEDLEY_HAS_WARNING("-Wc++98-compat")
904# if JSON_HEDLEY_HAS_WARNING("-Wc++17-extensions")
905# if JSON_HEDLEY_HAS_WARNING("-Wc++1z-extensions")
906# define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(xpr) \
907 JSON_HEDLEY_DIAGNOSTIC_PUSH \
908 _Pragma("clang diagnostic ignored \"-Wc++98-compat\"") \
909 _Pragma("clang diagnostic ignored \"-Wc++17-extensions\"") \
910 _Pragma("clang diagnostic ignored \"-Wc++1z-extensions\"") \
912 JSON_HEDLEY_DIAGNOSTIC_POP
914# define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(xpr) \
915 JSON_HEDLEY_DIAGNOSTIC_PUSH \
916 _Pragma("clang diagnostic ignored \"-Wc++98-compat\"") \
917 _Pragma("clang diagnostic ignored \"-Wc++17-extensions\"") \
919 JSON_HEDLEY_DIAGNOSTIC_POP
922# define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(xpr) \
923 JSON_HEDLEY_DIAGNOSTIC_PUSH \
924 _Pragma("clang diagnostic ignored \"-Wc++98-compat\"") \
926 JSON_HEDLEY_DIAGNOSTIC_POP
930#if !defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_)
931 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(x) x
934#if defined(JSON_HEDLEY_CONST_CAST)
935 #undef JSON_HEDLEY_CONST_CAST
937#if defined(__cplusplus)
938# define JSON_HEDLEY_CONST_CAST(T, expr) (const_cast<T>(expr))
940 JSON_HEDLEY_HAS_WARNING("-Wcast-qual") || \
941 JSON_HEDLEY_GCC_VERSION_CHECK(4,6,0) || \
942 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0)
943# define JSON_HEDLEY_CONST_CAST(T, expr) (__extension__ ({ \
944 JSON_HEDLEY_DIAGNOSTIC_PUSH \
945 JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL \
947 JSON_HEDLEY_DIAGNOSTIC_POP \
950# define JSON_HEDLEY_CONST_CAST(T, expr) ((T) (expr))
953#if defined(JSON_HEDLEY_REINTERPRET_CAST)
954 #undef JSON_HEDLEY_REINTERPRET_CAST
956#if defined(__cplusplus)
957 #define JSON_HEDLEY_REINTERPRET_CAST(T, expr) (reinterpret_cast<T>(expr))
959 #define JSON_HEDLEY_REINTERPRET_CAST(T, expr) ((T) (expr))
962#if defined(JSON_HEDLEY_STATIC_CAST)
963 #undef JSON_HEDLEY_STATIC_CAST
965#if defined(__cplusplus)
966 #define JSON_HEDLEY_STATIC_CAST(T, expr) (static_cast<T>(expr))
968 #define JSON_HEDLEY_STATIC_CAST(T, expr) ((T) (expr))
971#if defined(JSON_HEDLEY_CPP_CAST)
972 #undef JSON_HEDLEY_CPP_CAST
974#if defined(__cplusplus)
975# if JSON_HEDLEY_HAS_WARNING("-Wold-style-cast")
976# define JSON_HEDLEY_CPP_CAST(T, expr) \
977 JSON_HEDLEY_DIAGNOSTIC_PUSH \
978 _Pragma("clang diagnostic ignored \"-Wold-style-cast\"") \
980 JSON_HEDLEY_DIAGNOSTIC_POP
981# elif JSON_HEDLEY_IAR_VERSION_CHECK(8,3,0)
982# define JSON_HEDLEY_CPP_CAST(T, expr) \
983 JSON_HEDLEY_DIAGNOSTIC_PUSH \
984 _Pragma("diag_suppress=Pe137") \
985 JSON_HEDLEY_DIAGNOSTIC_POP
987# define JSON_HEDLEY_CPP_CAST(T, expr) ((T) (expr))
990# define JSON_HEDLEY_CPP_CAST(T, expr) (expr)
993#if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED)
994 #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED
996#if JSON_HEDLEY_HAS_WARNING("-Wdeprecated-declarations")
997 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("clang diagnostic ignored \"-Wdeprecated-declarations\"")
998#elif JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0)
999 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("warning(disable:1478 1786)")
1000#elif JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1001 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED __pragma(warning(disable:1478 1786))
1002#elif JSON_HEDLEY_PGI_VERSION_CHECK(20,7,0)
1003 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress 1215,1216,1444,1445")
1004#elif JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0)
1005 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress 1215,1444")
1006#elif JSON_HEDLEY_GCC_VERSION_CHECK(4,3,0)
1007 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"")
1008#elif JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0)
1009 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED __pragma(warning(disable:4996))
1010#elif JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1011 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress 1215,1444")
1013 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1014 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1015 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1016 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1017 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1018 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1019 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1020 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1021 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1022 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1023 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0)
1024 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress 1291,1718")
1025#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,13,0) && !defined(__cplusplus)
1026 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("error_messages(off,E_DEPRECATED_ATT,E_DEPRECATED_ATT_MESS)")
1027#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,13,0) && defined(__cplusplus)
1028 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("error_messages(off,symdeprecated,symdeprecated2)")
1029#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
1030 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress=Pe1444,Pe1215")
1031#elif JSON_HEDLEY_PELLES_VERSION_CHECK(2,90,0)
1032 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("warn(disable:2241)")
1034 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED
1037#if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS)
1038 #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS
1040#if JSON_HEDLEY_HAS_WARNING("-Wunknown-pragmas")
1041 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("clang diagnostic ignored \"-Wunknown-pragmas\"")
1042#elif JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0)
1043 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("warning(disable:161)")
1044#elif JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1045 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS __pragma(warning(disable:161))
1046#elif JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0)
1047 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress 1675")
1048#elif JSON_HEDLEY_GCC_VERSION_CHECK(4,3,0)
1049 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("GCC diagnostic ignored \"-Wunknown-pragmas\"")
1050#elif JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0)
1051 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS __pragma(warning(disable:4068))
1053 JSON_HEDLEY_TI_VERSION_CHECK(16,9,0) || \
1054 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,0,0) || \
1055 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1056 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,3,0)
1057 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress 163")
1058#elif JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,0,0)
1059 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress 163")
1060#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
1061 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress=Pe161")
1062#elif JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1063 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress 161")
1065 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS
1068#if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES)
1069 #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES
1071#if JSON_HEDLEY_HAS_WARNING("-Wunknown-attributes")
1072 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("clang diagnostic ignored \"-Wunknown-attributes\"")
1073#elif JSON_HEDLEY_GCC_VERSION_CHECK(4,6,0)
1074 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"")
1075#elif JSON_HEDLEY_INTEL_VERSION_CHECK(17,0,0)
1076 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("warning(disable:1292)")
1077#elif JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1078 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES __pragma(warning(disable:1292))
1079#elif JSON_HEDLEY_MSVC_VERSION_CHECK(19,0,0)
1080 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES __pragma(warning(disable:5030))
1081#elif JSON_HEDLEY_PGI_VERSION_CHECK(20,7,0)
1082 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress 1097,1098")
1083#elif JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0)
1084 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress 1097")
1085#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,14,0) && defined(__cplusplus)
1086 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("error_messages(off,attrskipunsup)")
1088 JSON_HEDLEY_TI_VERSION_CHECK(18,1,0) || \
1089 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,3,0) || \
1090 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0)
1091 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress 1173")
1092#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
1093 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress=Pe1097")
1094#elif JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1095 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress 1097")
1097 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES
1100#if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL)
1101 #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL
1103#if JSON_HEDLEY_HAS_WARNING("-Wcast-qual")
1104 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL _Pragma("clang diagnostic ignored \"-Wcast-qual\"")
1105#elif JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0)
1106 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL _Pragma("warning(disable:2203 2331)")
1107#elif JSON_HEDLEY_GCC_VERSION_CHECK(3,0,0)
1108 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL _Pragma("GCC diagnostic ignored \"-Wcast-qual\"")
1110 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL
1113#if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION)
1114 #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION
1116#if JSON_HEDLEY_HAS_WARNING("-Wunused-function")
1117 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION _Pragma("clang diagnostic ignored \"-Wunused-function\"")
1118#elif JSON_HEDLEY_GCC_VERSION_CHECK(3,4,0)
1119 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION _Pragma("GCC diagnostic ignored \"-Wunused-function\"")
1120#elif JSON_HEDLEY_MSVC_VERSION_CHECK(1,0,0)
1121 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION __pragma(warning(disable:4505))
1122#elif JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1123 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION _Pragma("diag_suppress 3142")
1125 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION
1128#if defined(JSON_HEDLEY_DEPRECATED)
1129 #undef JSON_HEDLEY_DEPRECATED
1131#if defined(JSON_HEDLEY_DEPRECATED_FOR)
1132 #undef JSON_HEDLEY_DEPRECATED_FOR
1135 JSON_HEDLEY_MSVC_VERSION_CHECK(14,0,0) || \
1136 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1137 #define JSON_HEDLEY_DEPRECATED(since) __declspec(deprecated("Since " # since))
1138 #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) __declspec(deprecated("Since " #since "; use " #replacement))
1140 (JSON_HEDLEY_HAS_EXTENSION(attribute_deprecated_with_message) && !defined(JSON_HEDLEY_IAR_VERSION)) || \
1141 JSON_HEDLEY_GCC_VERSION_CHECK(4,5,0) || \
1142 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1143 JSON_HEDLEY_ARM_VERSION_CHECK(5,6,0) || \
1144 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,13,0) || \
1145 JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) || \
1146 JSON_HEDLEY_TI_VERSION_CHECK(18,1,0) || \
1147 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(18,1,0) || \
1148 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,3,0) || \
1149 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1150 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,3,0) || \
1151 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1152 #define JSON_HEDLEY_DEPRECATED(since) __attribute__((__deprecated__("Since " #since)))
1153 #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) __attribute__((__deprecated__("Since " #since "; use " #replacement)))
1154#elif defined(__cplusplus) && (__cplusplus >= 201402L)
1155 #define JSON_HEDLEY_DEPRECATED(since) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[deprecated("Since " #since)]])
1156 #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[deprecated("Since " #since "; use " #replacement)]])
1158 JSON_HEDLEY_HAS_ATTRIBUTE(deprecated) || \
1159 JSON_HEDLEY_GCC_VERSION_CHECK(3,1,0) || \
1160 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1161 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1162 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1163 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1164 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1165 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1166 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1167 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1168 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1169 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1170 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1171 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1172 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) || \
1173 JSON_HEDLEY_IAR_VERSION_CHECK(8,10,0)
1174 #define JSON_HEDLEY_DEPRECATED(since) __attribute__((__deprecated__))
1175 #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) __attribute__((__deprecated__))
1177 JSON_HEDLEY_MSVC_VERSION_CHECK(13,10,0) || \
1178 JSON_HEDLEY_PELLES_VERSION_CHECK(6,50,0) || \
1179 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1180 #define JSON_HEDLEY_DEPRECATED(since) __declspec(deprecated)
1181 #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) __declspec(deprecated)
1182#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
1183 #define JSON_HEDLEY_DEPRECATED(since) _Pragma("deprecated")
1184 #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) _Pragma("deprecated")
1186 #define JSON_HEDLEY_DEPRECATED(since)
1187 #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement)
1190#if defined(JSON_HEDLEY_UNAVAILABLE)
1191 #undef JSON_HEDLEY_UNAVAILABLE
1194 JSON_HEDLEY_HAS_ATTRIBUTE(warning) || \
1195 JSON_HEDLEY_GCC_VERSION_CHECK(4,3,0) || \
1196 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1197 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1198 #define JSON_HEDLEY_UNAVAILABLE(available_since) __attribute__((__warning__("Not available until " #available_since)))
1200 #define JSON_HEDLEY_UNAVAILABLE(available_since)
1203#if defined(JSON_HEDLEY_WARN_UNUSED_RESULT)
1204 #undef JSON_HEDLEY_WARN_UNUSED_RESULT
1206#if defined(JSON_HEDLEY_WARN_UNUSED_RESULT_MSG)
1207 #undef JSON_HEDLEY_WARN_UNUSED_RESULT_MSG
1210 JSON_HEDLEY_HAS_ATTRIBUTE(warn_unused_result) || \
1211 JSON_HEDLEY_GCC_VERSION_CHECK(3,4,0) || \
1212 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1213 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1214 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1215 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1216 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1217 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1218 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1219 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1220 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1221 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1222 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1223 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1224 (JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,15,0) && defined(__cplusplus)) || \
1225 JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) || \
1226 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1227 #define JSON_HEDLEY_WARN_UNUSED_RESULT __attribute__((__warn_unused_result__))
1228 #define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg) __attribute__((__warn_unused_result__))
1229#elif (JSON_HEDLEY_HAS_CPP_ATTRIBUTE(nodiscard) >= 201907L)
1230 #define JSON_HEDLEY_WARN_UNUSED_RESULT JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[nodiscard]])
1231 #define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[nodiscard(msg)]])
1232#elif JSON_HEDLEY_HAS_CPP_ATTRIBUTE(nodiscard)
1233 #define JSON_HEDLEY_WARN_UNUSED_RESULT JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[nodiscard]])
1234 #define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[nodiscard]])
1235#elif defined(_Check_return_)
1236 #define JSON_HEDLEY_WARN_UNUSED_RESULT _Check_return_
1237 #define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg) _Check_return_
1239 #define JSON_HEDLEY_WARN_UNUSED_RESULT
1240 #define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg)
1243#if defined(JSON_HEDLEY_SENTINEL)
1244 #undef JSON_HEDLEY_SENTINEL
1247 JSON_HEDLEY_HAS_ATTRIBUTE(sentinel) || \
1248 JSON_HEDLEY_GCC_VERSION_CHECK(4,0,0) || \
1249 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1250 JSON_HEDLEY_ARM_VERSION_CHECK(5,4,0) || \
1251 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1252 #define JSON_HEDLEY_SENTINEL(position) __attribute__((__sentinel__(position)))
1254 #define JSON_HEDLEY_SENTINEL(position)
1257#if defined(JSON_HEDLEY_NO_RETURN)
1258 #undef JSON_HEDLEY_NO_RETURN
1260#if JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
1261 #define JSON_HEDLEY_NO_RETURN __noreturn
1263 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1264 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1265 #define JSON_HEDLEY_NO_RETURN __attribute__((__noreturn__))
1266#elif defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L
1267 #define JSON_HEDLEY_NO_RETURN _Noreturn
1268#elif defined(__cplusplus) && (__cplusplus >= 201103L)
1269 #define JSON_HEDLEY_NO_RETURN JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[noreturn]])
1271 JSON_HEDLEY_HAS_ATTRIBUTE(noreturn) || \
1272 JSON_HEDLEY_GCC_VERSION_CHECK(3,2,0) || \
1273 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \
1274 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1275 JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
1276 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1277 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1278 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1279 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1280 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1281 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1282 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1283 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1284 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1285 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1286 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1287 JSON_HEDLEY_IAR_VERSION_CHECK(8,10,0)
1288 #define JSON_HEDLEY_NO_RETURN __attribute__((__noreturn__))
1289#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0)
1290 #define JSON_HEDLEY_NO_RETURN _Pragma("does_not_return")
1292 JSON_HEDLEY_MSVC_VERSION_CHECK(13,10,0) || \
1293 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1294 #define JSON_HEDLEY_NO_RETURN __declspec(noreturn)
1295#elif JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6,0,0) && defined(__cplusplus)
1296 #define JSON_HEDLEY_NO_RETURN _Pragma("FUNC_NEVER_RETURNS;")
1297#elif JSON_HEDLEY_COMPCERT_VERSION_CHECK(3,2,0)
1298 #define JSON_HEDLEY_NO_RETURN __attribute((noreturn))
1299#elif JSON_HEDLEY_PELLES_VERSION_CHECK(9,0,0)
1300 #define JSON_HEDLEY_NO_RETURN __declspec(noreturn)
1302 #define JSON_HEDLEY_NO_RETURN
1305#if defined(JSON_HEDLEY_NO_ESCAPE)
1306 #undef JSON_HEDLEY_NO_ESCAPE
1308#if JSON_HEDLEY_HAS_ATTRIBUTE(noescape)
1309 #define JSON_HEDLEY_NO_ESCAPE __attribute__((__noescape__))
1311 #define JSON_HEDLEY_NO_ESCAPE
1314#if defined(JSON_HEDLEY_UNREACHABLE)
1315 #undef JSON_HEDLEY_UNREACHABLE
1317#if defined(JSON_HEDLEY_UNREACHABLE_RETURN)
1318 #undef JSON_HEDLEY_UNREACHABLE_RETURN
1320#if defined(JSON_HEDLEY_ASSUME)
1321 #undef JSON_HEDLEY_ASSUME
1324 JSON_HEDLEY_MSVC_VERSION_CHECK(13,10,0) || \
1325 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1326 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1327 #define JSON_HEDLEY_ASSUME(expr) __assume(expr)
1328#elif JSON_HEDLEY_HAS_BUILTIN(__builtin_assume)
1329 #define JSON_HEDLEY_ASSUME(expr) __builtin_assume(expr)
1331 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,2,0) || \
1332 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(4,0,0)
1333 #if defined(__cplusplus)
1334 #define JSON_HEDLEY_ASSUME(expr) std::_nassert(expr)
1336 #define JSON_HEDLEY_ASSUME(expr) _nassert(expr)
1340 (JSON_HEDLEY_HAS_BUILTIN(__builtin_unreachable) && (!defined(JSON_HEDLEY_ARM_VERSION))) || \
1341 JSON_HEDLEY_GCC_VERSION_CHECK(4,5,0) || \
1342 JSON_HEDLEY_PGI_VERSION_CHECK(18,10,0) || \
1343 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1344 JSON_HEDLEY_IBM_VERSION_CHECK(13,1,5) || \
1345 JSON_HEDLEY_CRAY_VERSION_CHECK(10,0,0) || \
1346 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1347 #define JSON_HEDLEY_UNREACHABLE() __builtin_unreachable()
1348#elif defined(JSON_HEDLEY_ASSUME)
1349 #define JSON_HEDLEY_UNREACHABLE() JSON_HEDLEY_ASSUME(0)
1351#if !defined(JSON_HEDLEY_ASSUME)
1352 #if defined(JSON_HEDLEY_UNREACHABLE)
1353 #define JSON_HEDLEY_ASSUME(expr) JSON_HEDLEY_STATIC_CAST(void, ((expr) ? 1 : (JSON_HEDLEY_UNREACHABLE(), 1)))
1355 #define JSON_HEDLEY_ASSUME(expr) JSON_HEDLEY_STATIC_CAST(void, expr)
1358#if defined(JSON_HEDLEY_UNREACHABLE)
1360 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,2,0) || \
1361 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(4,0,0)
1362 #define JSON_HEDLEY_UNREACHABLE_RETURN(value) return (JSON_HEDLEY_STATIC_CAST(void, JSON_HEDLEY_ASSUME(0)), (value))
1364 #define JSON_HEDLEY_UNREACHABLE_RETURN(value) JSON_HEDLEY_UNREACHABLE()
1367 #define JSON_HEDLEY_UNREACHABLE_RETURN(value) return (value)
1369#if !defined(JSON_HEDLEY_UNREACHABLE)
1370 #define JSON_HEDLEY_UNREACHABLE() JSON_HEDLEY_ASSUME(0)
1374#if JSON_HEDLEY_HAS_WARNING("-Wpedantic")
1375 #pragma clang diagnostic ignored "-Wpedantic"
1377#if JSON_HEDLEY_HAS_WARNING("-Wc++98-compat-pedantic") && defined(__cplusplus)
1378 #pragma clang diagnostic ignored "-Wc++98-compat-pedantic"
1380#if JSON_HEDLEY_GCC_HAS_WARNING("-Wvariadic-macros",4,0,0)
1381 #if defined(__clang__)
1382 #pragma clang diagnostic ignored "-Wvariadic-macros"
1383 #elif defined(JSON_HEDLEY_GCC_VERSION)
1384 #pragma GCC diagnostic ignored "-Wvariadic-macros"
1387#if defined(JSON_HEDLEY_NON_NULL)
1388 #undef JSON_HEDLEY_NON_NULL
1391 JSON_HEDLEY_HAS_ATTRIBUTE(nonnull) || \
1392 JSON_HEDLEY_GCC_VERSION_CHECK(3,3,0) || \
1393 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1394 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0)
1395 #define JSON_HEDLEY_NON_NULL(...) __attribute__((__nonnull__(__VA_ARGS__)))
1397 #define JSON_HEDLEY_NON_NULL(...)
1401#if defined(JSON_HEDLEY_PRINTF_FORMAT)
1402 #undef JSON_HEDLEY_PRINTF_FORMAT
1404#if defined(__MINGW32__) && JSON_HEDLEY_GCC_HAS_ATTRIBUTE(format,4,4,0) && !defined(__USE_MINGW_ANSI_STDIO)
1405 #define JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) __attribute__((__format__(ms_printf, string_idx, first_to_check)))
1406#elif defined(__MINGW32__) && JSON_HEDLEY_GCC_HAS_ATTRIBUTE(format,4,4,0) && defined(__USE_MINGW_ANSI_STDIO)
1407 #define JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) __attribute__((__format__(gnu_printf, string_idx, first_to_check)))
1409 JSON_HEDLEY_HAS_ATTRIBUTE(format) || \
1410 JSON_HEDLEY_GCC_VERSION_CHECK(3,1,0) || \
1411 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1412 JSON_HEDLEY_ARM_VERSION_CHECK(5,6,0) || \
1413 JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
1414 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1415 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1416 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1417 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1418 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1419 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1420 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1421 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1422 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1423 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1424 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1425 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1426 #define JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) __attribute__((__format__(__printf__, string_idx, first_to_check)))
1427#elif JSON_HEDLEY_PELLES_VERSION_CHECK(6,0,0)
1428 #define JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) __declspec(vaformat(printf,string_idx,first_to_check))
1430 #define JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check)
1433#if defined(JSON_HEDLEY_CONSTEXPR)
1434 #undef JSON_HEDLEY_CONSTEXPR
1436#if defined(__cplusplus)
1437 #if __cplusplus >= 201103L
1438 #define JSON_HEDLEY_CONSTEXPR JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(constexpr)
1441#if !defined(JSON_HEDLEY_CONSTEXPR)
1442 #define JSON_HEDLEY_CONSTEXPR
1445#if defined(JSON_HEDLEY_PREDICT)
1446 #undef JSON_HEDLEY_PREDICT
1448#if defined(JSON_HEDLEY_LIKELY)
1449 #undef JSON_HEDLEY_LIKELY
1451#if defined(JSON_HEDLEY_UNLIKELY)
1452 #undef JSON_HEDLEY_UNLIKELY
1454#if defined(JSON_HEDLEY_UNPREDICTABLE)
1455 #undef JSON_HEDLEY_UNPREDICTABLE
1457#if JSON_HEDLEY_HAS_BUILTIN(__builtin_unpredictable)
1458 #define JSON_HEDLEY_UNPREDICTABLE(expr) __builtin_unpredictable((expr))
1461 (JSON_HEDLEY_HAS_BUILTIN(__builtin_expect_with_probability) && !defined(JSON_HEDLEY_PGI_VERSION)) || \
1462 JSON_HEDLEY_GCC_VERSION_CHECK(9,0,0) || \
1463 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1464# define JSON_HEDLEY_PREDICT(expr, value, probability) __builtin_expect_with_probability( (expr), (value), (probability))
1465# define JSON_HEDLEY_PREDICT_TRUE(expr, probability) __builtin_expect_with_probability(!!(expr), 1 , (probability))
1466# define JSON_HEDLEY_PREDICT_FALSE(expr, probability) __builtin_expect_with_probability(!!(expr), 0 , (probability))
1467# define JSON_HEDLEY_LIKELY(expr) __builtin_expect (!!(expr), 1 )
1468# define JSON_HEDLEY_UNLIKELY(expr) __builtin_expect (!!(expr), 0 )
1470 (JSON_HEDLEY_HAS_BUILTIN(__builtin_expect) && !defined(JSON_HEDLEY_INTEL_CL_VERSION)) || \
1471 JSON_HEDLEY_GCC_VERSION_CHECK(3,0,0) || \
1472 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1473 (JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,15,0) && defined(__cplusplus)) || \
1474 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1475 JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
1476 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1477 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,7,0) || \
1478 JSON_HEDLEY_TI_CL430_VERSION_CHECK(3,1,0) || \
1479 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,1,0) || \
1480 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6,1,0) || \
1481 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1482 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1483 JSON_HEDLEY_TINYC_VERSION_CHECK(0,9,27) || \
1484 JSON_HEDLEY_CRAY_VERSION_CHECK(8,1,0) || \
1485 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1486# define JSON_HEDLEY_PREDICT(expr, expected, probability) \
1487 (((probability) >= 0.9) ? __builtin_expect((expr), (expected)) : (JSON_HEDLEY_STATIC_CAST(void, expected), (expr)))
1488# define JSON_HEDLEY_PREDICT_TRUE(expr, probability) \
1490 double hedley_probability_ = (probability); \
1491 ((hedley_probability_ >= 0.9) ? __builtin_expect(!!(expr), 1) : ((hedley_probability_ <= 0.1) ? __builtin_expect(!!(expr), 0) : !!(expr))); \
1493# define JSON_HEDLEY_PREDICT_FALSE(expr, probability) \
1495 double hedley_probability_ = (probability); \
1496 ((hedley_probability_ >= 0.9) ? __builtin_expect(!!(expr), 0) : ((hedley_probability_ <= 0.1) ? __builtin_expect(!!(expr), 1) : !!(expr))); \
1498# define JSON_HEDLEY_LIKELY(expr) __builtin_expect(!!(expr), 1)
1499# define JSON_HEDLEY_UNLIKELY(expr) __builtin_expect(!!(expr), 0)
1501# define JSON_HEDLEY_PREDICT(expr, expected, probability) (JSON_HEDLEY_STATIC_CAST(void, expected), (expr))
1502# define JSON_HEDLEY_PREDICT_TRUE(expr, probability) (!!(expr))
1503# define JSON_HEDLEY_PREDICT_FALSE(expr, probability) (!!(expr))
1504# define JSON_HEDLEY_LIKELY(expr) (!!(expr))
1505# define JSON_HEDLEY_UNLIKELY(expr) (!!(expr))
1507#if !defined(JSON_HEDLEY_UNPREDICTABLE)
1508 #define JSON_HEDLEY_UNPREDICTABLE(expr) JSON_HEDLEY_PREDICT(expr, 1, 0.5)
1511#if defined(JSON_HEDLEY_MALLOC)
1512 #undef JSON_HEDLEY_MALLOC
1515 JSON_HEDLEY_HAS_ATTRIBUTE(malloc) || \
1516 JSON_HEDLEY_GCC_VERSION_CHECK(3,1,0) || \
1517 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1518 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \
1519 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1520 JSON_HEDLEY_IBM_VERSION_CHECK(12,1,0) || \
1521 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1522 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1523 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1524 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1525 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1526 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1527 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1528 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1529 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1530 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1531 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1532 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1533 #define JSON_HEDLEY_MALLOC __attribute__((__malloc__))
1534#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0)
1535 #define JSON_HEDLEY_MALLOC _Pragma("returns_new_memory")
1537 JSON_HEDLEY_MSVC_VERSION_CHECK(14,0,0) || \
1538 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1539 #define JSON_HEDLEY_MALLOC __declspec(restrict)
1541 #define JSON_HEDLEY_MALLOC
1544#if defined(JSON_HEDLEY_PURE)
1545 #undef JSON_HEDLEY_PURE
1548 JSON_HEDLEY_HAS_ATTRIBUTE(pure) || \
1549 JSON_HEDLEY_GCC_VERSION_CHECK(2,96,0) || \
1550 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1551 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \
1552 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1553 JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
1554 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1555 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1556 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1557 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1558 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1559 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1560 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1561 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1562 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1563 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1564 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1565 JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) || \
1566 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1567# define JSON_HEDLEY_PURE __attribute__((__pure__))
1568#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0)
1569# define JSON_HEDLEY_PURE _Pragma("does_not_write_global_data")
1570#elif defined(__cplusplus) && \
1572 JSON_HEDLEY_TI_CL430_VERSION_CHECK(2,0,1) || \
1573 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(4,0,0) || \
1574 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) \
1576# define JSON_HEDLEY_PURE _Pragma("FUNC_IS_PURE;")
1578# define JSON_HEDLEY_PURE
1581#if defined(JSON_HEDLEY_CONST)
1582 #undef JSON_HEDLEY_CONST
1585 JSON_HEDLEY_HAS_ATTRIBUTE(const) || \
1586 JSON_HEDLEY_GCC_VERSION_CHECK(2,5,0) || \
1587 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1588 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \
1589 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1590 JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
1591 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1592 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1593 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1594 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1595 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1596 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1597 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1598 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1599 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1600 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1601 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1602 JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) || \
1603 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1604 #define JSON_HEDLEY_CONST __attribute__((__const__))
1606 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0)
1607 #define JSON_HEDLEY_CONST _Pragma("no_side_effect")
1609 #define JSON_HEDLEY_CONST JSON_HEDLEY_PURE
1612#if defined(JSON_HEDLEY_RESTRICT)
1613 #undef JSON_HEDLEY_RESTRICT
1615#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) && !defined(__cplusplus)
1616 #define JSON_HEDLEY_RESTRICT restrict
1618 JSON_HEDLEY_GCC_VERSION_CHECK(3,1,0) || \
1619 JSON_HEDLEY_MSVC_VERSION_CHECK(14,0,0) || \
1620 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1621 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) || \
1622 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1623 JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
1624 JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) || \
1625 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1626 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,2,4) || \
1627 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,1,0) || \
1628 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1629 (JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,14,0) && defined(__cplusplus)) || \
1630 JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) || \
1631 defined(__clang__) || \
1632 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1633 #define JSON_HEDLEY_RESTRICT __restrict
1634#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,3,0) && !defined(__cplusplus)
1635 #define JSON_HEDLEY_RESTRICT _Restrict
1637 #define JSON_HEDLEY_RESTRICT
1640#if defined(JSON_HEDLEY_INLINE)
1641 #undef JSON_HEDLEY_INLINE
1644 (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)) || \
1645 (defined(__cplusplus) && (__cplusplus >= 199711L))
1646 #define JSON_HEDLEY_INLINE inline
1648 defined(JSON_HEDLEY_GCC_VERSION) || \
1649 JSON_HEDLEY_ARM_VERSION_CHECK(6,2,0)
1650 #define JSON_HEDLEY_INLINE __inline__
1652 JSON_HEDLEY_MSVC_VERSION_CHECK(12,0,0) || \
1653 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) || \
1654 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1655 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,1,0) || \
1656 JSON_HEDLEY_TI_CL430_VERSION_CHECK(3,1,0) || \
1657 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,2,0) || \
1658 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,0,0) || \
1659 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1660 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1661 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1662 #define JSON_HEDLEY_INLINE __inline
1664 #define JSON_HEDLEY_INLINE
1667#if defined(JSON_HEDLEY_ALWAYS_INLINE)
1668 #undef JSON_HEDLEY_ALWAYS_INLINE
1671 JSON_HEDLEY_HAS_ATTRIBUTE(always_inline) || \
1672 JSON_HEDLEY_GCC_VERSION_CHECK(4,0,0) || \
1673 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1674 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \
1675 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1676 JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
1677 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1678 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1679 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1680 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1681 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1682 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1683 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1684 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1685 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1686 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1687 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1688 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) || \
1689 JSON_HEDLEY_IAR_VERSION_CHECK(8,10,0)
1690# define JSON_HEDLEY_ALWAYS_INLINE __attribute__((__always_inline__)) JSON_HEDLEY_INLINE
1692 JSON_HEDLEY_MSVC_VERSION_CHECK(12,0,0) || \
1693 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1694# define JSON_HEDLEY_ALWAYS_INLINE __forceinline
1695#elif defined(__cplusplus) && \
1697 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1698 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1699 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1700 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6,1,0) || \
1701 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1702 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) \
1704# define JSON_HEDLEY_ALWAYS_INLINE _Pragma("FUNC_ALWAYS_INLINE;")
1705#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
1706# define JSON_HEDLEY_ALWAYS_INLINE _Pragma("inline=forced")
1708# define JSON_HEDLEY_ALWAYS_INLINE JSON_HEDLEY_INLINE
1711#if defined(JSON_HEDLEY_NEVER_INLINE)
1712 #undef JSON_HEDLEY_NEVER_INLINE
1715 JSON_HEDLEY_HAS_ATTRIBUTE(noinline) || \
1716 JSON_HEDLEY_GCC_VERSION_CHECK(4,0,0) || \
1717 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1718 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \
1719 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1720 JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
1721 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1722 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1723 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1724 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1725 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1726 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1727 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1728 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1729 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1730 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1731 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1732 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) || \
1733 JSON_HEDLEY_IAR_VERSION_CHECK(8,10,0)
1734 #define JSON_HEDLEY_NEVER_INLINE __attribute__((__noinline__))
1736 JSON_HEDLEY_MSVC_VERSION_CHECK(13,10,0) || \
1737 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1738 #define JSON_HEDLEY_NEVER_INLINE __declspec(noinline)
1739#elif JSON_HEDLEY_PGI_VERSION_CHECK(10,2,0)
1740 #define JSON_HEDLEY_NEVER_INLINE _Pragma("noinline")
1741#elif JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6,0,0) && defined(__cplusplus)
1742 #define JSON_HEDLEY_NEVER_INLINE _Pragma("FUNC_CANNOT_INLINE;")
1743#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
1744 #define JSON_HEDLEY_NEVER_INLINE _Pragma("inline=never")
1745#elif JSON_HEDLEY_COMPCERT_VERSION_CHECK(3,2,0)
1746 #define JSON_HEDLEY_NEVER_INLINE __attribute((noinline))
1747#elif JSON_HEDLEY_PELLES_VERSION_CHECK(9,0,0)
1748 #define JSON_HEDLEY_NEVER_INLINE __declspec(noinline)
1750 #define JSON_HEDLEY_NEVER_INLINE
1753#if defined(JSON_HEDLEY_PRIVATE)
1754 #undef JSON_HEDLEY_PRIVATE
1756#if defined(JSON_HEDLEY_PUBLIC)
1757 #undef JSON_HEDLEY_PUBLIC
1759#if defined(JSON_HEDLEY_IMPORT)
1760 #undef JSON_HEDLEY_IMPORT
1762#if defined(_WIN32) || defined(__CYGWIN__)
1763# define JSON_HEDLEY_PRIVATE
1764# define JSON_HEDLEY_PUBLIC __declspec(dllexport)
1765# define JSON_HEDLEY_IMPORT __declspec(dllimport)
1768 JSON_HEDLEY_HAS_ATTRIBUTE(visibility) || \
1769 JSON_HEDLEY_GCC_VERSION_CHECK(3,3,0) || \
1770 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \
1771 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1772 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1773 JSON_HEDLEY_IBM_VERSION_CHECK(13,1,0) || \
1775 defined(__TI_EABI__) && \
1777 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1778 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) \
1781 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1782# define JSON_HEDLEY_PRIVATE __attribute__((__visibility__("hidden")))
1783# define JSON_HEDLEY_PUBLIC __attribute__((__visibility__("default")))
1785# define JSON_HEDLEY_PRIVATE
1786# define JSON_HEDLEY_PUBLIC
1788# define JSON_HEDLEY_IMPORT extern
1791#if defined(JSON_HEDLEY_NO_THROW)
1792 #undef JSON_HEDLEY_NO_THROW
1795 JSON_HEDLEY_HAS_ATTRIBUTE(nothrow) || \
1796 JSON_HEDLEY_GCC_VERSION_CHECK(3,3,0) || \
1797 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1798 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1799 #define JSON_HEDLEY_NO_THROW __attribute__((__nothrow__))
1801 JSON_HEDLEY_MSVC_VERSION_CHECK(13,1,0) || \
1802 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) || \
1803 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0)
1804 #define JSON_HEDLEY_NO_THROW __declspec(nothrow)
1806 #define JSON_HEDLEY_NO_THROW
1809#if defined(JSON_HEDLEY_FALL_THROUGH)
1810 #undef JSON_HEDLEY_FALL_THROUGH
1813 JSON_HEDLEY_HAS_ATTRIBUTE(fallthrough) || \
1814 JSON_HEDLEY_GCC_VERSION_CHECK(7,0,0) || \
1815 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1816 #define JSON_HEDLEY_FALL_THROUGH __attribute__((__fallthrough__))
1817#elif JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS(clang,fallthrough)
1818 #define JSON_HEDLEY_FALL_THROUGH JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[clang::fallthrough]])
1819#elif JSON_HEDLEY_HAS_CPP_ATTRIBUTE(fallthrough)
1820 #define JSON_HEDLEY_FALL_THROUGH JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[fallthrough]])
1821#elif defined(__fallthrough)
1822 #define JSON_HEDLEY_FALL_THROUGH __fallthrough
1824 #define JSON_HEDLEY_FALL_THROUGH
1827#if defined(JSON_HEDLEY_RETURNS_NON_NULL)
1828 #undef JSON_HEDLEY_RETURNS_NON_NULL
1831 JSON_HEDLEY_HAS_ATTRIBUTE(returns_nonnull) || \
1832 JSON_HEDLEY_GCC_VERSION_CHECK(4,9,0) || \
1833 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1834 #define JSON_HEDLEY_RETURNS_NON_NULL __attribute__((__returns_nonnull__))
1835#elif defined(_Ret_notnull_)
1836 #define JSON_HEDLEY_RETURNS_NON_NULL _Ret_notnull_
1838 #define JSON_HEDLEY_RETURNS_NON_NULL
1841#if defined(JSON_HEDLEY_ARRAY_PARAM)
1842 #undef JSON_HEDLEY_ARRAY_PARAM
1845 defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) && \
1846 !defined(__STDC_NO_VLA__) && \
1847 !defined(__cplusplus) && \
1848 !defined(JSON_HEDLEY_PGI_VERSION) && \
1849 !defined(JSON_HEDLEY_TINYC_VERSION)
1850 #define JSON_HEDLEY_ARRAY_PARAM(name) (name)
1852 #define JSON_HEDLEY_ARRAY_PARAM(name)
1855#if defined(JSON_HEDLEY_IS_CONSTANT)
1856 #undef JSON_HEDLEY_IS_CONSTANT
1858#if defined(JSON_HEDLEY_REQUIRE_CONSTEXPR)
1859 #undef JSON_HEDLEY_REQUIRE_CONSTEXPR
1863#if defined(JSON_HEDLEY_IS_CONSTEXPR_)
1864 #undef JSON_HEDLEY_IS_CONSTEXPR_
1867 JSON_HEDLEY_HAS_BUILTIN(__builtin_constant_p) || \
1868 JSON_HEDLEY_GCC_VERSION_CHECK(3,4,0) || \
1869 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1870 JSON_HEDLEY_TINYC_VERSION_CHECK(0,9,19) || \
1871 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1872 JSON_HEDLEY_IBM_VERSION_CHECK(13,1,0) || \
1873 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6,1,0) || \
1874 (JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0) && !defined(__cplusplus)) || \
1875 JSON_HEDLEY_CRAY_VERSION_CHECK(8,1,0) || \
1876 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1877 #define JSON_HEDLEY_IS_CONSTANT(expr) __builtin_constant_p(expr)
1879#if !defined(__cplusplus)
1881 JSON_HEDLEY_HAS_BUILTIN(__builtin_types_compatible_p) || \
1882 JSON_HEDLEY_GCC_VERSION_CHECK(3,4,0) || \
1883 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1884 JSON_HEDLEY_IBM_VERSION_CHECK(13,1,0) || \
1885 JSON_HEDLEY_CRAY_VERSION_CHECK(8,1,0) || \
1886 JSON_HEDLEY_ARM_VERSION_CHECK(5,4,0) || \
1887 JSON_HEDLEY_TINYC_VERSION_CHECK(0,9,24)
1888#if defined(__INTPTR_TYPE__)
1889 #define JSON_HEDLEY_IS_CONSTEXPR_(expr) __builtin_types_compatible_p(__typeof__((1 ? (void*) ((__INTPTR_TYPE__) ((expr) * 0)) : (int*) 0)), int*)
1892 #define JSON_HEDLEY_IS_CONSTEXPR_(expr) __builtin_types_compatible_p(__typeof__((1 ? (void*) ((intptr_t) ((expr) * 0)) : (int*) 0)), int*)
1896 defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L) && \
1897 !defined(JSON_HEDLEY_SUNPRO_VERSION) && \
1898 !defined(JSON_HEDLEY_PGI_VERSION) && \
1899 !defined(JSON_HEDLEY_IAR_VERSION)) || \
1900 (JSON_HEDLEY_HAS_EXTENSION(c_generic_selections) && !defined(JSON_HEDLEY_IAR_VERSION)) || \
1901 JSON_HEDLEY_GCC_VERSION_CHECK(4,9,0) || \
1902 JSON_HEDLEY_INTEL_VERSION_CHECK(17,0,0) || \
1903 JSON_HEDLEY_IBM_VERSION_CHECK(12,1,0) || \
1904 JSON_HEDLEY_ARM_VERSION_CHECK(5,3,0)
1905#if defined(__INTPTR_TYPE__)
1906 #define JSON_HEDLEY_IS_CONSTEXPR_(expr) _Generic((1 ? (void*) ((__INTPTR_TYPE__) ((expr) * 0)) : (int*) 0), int*: 1, void*: 0)
1909 #define JSON_HEDLEY_IS_CONSTEXPR_(expr) _Generic((1 ? (void*) ((intptr_t) * 0) : (int*) 0), int*: 1, void*: 0)
1912 defined(JSON_HEDLEY_GCC_VERSION) || \
1913 defined(JSON_HEDLEY_INTEL_VERSION) || \
1914 defined(JSON_HEDLEY_TINYC_VERSION) || \
1915 defined(JSON_HEDLEY_TI_ARMCL_VERSION) || \
1916 JSON_HEDLEY_TI_CL430_VERSION_CHECK(18,12,0) || \
1917 defined(JSON_HEDLEY_TI_CL2000_VERSION) || \
1918 defined(JSON_HEDLEY_TI_CL6X_VERSION) || \
1919 defined(JSON_HEDLEY_TI_CL7X_VERSION) || \
1920 defined(JSON_HEDLEY_TI_CLPRU_VERSION) || \
1922# define JSON_HEDLEY_IS_CONSTEXPR_(expr) ( \
1926 ((void*) ((expr) * 0L) ) : \
1927((struct { char v[sizeof(void) * 2]; } *) 1) \
1933#if defined(JSON_HEDLEY_IS_CONSTEXPR_)
1934 #if !defined(JSON_HEDLEY_IS_CONSTANT)
1935 #define JSON_HEDLEY_IS_CONSTANT(expr) JSON_HEDLEY_IS_CONSTEXPR_(expr)
1937 #define JSON_HEDLEY_REQUIRE_CONSTEXPR(expr) (JSON_HEDLEY_IS_CONSTEXPR_(expr) ? (expr) : (-1))
1939 #if !defined(JSON_HEDLEY_IS_CONSTANT)
1940 #define JSON_HEDLEY_IS_CONSTANT(expr) (0)
1942 #define JSON_HEDLEY_REQUIRE_CONSTEXPR(expr) (expr)
1945#if defined(JSON_HEDLEY_BEGIN_C_DECLS)
1946 #undef JSON_HEDLEY_BEGIN_C_DECLS
1948#if defined(JSON_HEDLEY_END_C_DECLS)
1949 #undef JSON_HEDLEY_END_C_DECLS
1951#if defined(JSON_HEDLEY_C_DECL)
1952 #undef JSON_HEDLEY_C_DECL
1954#if defined(__cplusplus)
1955 #define JSON_HEDLEY_BEGIN_C_DECLS extern "C" {
1956 #define JSON_HEDLEY_END_C_DECLS }
1957 #define JSON_HEDLEY_C_DECL extern "C"
1959 #define JSON_HEDLEY_BEGIN_C_DECLS
1960 #define JSON_HEDLEY_END_C_DECLS
1961 #define JSON_HEDLEY_C_DECL
1964#if defined(JSON_HEDLEY_STATIC_ASSERT)
1965 #undef JSON_HEDLEY_STATIC_ASSERT
1968 !defined(__cplusplus) && ( \
1969 (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L)) || \
1970 (JSON_HEDLEY_HAS_FEATURE(c_static_assert) && !defined(JSON_HEDLEY_INTEL_CL_VERSION)) || \
1971 JSON_HEDLEY_GCC_VERSION_CHECK(6,0,0) || \
1972 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1973 defined(_Static_assert) \
1975# define JSON_HEDLEY_STATIC_ASSERT(expr, message) _Static_assert(expr, message)
1977 (defined(__cplusplus) && (__cplusplus >= 201103L)) || \
1978 JSON_HEDLEY_MSVC_VERSION_CHECK(16,0,0) || \
1979 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1980# define JSON_HEDLEY_STATIC_ASSERT(expr, message) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(static_assert(expr, message))
1982# define JSON_HEDLEY_STATIC_ASSERT(expr, message)
1985#if defined(JSON_HEDLEY_NULL)
1986 #undef JSON_HEDLEY_NULL
1988#if defined(__cplusplus)
1989 #if __cplusplus >= 201103L
1990 #define JSON_HEDLEY_NULL JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(nullptr)
1992 #define JSON_HEDLEY_NULL NULL
1994 #define JSON_HEDLEY_NULL JSON_HEDLEY_STATIC_CAST(void*, 0)
1997 #define JSON_HEDLEY_NULL NULL
1999 #define JSON_HEDLEY_NULL ((void*) 0)
2002#if defined(JSON_HEDLEY_MESSAGE)
2003 #undef JSON_HEDLEY_MESSAGE
2005#if JSON_HEDLEY_HAS_WARNING("-Wunknown-pragmas")
2006# define JSON_HEDLEY_MESSAGE(msg) \
2007 JSON_HEDLEY_DIAGNOSTIC_PUSH \
2008 JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS \
2009 JSON_HEDLEY_PRAGMA(message msg) \
2010 JSON_HEDLEY_DIAGNOSTIC_POP
2012 JSON_HEDLEY_GCC_VERSION_CHECK(4,4,0) || \
2013 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0)
2014# define JSON_HEDLEY_MESSAGE(msg) JSON_HEDLEY_PRAGMA(message msg)
2015#elif JSON_HEDLEY_CRAY_VERSION_CHECK(5,0,0)
2016# define JSON_HEDLEY_MESSAGE(msg) JSON_HEDLEY_PRAGMA(_CRI message msg)
2017#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
2018# define JSON_HEDLEY_MESSAGE(msg) JSON_HEDLEY_PRAGMA(message(msg))
2019#elif JSON_HEDLEY_PELLES_VERSION_CHECK(2,0,0)
2020# define JSON_HEDLEY_MESSAGE(msg) JSON_HEDLEY_PRAGMA(message(msg))
2022# define JSON_HEDLEY_MESSAGE(msg)
2025#if defined(JSON_HEDLEY_WARNING)
2026 #undef JSON_HEDLEY_WARNING
2028#if JSON_HEDLEY_HAS_WARNING("-Wunknown-pragmas")
2029# define JSON_HEDLEY_WARNING(msg) \
2030 JSON_HEDLEY_DIAGNOSTIC_PUSH \
2031 JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS \
2032 JSON_HEDLEY_PRAGMA(clang warning msg) \
2033 JSON_HEDLEY_DIAGNOSTIC_POP
2035 JSON_HEDLEY_GCC_VERSION_CHECK(4,8,0) || \
2036 JSON_HEDLEY_PGI_VERSION_CHECK(18,4,0) || \
2037 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0)
2038# define JSON_HEDLEY_WARNING(msg) JSON_HEDLEY_PRAGMA(GCC warning msg)
2040 JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0) || \
2041 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
2042# define JSON_HEDLEY_WARNING(msg) JSON_HEDLEY_PRAGMA(message(msg))
2044# define JSON_HEDLEY_WARNING(msg) JSON_HEDLEY_MESSAGE(msg)
2047#if defined(JSON_HEDLEY_REQUIRE)
2048 #undef JSON_HEDLEY_REQUIRE
2050#if defined(JSON_HEDLEY_REQUIRE_MSG)
2051 #undef JSON_HEDLEY_REQUIRE_MSG
2053#if JSON_HEDLEY_HAS_ATTRIBUTE(diagnose_if)
2054# if JSON_HEDLEY_HAS_WARNING("-Wgcc-compat")
2055# define JSON_HEDLEY_REQUIRE(expr) \
2056 JSON_HEDLEY_DIAGNOSTIC_PUSH \
2057 _Pragma("clang diagnostic ignored \"-Wgcc-compat\"") \
2058 __attribute__((diagnose_if(!(expr), #expr, "error"))) \
2059 JSON_HEDLEY_DIAGNOSTIC_POP
2060# define JSON_HEDLEY_REQUIRE_MSG(expr,msg) \
2061 JSON_HEDLEY_DIAGNOSTIC_PUSH \
2062 _Pragma("clang diagnostic ignored \"-Wgcc-compat\"") \
2063 __attribute__((diagnose_if(!(expr), msg, "error"))) \
2064 JSON_HEDLEY_DIAGNOSTIC_POP
2066# define JSON_HEDLEY_REQUIRE(expr) __attribute__((diagnose_if(!(expr), #expr, "error")))
2067# define JSON_HEDLEY_REQUIRE_MSG(expr,msg) __attribute__((diagnose_if(!(expr), msg, "error")))
2070# define JSON_HEDLEY_REQUIRE(expr)
2071# define JSON_HEDLEY_REQUIRE_MSG(expr,msg)
2074#if defined(JSON_HEDLEY_FLAGS)
2075 #undef JSON_HEDLEY_FLAGS
2077#if JSON_HEDLEY_HAS_ATTRIBUTE(flag_enum) && (!defined(__cplusplus) || JSON_HEDLEY_HAS_WARNING("-Wbitfield-enum-conversion"))
2078 #define JSON_HEDLEY_FLAGS __attribute__((__flag_enum__))
2080 #define JSON_HEDLEY_FLAGS
2083#if defined(JSON_HEDLEY_FLAGS_CAST)
2084 #undef JSON_HEDLEY_FLAGS_CAST
2086#if JSON_HEDLEY_INTEL_VERSION_CHECK(19,0,0)
2087# define JSON_HEDLEY_FLAGS_CAST(T, expr) (__extension__ ({ \
2088 JSON_HEDLEY_DIAGNOSTIC_PUSH \
2089 _Pragma("warning(disable:188)") \
2091 JSON_HEDLEY_DIAGNOSTIC_POP \
2094# define JSON_HEDLEY_FLAGS_CAST(T, expr) JSON_HEDLEY_STATIC_CAST(T, expr)
2097#if defined(JSON_HEDLEY_EMPTY_BASES)
2098 #undef JSON_HEDLEY_EMPTY_BASES
2101 (JSON_HEDLEY_MSVC_VERSION_CHECK(19,0,23918) && !JSON_HEDLEY_MSVC_VERSION_CHECK(20,0,0)) || \
2102 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
2103 #define JSON_HEDLEY_EMPTY_BASES __declspec(empty_bases)
2105 #define JSON_HEDLEY_EMPTY_BASES
2110#if defined(JSON_HEDLEY_GCC_NOT_CLANG_VERSION_CHECK)
2111 #undef JSON_HEDLEY_GCC_NOT_CLANG_VERSION_CHECK
2113#if defined(__clang__)
2114 #define JSON_HEDLEY_GCC_NOT_CLANG_VERSION_CHECK(major,minor,patch) (0)
2116 #define JSON_HEDLEY_GCC_NOT_CLANG_VERSION_CHECK(major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch)
2119#if defined(JSON_HEDLEY_CLANG_HAS_ATTRIBUTE)
2120 #undef JSON_HEDLEY_CLANG_HAS_ATTRIBUTE
2122#define JSON_HEDLEY_CLANG_HAS_ATTRIBUTE(attribute) JSON_HEDLEY_HAS_ATTRIBUTE(attribute)
2124#if defined(JSON_HEDLEY_CLANG_HAS_CPP_ATTRIBUTE)
2125 #undef JSON_HEDLEY_CLANG_HAS_CPP_ATTRIBUTE
2127#define JSON_HEDLEY_CLANG_HAS_CPP_ATTRIBUTE(attribute) JSON_HEDLEY_HAS_CPP_ATTRIBUTE(attribute)
2129#if defined(JSON_HEDLEY_CLANG_HAS_BUILTIN)
2130 #undef JSON_HEDLEY_CLANG_HAS_BUILTIN
2132#define JSON_HEDLEY_CLANG_HAS_BUILTIN(builtin) JSON_HEDLEY_HAS_BUILTIN(builtin)
2134#if defined(JSON_HEDLEY_CLANG_HAS_FEATURE)
2135 #undef JSON_HEDLEY_CLANG_HAS_FEATURE
2137#define JSON_HEDLEY_CLANG_HAS_FEATURE(feature) JSON_HEDLEY_HAS_FEATURE(feature)
2139#if defined(JSON_HEDLEY_CLANG_HAS_EXTENSION)
2140 #undef JSON_HEDLEY_CLANG_HAS_EXTENSION
2142#define JSON_HEDLEY_CLANG_HAS_EXTENSION(extension) JSON_HEDLEY_HAS_EXTENSION(extension)
2144#if defined(JSON_HEDLEY_CLANG_HAS_DECLSPEC_DECLSPEC_ATTRIBUTE)
2145 #undef JSON_HEDLEY_CLANG_HAS_DECLSPEC_DECLSPEC_ATTRIBUTE
2147#define JSON_HEDLEY_CLANG_HAS_DECLSPEC_ATTRIBUTE(attribute) JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE(attribute)
2149#if defined(JSON_HEDLEY_CLANG_HAS_WARNING)
2150 #undef JSON_HEDLEY_CLANG_HAS_WARNING
2152#define JSON_HEDLEY_CLANG_HAS_WARNING(warning) JSON_HEDLEY_HAS_WARNING(warning)
2159#include <type_traits>
2192template<
class Default,
2194 template<
class...>
class Op,
2202template<
class Default,
template<
class...>
class Op,
class... Args>
2209template<
template<
class...>
class Op,
class... Args>
2212template<
template<
class...>
class Op,
class... Args>
2215template<
template<
class...>
class Op,
class... Args>
2218template<
class Default,
template<
class...>
class Op,
class... Args>
2221template<
class Default,
template<
class...>
class Op,
class... Args>
2224template<
class Expected,
template<
class...>
class Op,
class... Args>
2227template<
class To,
template<
class...>
class Op,
class... Args>
2229 std::is_convertible<
detected_t<Op, Args...>, To>;
2238#if !defined(JSON_SKIP_UNSUPPORTED_COMPILER_CHECK)
2239 #if defined(__clang__)
2240 #if (__clang_major__ * 10000 + __clang_minor__ * 100 + __clang_patchlevel__) < 30400
2241 #error "unsupported Clang version - see https://github.com/nlohmann/json#supported-compilers"
2243 #elif defined(__GNUC__) && !(defined(__ICC) || defined(__INTEL_COMPILER))
2244 #if (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) < 40800
2245 #error "unsupported GCC version - see https://github.com/nlohmann/json#supported-compilers"
2252#if !defined(JSON_HAS_CPP_20) && !defined(JSON_HAS_CPP_17) && !defined(JSON_HAS_CPP_14) && !defined(JSON_HAS_CPP_11)
2253 #if (defined(__cplusplus) && __cplusplus >= 202002L) || (defined(_MSVC_LANG) && _MSVC_LANG >= 202002L)
2254 #define JSON_HAS_CPP_20
2255 #define JSON_HAS_CPP_17
2256 #define JSON_HAS_CPP_14
2257 #elif (defined(__cplusplus) && __cplusplus >= 201703L) || (defined(_HAS_CXX17) && _HAS_CXX17 == 1)
2258 #define JSON_HAS_CPP_17
2259 #define JSON_HAS_CPP_14
2260 #elif (defined(__cplusplus) && __cplusplus >= 201402L) || (defined(_HAS_CXX14) && _HAS_CXX14 == 1)
2261 #define JSON_HAS_CPP_14
2264 #define JSON_HAS_CPP_11
2268 #if __has_include(<version>)
2273#if !defined(JSON_HAS_FILESYSTEM) && !defined(JSON_HAS_EXPERIMENTAL_FILESYSTEM)
2274 #ifdef JSON_HAS_CPP_17
2275 #if defined(__cpp_lib_filesystem)
2276 #define JSON_HAS_FILESYSTEM 1
2277 #elif defined(__cpp_lib_experimental_filesystem)
2278 #define JSON_HAS_EXPERIMENTAL_FILESYSTEM 1
2279 #elif !defined(__has_include)
2280 #define JSON_HAS_EXPERIMENTAL_FILESYSTEM 1
2281 #elif __has_include(<filesystem>)
2282 #define JSON_HAS_FILESYSTEM 1
2283 #elif __has_include(<experimental/filesystem>)
2284 #define JSON_HAS_EXPERIMENTAL_FILESYSTEM 1
2288 #if defined(__MINGW32__) && defined(__GNUC__) && __GNUC__ == 8
2289 #undef JSON_HAS_FILESYSTEM
2290 #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM
2294 #if defined(__GNUC__) && !defined(__clang__) && __GNUC__ < 8
2295 #undef JSON_HAS_FILESYSTEM
2296 #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM
2300 #if defined(__clang_major__) && __clang_major__ < 7
2301 #undef JSON_HAS_FILESYSTEM
2302 #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM
2306 #if defined(_MSC_VER) && _MSC_VER < 1914
2307 #undef JSON_HAS_FILESYSTEM
2308 #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM
2312 #if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) && __IPHONE_OS_VERSION_MIN_REQUIRED < 130000
2313 #undef JSON_HAS_FILESYSTEM
2314 #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM
2318 #if defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && __MAC_OS_X_VERSION_MIN_REQUIRED < 101500
2319 #undef JSON_HAS_FILESYSTEM
2320 #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM
2325#ifndef JSON_HAS_EXPERIMENTAL_FILESYSTEM
2326 #define JSON_HAS_EXPERIMENTAL_FILESYSTEM 0
2329#ifndef JSON_HAS_FILESYSTEM
2330 #define JSON_HAS_FILESYSTEM 0
2333#ifndef JSON_HAS_THREE_WAY_COMPARISON
2334 #if defined(__cpp_impl_three_way_comparison) && __cpp_impl_three_way_comparison >= 201907L \
2335 && defined(__cpp_lib_three_way_comparison) && __cpp_lib_three_way_comparison >= 201907L
2336 #define JSON_HAS_THREE_WAY_COMPARISON 1
2338 #define JSON_HAS_THREE_WAY_COMPARISON 0
2342#ifndef JSON_HAS_RANGES
2344 #if defined(__GLIBCXX__) && __GLIBCXX__ == 20210427
2345 #define JSON_HAS_RANGES 0
2346 #elif defined(__cpp_lib_ranges)
2347 #define JSON_HAS_RANGES 1
2349 #define JSON_HAS_RANGES 0
2353#ifdef JSON_HAS_CPP_17
2354 #define JSON_INLINE_VARIABLE inline
2356 #define JSON_INLINE_VARIABLE
2359#if JSON_HEDLEY_HAS_ATTRIBUTE(no_unique_address)
2360 #define JSON_NO_UNIQUE_ADDRESS [[no_unique_address]]
2362 #define JSON_NO_UNIQUE_ADDRESS
2366#if defined(__clang__)
2367 #pragma clang diagnostic push
2368 #pragma clang diagnostic ignored "-Wdocumentation"
2369 #pragma clang diagnostic ignored "-Wdocumentation-unknown-command"
2373#if (defined(__cpp_exceptions) || defined(__EXCEPTIONS) || defined(_CPPUNWIND)) && !defined(JSON_NOEXCEPTION)
2374 #define JSON_THROW(exception) throw exception
2375 #define JSON_TRY try
2376 #define JSON_CATCH(exception) catch(exception)
2377 #define JSON_INTERNAL_CATCH(exception) catch(exception)
2380 #define JSON_THROW(exception) std::abort()
2381 #define JSON_TRY if(true)
2382 #define JSON_CATCH(exception) if(false)
2383 #define JSON_INTERNAL_CATCH(exception) if(false)
2387#if defined(JSON_THROW_USER)
2389 #define JSON_THROW JSON_THROW_USER
2391#if defined(JSON_TRY_USER)
2393 #define JSON_TRY JSON_TRY_USER
2395#if defined(JSON_CATCH_USER)
2397 #define JSON_CATCH JSON_CATCH_USER
2398 #undef JSON_INTERNAL_CATCH
2399 #define JSON_INTERNAL_CATCH JSON_CATCH_USER
2401#if defined(JSON_INTERNAL_CATCH_USER)
2402 #undef JSON_INTERNAL_CATCH
2403 #define JSON_INTERNAL_CATCH JSON_INTERNAL_CATCH_USER
2407#if !defined(JSON_ASSERT)
2409 #define JSON_ASSERT(x) assert(x)
2413#if defined(JSON_TESTS_PRIVATE)
2414 #define JSON_PRIVATE_UNLESS_TESTED public
2416 #define JSON_PRIVATE_UNLESS_TESTED private
2424#define NLOHMANN_JSON_SERIALIZE_ENUM(ENUM_TYPE, ...) \
2425 template<typename BasicJsonType> \
2426 inline void to_json(BasicJsonType& j, const ENUM_TYPE& e) \
2428 static_assert(std::is_enum<ENUM_TYPE>::value, #ENUM_TYPE " must be an enum!"); \
2429 static const std::pair<ENUM_TYPE, BasicJsonType> m[] = __VA_ARGS__; \
2430 auto it = std::find_if(std::begin(m), std::end(m), \
2431 [e](const std::pair<ENUM_TYPE, BasicJsonType>& ej_pair) -> bool \
2433 return ej_pair.first == e; \
2435 j = ((it != std::end(m)) ? it : std::begin(m))->second; \
2437 template<typename BasicJsonType> \
2438 inline void from_json(const BasicJsonType& j, ENUM_TYPE& e) \
2440 static_assert(std::is_enum<ENUM_TYPE>::value, #ENUM_TYPE " must be an enum!"); \
2441 static const std::pair<ENUM_TYPE, BasicJsonType> m[] = __VA_ARGS__; \
2442 auto it = std::find_if(std::begin(m), std::end(m), \
2443 [&j](const std::pair<ENUM_TYPE, BasicJsonType>& ej_pair) -> bool \
2445 return ej_pair.second == j; \
2447 e = ((it != std::end(m)) ? it : std::begin(m))->first; \
2453#define NLOHMANN_BASIC_JSON_TPL_DECLARATION \
2454 template<template<typename, typename, typename...> class ObjectType, \
2455 template<typename, typename...> class ArrayType, \
2456 class StringType, class BooleanType, class NumberIntegerType, \
2457 class NumberUnsignedType, class NumberFloatType, \
2458 template<typename> class AllocatorType, \
2459 template<typename, typename = void> class JSONSerializer, \
2462#define NLOHMANN_BASIC_JSON_TPL \
2463 basic_json<ObjectType, ArrayType, StringType, BooleanType, \
2464 NumberIntegerType, NumberUnsignedType, NumberFloatType, \
2465 AllocatorType, JSONSerializer, BinaryType>
2469#define NLOHMANN_JSON_EXPAND( x ) x
2470#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
2471#define NLOHMANN_JSON_PASTE(...) NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_GET_MACRO(__VA_ARGS__, \
2472 NLOHMANN_JSON_PASTE64, \
2473 NLOHMANN_JSON_PASTE63, \
2474 NLOHMANN_JSON_PASTE62, \
2475 NLOHMANN_JSON_PASTE61, \
2476 NLOHMANN_JSON_PASTE60, \
2477 NLOHMANN_JSON_PASTE59, \
2478 NLOHMANN_JSON_PASTE58, \
2479 NLOHMANN_JSON_PASTE57, \
2480 NLOHMANN_JSON_PASTE56, \
2481 NLOHMANN_JSON_PASTE55, \
2482 NLOHMANN_JSON_PASTE54, \
2483 NLOHMANN_JSON_PASTE53, \
2484 NLOHMANN_JSON_PASTE52, \
2485 NLOHMANN_JSON_PASTE51, \
2486 NLOHMANN_JSON_PASTE50, \
2487 NLOHMANN_JSON_PASTE49, \
2488 NLOHMANN_JSON_PASTE48, \
2489 NLOHMANN_JSON_PASTE47, \
2490 NLOHMANN_JSON_PASTE46, \
2491 NLOHMANN_JSON_PASTE45, \
2492 NLOHMANN_JSON_PASTE44, \
2493 NLOHMANN_JSON_PASTE43, \
2494 NLOHMANN_JSON_PASTE42, \
2495 NLOHMANN_JSON_PASTE41, \
2496 NLOHMANN_JSON_PASTE40, \
2497 NLOHMANN_JSON_PASTE39, \
2498 NLOHMANN_JSON_PASTE38, \
2499 NLOHMANN_JSON_PASTE37, \
2500 NLOHMANN_JSON_PASTE36, \
2501 NLOHMANN_JSON_PASTE35, \
2502 NLOHMANN_JSON_PASTE34, \
2503 NLOHMANN_JSON_PASTE33, \
2504 NLOHMANN_JSON_PASTE32, \
2505 NLOHMANN_JSON_PASTE31, \
2506 NLOHMANN_JSON_PASTE30, \
2507 NLOHMANN_JSON_PASTE29, \
2508 NLOHMANN_JSON_PASTE28, \
2509 NLOHMANN_JSON_PASTE27, \
2510 NLOHMANN_JSON_PASTE26, \
2511 NLOHMANN_JSON_PASTE25, \
2512 NLOHMANN_JSON_PASTE24, \
2513 NLOHMANN_JSON_PASTE23, \
2514 NLOHMANN_JSON_PASTE22, \
2515 NLOHMANN_JSON_PASTE21, \
2516 NLOHMANN_JSON_PASTE20, \
2517 NLOHMANN_JSON_PASTE19, \
2518 NLOHMANN_JSON_PASTE18, \
2519 NLOHMANN_JSON_PASTE17, \
2520 NLOHMANN_JSON_PASTE16, \
2521 NLOHMANN_JSON_PASTE15, \
2522 NLOHMANN_JSON_PASTE14, \
2523 NLOHMANN_JSON_PASTE13, \
2524 NLOHMANN_JSON_PASTE12, \
2525 NLOHMANN_JSON_PASTE11, \
2526 NLOHMANN_JSON_PASTE10, \
2527 NLOHMANN_JSON_PASTE9, \
2528 NLOHMANN_JSON_PASTE8, \
2529 NLOHMANN_JSON_PASTE7, \
2530 NLOHMANN_JSON_PASTE6, \
2531 NLOHMANN_JSON_PASTE5, \
2532 NLOHMANN_JSON_PASTE4, \
2533 NLOHMANN_JSON_PASTE3, \
2534 NLOHMANN_JSON_PASTE2, \
2535 NLOHMANN_JSON_PASTE1)(__VA_ARGS__))
2536#define NLOHMANN_JSON_PASTE2(func, v1) func(v1)
2537#define NLOHMANN_JSON_PASTE3(func, v1, v2) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE2(func, v2)
2538#define NLOHMANN_JSON_PASTE4(func, v1, v2, v3) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE3(func, v2, v3)
2539#define NLOHMANN_JSON_PASTE5(func, v1, v2, v3, v4) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE4(func, v2, v3, v4)
2540#define NLOHMANN_JSON_PASTE6(func, v1, v2, v3, v4, v5) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE5(func, v2, v3, v4, v5)
2541#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)
2542#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)
2543#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)
2544#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)
2545#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)
2546#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)
2547#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)
2548#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)
2549#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)
2550#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)
2551#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)
2552#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)
2553#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)
2554#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)
2555#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)
2556#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)
2557#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)
2558#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)
2559#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)
2560#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)
2561#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)
2562#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)
2563#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)
2564#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)
2565#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)
2566#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)
2567#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)
2568#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)
2569#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)
2570#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)
2571#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)
2572#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)
2573#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)
2574#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)
2575#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)
2576#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)
2577#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)
2578#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)
2579#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)
2580#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)
2581#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)
2582#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)
2583#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)
2584#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)
2585#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)
2586#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)
2587#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)
2588#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)
2589#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)
2590#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)
2591#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)
2592#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)
2593#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)
2594#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)
2595#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)
2596#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)
2597#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)
2598#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)
2600#define NLOHMANN_JSON_TO(v1) nlohmann_json_j[#v1] = nlohmann_json_t.v1;
2601#define NLOHMANN_JSON_FROM(v1) nlohmann_json_j.at(#v1).get_to(nlohmann_json_t.v1);
2602#define NLOHMANN_JSON_FROM_WITH_DEFAULT(v1) nlohmann_json_t.v1 = nlohmann_json_j.value(#v1, nlohmann_json_default_obj.v1);
2609#define NLOHMANN_DEFINE_TYPE_INTRUSIVE(Type, ...) \
2610 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__)) } \
2611 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__)) }
2613#define NLOHMANN_DEFINE_TYPE_INTRUSIVE_WITH_DEFAULT(Type, ...) \
2614 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__)) } \
2615 friend void from_json(const nlohmann::json& nlohmann_json_j, Type& nlohmann_json_t) { Type nlohmann_json_default_obj; NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM_WITH_DEFAULT, __VA_ARGS__)) }
2622#define NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(Type, ...) \
2623 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__)) } \
2624 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__)) }
2626#define NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_WITH_DEFAULT(Type, ...) \
2627 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__)) } \
2628 inline void from_json(const nlohmann::json& nlohmann_json_j, Type& nlohmann_json_t) { Type nlohmann_json_default_obj; NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM_WITH_DEFAULT, __VA_ARGS__)) }
2637#define NLOHMANN_CAN_CALL_STD_FUNC_IMPL(std_name) \
2638 namespace detail { \
2639 using std::std_name; \
2641 template<typename... T> \
2642 using result_of_##std_name = decltype(std_name(std::declval<T>()...)); \
2645 namespace detail2 { \
2646 struct std_name##_tag \
2650 template<typename... T> \
2651 std_name##_tag std_name(T&&...); \
2653 template<typename... T> \
2654 using result_of_##std_name = decltype(std_name(std::declval<T>()...)); \
2656 template<typename... T> \
2657 struct would_call_std_##std_name \
2659 static constexpr auto const value = ::nlohmann::detail:: \
2660 is_detected_exact<std_name##_tag, result_of_##std_name, T...>::value; \
2664 template<typename... T> \
2665 struct would_call_std_##std_name : detail2::would_call_std_##std_name<T...> \
2669#ifndef JSON_USE_IMPLICIT_CONVERSIONS
2670 #define JSON_USE_IMPLICIT_CONVERSIONS 1
2673#if JSON_USE_IMPLICIT_CONVERSIONS
2674 #define JSON_EXPLICIT
2676 #define JSON_EXPLICIT explicit
2679#ifndef JSON_DIAGNOSTICS
2680 #define JSON_DIAGNOSTICS 0
2683#ifndef JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON
2684 #define JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON 0
2687#ifndef JSON_DISABLE_ENUM_SERIALIZATION
2688 #define JSON_DISABLE_ENUM_SERIALIZATION 0
2691#if JSON_HAS_THREE_WAY_COMPARISON
2754#if JSON_HAS_THREE_WAY_COMPARISON
2755 inline std::partial_ordering operator<=>(
const value_t lhs,
const value_t rhs)
noexcept
2760 static constexpr std::array<std::uint8_t, 9> order = {{
2767 const auto l_index =
static_cast<std::size_t
>(lhs);
2768 const auto r_index =
static_cast<std::size_t
>(
rhs);
2769#if JSON_HAS_THREE_WAY_COMPARISON
2770 if (l_index < order.size() && r_index < order.size())
2772 return order[l_index] <=> order[r_index];
2774 return std::partial_ordering::unordered;
2776 return l_index < order.size() && r_index < order.size() && order[l_index] < order[r_index];
2784#if JSON_HAS_THREE_WAY_COMPARISON && defined(__GNUC__)
2787 return std::is_lt(lhs <=>
rhs);
2817template<
typename StringType>
2819 const StringType& t)
2822 for (
auto pos = s.find(f);
2823 pos != StringType::npos;
2824 s.replace(pos, f.size(), t),
2825 pos = s.find(f, pos + t.size()))
2836template<
typename StringType>
2851template<
typename StringType>
2852static void unescape(StringType& s)
2881 constexpr operator size_t()
const
2896#include <type_traits>
2910#ifdef JSON_HAS_CPP_14
2913using std::enable_if_t;
2914using std::index_sequence;
2915using std::make_index_sequence;
2916using std::index_sequence_for;
2921template<
bool B,
typename T =
void>
2948template <
typename T, T... Ints>
2952 static constexpr std::size_t
size() noexcept
2954 return sizeof...(Ints);
2963template <
size_t... Ints>
2969template <
typename Seq,
size_t SeqSize,
size_t Rem>
2973template <
typename T, T... Ints,
size_t SeqSize>
2979template <
typename T, T... Ints,
size_t SeqSize>
2987template <
typename T,
size_t N>
2994template <
typename T>
3009template <
typename T, T N>
3025template <
typename... Ts>
3043#ifndef JSON_HAS_CPP_17
3045 template<
typename T>
3057#include <type_traits>
3078template<
typename It,
typename =
void>
3081template<
typename It>
3085 typename It::reference, typename It::iterator_category >>
3096template<
typename T,
typename =
void>
3146#ifndef INCLUDE_NLOHMANN_JSON_FWD_HPP_
3147#define INCLUDE_NLOHMANN_JSON_FWD_HPP_
3169template<
typename T =
void,
typename SFINAE =
void>
3170struct adl_serializer;
3174template<
template<
typename U,
typename V,
typename... Args>
class ObjectType =
3176 template<
typename U,
typename... Args>
class ArrayType = std::vector,
3177 class StringType = std::string,
class BooleanType = bool,
3178 class NumberIntegerType = std::int64_t,
3179 class NumberUnsignedType = std::uint64_t,
3180 class NumberFloatType = double,
3181 template<
typename U>
class AllocatorType = std::allocator,
3182 template<
typename T,
typename SFINAE =
void>
class JSONSerializer =
3184 class BinaryType = std::vector<std::uint8_t>>
3189template<
typename BasicJsonType>
3200template<
class Key,
class T,
class IgnoredLess,
class Allocator>
3245template<
typename BasicJsonContext>
3247 std::integral_constant < bool,
3248 is_basic_json<typename std::remove_cv<typename std::remove_pointer<BasicJsonContext>::type>::type>::value
3249 || std::is_same<BasicJsonContext, std::nullptr_t>::value >
3290template<
typename T,
typename... Args>
3293template<
typename T,
typename... Args>
3296template<
typename T,
typename U>
3300template<
typename BasicJsonType,
typename T,
typename =
void>
3307template <
typename BasicJsonType,
typename T>
3313template<
typename BasicJsonType,
typename T>
3316 using serializer =
typename BasicJsonType::template json_serializer<T, void>;
3320 const BasicJsonType&, T&>
::value;
3325template<
typename BasicJsonType,
typename T,
typename =
void>
3328template<
typename BasicJsonType,
typename T>
3331 using serializer =
typename BasicJsonType::template json_serializer<T, void>;
3340template<
typename BasicJsonType,
typename T,
typename =
void>
3343template<
typename BasicJsonType,
typename T>
3346 using serializer =
typename BasicJsonType::template json_serializer<T, void>;
3357struct has_key_compare : std::integral_constant<bool, is_detected<detect_key_compare, T>::value> {};
3360template<
typename BasicJsonType>
3365 using type =
typename std::conditional < has_key_compare<object_t>::value,
3369template<
typename BasicJsonType>
3379template<
class B,
class... Bn>
3381: std::conditional<static_cast<bool>(B::value), conjunction<Bn...>, B>
::type {};
3384template<
class B>
struct negation : std::integral_constant < bool, !B::value > { };
3389template <
typename T>
3392template <
typename T1,
typename T2>
3394 :
conjunction<is_default_constructible<T1>, is_default_constructible<T2>> {};
3396template <
typename T1,
typename T2>
3398 :
conjunction<is_default_constructible<T1>, is_default_constructible<T2>> {};
3400template <
typename... Ts>
3402 :
conjunction<is_default_constructible<Ts>...> {};
3404template <
typename... Ts>
3406 :
conjunction<is_default_constructible<Ts>...> {};
3409template <
typename T,
typename... Args>
3412template <
typename T1,
typename T2>
3415template <
typename T1,
typename T2>
3418template <
typename... Ts>
3421template <
typename... Ts>
3425template<
typename T,
typename =
void>
3447 using t_ref =
typename std::add_lvalue_reference<T>::type;
3455 static constexpr auto is_iterator_begin =
3459 static constexpr bool value = !std::is_same<iterator, nonesuch>::value && !std::is_same<sentinel, nonesuch>::value && is_iterator_begin;
3472template<
typename T,
typename =
void>
3478template<
typename BasicJsonType,
typename CompatibleObjectType,
3482template<
typename BasicJsonType,
typename CompatibleObjectType>
3484 BasicJsonType, CompatibleObjectType,
3493 typename CompatibleObjectType::key_type>
::value &&
3495 typename CompatibleObjectType::mapped_type>
::value;
3498template<
typename BasicJsonType,
typename CompatibleObjectType>
3502template<
typename BasicJsonType,
typename ConstructibleObjectType,
3506template<
typename BasicJsonType,
typename ConstructibleObjectType>
3508 BasicJsonType, ConstructibleObjectType,
3516 (std::is_move_assignable<ConstructibleObjectType>::value ||
3517 std::is_copy_assignable<ConstructibleObjectType>::value) &&
3519 typename object_t::key_type>
::value &&
3521 typename object_t::mapped_type,
3522 typename ConstructibleObjectType::mapped_type >
::value)) ||
3524 typename ConstructibleObjectType::mapped_type>
::value ||
3527 typename ConstructibleObjectType::mapped_type >
::value);
3530template<
typename BasicJsonType,
typename ConstructibleObjectType>
3533 ConstructibleObjectType> {};
3535template<
typename BasicJsonType,
typename CompatibleStringType>
3542template<
typename BasicJsonType,
typename ConstructibleStringType>
3546#ifdef __INTEL_COMPILER
3547 using laundered_type =
decltype(std::declval<ConstructibleStringType>());
3554 typename BasicJsonType::string_t>
::value;
3557template<
typename BasicJsonType,
typename CompatibleArrayType,
typename =
void>
3560template<
typename BasicJsonType,
typename CompatibleArrayType>
3562 BasicJsonType, CompatibleArrayType,
3568 !std::is_same<CompatibleArrayType, detected_t<range_value_t, CompatibleArrayType>>
::value >>
3575template<
typename BasicJsonType,
typename CompatibleArrayType>
3579template<
typename BasicJsonType,
typename ConstructibleArrayType,
typename =
void>
3582template<
typename BasicJsonType,
typename ConstructibleArrayType>
3584 BasicJsonType, ConstructibleArrayType,
3586 typename BasicJsonType::value_type>
::value >>
3587 : std::true_type {};
3589template<
typename BasicJsonType,
typename ConstructibleArrayType>
3591 BasicJsonType, ConstructibleArrayType,
3593 typename BasicJsonType::value_type>
::value&&
3596(std::is_move_assignable<ConstructibleArrayType>::value ||
3597 std::is_copy_assignable<ConstructibleArrayType>::value)&&
3603!std::is_same<ConstructibleArrayType, detected_t<range_value_t, ConstructibleArrayType>>
::value&&
3605 detected_t<range_value_t, ConstructibleArrayType >>
::value >>
3611 typename BasicJsonType::array_t::value_type>
::value ||
3619template<
typename BasicJsonType,
typename ConstructibleArrayType>
3623template<
typename RealIntegerType,
typename CompatibleNumberIntegerType,
3627template<
typename RealIntegerType,
typename CompatibleNumberIntegerType>
3629 RealIntegerType, CompatibleNumberIntegerType,
3631 std::is_integral<CompatibleNumberIntegerType>
::value&&
3632 !std::is_same<bool, CompatibleNumberIntegerType>
::value >>
3640 CompatibleNumberIntegerType>
::value &&
3641 CompatibleLimits::is_integer &&
3642 RealLimits::is_signed == CompatibleLimits::is_signed;
3645template<
typename RealIntegerType,
typename CompatibleNumberIntegerType>
3648 CompatibleNumberIntegerType> {};
3650template<
typename BasicJsonType,
typename CompatibleType,
typename =
void>
3653template<
typename BasicJsonType,
typename CompatibleType>
3655 BasicJsonType, CompatibleType,
3662template<
typename BasicJsonType,
typename CompatibleType>
3666template<
typename T1,
typename T2>
3669template<
typename T1,
typename... Args>
3672template<
typename BasicJsonType,
typename T>
3675template<
typename BasicJsonType>
3678template<
typename BasicJsonType>
3683template<
template <
typename...>
class Primary,
typename T>
3686template<
template <
typename...>
class Primary,
typename... Args>
3693template<
typename Compare,
typename A,
typename B,
typename =
void>
3696template<
typename Compare,
typename A,
typename B>
3698decltype(
std::declval<Compare>()(std::declval<A>(), std::declval<B>())),
3699decltype(std::declval<Compare>()(std::declval<B>(), std::declval<A>()))
3700>> : std::true_type {};
3707template<
typename Comparator,
typename ObjectKeyType,
typename KeyTypeCVRef,
bool RequireTransparentComparator =
true,
3711 && !(ExcludeObjectKeyType && std::is_same<KeyType,
3713 && (!RequireTransparentComparator
3714 || is_detected <detect_is_transparent, Comparator>::value)
3725template<
typename BasicJsonType,
typename KeyTypeCVRef,
bool RequireTransparentComparator =
true,
3729 typename BasicJsonType::object_t::key_type, KeyTypeCVRef,
3730 RequireTransparentComparator, ExcludeObjectKeyType>
::value
3735template<
typename ObjectType,
typename KeyType>
3739template<
typename BasicJsonType,
typename KeyType>
3743 typename BasicJsonType::object_t, KeyType >
::value,
3749template <
typename T>
3759 template <
typename C>
static one test(
decltype(&C::capacity) ) ;
3766template < typename T, typename U, enable_if_t < !std::is_same<T, U>::value,
int > = 0 >
3769 return static_cast<T
>(
value);
3772template<typename T, typename U, enable_if_t<std::is_same<T, U>::value,
int> = 0>
3778template<
typename... Types>
3781template<
typename... Types>
3784template<
typename... Types>
3788template<
typename... Types>
3792template<
typename OfType,
typename T>
3794 (std::is_signed<OfType>::value && (
sizeof(T) <
sizeof(OfType)))
3797template<
typename OfType,
typename T,
3798 bool OfTypeSigned = std::is_signed<OfType>::value,
3799 bool TSigned = std::is_signed<T>::value>
3802template<
typename OfType,
typename T>
3807 using CommonType =
typename std::common_type<OfType, T>::type;
3808 return static_cast<CommonType
>(val) <=
static_cast<CommonType
>(std::numeric_limits<OfType>::max());
3812template<
typename OfType,
typename T>
3817 using CommonType =
typename std::common_type<OfType, T>::type;
3818 return static_cast<CommonType
>(val) <=
static_cast<CommonType
>(std::numeric_limits<OfType>::max());
3822template<
typename OfType,
typename T>
3827 using CommonType =
typename std::common_type<OfType, T>::type;
3828 return val >= 0 &&
static_cast<CommonType
>(val) <=
static_cast<CommonType
>(std::numeric_limits<OfType>::max());
3833template<
typename OfType,
typename T>
3838 using CommonType =
typename std::common_type<OfType, T>::type;
3839 return static_cast<CommonType
>(val) >=
static_cast<CommonType
>(std::numeric_limits<OfType>::min())
3840 &&
static_cast<CommonType
>(val) <=
static_cast<CommonType
>(std::numeric_limits<OfType>::max());
3844template<
typename OfType,
typename T,
3845 bool NeverOutOfRange = never_out_of_range<OfType, T>::value,
3849template<
typename OfType,
typename T>
3858template<
typename OfType,
typename T>
3867template<
typename OfType,
typename T>
3898template<
typename... Args>
3899inline std::size_t
concat_length(
const char* cstr, Args&& ... rest);
3901template<
typename StringType,
typename... Args>
3902inline std::size_t
concat_length(
const StringType& str, Args&& ... rest);
3904template<
typename... Args>
3910template<
typename... Args>
3914 return ::strlen(cstr) +
concat_length(std::forward<Args>(rest)...);
3917template<
typename StringType,
typename... Args>
3920 return str.size() +
concat_length(std::forward<Args>(rest)...);
3923template<
typename OutStringType>
3927template<
typename StringType,
typename Arg>
3930template<
typename StringType,
typename Arg>
3933template<
typename StringType,
typename Arg>
3936template<
typename StringType,
typename Arg>
3939template<
typename StringType,
typename Arg>
3942template<
typename StringType,
typename Arg>
3945template<
typename StringType,
typename Arg>
3946using string_can_append_data =
decltype(std::declval<StringType&>().append(std::declval<const Arg&>().data(), std::declval<const Arg&>().size()));
3948template<
typename StringType,
typename Arg>
3951template <
typename OutStringType,
typename Arg,
typename... Args,
3952 enable_if_t < !detect_string_can_append<OutStringType, Arg>::value
3954inline void concat_into(OutStringType& out, Arg && arg, Args && ... rest);
3956template <
typename OutStringType,
typename Arg,
typename... Args,
3957 enable_if_t < !detect_string_can_append<OutStringType, Arg>::value
3960inline void concat_into(OutStringType& out,
const Arg& arg, Args && ... rest);
3962template <
typename OutStringType,
typename Arg,
typename... Args,
3963 enable_if_t < !detect_string_can_append<OutStringType, Arg>::value
3967inline void concat_into(OutStringType& out,
const Arg& arg, Args && ... rest);
3969template<
typename OutStringType,
typename Arg,
typename... Args,
3971inline void concat_into(OutStringType& out, Arg && arg, Args && ... rest)
3973 out.append(std::forward<Arg>(arg));
3977template <
typename OutStringType,
typename Arg,
typename... Args,
3978 enable_if_t < !detect_string_can_append<OutStringType, Arg>::value
3979 && detect_string_can_append_op<OutStringType, Arg>::value,
int > >
3980inline void concat_into(OutStringType& out, Arg&& arg, Args&& ... rest)
3982 out += std::forward<Arg>(arg);
3986template <
typename OutStringType,
typename Arg,
typename... Args,
3987 enable_if_t < !detect_string_can_append<OutStringType, Arg>::value
3988 && !detect_string_can_append_op<OutStringType, Arg>::value
3989 && detect_string_can_append_iter<OutStringType, Arg>::value,
int > >
3990inline void concat_into(OutStringType& out,
const Arg& arg, Args&& ... rest)
3992 out.append(arg.begin(), arg.end());
3996template <
typename OutStringType,
typename Arg,
typename... Args,
3997 enable_if_t < !detect_string_can_append<OutStringType, Arg>::value
3998 && !detect_string_can_append_op<OutStringType, Arg>::value
3999 && !detect_string_can_append_iter<OutStringType, Arg>::value
4000 && detect_string_can_append_data<OutStringType, Arg>::value,
int > >
4001inline void concat_into(OutStringType& out,
const Arg& arg, Args&& ... rest)
4003 out.append(arg.data(), arg.size());
4007template<
typename OutStringType = std::string,
typename... Args>
4035 const char*
what() const noexcept
override
4045 exception(
int id_, const
char* what_arg) :
id(id_), m(what_arg) {}
4047 static std::string
name(
const std::string& ename,
int id_)
4049 return concat(
"[json.exception.", ename,
'.', std::to_string(id_),
"] ");
4057 template<
typename BasicJsonType>
4061 std::vector<std::string> tokens;
4062 for (
const auto* current = leaf_element; current !=
nullptr && current->m_parent !=
nullptr; current = current->m_parent)
4064 switch (current->m_parent->type())
4068 for (std::size_t i = 0; i < current->m_parent->m_value.array->size(); ++i)
4070 if (¤t->m_parent->m_value.array->operator[](i) == current)
4072 tokens.emplace_back(std::to_string(i));
4081 for (
const auto& element : *current->m_parent->m_value.object)
4083 if (&element.second == current)
4085 tokens.emplace_back(element.first.c_str());
4110 auto str = std::accumulate(tokens.rbegin(), tokens.rend(), std::string{},
4111 [](
const std::string &
a,
const std::string &
b)
4113 return concat(a,
'/', detail::escape(b));
4115 return concat(
'(', str,
") ");
4117 static_cast<void>(leaf_element);
4124 std::runtime_error m;
4141 template<typename BasicJsonContext, enable_if_t<is_basic_json_context<BasicJsonContext>::value,
int> = 0>
4142 static parse_error
create(
int id_,
const position_t& pos,
const std::string& what_arg, BasicJsonContext context)
4149 template<typename BasicJsonContext, enable_if_t<is_basic_json_context<BasicJsonContext>::value,
int> = 0>
4150 static parse_error
create(
int id_, std::size_t byte_,
const std::string& what_arg, BasicJsonContext context)
4153 (byte_ != 0 ? (
concat(
" at byte ", std::to_string(byte_))) :
""),
4155 return {id_, byte_, w.c_str()};
4170 parse_error(
int id_, std::size_t byte_,
const char* what_arg)
4173 static std::string position_string(
const position_t& pos)
4185 template<typename BasicJsonContext, enable_if_t<is_basic_json_context<BasicJsonContext>::value,
int> = 0>
4186 static invalid_iterator
create(
int id_,
const std::string& what_arg, BasicJsonContext context)
4189 return {id_, w.c_str()};
4203 template<typename BasicJsonContext, enable_if_t<is_basic_json_context<BasicJsonContext>::value,
int> = 0>
4204 static type_error
create(
int id_,
const std::string& what_arg, BasicJsonContext context)
4207 return {id_, w.c_str()};
4220 template<typename BasicJsonContext, enable_if_t<is_basic_json_context<BasicJsonContext>::value,
int> = 0>
4221 static out_of_range
create(
int id_,
const std::string& what_arg, BasicJsonContext context)
4224 return {id_, w.c_str()};
4237 template<typename BasicJsonContext, enable_if_t<is_basic_json_context<BasicJsonContext>::value,
int> = 0>
4238 static other_error
create(
int id_,
const std::string& what_arg, BasicJsonContext context)
4241 return {id_, w.c_str()};
4275#if JSON_HAS_EXPERIMENTAL_FILESYSTEM
4276#include <experimental/filesystem>
4279namespace std_fs = std::experimental::filesystem;
4281#elif JSON_HAS_FILESYSTEM
4282#include <filesystem>
4285namespace std_fs = std::filesystem;
4293template<
typename BasicJsonType>
4294inline void from_json(
const BasicJsonType& j,
typename std::nullptr_t&
n)
4304template <
typename BasicJsonType,
typename ArithmeticType,
4305 enable_if_t < std::is_arithmetic<ArithmeticType>::value&&
4306 !std::is_same<ArithmeticType, typename BasicJsonType::boolean_t>::value,
4310 switch (
static_cast<value_t>(j))
4314 val =
static_cast<ArithmeticType
>(*j.template get_ptr<const typename BasicJsonType::number_unsigned_t*>());
4319 val =
static_cast<ArithmeticType
>(*j.template get_ptr<const typename BasicJsonType::number_integer_t*>());
4324 val =
static_cast<ArithmeticType
>(*j.template get_ptr<const typename BasicJsonType::number_float_t*>());
4340template<
typename BasicJsonType>
4341inline void from_json(
const BasicJsonType& j,
typename BasicJsonType::boolean_t&
b)
4347 b = *j.template get_ptr<const typename BasicJsonType::boolean_t*>();
4350template<
typename BasicJsonType>
4351inline void from_json(
const BasicJsonType& j,
typename BasicJsonType::string_t& s)
4357 s = *j.template get_ptr<const typename BasicJsonType::string_t*>();
4361 typename BasicJsonType,
typename StringType,
4363 std::is_assignable<StringType&, const typename BasicJsonType::string_t>::value
4364 && !std::is_same<typename BasicJsonType::string_t, StringType>::value
4365 && !is_json_ref<StringType>::value,
int > = 0 >
4373 s = *j.template get_ptr<const typename BasicJsonType::string_t*>();
4376template<
typename BasicJsonType>
4377inline void from_json(
const BasicJsonType& j,
typename BasicJsonType::number_float_t& val)
4382template<
typename BasicJsonType>
4383inline void from_json(
const BasicJsonType& j,
typename BasicJsonType::number_unsigned_t& val)
4388template<
typename BasicJsonType>
4389inline void from_json(
const BasicJsonType& j,
typename BasicJsonType::number_integer_t& val)
4394#if !JSON_DISABLE_ENUM_SERIALIZATION
4395template<
typename BasicJsonType,
typename EnumType,
4396 enable_if_t<std::is_enum<EnumType>::value,
int> = 0>
4399 typename std::underlying_type<EnumType>::type val;
4401 e =
static_cast<EnumType
>(val);
4406template<
typename BasicJsonType,
typename T,
typename Allocator,
4407 enable_if_t<is_getable<BasicJsonType, T>::value,
int> = 0>
4408inline void from_json(
const BasicJsonType& j, std::forward_list<T, Allocator>& l)
4415 std::transform(j.rbegin(), j.rend(),
4416 std::front_inserter(l), [](
const BasicJsonType & i)
4418 return i.template get<T>();
4423template<
typename BasicJsonType,
typename T,
4424 enable_if_t<is_getable<BasicJsonType, T>::value,
int> = 0>
4425inline void from_json(
const BasicJsonType& j, std::valarray<T>& l)
4432 std::transform(j.begin(), j.end(), std::begin(l),
4433 [](
const BasicJsonType & elem)
4435 return elem.template get<T>();
4439template<
typename BasicJsonType,
typename T, std::
size_t N>
4441->
decltype(j.template
get<T>(), void())
4443 for (std::size_t i = 0; i < N; ++i)
4445 arr[i] = j.at(i).template
get<T>();
4449template<
typename BasicJsonType>
4452 arr = *j.template get_ptr<const typename BasicJsonType::array_t*>();
4455template<
typename BasicJsonType,
typename T, std::
size_t N>
4458->
decltype(j.template
get<T>(), void())
4460 for (std::size_t i = 0; i < N; ++i)
4462 arr[i] = j.at(i).template
get<T>();
4466template<
typename BasicJsonType,
typename ConstructibleArrayType,
4468 std::is_assignable<ConstructibleArrayType&, ConstructibleArrayType>::value,
4472 arr.reserve(std::declval<typename ConstructibleArrayType::size_type>()),
4478 ConstructibleArrayType ret;
4479 ret.reserve(j.size());
4480 std::transform(j.begin(), j.end(),
4481 std::inserter(ret,
end(ret)), [](
const BasicJsonType & i)
4487 arr = std::move(ret);
4490template<
typename BasicJsonType,
typename ConstructibleArrayType,
4492 std::is_assignable<ConstructibleArrayType&, ConstructibleArrayType>::value,
4499 ConstructibleArrayType ret;
4501 j.begin(), j.end(), std::inserter(ret,
end(ret)),
4502 [](
const BasicJsonType & i)
4508 arr = std::move(ret);
4511template <
typename BasicJsonType,
typename ConstructibleArrayType,
4513 is_constructible_array_type<BasicJsonType, ConstructibleArrayType>::value&&
4514 !is_constructible_object_type<BasicJsonType, ConstructibleArrayType>::value&&
4516 !std::is_same<ConstructibleArrayType, typename BasicJsonType::binary_t>::value&&
4517 !is_basic_json<ConstructibleArrayType>::value,
4519auto from_json(
const BasicJsonType& j, ConstructibleArrayType& arr)
4532template <
typename BasicJsonType,
typename T, std::size_t... Idx >
4536 return { { std::forward<BasicJsonType>(j).at(Idx).template
get<T>()... } };
4539template <
typename BasicJsonType,
typename T, std::
size_t N >
4551template<
typename BasicJsonType>
4552inline void from_json(
const BasicJsonType& j,
typename BasicJsonType::binary_t& bin)
4559 bin = *j.template get_ptr<const typename BasicJsonType::binary_t*>();
4562template<
typename BasicJsonType,
typename ConstructibleObjectType,
4563 enable_if_t<is_constructible_object_type<BasicJsonType, ConstructibleObjectType>::value,
int> = 0>
4564inline void from_json(
const BasicJsonType& j, ConstructibleObjectType& obj)
4571 ConstructibleObjectType ret;
4572 const auto* inner_object = j.template get_ptr<const typename BasicJsonType::object_t*>();
4573 using value_type =
typename ConstructibleObjectType::value_type;
4575 inner_object->begin(), inner_object->end(),
4576 std::inserter(ret, ret.begin()),
4577 [](
typename BasicJsonType::object_t::value_type
const & p)
4579 return value_type(p.first, p.second.template get<typename ConstructibleObjectType::mapped_type>());
4581 obj = std::move(ret);
4588template <
typename BasicJsonType,
typename ArithmeticType,
4590 std::is_arithmetic<ArithmeticType>::value&&
4591 !std::is_same<ArithmeticType, typename BasicJsonType::number_unsigned_t>::value&&
4592 !std::is_same<ArithmeticType, typename BasicJsonType::number_integer_t>::value&&
4593 !std::is_same<ArithmeticType, typename BasicJsonType::number_float_t>::value&&
4594 !std::is_same<ArithmeticType, typename BasicJsonType::boolean_t>::value,
4596inline void from_json(
const BasicJsonType& j, ArithmeticType& val)
4598 switch (
static_cast<value_t>(j))
4602 val =
static_cast<ArithmeticType
>(*j.template get_ptr<const typename BasicJsonType::number_unsigned_t*>());
4607 val =
static_cast<ArithmeticType
>(*j.template get_ptr<const typename BasicJsonType::number_integer_t*>());
4612 val =
static_cast<ArithmeticType
>(*j.template get_ptr<const typename BasicJsonType::number_float_t*>());
4617 val =
static_cast<ArithmeticType
>(*j.template get_ptr<const typename BasicJsonType::boolean_t*>());
4632template<
typename BasicJsonType,
typename... Args, std::size_t... Idx>
4635 return std::make_tuple(std::forward<BasicJsonType>(j).
at(Idx).
template get<Args>()...);
4638template <
typename BasicJsonType,
class A1,
class A2 >
4641 return {std::forward<BasicJsonType>(j).at(0).template
get<A1>(),
4642 std::forward<BasicJsonType>(j).at(1).template
get<A2>()};
4645template<
typename BasicJsonType,
typename A1,
typename A2>
4651template<
typename BasicJsonType,
typename... Args>
4657template<
typename BasicJsonType,
typename... Args>
4663template<
typename BasicJsonType,
typename TupleRelated>
4672 return from_json_tuple_impl(std::forward<BasicJsonType>(j), std::forward<TupleRelated>(t), priority_tag<3> {});
4675template <
typename BasicJsonType,
typename Key,
typename Value,
typename Compare,
typename Allocator,
4677 typename BasicJsonType::string_t, Key >
::value >>
4678inline void from_json(
const BasicJsonType& j, std::map<Key, Value, Compare, Allocator>& m)
4685 for (
const auto& p : j)
4695template <
typename BasicJsonType,
typename Key,
typename Value,
typename Hash,
typename KeyEqual,
typename Allocator,
4697 typename BasicJsonType::string_t, Key >
::value >>
4698inline void from_json(
const BasicJsonType& j, std::unordered_map<Key, Value, Hash, KeyEqual, Allocator>& m)
4705 for (
const auto& p : j)
4715#if JSON_HAS_FILESYSTEM || JSON_HAS_EXPERIMENTAL_FILESYSTEM
4716template<
typename BasicJsonType>
4717inline void from_json(
const BasicJsonType& j, std_fs::path& p)
4723 p = *j.template get_ptr<const typename BasicJsonType::string_t*>();
4729 template<
typename BasicJsonType,
typename T>
4731 noexcept(
noexcept(
from_json(j, std::forward<T>(val))))
4732 ->
decltype(
from_json(j, std::forward<T>(val)))
4734 return from_json(j, std::forward<T>(val));
4739#ifndef JSON_HAS_CPP_17
4748#ifndef JSON_HAS_CPP_17
4760#include <type_traits>
4789template<
typename string_type>
4793 using std::to_string;
4794 target = to_string(
value);
4804 using string_type =
typename std::remove_cv< typename std::remove_reference<decltype( std::declval<IteratorType>().key() ) >
::type >
::type;
4808 IteratorType anchor{};
4810 std::size_t array_index = 0;
4812 mutable std::size_t array_index_last = 0;
4821 noexcept(
std::is_nothrow_move_constructible<IteratorType>::
value
4823 : anchor(
std::move(it))
4824 , array_index(array_index_)
4831 noexcept(
std::is_nothrow_move_constructible<IteratorType>::
value
4834 noexcept(
std::is_nothrow_move_assignable<IteratorType>::
value
4864 return anchor == o.anchor;
4870 return anchor != o.anchor;
4878 switch (anchor.m_object->type())
4883 if (array_index != array_index_last)
4886 array_index_last = array_index;
4888 return array_index_str;
4893 return anchor.key();
4910 typename IteratorType::reference
value()
const
4912 return anchor.value();
4921 typename IteratorType::pointer container =
nullptr;
4928 : container(&cont) {}
4952template<std::
size_t N,
typename IteratorType, enable_if_t<N == 0,
int> = 0>
4960template<std::
size_t N,
typename IteratorType, enable_if_t<N == 1,
int> = 0>
4974#if defined(__clang__)
4976 #pragma clang diagnostic push
4977 #pragma clang diagnostic ignored "-Wmismatched-tags"
4979template<
typename IteratorType>
4981 :
public std::integral_constant<std::size_t, 2> {};
4983template<std::
size_t N,
typename IteratorType>
4988 get<N>(std::declval <
4991#if defined(__clang__)
4992 #pragma clang diagnostic pop
4997 template <
typename IteratorType>
4998 inline constexpr bool ::std::ranges::enable_borrowed_range<::nlohmann::detail::iteration_proxy<IteratorType>> =
true;
5008#if JSON_HAS_EXPERIMENTAL_FILESYSTEM
5009#include <experimental/filesystem>
5012namespace std_fs = std::experimental::filesystem;
5014#elif JSON_HAS_FILESYSTEM
5015#include <filesystem>
5018namespace std_fs = std::filesystem;
5042 template<
typename BasicJsonType>
5043 static void construct(BasicJsonType& j,
typename BasicJsonType::boolean_t
b)
noexcept
5045 j.m_value.destroy(j.m_type);
5048 j.assert_invariant();
5055 template<
typename BasicJsonType>
5056 static void construct(BasicJsonType& j,
const typename BasicJsonType::string_t& s)
5058 j.m_value.destroy(j.m_type);
5061 j.assert_invariant();
5064 template<
typename BasicJsonType>
5065 static void construct(BasicJsonType& j,
typename BasicJsonType::string_t&& s)
5067 j.m_value.destroy(j.m_type);
5069 j.m_value = std::move(s);
5070 j.assert_invariant();
5073 template <
typename BasicJsonType,
typename CompatibleStringType,
5074 enable_if_t < !std::is_same<CompatibleStringType, typename BasicJsonType::string_t>::value,
5076 static void construct(BasicJsonType& j,
const CompatibleStringType& str)
5078 j.m_value.destroy(j.m_type);
5080 j.m_value.string = j.template create<typename BasicJsonType::string_t>(str);
5081 j.assert_invariant();
5088 template<
typename BasicJsonType>
5089 static void construct(BasicJsonType& j,
const typename BasicJsonType::binary_t&
b)
5091 j.m_value.destroy(j.m_type);
5093 j.m_value =
typename BasicJsonType::binary_t(
b);
5094 j.assert_invariant();
5097 template<
typename BasicJsonType>
5098 static void construct(BasicJsonType& j,
typename BasicJsonType::binary_t&&
b)
5100 j.m_value.destroy(j.m_type);
5102 j.m_value =
typename BasicJsonType::binary_t(std::move(
b));
5103 j.assert_invariant();
5110 template<
typename BasicJsonType>
5111 static void construct(BasicJsonType& j,
typename BasicJsonType::number_float_t val)
noexcept
5113 j.m_value.destroy(j.m_type);
5116 j.assert_invariant();
5123 template<
typename BasicJsonType>
5124 static void construct(BasicJsonType& j,
typename BasicJsonType::number_unsigned_t val)
noexcept
5126 j.m_value.destroy(j.m_type);
5129 j.assert_invariant();
5136 template<
typename BasicJsonType>
5137 static void construct(BasicJsonType& j,
typename BasicJsonType::number_integer_t val)
noexcept
5139 j.m_value.destroy(j.m_type);
5142 j.assert_invariant();
5149 template<
typename BasicJsonType>
5150 static void construct(BasicJsonType& j,
const typename BasicJsonType::array_t& arr)
5152 j.m_value.destroy(j.m_type);
5156 j.assert_invariant();
5159 template<
typename BasicJsonType>
5160 static void construct(BasicJsonType& j,
typename BasicJsonType::array_t&& arr)
5162 j.m_value.destroy(j.m_type);
5164 j.m_value = std::move(arr);
5166 j.assert_invariant();
5169 template <
typename BasicJsonType,
typename CompatibleArrayType,
5170 enable_if_t < !std::is_same<CompatibleArrayType, typename BasicJsonType::array_t>::value,
5172 static void construct(BasicJsonType& j,
const CompatibleArrayType& arr)
5177 j.m_value.destroy(j.m_type);
5179 j.m_value.array = j.template create<typename BasicJsonType::array_t>(
begin(arr),
end(arr));
5181 j.assert_invariant();
5184 template<
typename BasicJsonType>
5185 static void construct(BasicJsonType& j,
const std::vector<bool>& arr)
5187 j.m_value.destroy(j.m_type);
5190 j.m_value.array->reserve(arr.size());
5191 for (
const bool x : arr)
5193 j.m_value.array->push_back(x);
5194 j.set_parent(j.m_value.array->back());
5196 j.assert_invariant();
5199 template<
typename BasicJsonType,
typename T,
5201 static void construct(BasicJsonType& j,
const std::valarray<T>& arr)
5203 j.m_value.destroy(j.m_type);
5206 j.m_value.array->resize(arr.size());
5209 std::copy(std::begin(arr), std::end(arr), j.m_value.array->begin());
5212 j.assert_invariant();
5219 template<
typename BasicJsonType>
5220 static void construct(BasicJsonType& j,
const typename BasicJsonType::object_t& obj)
5222 j.m_value.destroy(j.m_type);
5226 j.assert_invariant();
5229 template<
typename BasicJsonType>
5230 static void construct(BasicJsonType& j,
typename BasicJsonType::object_t&& obj)
5232 j.m_value.destroy(j.m_type);
5234 j.m_value = std::move(obj);
5236 j.assert_invariant();
5239 template <
typename BasicJsonType,
typename CompatibleObjectType,
5240 enable_if_t < !std::is_same<CompatibleObjectType, typename BasicJsonType::object_t>::value,
int > = 0 >
5241 static void construct(BasicJsonType& j,
const CompatibleObjectType& obj)
5246 j.m_value.destroy(j.m_type);
5248 j.m_value.object = j.template create<typename BasicJsonType::object_t>(
begin(obj),
end(obj));
5250 j.assert_invariant();
5258template<
typename BasicJsonType,
typename T,
5259 enable_if_t<std::is_same<T, typename BasicJsonType::boolean_t>::value,
int> = 0>
5265template<
typename BasicJsonType,
5266 enable_if_t<std::is_convertible<const std::vector<bool>::reference&,
typename BasicJsonType::boolean_t>
::value,
int> = 0>
5267inline void to_json(BasicJsonType& j,
const std::vector<bool>::reference&
b)
noexcept
5272template<
typename BasicJsonType,
typename CompatibleString,
5273 enable_if_t<std::is_constructible<typename BasicJsonType::string_t, CompatibleString>::value,
int> = 0>
5274inline void to_json(BasicJsonType& j,
const CompatibleString& s)
5279template<
typename BasicJsonType>
5280inline void to_json(BasicJsonType& j,
typename BasicJsonType::string_t&& s)
5285template<
typename BasicJsonType,
typename FloatType,
5286 enable_if_t<std::is_floating_point<FloatType>::value,
int> = 0>
5287inline void to_json(BasicJsonType& j, FloatType val)
noexcept
5292template<
typename BasicJsonType,
typename CompatibleNumberUnsignedType,
5293 enable_if_t<is_compatible_integer_type<typename BasicJsonType::number_unsigned_t, CompatibleNumberUnsignedType>::value,
int> = 0>
5294inline void to_json(BasicJsonType& j, CompatibleNumberUnsignedType val)
noexcept
5299template<
typename BasicJsonType,
typename CompatibleNumberIntegerType,
5300 enable_if_t<is_compatible_integer_type<typename BasicJsonType::number_integer_t, CompatibleNumberIntegerType>::value,
int> = 0>
5301inline void to_json(BasicJsonType& j, CompatibleNumberIntegerType val)
noexcept
5306#if !JSON_DISABLE_ENUM_SERIALIZATION
5307template<
typename BasicJsonType,
typename EnumType,
5308 enable_if_t<std::is_enum<EnumType>::value,
int> = 0>
5309inline void to_json(BasicJsonType& j, EnumType e)
noexcept
5311 using underlying_type =
typename std::underlying_type<EnumType>::type;
5316template<
typename BasicJsonType>
5317inline void to_json(BasicJsonType& j,
const std::vector<bool>& e)
5322template <
typename BasicJsonType,
typename CompatibleArrayType,
5323 enable_if_t < is_compatible_array_type<BasicJsonType,
5325 !is_compatible_object_type<BasicJsonType, CompatibleArrayType>::value&&
5327 !std::is_same<typename BasicJsonType::binary_t, CompatibleArrayType>::value&&
5328 !is_basic_json<CompatibleArrayType>::value,
5330inline void to_json(BasicJsonType& j,
const CompatibleArrayType& arr)
5335template<
typename BasicJsonType>
5336inline void to_json(BasicJsonType& j,
const typename BasicJsonType::binary_t& bin)
5341template<
typename BasicJsonType,
typename T,
5342 enable_if_t<std::is_convertible<T, BasicJsonType>::value,
int> = 0>
5343inline void to_json(BasicJsonType& j,
const std::valarray<T>& arr)
5348template<
typename BasicJsonType>
5349inline void to_json(BasicJsonType& j,
typename BasicJsonType::array_t&& arr)
5354template <
typename BasicJsonType,
typename CompatibleObjectType,
5355 enable_if_t < is_compatible_object_type<BasicJsonType, CompatibleObjectType>::value&& !is_basic_json<CompatibleObjectType>::value,
int > = 0 >
5356inline void to_json(BasicJsonType& j,
const CompatibleObjectType& obj)
5361template<
typename BasicJsonType>
5362inline void to_json(BasicJsonType& j,
typename BasicJsonType::object_t&& obj)
5368 typename BasicJsonType,
typename T, std::size_t N,
5369 enable_if_t < !std::is_constructible<
typename BasicJsonType::string_t,
5372inline void to_json(BasicJsonType& j,
const T(&arr)[N])
5377template < typename BasicJsonType, typename T1, typename T2, enable_if_t < std::is_constructible<BasicJsonType, T1>::value&& std::is_constructible<BasicJsonType, T2>::value,
int > = 0 >
5378inline void to_json(BasicJsonType& j,
const std::pair<T1, T2>& p)
5380 j = { p.first, p.second };
5384template<
typename BasicJsonType,
typename T,
5388 j = { {
b.key(),
b.value()} };
5391template<
typename BasicJsonType,
typename Tuple, std::size_t... Idx>
5394 j = { std::get<Idx>(t)... };
5397template<typename BasicJsonType, typename T, enable_if_t<is_constructible_tuple<BasicJsonType, T>::value,
int > = 0>
5403#if JSON_HAS_FILESYSTEM || JSON_HAS_EXPERIMENTAL_FILESYSTEM
5404template<
typename BasicJsonType>
5405inline void to_json(BasicJsonType& j,
const std_fs::path& p)
5413 template<
typename BasicJsonType,
typename T>
5414 auto operator()(BasicJsonType& j, T&& val)
const noexcept(
noexcept(
to_json(j, std::forward<T>(val))))
5415 ->
decltype(
to_json(j, std::forward<T>(val)),
void())
5417 return to_json(j, std::forward<T>(val));
5422#ifndef JSON_HAS_CPP_17
5431#ifndef JSON_HAS_CPP_17
5445template<
typename ValueType,
typename>
5450 template<
typename BasicJsonType,
typename TargetType = ValueType>
5451 static auto from_json(BasicJsonType && j, TargetType& val)
noexcept(
5452 noexcept(::nlohmann::from_json(std::forward<BasicJsonType>(j), val)))
5453 ->
decltype(::nlohmann::from_json(std::forward<BasicJsonType>(j), val),
void())
5455 ::nlohmann::from_json(std::forward<BasicJsonType>(j), val);
5460 template<
typename BasicJsonType,
typename TargetType = ValueType>
5465 return ::nlohmann::from_json(std::forward<BasicJsonType>(j), detail::identity_tag<TargetType> {});
5470 template<
typename BasicJsonType,
typename TargetType = ValueType>
5471 static auto to_json(BasicJsonType& j, TargetType && val)
noexcept(
5472 noexcept(::nlohmann::to_json(j, std::forward<TargetType>(val))))
5473 ->
decltype(::nlohmann::to_json(j, std::forward<TargetType>(val)),
void())
5475 ::nlohmann::to_json(j, std::forward<TargetType>(val));
5492template<
typename BinaryType>
5517 , m_subtype(subtype_)
5518 , m_has_subtype(true)
5524 , m_subtype(subtype_)
5525 , m_has_subtype(true)
5530 return std::tie(
static_cast<const BinaryType&
>(*
this), m_subtype, m_has_subtype) ==
5531 std::tie(
static_cast<const BinaryType&
>(
rhs),
rhs.m_subtype,
rhs.m_has_subtype);
5536 return !(
rhs == *
this);
5543 m_subtype = subtype_;
5544 m_has_subtype =
true;
5551 return m_has_subtype ? m_subtype :
static_cast<subtype_type>(-1);
5558 return m_has_subtype;
5566 m_has_subtype =
false;
5571 bool m_has_subtype =
false;
5587#include <functional>
5600inline std::size_t
combine(std::size_t seed, std::size_t h)
noexcept
5602 seed ^= h + 0x9e3779b9 + (seed << 6U) + (seed >> 2U);
5617template<
typename BasicJsonType>
5618std::size_t
hash(
const BasicJsonType& j)
5620 using string_t =
typename BasicJsonType::string_t;
5621 using number_integer_t =
typename BasicJsonType::number_integer_t;
5622 using number_unsigned_t =
typename BasicJsonType::number_unsigned_t;
5623 using number_float_t =
typename BasicJsonType::number_float_t;
5625 const auto type =
static_cast<std::size_t
>(j.type());
5628 case BasicJsonType::value_t::null:
5629 case BasicJsonType::value_t::discarded:
5634 case BasicJsonType::value_t::object:
5637 for (
const auto& element : j.items())
5639 const auto h = std::hash<string_t> {}(element.key());
5646 case BasicJsonType::value_t::array:
5649 for (
const auto& element : j)
5656 case BasicJsonType::value_t::string:
5658 const auto h = std::hash<string_t> {}(j.template get_ref<const string_t&>());
5662 case BasicJsonType::value_t::boolean:
5664 const auto h = std::hash<bool> {}(j.template
get<bool>());
5668 case BasicJsonType::value_t::number_integer:
5674 case BasicJsonType::value_t::number_unsigned:
5680 case BasicJsonType::value_t::number_float:
5686 case BasicJsonType::value_t::binary:
5689 const auto h = std::hash<bool> {}(j.get_binary().has_subtype());
5691 seed =
combine(seed,
static_cast<std::size_t
>(j.get_binary().subtype()));
5692 for (
const auto byte : j.get_binary())
5694 seed =
combine(seed, std::hash<std::uint8_t> {}(
byte));
5737#include <type_traits>
5785 return std::fgetc(m_file);
5814 is->clear(is->rdstate() & std::ios::eofbit);
5819 : is(&i), sb(i.rdbuf())
5839 auto res = sb->sbumpc();
5843 is->clear(is->rdstate() | std::ios::eofbit);
5850 std::istream* is =
nullptr;
5851 std::streambuf* sb =
nullptr;
5857template<
typename IteratorType>
5861 using char_type =
typename std::iterator_traits<IteratorType>::value_type;
5864 : current(
std::move(first)), end(
std::move(last))
5871 auto result = std::char_traits<char_type>::to_int_type(*current);
5872 std::advance(current, 1);
5876 return std::char_traits<char_type>::eof();
5880 IteratorType current;
5883 template<
typename BaseInputAdapter,
size_t T>
5888 return current == end;
5893template<
typename BaseInputAdapter,
size_t T>
5896template<
typename BaseInputAdapter>
5901 std::array<std::char_traits<char>::int_type, 4>& utf8_bytes,
5902 size_t& utf8_bytes_index,
5903 size_t& utf8_bytes_filled)
5905 utf8_bytes_index = 0;
5909 utf8_bytes[0] = std::char_traits<char>::eof();
5910 utf8_bytes_filled = 1;
5915 const auto wc = input.get_character();
5920 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(wc);
5921 utf8_bytes_filled = 1;
5923 else if (wc <= 0x7FF)
5925 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(0xC0u | ((
static_cast<unsigned int>(wc) >> 6u) & 0x1Fu));
5926 utf8_bytes[1] =
static_cast<std::char_traits<char>::int_type
>(0x80u | (
static_cast<unsigned int>(wc) & 0x3Fu));
5927 utf8_bytes_filled = 2;
5929 else if (wc <= 0xFFFF)
5931 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(0xE0u | ((
static_cast<unsigned int>(wc) >> 12u) & 0x0Fu));
5932 utf8_bytes[1] =
static_cast<std::char_traits<char>::int_type
>(0x80u | ((
static_cast<unsigned int>(wc) >> 6u) & 0x3Fu));
5933 utf8_bytes[2] =
static_cast<std::char_traits<char>::int_type
>(0x80u | (
static_cast<unsigned int>(wc) & 0x3Fu));
5934 utf8_bytes_filled = 3;
5936 else if (wc <= 0x10FFFF)
5938 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(0xF0u | ((
static_cast<unsigned int>(wc) >> 18u) & 0x07u));
5939 utf8_bytes[1] =
static_cast<std::char_traits<char>::int_type
>(0x80u | ((
static_cast<unsigned int>(wc) >> 12u) & 0x3Fu));
5940 utf8_bytes[2] =
static_cast<std::char_traits<char>::int_type
>(0x80u | ((
static_cast<unsigned int>(wc) >> 6u) & 0x3Fu));
5941 utf8_bytes[3] =
static_cast<std::char_traits<char>::int_type
>(0x80u | (
static_cast<unsigned int>(wc) & 0x3Fu));
5942 utf8_bytes_filled = 4;
5947 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(wc);
5948 utf8_bytes_filled = 1;
5954template<
typename BaseInputAdapter>
5959 std::array<std::char_traits<char>::int_type, 4>& utf8_bytes,
5960 size_t& utf8_bytes_index,
5961 size_t& utf8_bytes_filled)
5963 utf8_bytes_index = 0;
5967 utf8_bytes[0] = std::char_traits<char>::eof();
5968 utf8_bytes_filled = 1;
5973 const auto wc = input.get_character();
5978 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(wc);
5979 utf8_bytes_filled = 1;
5981 else if (wc <= 0x7FF)
5983 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(0xC0u | ((
static_cast<unsigned int>(wc) >> 6u)));
5984 utf8_bytes[1] =
static_cast<std::char_traits<char>::int_type
>(0x80u | (
static_cast<unsigned int>(wc) & 0x3Fu));
5985 utf8_bytes_filled = 2;
5987 else if (0xD800 > wc || wc >= 0xE000)
5989 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(0xE0u | ((
static_cast<unsigned int>(wc) >> 12u)));
5990 utf8_bytes[1] =
static_cast<std::char_traits<char>::int_type
>(0x80u | ((
static_cast<unsigned int>(wc) >> 6u) & 0x3Fu));
5991 utf8_bytes[2] =
static_cast<std::char_traits<char>::int_type
>(0x80u | (
static_cast<unsigned int>(wc) & 0x3Fu));
5992 utf8_bytes_filled = 3;
5998 const auto wc2 =
static_cast<unsigned int>(input.get_character());
5999 const auto charcode = 0x10000u + (((
static_cast<unsigned int>(wc) & 0x3FFu) << 10u) | (wc2 & 0x3FFu));
6000 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(0xF0u | (charcode >> 18u));
6001 utf8_bytes[1] =
static_cast<std::char_traits<char>::int_type
>(0x80u | ((charcode >> 12u) & 0x3Fu));
6002 utf8_bytes[2] =
static_cast<std::char_traits<char>::int_type
>(0x80u | ((charcode >> 6u) & 0x3Fu));
6003 utf8_bytes[3] =
static_cast<std::char_traits<char>::int_type
>(0x80u | (charcode & 0x3Fu));
6004 utf8_bytes_filled = 4;
6008 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(wc);
6009 utf8_bytes_filled = 1;
6017template<
typename BaseInputAdapter,
typename W
ideCharType>
6024 : base_adapter(base) {}
6029 if (utf8_bytes_index == utf8_bytes_filled)
6031 fill_buffer<sizeof(WideCharType)>();
6039 JSON_ASSERT(utf8_bytes_index < utf8_bytes_filled);
6040 return utf8_bytes[utf8_bytes_index++];
6044 BaseInputAdapter base_adapter;
6053 std::array<std::char_traits<char>::int_type, 4> utf8_bytes = {{0, 0, 0, 0}};
6056 std::size_t utf8_bytes_index = 0;
6058 std::size_t utf8_bytes_filled = 0;
6062template<
typename IteratorType,
typename Enable =
void>
6066 using char_type =
typename std::iterator_traits<iterator_type>::value_type;
6071 return adapter_type(std::move(first), std::move(last));
6085template<
typename IteratorType>
6089 using char_type =
typename std::iterator_traits<iterator_type>::value_type;
6100template<
typename IteratorType>
6104 return factory_type::create(first, last);
6117template<
typename ContainerType,
typename Enable =
void>
6120template<
typename ContainerType>
6122 void_t<decltype(
begin(
std::declval<ContainerType>()),
end(std::declval<ContainerType>()))>>
6134template<
typename ContainerType>
6161template <
typename CharT,
6162 typename std::enable_if <
6163 std::is_pointer<CharT>::value&&
6164 !std::is_array<CharT>::value&&
6165 std::is_integral<typename std::remove_pointer<CharT>::type>
::value&&
6166 sizeof(
typename std::remove_pointer<CharT>::type) == 1,
6170 auto length = std::strlen(
reinterpret_cast<const char*
>(
b));
6171 const auto* ptr =
reinterpret_cast<const char*
>(
b);
6175template<
typename T, std::
size_t N>
6187 template <
typename CharT,
6188 typename std::enable_if <
6189 std::is_pointer<CharT>::value&&
6190 std::is_integral<typename std::remove_pointer<CharT>::type>
::value&&
6191 sizeof(
typename std::remove_pointer<CharT>::type) == 1,
6194 : ia(
reinterpret_cast<const char*
>(
b),
reinterpret_cast<const char*
>(
b) + l) {}
6196 template<
class IteratorType,
6197 typename std::enable_if<
6198 std::is_same<typename iterator_traits<IteratorType>::iterator_category, std::random_access_iterator_tag>
::value,
6205 return std::move(ia);
6240template<
typename BasicJsonType>
6344 const std::string& last_token,
6371template<
typename BasicJsonType>
6387 : root(r), allow_exceptions(allow_exceptions_)
6399 handle_value(
nullptr);
6435 handle_value(std::move(val));
6441 ref_stack.push_back(handle_value(BasicJsonType::value_t::object));
6443 if (
JSON_HEDLEY_UNLIKELY(len !=
static_cast<std::size_t
>(-1) && len > ref_stack.back()->max_size()))
6457 object_element = &(ref_stack.back()->m_value.object->operator[](val));
6466 ref_stack.back()->set_parents();
6467 ref_stack.pop_back();
6473 ref_stack.push_back(handle_value(BasicJsonType::value_t::array));
6475 if (
JSON_HEDLEY_UNLIKELY(len !=
static_cast<std::size_t
>(-1) && len > ref_stack.back()->max_size()))
6488 ref_stack.back()->set_parents();
6489 ref_stack.pop_back();
6493 template<
class Exception>
6495 const Exception& ex)
6498 static_cast<void>(ex);
6499 if (allow_exceptions)
6518 template<
typename Value>
6520 BasicJsonType* handle_value(Value&& v)
6522 if (ref_stack.empty())
6524 root = BasicJsonType(std::forward<Value>(v));
6528 JSON_ASSERT(ref_stack.back()->is_array() || ref_stack.back()->is_object());
6530 if (ref_stack.back()->is_array())
6532 ref_stack.back()->m_value.array->emplace_back(std::forward<Value>(v));
6533 return &(ref_stack.back()->m_value.array->back());
6538 *object_element = BasicJsonType(std::forward<Value>(v));
6539 return object_element;
6543 BasicJsonType& root;
6545 std::vector<BasicJsonType*> ref_stack {};
6547 BasicJsonType* object_element =
nullptr;
6549 bool errored =
false;
6551 const bool allow_exceptions =
true;
6554template<
typename BasicJsonType>
6568 const bool allow_exceptions_ =
true)
6569 : root(r), callback(cb), allow_exceptions(allow_exceptions_)
6571 keep_stack.push_back(
true);
6583 handle_value(
nullptr);
6619 handle_value(std::move(val));
6626 const bool keep = callback(
static_cast<int>(ref_stack.size()), parse_event_t::object_start, discarded);
6627 keep_stack.push_back(keep);
6629 auto val = handle_value(BasicJsonType::value_t::object,
true);
6630 ref_stack.push_back(val.second);
6633 if (ref_stack.back() &&
JSON_HEDLEY_UNLIKELY(len !=
static_cast<std::size_t
>(-1) && len > ref_stack.back()->max_size()))
6643 BasicJsonType k = BasicJsonType(val);
6646 const bool keep = callback(
static_cast<int>(ref_stack.size()),
parse_event_t::key, k);
6647 key_keep_stack.push_back(keep);
6650 if (keep && ref_stack.back())
6652 object_element = &(ref_stack.back()->m_value.object->operator[](val) = discarded);
6660 if (ref_stack.back())
6662 if (!callback(
static_cast<int>(ref_stack.size()) - 1, parse_event_t::object_end, *ref_stack.back()))
6665 *ref_stack.back() = discarded;
6669 ref_stack.back()->set_parents();
6675 ref_stack.pop_back();
6676 keep_stack.pop_back();
6678 if (!ref_stack.empty() && ref_stack.back() && ref_stack.back()->is_structured())
6681 for (
auto it = ref_stack.back()->begin(); it != ref_stack.back()->end(); ++it)
6683 if (it->is_discarded())
6685 ref_stack.back()->erase(it);
6696 const bool keep = callback(
static_cast<int>(ref_stack.size()), parse_event_t::array_start, discarded);
6697 keep_stack.push_back(keep);
6699 auto val = handle_value(BasicJsonType::value_t::array,
true);
6700 ref_stack.push_back(val.second);
6703 if (ref_stack.back() &&
JSON_HEDLEY_UNLIKELY(len !=
static_cast<std::size_t
>(-1) && len > ref_stack.back()->max_size()))
6715 if (ref_stack.back())
6720 ref_stack.back()->set_parents();
6725 *ref_stack.back() = discarded;
6731 ref_stack.pop_back();
6732 keep_stack.pop_back();
6735 if (!keep && !ref_stack.empty() && ref_stack.back()->is_array())
6737 ref_stack.back()->m_value.array->pop_back();
6743 template<
class Exception>
6745 const Exception& ex)
6748 static_cast<void>(ex);
6749 if (allow_exceptions)
6777 template<
typename Value>
6778 std::pair<bool, BasicJsonType*> handle_value(Value&& v,
const bool skip_callback =
false)
6784 if (!keep_stack.back())
6786 return {
false,
nullptr};
6790 auto value = BasicJsonType(std::forward<Value>(v));
6793 const bool keep = skip_callback || callback(
static_cast<int>(ref_stack.size()), parse_event_t::value, value);
6798 return {
false,
nullptr};
6801 if (ref_stack.empty())
6803 root = std::move(value);
6804 return {
true, &root};
6809 if (!ref_stack.back())
6811 return {
false,
nullptr};
6815 JSON_ASSERT(ref_stack.back()->is_array() || ref_stack.back()->is_object());
6818 if (ref_stack.back()->is_array())
6820 ref_stack.back()->m_value.array->emplace_back(std::move(value));
6821 return {
true, &(ref_stack.back()->m_value.array->back())};
6828 const bool store_element = key_keep_stack.back();
6829 key_keep_stack.pop_back();
6833 return {
false,
nullptr};
6837 *object_element = std::move(value);
6838 return {
true, object_element};
6842 BasicJsonType& root;
6844 std::vector<BasicJsonType*> ref_stack {};
6846 std::vector<bool> keep_stack {};
6848 std::vector<bool> key_keep_stack {};
6850 BasicJsonType* object_element =
nullptr;
6852 bool errored =
false;
6856 const bool allow_exceptions =
true;
6858 BasicJsonType
discarded = BasicJsonType::value_t::discarded;
6861template<
typename BasicJsonType>
6948#include <initializer_list>
6968template<
typename BasicJsonType>
7002 return "<uninitialized>";
7004 return "true literal";
7006 return "false literal";
7008 return "null literal";
7010 return "string literal";
7014 return "number literal";
7028 return "<parse error>";
7030 return "end of input";
7032 return "'[', '{', or a literal";
7035 return "unknown token";
7045template<
typename BasicJsonType,
typename InputAdapterType>
7048 using number_integer_t =
typename BasicJsonType::number_integer_t;
7049 using number_unsigned_t =
typename BasicJsonType::number_unsigned_t;
7050 using number_float_t =
typename BasicJsonType::number_float_t;
7051 using string_t =
typename BasicJsonType::string_t;
7052 using char_type =
typename InputAdapterType::char_type;
7053 using char_int_type =
typename std::char_traits<char_type>::int_type;
7058 explicit lexer(InputAdapterType&& adapter,
bool ignore_comments_ =
false) noexcept
7059 : ia(
std::move(adapter))
7060 , ignore_comments(ignore_comments_)
7061 , decimal_point_char(static_cast<char_int_type>(get_decimal_point()))
7078 static char get_decimal_point() noexcept
7080 const auto* loc = localeconv();
7082 return (loc->decimal_point ==
nullptr) ?
'.' : *(loc->decimal_point);
7110 const auto factors = { 12u, 8u, 4u, 0u };
7111 for (
const auto factor : factors)
7115 if (current >=
'0' && current <=
'9')
7117 codepoint +=
static_cast<int>((
static_cast<unsigned int>(current) - 0x30u) << factor);
7119 else if (current >=
'A' && current <=
'F')
7121 codepoint +=
static_cast<int>((
static_cast<unsigned int>(current) - 0x37u) << factor);
7123 else if (current >=
'a' && current <=
'f')
7125 codepoint +=
static_cast<int>((
static_cast<unsigned int>(current) - 0x57u) << factor);
7133 JSON_ASSERT(0x0000 <= codepoint && codepoint <= 0xFFFF);
7152 bool next_byte_in_range(std::initializer_list<char_int_type> ranges)
7154 JSON_ASSERT(ranges.size() == 2 || ranges.size() == 4 || ranges.size() == 6);
7157 for (
auto range = ranges.begin(); range != ranges.end(); ++range)
7166 error_message =
"invalid string: ill-formed UTF-8 byte";
7203 case std::char_traits<char_type>::eof():
7205 error_message =
"invalid string: missing closing quote";
7206 return token_type::parse_error;
7212 return token_type::value_string;
7256 const int codepoint1 = get_codepoint();
7257 int codepoint = codepoint1;
7261 error_message =
"invalid string: '\\u' must be followed by 4 hex digits";
7262 return token_type::parse_error;
7266 if (0xD800 <= codepoint1 && codepoint1 <= 0xDBFF)
7271 const int codepoint2 = get_codepoint();
7275 error_message =
"invalid string: '\\u' must be followed by 4 hex digits";
7276 return token_type::parse_error;
7283 codepoint =
static_cast<int>(
7285 (
static_cast<unsigned int>(codepoint1) << 10u)
7287 +
static_cast<unsigned int>(codepoint2)
7295 error_message =
"invalid string: surrogate U+D800..U+DBFF must be followed by U+DC00..U+DFFF";
7296 return token_type::parse_error;
7301 error_message =
"invalid string: surrogate U+D800..U+DBFF must be followed by U+DC00..U+DFFF";
7302 return token_type::parse_error;
7309 error_message =
"invalid string: surrogate U+DC00..U+DFFF must follow U+D800..U+DBFF";
7310 return token_type::parse_error;
7315 JSON_ASSERT(0x00 <= codepoint && codepoint <= 0x10FFFF);
7318 if (codepoint < 0x80)
7321 add(
static_cast<char_int_type
>(codepoint));
7323 else if (codepoint <= 0x7FF)
7326 add(
static_cast<char_int_type
>(0xC0u | (
static_cast<unsigned int>(codepoint) >> 6u)));
7327 add(
static_cast<char_int_type
>(0x80u | (
static_cast<unsigned int>(codepoint) & 0x3Fu)));
7329 else if (codepoint <= 0xFFFF)
7332 add(
static_cast<char_int_type
>(0xE0u | (
static_cast<unsigned int>(codepoint) >> 12u)));
7333 add(
static_cast<char_int_type
>(0x80u | ((
static_cast<unsigned int>(codepoint) >> 6u) & 0x3Fu)));
7334 add(
static_cast<char_int_type
>(0x80u | (
static_cast<unsigned int>(codepoint) & 0x3Fu)));
7339 add(
static_cast<char_int_type
>(0xF0u | (
static_cast<unsigned int>(codepoint) >> 18u)));
7340 add(
static_cast<char_int_type
>(0x80u | ((
static_cast<unsigned int>(codepoint) >> 12u) & 0x3Fu)));
7341 add(
static_cast<char_int_type
>(0x80u | ((
static_cast<unsigned int>(codepoint) >> 6u) & 0x3Fu)));
7342 add(
static_cast<char_int_type
>(0x80u | (
static_cast<unsigned int>(codepoint) & 0x3Fu)));
7350 error_message =
"invalid string: forbidden character after backslash";
7351 return token_type::parse_error;
7360 error_message =
"invalid string: control character U+0000 (NUL) must be escaped to \\u0000";
7361 return token_type::parse_error;
7366 error_message =
"invalid string: control character U+0001 (SOH) must be escaped to \\u0001";
7367 return token_type::parse_error;
7372 error_message =
"invalid string: control character U+0002 (STX) must be escaped to \\u0002";
7373 return token_type::parse_error;
7378 error_message =
"invalid string: control character U+0003 (ETX) must be escaped to \\u0003";
7379 return token_type::parse_error;
7384 error_message =
"invalid string: control character U+0004 (EOT) must be escaped to \\u0004";
7385 return token_type::parse_error;
7390 error_message =
"invalid string: control character U+0005 (ENQ) must be escaped to \\u0005";
7391 return token_type::parse_error;
7396 error_message =
"invalid string: control character U+0006 (ACK) must be escaped to \\u0006";
7397 return token_type::parse_error;
7402 error_message =
"invalid string: control character U+0007 (BEL) must be escaped to \\u0007";
7403 return token_type::parse_error;
7408 error_message =
"invalid string: control character U+0008 (BS) must be escaped to \\u0008 or \\b";
7409 return token_type::parse_error;
7414 error_message =
"invalid string: control character U+0009 (HT) must be escaped to \\u0009 or \\t";
7415 return token_type::parse_error;
7420 error_message =
"invalid string: control character U+000A (LF) must be escaped to \\u000A or \\n";
7421 return token_type::parse_error;
7426 error_message =
"invalid string: control character U+000B (VT) must be escaped to \\u000B";
7427 return token_type::parse_error;
7432 error_message =
"invalid string: control character U+000C (FF) must be escaped to \\u000C or \\f";
7433 return token_type::parse_error;
7438 error_message =
"invalid string: control character U+000D (CR) must be escaped to \\u000D or \\r";
7439 return token_type::parse_error;
7444 error_message =
"invalid string: control character U+000E (SO) must be escaped to \\u000E";
7445 return token_type::parse_error;
7450 error_message =
"invalid string: control character U+000F (SI) must be escaped to \\u000F";
7451 return token_type::parse_error;
7456 error_message =
"invalid string: control character U+0010 (DLE) must be escaped to \\u0010";
7457 return token_type::parse_error;
7462 error_message =
"invalid string: control character U+0011 (DC1) must be escaped to \\u0011";
7463 return token_type::parse_error;
7468 error_message =
"invalid string: control character U+0012 (DC2) must be escaped to \\u0012";
7469 return token_type::parse_error;
7474 error_message =
"invalid string: control character U+0013 (DC3) must be escaped to \\u0013";
7475 return token_type::parse_error;
7480 error_message =
"invalid string: control character U+0014 (DC4) must be escaped to \\u0014";
7481 return token_type::parse_error;
7486 error_message =
"invalid string: control character U+0015 (NAK) must be escaped to \\u0015";
7487 return token_type::parse_error;
7492 error_message =
"invalid string: control character U+0016 (SYN) must be escaped to \\u0016";
7493 return token_type::parse_error;
7498 error_message =
"invalid string: control character U+0017 (ETB) must be escaped to \\u0017";
7499 return token_type::parse_error;
7504 error_message =
"invalid string: control character U+0018 (CAN) must be escaped to \\u0018";
7505 return token_type::parse_error;
7510 error_message =
"invalid string: control character U+0019 (EM) must be escaped to \\u0019";
7511 return token_type::parse_error;
7516 error_message =
"invalid string: control character U+001A (SUB) must be escaped to \\u001A";
7517 return token_type::parse_error;
7522 error_message =
"invalid string: control character U+001B (ESC) must be escaped to \\u001B";
7523 return token_type::parse_error;
7528 error_message =
"invalid string: control character U+001C (FS) must be escaped to \\u001C";
7529 return token_type::parse_error;
7534 error_message =
"invalid string: control character U+001D (GS) must be escaped to \\u001D";
7535 return token_type::parse_error;
7540 error_message =
"invalid string: control character U+001E (RS) must be escaped to \\u001E";
7541 return token_type::parse_error;
7546 error_message =
"invalid string: control character U+001F (US) must be escaped to \\u001F";
7547 return token_type::parse_error;
7684 return token_type::parse_error;
7694 return token_type::parse_error;
7718 return token_type::parse_error;
7728 return token_type::parse_error;
7738 return token_type::parse_error;
7750 return token_type::parse_error;
7760 return token_type::parse_error;
7768 error_message =
"invalid string: ill-formed UTF-8 byte";
7769 return token_type::parse_error;
7792 case std::char_traits<char_type>::eof():
7809 case std::char_traits<char_type>::eof():
7812 error_message =
"invalid comment; missing closing '*/'";
7840 error_message =
"invalid comment; expecting '/' or '*' after '/'";
7847 static
void strtof(
float& f, const
char* str,
char** endptr) noexcept
7849 f = std::strtof(str, endptr);
7853 static
void strtof(
double& f, const
char* str,
char** endptr) noexcept
7855 f = std::strtod(str, endptr);
7859 static
void strtof(
long double& f, const
char* str,
char** endptr) noexcept
7861 f = std::strtold(str, endptr);
7904 token_type scan_number()
7911 token_type number_type = token_type::value_unsigned;
7919 goto scan_number_minus;
7925 goto scan_number_zero;
7939 goto scan_number_any1;
7949 number_type = token_type::value_integer;
7955 goto scan_number_zero;
7969 goto scan_number_any1;
7974 error_message =
"invalid number; expected digit after '-'";
7975 return token_type::parse_error;
7985 add(decimal_point_char);
7986 goto scan_number_decimal1;
7993 goto scan_number_exponent;
7997 goto scan_number_done;
8016 goto scan_number_any1;
8021 add(decimal_point_char);
8022 goto scan_number_decimal1;
8029 goto scan_number_exponent;
8033 goto scan_number_done;
8036scan_number_decimal1:
8038 number_type = token_type::value_float;
8053 goto scan_number_decimal2;
8058 error_message =
"invalid number; expected digit after '.'";
8059 return token_type::parse_error;
8063scan_number_decimal2:
8079 goto scan_number_decimal2;
8086 goto scan_number_exponent;
8090 goto scan_number_done;
8093scan_number_exponent:
8095 number_type = token_type::value_float;
8102 goto scan_number_sign;
8117 goto scan_number_any2;
8123 "invalid number; expected '+', '-', or digit after exponent";
8124 return token_type::parse_error;
8144 goto scan_number_any2;
8149 error_message =
"invalid number; expected digit after exponent sign";
8150 return token_type::parse_error;
8170 goto scan_number_any2;
8174 goto scan_number_done;
8182 char* endptr =
nullptr;
8186 if (number_type == token_type::value_unsigned)
8188 const auto x = std::strtoull(token_buffer.data(), &endptr, 10);
8191 JSON_ASSERT(endptr == token_buffer.data() + token_buffer.size());
8195 value_unsigned =
static_cast<number_unsigned_t
>(x);
8196 if (value_unsigned == x)
8198 return token_type::value_unsigned;
8202 else if (number_type == token_type::value_integer)
8204 const auto x = std::strtoll(token_buffer.data(), &endptr, 10);
8207 JSON_ASSERT(endptr == token_buffer.data() + token_buffer.size());
8211 value_integer =
static_cast<number_integer_t
>(x);
8212 if (value_integer == x)
8214 return token_type::value_integer;
8221 strtof(value_float, token_buffer.data(), &endptr);
8224 JSON_ASSERT(endptr == token_buffer.data() + token_buffer.size());
8226 return token_type::value_float;
8235 token_type scan_literal(const char_type* literal_text, const std::
size_t length,
8236 token_type return_type)
8238 JSON_ASSERT(std::char_traits<char_type>::to_char_type(current) == literal_text[0]);
8239 for (std::size_t i = 1; i < length; ++i)
8243 error_message =
"invalid literal";
8244 return token_type::parse_error;
8255 void reset() noexcept
8257 token_buffer.clear();
8258 token_string.clear();
8259 token_string.push_back(std::char_traits<char_type>::to_char_type(current));
8274 ++position.chars_read_total;
8275 ++position.chars_read_current_line;
8284 current = ia.get_character();
8289 token_string.push_back(std::char_traits<char_type>::to_char_type(current));
8292 if (current ==
'\n')
8294 ++position.lines_read;
8295 position.chars_read_current_line = 0;
8313 --position.chars_read_total;
8316 if (position.chars_read_current_line == 0)
8318 if (position.lines_read > 0)
8320 --position.lines_read;
8325 --position.chars_read_current_line;
8331 token_string.pop_back();
8336 void add(char_int_type c)
8338 token_buffer.push_back(
static_cast<typename string_t::value_type
>(c));
8349 return value_integer;
8355 return value_unsigned;
8367 return token_buffer;
8387 for (
const auto c : token_string)
8389 if (
static_cast<unsigned char>(c) <=
'\x1F')
8392 std::array<char, 9> cs{{}};
8393 static_cast<void>((std::snprintf)(cs.data(), cs.size(),
"<U+%.4X>",
static_cast<unsigned char>(c)));
8394 result += cs.data();
8399 result.push_back(
static_cast<std::string::value_type
>(c));
8410 return error_message;
8426 return get() == 0xBB &&
get() == 0xBF;
8441 while (current ==
' ' || current ==
'\t' || current ==
'\n' || current ==
'\r');
8447 if (position.chars_read_total == 0 && !
skip_bom())
8449 error_message =
"invalid BOM; must be 0xEF 0xBB 0xBF if given";
8450 return token_type::parse_error;
8457 while (ignore_comments && current ==
'/')
8459 if (!scan_comment())
8461 return token_type::parse_error;
8472 return token_type::begin_array;
8474 return token_type::end_array;
8476 return token_type::begin_object;
8478 return token_type::end_object;
8480 return token_type::name_separator;
8482 return token_type::value_separator;
8487 std::array<char_type, 4> true_literal = {{
static_cast<char_type
>(
't'),
static_cast<char_type
>(
'r'),
static_cast<char_type
>(
'u'),
static_cast<char_type
>(
'e')}};
8488 return scan_literal(true_literal.data(), true_literal.size(), token_type::literal_true);
8492 std::array<char_type, 5> false_literal = {{
static_cast<char_type
>(
'f'),
static_cast<char_type
>(
'a'),
static_cast<char_type
>(
'l'),
static_cast<char_type
>(
's'),
static_cast<char_type
>(
'e')}};
8493 return scan_literal(false_literal.data(), false_literal.size(), token_type::literal_false);
8497 std::array<char_type, 4> null_literal = {{
static_cast<char_type
>(
'n'),
static_cast<char_type
>(
'u'),
static_cast<char_type
>(
'l'),
static_cast<char_type
>(
'l')}};
8498 return scan_literal(null_literal.data(), null_literal.size(), token_type::literal_null);
8503 return scan_string();
8517 return scan_number();
8522 case std::char_traits<char_type>::eof():
8523 return token_type::end_of_input;
8527 error_message =
"invalid literal";
8528 return token_type::parse_error;
8534 InputAdapterType ia;
8537 const bool ignore_comments =
false;
8540 char_int_type current = std::char_traits<char_type>::eof();
8543 bool next_unget =
false;
8549 std::vector<char_type> token_string {};
8555 const char* error_message =
"";
8558 number_integer_t value_integer = 0;
8559 number_unsigned_t value_unsigned = 0;
8560 number_float_t value_float = 0;
8563 const char_int_type decimal_point_char =
'.';
8591 decltype(std::declval<T&>().boolean(std::declval<bool>()));
8593template<
typename T,
typename Integer>
8595 decltype(std::declval<T&>().number_integer(std::declval<Integer>()));
8597template<
typename T,
typename Un
signed>
8599 decltype(std::declval<T&>().number_unsigned(std::declval<Unsigned>()));
8601template<
typename T,
typename Float,
typename String>
8603 std::declval<Float>(), std::declval<const String&>()));
8605template<
typename T,
typename String>
8607 decltype(std::declval<T&>().string(std::declval<String&>()));
8609template<
typename T,
typename Binary>
8611 decltype(std::declval<T&>().binary(std::declval<Binary&>()));
8615 decltype(std::declval<T&>().start_object(std::declval<std::size_t>()));
8617template<
typename T,
typename String>
8619 decltype(std::declval<T&>().key(std::declval<String&>()));
8626 decltype(std::declval<T&>().start_array(std::declval<std::size_t>()));
8631template<
typename T,
typename Exception>
8633 std::declval<std::size_t>(), std::declval<const std::string&>(),
8634 std::declval<const Exception&>()));
8636template<
typename SAX,
typename BasicJsonType>
8641 "BasicJsonType must be of type basic_json<...>");
8643 using number_integer_t =
typename BasicJsonType::number_integer_t;
8644 using number_unsigned_t =
typename BasicJsonType::number_unsigned_t;
8645 using number_float_t =
typename BasicJsonType::number_float_t;
8646 using string_t =
typename BasicJsonType::string_t;
8647 using binary_t =
typename BasicJsonType::binary_t;
8648 using exception_t =
typename BasicJsonType::exception;
8667template<
typename SAX,
typename BasicJsonType>
8672 "BasicJsonType must be of type basic_json<...>");
8674 using number_integer_t =
typename BasicJsonType::number_integer_t;
8675 using number_unsigned_t =
typename BasicJsonType::number_unsigned_t;
8676 using number_float_t =
typename BasicJsonType::number_float_t;
8677 using string_t =
typename BasicJsonType::string_t;
8678 using binary_t =
typename BasicJsonType::binary_t;
8679 using exception_t =
typename BasicJsonType::exception;
8683 "Missing/invalid function: bool null()");
8685 "Missing/invalid function: bool boolean(bool)");
8687 "Missing/invalid function: bool boolean(bool)");
8691 "Missing/invalid function: bool number_integer(number_integer_t)");
8695 "Missing/invalid function: bool number_unsigned(number_unsigned_t)");
8697 number_float_t, string_t>
::value,
8698 "Missing/invalid function: bool number_float(number_float_t, const string_t&)");
8701 "Missing/invalid function: bool string(string_t&)");
8704 "Missing/invalid function: bool binary(binary_t&)");
8706 "Missing/invalid function: bool start_object(std::size_t)");
8708 "Missing/invalid function: bool key(string_t&)");
8710 "Missing/invalid function: bool end_object()");
8712 "Missing/invalid function: bool start_array(std::size_t)");
8714 "Missing/invalid function: bool end_array()");
8717 "Missing/invalid function: bool parse_error(std::size_t, const "
8718 "std::string&, const exception&)");
8750static inline bool little_endianness(
int num = 1) noexcept
8752 return *
reinterpret_cast<char*
>(&num) == 1;
8763template<
typename BasicJsonType,
typename InputAdapterType,
typename SAX = json_sax_dom_parser<BasicJsonType>>
8766 using number_integer_t =
typename BasicJsonType::number_integer_t;
8767 using number_unsigned_t =
typename BasicJsonType::number_unsigned_t;
8768 using number_float_t =
typename BasicJsonType::number_float_t;
8769 using string_t =
typename BasicJsonType::string_t;
8770 using binary_t =
typename BasicJsonType::binary_t;
8771 using json_sax_t = SAX;
8772 using char_type =
typename InputAdapterType::char_type;
8773 using char_int_type =
typename std::char_traits<char_type>::int_type;
8804 const
bool strict = true,
8808 bool result =
false;
8813 result = parse_bson_internal();
8817 result = parse_cbor_internal(
true, tag_handler);
8821 result = parse_msgpack_internal();
8826 result = parse_ubjson_internal();
8848 return sax->parse_error(chars_read, get_token_string(),
parse_error::create(110, chars_read,
8849 exception_message(input_format,
concat(
"expected end of input; last byte: 0x", get_token_string()),
"value"),
nullptr));
8865 bool parse_bson_internal()
8867 std::int32_t document_size{};
8880 return sax->end_object();
8890 bool get_bson_cstr(string_t& result)
8892 auto out = std::back_inserter(result);
8900 if (current == 0x00)
8904 *out++ =
static_cast<typename string_t::value_type
>(current);
8919 template<
typename NumberType>
8920 bool get_bson_string(
const NumberType len, string_t& result)
8924 auto last_token = get_token_string();
8926 exception_message(
input_format_t::bson,
concat(
"string length must be at least 1, is ", std::to_string(len)),
"string"),
nullptr));
8929 return get_string(
input_format_t::bson, len -
static_cast<NumberType
>(1), result) && get() != std::char_traits<char_type>::eof();
8941 template<
typename NumberType>
8942 bool get_bson_binary(
const NumberType len, binary_t& result)
8946 auto last_token = get_token_string();
8948 exception_message(
input_format_t::bson,
concat(
"byte array length cannot be negative, is ", std::to_string(len)),
"binary"),
nullptr));
8952 std::uint8_t subtype{};
8954 result.set_subtype(subtype);
8969 bool parse_bson_element_internal(
const char_int_type element_type,
8970 const std::size_t element_type_parse_position)
8972 switch (element_type)
8977 return get_number<double, true>(
input_format_t::bson, number) && sax->number_float(
static_cast<number_float_t
>(number),
"");
8989 return parse_bson_internal();
8994 return parse_bson_array();
9006 return sax->boolean(get() != 0);
9016 std::int32_t
value{};
9022 std::int64_t
value{};
9028 std::array<char, 3> cr{{}};
9029 static_cast<void>((std::snprintf)(cr.data(), cr.size(),
"%.2hhX",
static_cast<unsigned char>(element_type)));
9030 std::string cr_str{cr.data()};
9031 return sax->parse_error(element_type_parse_position, cr_str,
9049 bool parse_bson_element_list(
const bool is_array)
9053 while (
auto element_type = get())
9060 const std::size_t element_type_parse_position = chars_read;
9066 if (!is_array && !sax->key(
key))
9071 if (
JSON_HEDLEY_UNLIKELY(!parse_bson_element_internal(element_type, element_type_parse_position)))
9087 bool parse_bson_array()
9089 std::int32_t document_size{};
9102 return sax->end_array();
9117 bool parse_cbor_internal(
const bool get_char,
9120 switch (get_char ? get() : current)
9123 case std::char_traits<char_type>::eof():
9151 return sax->number_unsigned(
static_cast<number_unsigned_t
>(current));
9155 std::uint8_t number{};
9161 std::uint16_t number{};
9167 std::uint32_t number{};
9173 std::uint64_t number{};
9202 return sax->number_integer(
static_cast<std::int8_t
>(0x20 - 1 - current));
9206 std::uint8_t number{};
9207 return get_number(
input_format_t::cbor, number) && sax->number_integer(
static_cast<number_integer_t
>(-1) - number);
9212 std::uint16_t number{};
9213 return get_number(
input_format_t::cbor, number) && sax->number_integer(
static_cast<number_integer_t
>(-1) - number);
9218 std::uint32_t number{};
9219 return get_number(
input_format_t::cbor, number) && sax->number_integer(
static_cast<number_integer_t
>(-1) - number);
9224 std::uint64_t number{};
9225 return get_number(
input_format_t::cbor, number) && sax->number_integer(
static_cast<number_integer_t
>(-1)
9226 -
static_cast<number_integer_t
>(number));
9261 return get_cbor_binary(
b) && sax->binary(
b);
9296 return get_cbor_string(s) && sax->string(s);
9324 return get_cbor_array(
9330 return get_number(
input_format_t::cbor, len) && get_cbor_array(
static_cast<std::size_t
>(len), tag_handler);
9335 std::uint16_t len{};
9336 return get_number(
input_format_t::cbor, len) && get_cbor_array(
static_cast<std::size_t
>(len), tag_handler);
9341 std::uint32_t len{};
9347 std::uint64_t len{};
9352 return get_cbor_array(
static_cast<std::size_t
>(-1), tag_handler);
9384 return get_number(
input_format_t::cbor, len) && get_cbor_object(
static_cast<std::size_t
>(len), tag_handler);
9389 std::uint16_t len{};
9390 return get_number(
input_format_t::cbor, len) && get_cbor_object(
static_cast<std::size_t
>(len), tag_handler);
9395 std::uint32_t len{};
9401 std::uint64_t len{};
9406 return get_cbor_object(
static_cast<std::size_t
>(-1), tag_handler);
9428 switch (tag_handler)
9432 auto last_token = get_token_string();
9444 std::uint8_t subtype_to_ignore{};
9450 std::uint16_t subtype_to_ignore{};
9456 std::uint32_t subtype_to_ignore{};
9462 std::uint64_t subtype_to_ignore{};
9469 return parse_cbor_internal(
true, tag_handler);
9480 std::uint8_t subtype{};
9487 std::uint16_t subtype{};
9494 std::uint32_t subtype{};
9501 std::uint64_t subtype{};
9507 return parse_cbor_internal(
true, tag_handler);
9510 return get_cbor_binary(
b) && sax->binary(
b);
9520 return sax->boolean(
false);
9523 return sax->boolean(
true);
9530 const auto byte1_raw = get();
9535 const auto byte2_raw = get();
9541 const auto byte1 =
static_cast<unsigned char>(byte1_raw);
9542 const auto byte2 =
static_cast<unsigned char>(byte2_raw);
9552 const auto half =
static_cast<unsigned int>((byte1 << 8u) + byte2);
9553 const double val = [&half]
9555 const int exp = (half >> 10u) & 0x1Fu;
9556 const unsigned int mant = half & 0x3FFu;
9562 return std::ldexp(mant, -24);
9565 ? std::numeric_limits<double>::infinity()
9566 : std::numeric_limits<double>::quiet_NaN();
9568 return std::ldexp(mant + 1024, exp - 25);
9571 return sax->number_float((half & 0x8000u) != 0
9572 ?
static_cast<number_float_t
>(-val)
9573 :
static_cast<number_float_t
>(val),
"");
9579 return get_number(
input_format_t::cbor, number) && sax->number_float(
static_cast<number_float_t
>(number),
"");
9585 return get_number(
input_format_t::cbor, number) && sax->number_float(
static_cast<number_float_t
>(number),
"");
9590 auto last_token = get_token_string();
9608 bool get_cbor_string(string_t& result)
9654 std::uint16_t len{};
9660 std::uint32_t len{};
9666 std::uint64_t len{};
9672 while (get() != 0xFF)
9675 if (!get_cbor_string(chunk))
9679 result.append(chunk);
9686 auto last_token = get_token_string();
9688 exception_message(
input_format_t::cbor,
concat(
"expected length specification (0x60-0x7B) or indefinite string type (0x7F); last byte: 0x", last_token),
"string"),
nullptr));
9704 bool get_cbor_binary(binary_t& result)
9751 std::uint16_t len{};
9758 std::uint32_t len{};
9765 std::uint64_t len{};
9772 while (get() != 0xFF)
9775 if (!get_cbor_binary(chunk))
9779 result.insert(result.end(), chunk.begin(), chunk.end());
9786 auto last_token = get_token_string();
9788 exception_message(
input_format_t::cbor,
concat(
"expected length specification (0x40-0x5B) or indefinite binary array type (0x5F); last byte: 0x", last_token),
"binary"),
nullptr));
9799 bool get_cbor_array(
const std::size_t len,
9807 if (len !=
static_cast<std::size_t
>(-1))
9809 for (std::size_t i = 0; i < len; ++i)
9819 while (get() != 0xFF)
9828 return sax->end_array();
9837 bool get_cbor_object(
const std::size_t len,
9848 if (len !=
static_cast<std::size_t
>(-1))
9850 for (std::size_t i = 0; i < len; ++i)
9867 while (get() != 0xFF)
9883 return sax->end_object();
9893 bool parse_msgpack_internal()
9898 case std::char_traits<char_type>::eof():
10030 return sax->number_unsigned(
static_cast<number_unsigned_t
>(current));
10108 return get_msgpack_string(s) && sax->string(s);
10112 return sax->null();
10115 return sax->boolean(
false);
10118 return sax->boolean(
true);
10133 return get_msgpack_binary(
b) && sax->binary(
b);
10139 return get_number(
input_format_t::msgpack, number) && sax->number_float(
static_cast<number_float_t
>(number),
"");
10145 return get_number(
input_format_t::msgpack, number) && sax->number_float(
static_cast<number_float_t
>(number),
"");
10150 std::uint8_t number{};
10156 std::uint16_t number{};
10162 std::uint32_t number{};
10168 std::uint64_t number{};
10174 std::int8_t number{};
10180 std::int16_t number{};
10186 std::int32_t number{};
10192 std::int64_t number{};
10198 std::uint16_t len{};
10204 std::uint32_t len{};
10210 std::uint16_t len{};
10216 std::uint32_t len{};
10253 return sax->number_integer(
static_cast<std::int8_t
>(current));
10257 auto last_token = get_token_string();
10274 bool get_msgpack_string(string_t& result)
10322 std::uint8_t len{};
10328 std::uint16_t len{};
10334 std::uint32_t len{};
10340 auto last_token = get_token_string();
10342 exception_message(
input_format_t::msgpack,
concat(
"expected length specification (0xA0-0xBF, 0xD9-0xDB); last byte: 0x", last_token),
"string"),
nullptr));
10357 bool get_msgpack_binary(binary_t& result)
10360 auto assign_and_return_true = [&result](std::int8_t subtype)
10362 result.set_subtype(
static_cast<std::uint8_t
>(subtype));
10370 std::uint8_t len{};
10377 std::uint16_t len{};
10384 std::uint32_t len{};
10391 std::uint8_t len{};
10392 std::int8_t subtype{};
10396 assign_and_return_true(subtype);
10401 std::uint16_t len{};
10402 std::int8_t subtype{};
10406 assign_and_return_true(subtype);
10411 std::uint32_t len{};
10412 std::int8_t subtype{};
10416 assign_and_return_true(subtype);
10421 std::int8_t subtype{};
10424 assign_and_return_true(subtype);
10429 std::int8_t subtype{};
10432 assign_and_return_true(subtype);
10437 std::int8_t subtype{};
10440 assign_and_return_true(subtype);
10445 std::int8_t subtype{};
10448 assign_and_return_true(subtype);
10453 std::int8_t subtype{};
10456 assign_and_return_true(subtype);
10468 bool get_msgpack_array(
const std::size_t len)
10475 for (std::size_t i = 0; i < len; ++i)
10483 return sax->end_array();
10490 bool get_msgpack_object(
const std::size_t len)
10498 for (std::size_t i = 0; i < len; ++i)
10513 return sax->end_object();
10527 bool parse_ubjson_internal(
const bool get_char =
true)
10529 return get_ubjson_value(get_char ? get_ignore_noop() : current);
10546 bool get_ubjson_string(string_t& result,
const bool get_char =
true)
10562 std::uint8_t len{};
10563 return get_number(input_format, len) && get_string(input_format, len, result);
10569 return get_number(input_format, len) && get_string(input_format, len, result);
10574 std::int16_t len{};
10575 return get_number(input_format, len) && get_string(input_format, len, result);
10580 std::int32_t len{};
10581 return get_number(input_format, len) && get_string(input_format, len, result);
10586 std::int64_t len{};
10587 return get_number(input_format, len) && get_string(input_format, len, result);
10596 std::uint16_t len{};
10597 return get_number(input_format, len) && get_string(input_format, len, result);
10606 std::uint32_t len{};
10607 return get_number(input_format, len) && get_string(input_format, len, result);
10616 std::uint64_t len{};
10617 return get_number(input_format, len) && get_string(input_format, len, result);
10623 auto last_token = get_token_string();
10624 std::string message;
10628 message =
"expected length type specification (U, i, I, l, L); last byte: 0x" + last_token;
10632 message =
"expected length type specification (U, i, u, I, m, l, M, L); last byte: 0x" + last_token;
10634 return sax->parse_error(chars_read, last_token,
parse_error::create(113, chars_read, exception_message(input_format, message,
"string"),
nullptr));
10641 bool get_ubjson_ndarray_size(std::vector<size_t>& dim)
10643 std::pair<std::size_t, char_int_type> size_and_type;
10645 bool no_ndarray =
true;
10652 if (size_and_type.first != string_t::npos)
10654 if (size_and_type.second != 0)
10656 if (size_and_type.second !=
'N')
10658 for (std::size_t i = 0; i < size_and_type.first; ++i)
10664 dim.push_back(dimlen);
10670 for (std::size_t i = 0; i < size_and_type.first; ++i)
10676 dim.push_back(dimlen);
10682 while (current !=
']')
10688 dim.push_back(dimlen);
10706 bool get_ubjson_size_value(std::size_t& result,
bool& is_ndarray, char_int_type prefix = 0)
10710 prefix = get_ignore_noop();
10717 std::uint8_t number{};
10722 result =
static_cast<std::size_t
>(number);
10728 std::int8_t number{};
10735 return sax->parse_error(chars_read, get_token_string(),
parse_error::create(113, chars_read,
10736 exception_message(input_format,
"count in an optimized container must be positive",
"size"),
nullptr));
10738 result =
static_cast<std::size_t
>(number);
10744 std::int16_t number{};
10751 return sax->parse_error(chars_read, get_token_string(),
parse_error::create(113, chars_read,
10752 exception_message(input_format,
"count in an optimized container must be positive",
"size"),
nullptr));
10754 result =
static_cast<std::size_t
>(number);
10760 std::int32_t number{};
10767 return sax->parse_error(chars_read, get_token_string(),
parse_error::create(113, chars_read,
10768 exception_message(input_format,
"count in an optimized container must be positive",
"size"),
nullptr));
10770 result =
static_cast<std::size_t
>(number);
10776 std::int64_t number{};
10783 return sax->parse_error(chars_read, get_token_string(),
parse_error::create(113, chars_read,
10784 exception_message(input_format,
"count in an optimized container must be positive",
"size"),
nullptr));
10789 exception_message(input_format,
"integer value overflow",
"size"),
nullptr));
10791 result =
static_cast<std::size_t
>(number);
10801 std::uint16_t number{};
10806 result =
static_cast<std::size_t
>(number);
10816 std::uint32_t number{};
10831 std::uint64_t number{};
10839 exception_message(input_format,
"integer value overflow",
"size"),
nullptr));
10853 return sax->parse_error(chars_read, get_token_string(),
parse_error::create(113, chars_read, exception_message(input_format,
"ndarray dimensional vector is not allowed",
"size"),
nullptr));
10855 std::vector<size_t> dim;
10860 if (dim.size() == 1 || (dim.size() == 2 && dim.at(0) == 1))
10862 result = dim.at(dim.size() - 1);
10876 string_t
key =
"_ArraySize_";
10885 if (result == 0 || result == string_t::npos)
10887 return sax->parse_error(chars_read, get_token_string(),
out_of_range::create(408, exception_message(input_format,
"excessive ndarray size caused overflow",
"size"),
nullptr));
10895 return sax->end_array();
10904 auto last_token = get_token_string();
10905 std::string message;
10909 message =
"expected length type specification (U, i, I, l, L) after '#'; last byte: 0x" + last_token;
10913 message =
"expected length type specification (U, i, u, I, m, l, M, L) after '#'; last byte: 0x" + last_token;
10915 return sax->parse_error(chars_read, last_token,
parse_error::create(113, chars_read, exception_message(input_format, message,
"size"),
nullptr));
10929 bool get_ubjson_size_type(std::pair<std::size_t, char_int_type>& result,
bool inside_ndarray =
false)
10931 result.first = string_t::npos;
10933 bool is_ndarray =
false;
10937 if (current ==
'$')
10939 std::vector<char_int_type> bjdx = {
'[',
'{',
'S',
'H',
'T',
'F',
'N',
'Z'};
10941 result.second = get();
10944 auto last_token = get_token_string();
10946 exception_message(input_format,
concat(
"marker 0x", last_token,
" is not a permitted optimized array type"),
"type"),
nullptr));
10961 auto last_token = get_token_string();
10963 exception_message(input_format,
concat(
"expected '#' after type information; last byte: 0x", last_token),
"size"),
nullptr));
10966 bool is_error = get_ubjson_size_value(result.first, is_ndarray);
10969 if (inside_ndarray)
10971 return sax->parse_error(chars_read, get_token_string(),
parse_error::create(112, chars_read,
10972 exception_message(input_format,
"ndarray can not be recursive",
"size"),
nullptr));
10974 result.second |= (1 << 8);
10979 if (current ==
'#')
10981 bool is_error = get_ubjson_size_value(result.first, is_ndarray);
10984 return sax->parse_error(chars_read, get_token_string(),
parse_error::create(112, chars_read,
10985 exception_message(input_format,
"ndarray requires both type and size",
"size"),
nullptr));
10997 bool get_ubjson_value(
const char_int_type prefix)
11001 case std::char_traits<char_type>::eof():
11002 return unexpect_eof(input_format,
"value");
11005 return sax->boolean(
true);
11007 return sax->boolean(
false);
11010 return sax->null();
11014 std::uint8_t number{};
11015 return get_number(input_format, number) && sax->number_unsigned(number);
11020 std::int8_t number{};
11021 return get_number(input_format, number) && sax->number_integer(number);
11026 std::int16_t number{};
11027 return get_number(input_format, number) && sax->number_integer(number);
11032 std::int32_t number{};
11033 return get_number(input_format, number) && sax->number_integer(number);
11038 std::int64_t number{};
11039 return get_number(input_format, number) && sax->number_integer(number);
11048 std::uint16_t number{};
11049 return get_number(input_format, number) && sax->number_unsigned(number);
11058 std::uint32_t number{};
11059 return get_number(input_format, number) && sax->number_unsigned(number);
11068 std::uint64_t number{};
11069 return get_number(input_format, number) && sax->number_unsigned(number);
11078 const auto byte1_raw = get();
11083 const auto byte2_raw = get();
11089 const auto byte1 =
static_cast<unsigned char>(byte1_raw);
11090 const auto byte2 =
static_cast<unsigned char>(byte2_raw);
11100 const auto half =
static_cast<unsigned int>((byte2 << 8u) + byte1);
11101 const double val = [&half]
11103 const int exp = (half >> 10u) & 0x1Fu;
11104 const unsigned int mant = half & 0x3FFu;
11110 return std::ldexp(mant, -24);
11113 ? std::numeric_limits<double>::infinity()
11114 : std::numeric_limits<double>::quiet_NaN();
11116 return std::ldexp(mant + 1024, exp - 25);
11119 return sax->number_float((half & 0x8000u) != 0
11120 ?
static_cast<number_float_t
>(-val)
11121 :
static_cast<number_float_t
>(val),
"");
11127 return get_number(input_format, number) && sax->number_float(
static_cast<number_float_t
>(number),
"");
11133 return get_number(input_format, number) && sax->number_float(
static_cast<number_float_t
>(number),
"");
11138 return get_ubjson_high_precision_number();
11150 auto last_token = get_token_string();
11152 exception_message(input_format,
concat(
"byte after 'C' must be in range 0x00..0x7F; last byte: 0x", last_token),
"char"),
nullptr));
11154 string_t s(1,
static_cast<typename string_t::value_type
>(current));
11155 return sax->string(s);
11161 return get_ubjson_string(s) && sax->string(s);
11165 return get_ubjson_array();
11168 return get_ubjson_object();
11173 auto last_token = get_token_string();
11174 return sax->parse_error(chars_read, last_token,
parse_error::create(112, chars_read, exception_message(input_format,
"invalid byte: 0x" + last_token,
"value"),
nullptr));
11180 bool get_ubjson_array()
11182 std::pair<std::size_t, char_int_type> size_and_type;
11191 if (input_format ==
input_format_t::bjdata && size_and_type.first != string_t::npos && (size_and_type.second & (1 << 8)) != 0)
11193 std::map<char_int_type, string_t> bjdtype = {{
'U',
"uint8"}, {
'i',
"int8"}, {
'u',
"uint16"}, {
'I',
"int16"},
11194 {
'm',
"uint32"}, {
'l',
"int32"}, {
'M',
"uint64"}, {
'L',
"int64"}, {
'd',
"single"}, {
'D',
"double"}, {
'C',
"char"}
11197 size_and_type.second &= ~(
static_cast<char_int_type
>(1) << 8);
11199 string_t
key =
"_ArrayType_";
11202 auto last_token = get_token_string();
11204 exception_message(input_format,
"invalid byte: 0x" + last_token,
"type"),
nullptr));
11212 if (size_and_type.second ==
'C')
11214 size_and_type.second =
'U';
11217 key =
"_ArrayData_";
11223 for (std::size_t i = 0; i < size_and_type.first; ++i)
11231 return (sax->end_array() && sax->end_object());
11234 if (size_and_type.first != string_t::npos)
11241 if (size_and_type.second != 0)
11243 if (size_and_type.second !=
'N')
11245 for (std::size_t i = 0; i < size_and_type.first; ++i)
11256 for (std::size_t i = 0; i < size_and_type.first; ++i)
11272 while (current !=
']')
11282 return sax->end_array();
11288 bool get_ubjson_object()
11290 std::pair<std::size_t, char_int_type> size_and_type;
11297 if (input_format ==
input_format_t::bjdata && size_and_type.first != string_t::npos && (size_and_type.second & (1 << 8)) != 0)
11299 auto last_token = get_token_string();
11301 exception_message(input_format,
"BJData object does not support ND-array size in optimized format",
"object"),
nullptr));
11305 if (size_and_type.first != string_t::npos)
11312 if (size_and_type.second != 0)
11314 for (std::size_t i = 0; i < size_and_type.first; ++i)
11329 for (std::size_t i = 0; i < size_and_type.first; ++i)
11350 while (current !=
'}')
11365 return sax->end_object();
11371 bool get_ubjson_high_precision_number()
11374 std::size_t size{};
11375 bool no_ndarray =
true;
11376 auto res = get_ubjson_size_value(size, no_ndarray);
11383 std::vector<char> number_vector;
11384 for (std::size_t i = 0; i < size; ++i)
11391 number_vector.push_back(
static_cast<char>(current));
11396 auto number_lexer = detail::lexer<BasicJsonType, ia_type>(
detail::input_adapter(number_vector),
false);
11397 const auto result_number = number_lexer.scan();
11398 const auto number_string = number_lexer.get_token_string();
11399 const auto result_remainder = number_lexer.scan();
11406 exception_message(input_format,
concat(
"invalid number text: ", number_lexer.get_token_string()),
"high-precision number"),
nullptr));
11409 switch (result_number)
11411 case token_type::value_integer:
11412 return sax->number_integer(number_lexer.get_number_integer());
11413 case token_type::value_unsigned:
11414 return sax->number_unsigned(number_lexer.get_number_unsigned());
11415 case token_type::value_float:
11416 return sax->number_float(number_lexer.get_number_float(), std::move(number_string));
11417 case token_type::uninitialized:
11418 case token_type::literal_true:
11419 case token_type::literal_false:
11420 case token_type::literal_null:
11421 case token_type::value_string:
11422 case token_type::begin_array:
11423 case token_type::begin_object:
11424 case token_type::end_array:
11425 case token_type::end_object:
11426 case token_type::name_separator:
11427 case token_type::value_separator:
11428 case token_type::parse_error:
11429 case token_type::end_of_input:
11430 case token_type::literal_or_value:
11433 exception_message(input_format,
concat(
"invalid number text: ", number_lexer.get_token_string()),
"high-precision number"),
nullptr));
11450 char_int_type get()
11453 return current = ia.get_character();
11459 char_int_type get_ignore_noop()
11465 while (current ==
'N');
11485 template<
typename NumberType,
bool InputIsLittleEndian = false>
11486 bool get_number(
const input_format_t format, NumberType& result)
11489 std::array<std::uint8_t,
sizeof(NumberType)> vec{};
11490 for (std::size_t i = 0; i <
sizeof(NumberType); ++i)
11501 vec[
sizeof(NumberType) - i - 1] =
static_cast<std::uint8_t
>(current);
11505 vec[i] =
static_cast<std::uint8_t
>(current);
11510 std::memcpy(&result, vec.data(),
sizeof(NumberType));
11528 template<
typename NumberType>
11530 const NumberType len,
11533 bool success =
true;
11534 for (NumberType i = 0; i < len; i++)
11542 result.push_back(
static_cast<typename string_t::value_type
>(current));
11561 template<
typename NumberType>
11563 const NumberType len,
11566 bool success =
true;
11567 for (NumberType i = 0; i < len; i++)
11575 result.push_back(
static_cast<std::uint8_t
>(current));
11586 bool unexpect_eof(const
input_format_t format, const
char* context)
const
11590 return sax->parse_error(chars_read,
"<end of file>",
11591 parse_error::create(110, chars_read, exception_message(format,
"unexpected end of input", context),
nullptr));
11599 std::string get_token_string()
const
11601 std::array<char, 3> cr{{}};
11602 static_cast<void>((std::snprintf)(cr.data(), cr.size(),
"%.2hhX",
static_cast<unsigned char>(current)));
11603 return std::string{cr.data()};
11613 const std::string& detail,
11614 const std::string& context)
const
11616 std::string error_msg =
"syntax error while parsing ";
11621 error_msg +=
"CBOR";
11625 error_msg +=
"MessagePack";
11629 error_msg +=
"UBJSON";
11633 error_msg +=
"BSON";
11637 error_msg +=
"BJData";
11645 return concat(error_msg,
' ', context,
": ", detail);
11650 InputAdapterType ia;
11653 char_int_type current = std::char_traits<char_type>::eof();
11656 std::size_t chars_read = 0;
11659 const bool is_little_endian = little_endianness();
11665 json_sax_t* sax =
nullptr;
11679#include <functional>
11725template<
typename BasicJsonType>
11727 std::function<bool(
int ,
parse_event_t , BasicJsonType& )>;
11734template<
typename BasicJsonType,
typename InputAdapterType>
11737 using number_integer_t =
typename BasicJsonType::number_integer_t;
11738 using number_unsigned_t =
typename BasicJsonType::number_unsigned_t;
11739 using number_float_t =
typename BasicJsonType::number_float_t;
11740 using string_t =
typename BasicJsonType::string_t;
11748 const bool allow_exceptions_ =
true,
11749 const bool skip_comments =
false)
11751 , m_lexer(
std::move(adapter), skip_comments)
11752 , allow_exceptions(allow_exceptions_)
11773 sax_parse_internal(&sdp);
11776 if (
strict && (get_token() != token_type::end_of_input))
11779 m_lexer.get_token_string(),
11781 exception_message(token_type::end_of_input,
"value"),
nullptr));
11793 if (result.is_discarded())
11801 sax_parse_internal(&sdp);
11804 if (
strict && (get_token() != token_type::end_of_input))
11807 m_lexer.get_token_string(),
11808 parse_error::create(101, m_lexer.get_position(), exception_message(token_type::end_of_input,
"value"),
nullptr));
11819 result.assert_invariant();
11834 template<
typename SAX>
11839 const bool result = sax_parse_internal(sax);
11842 if (result &&
strict && (get_token() != token_type::end_of_input))
11844 return sax->parse_error(m_lexer.get_position(),
11845 m_lexer.get_token_string(),
11846 parse_error::create(101, m_lexer.get_position(), exception_message(token_type::end_of_input,
"value"),
nullptr));
11853 template<
typename SAX>
11855 bool sax_parse_internal(SAX* sax)
11859 std::vector<bool> states;
11861 bool skip_to_state_evaluation =
false;
11865 if (!skip_to_state_evaluation)
11868 switch (last_token)
11870 case token_type::begin_object:
11878 if (get_token() == token_type::end_object)
11890 return sax->parse_error(m_lexer.get_position(),
11891 m_lexer.get_token_string(),
11892 parse_error::create(101, m_lexer.get_position(), exception_message(token_type::value_string,
"object key"),
nullptr));
11902 return sax->parse_error(m_lexer.get_position(),
11903 m_lexer.get_token_string(),
11904 parse_error::create(101, m_lexer.get_position(), exception_message(token_type::name_separator,
"object separator"),
nullptr));
11908 states.push_back(
false);
11915 case token_type::begin_array:
11923 if (get_token() == token_type::end_array)
11933 states.push_back(
true);
11939 case token_type::value_float:
11941 const auto res = m_lexer.get_number_float();
11945 return sax->parse_error(m_lexer.get_position(),
11946 m_lexer.get_token_string(),
11958 case token_type::literal_false:
11967 case token_type::literal_null:
11976 case token_type::literal_true:
11985 case token_type::value_integer:
11994 case token_type::value_string:
12003 case token_type::value_unsigned:
12012 case token_type::parse_error:
12015 return sax->parse_error(m_lexer.get_position(),
12016 m_lexer.get_token_string(),
12017 parse_error::create(101, m_lexer.get_position(), exception_message(token_type::uninitialized,
"value"),
nullptr));
12020 case token_type::uninitialized:
12021 case token_type::end_array:
12022 case token_type::end_object:
12023 case token_type::name_separator:
12024 case token_type::value_separator:
12025 case token_type::end_of_input:
12026 case token_type::literal_or_value:
12029 return sax->parse_error(m_lexer.get_position(),
12030 m_lexer.get_token_string(),
12031 parse_error::create(101, m_lexer.get_position(), exception_message(token_type::literal_or_value,
"value"),
nullptr));
12037 skip_to_state_evaluation =
false;
12041 if (states.empty())
12050 if (get_token() == token_type::value_separator)
12071 skip_to_state_evaluation =
true;
12075 return sax->parse_error(m_lexer.get_position(),
12076 m_lexer.get_token_string(),
12077 parse_error::create(101, m_lexer.get_position(), exception_message(token_type::end_array,
"array"),
nullptr));
12083 if (get_token() == token_type::value_separator)
12088 return sax->parse_error(m_lexer.get_position(),
12089 m_lexer.get_token_string(),
12090 parse_error::create(101, m_lexer.get_position(), exception_message(token_type::value_string,
"object key"),
nullptr));
12101 return sax->parse_error(m_lexer.get_position(),
12102 m_lexer.get_token_string(),
12103 parse_error::create(101, m_lexer.get_position(), exception_message(token_type::name_separator,
"object separator"),
nullptr));
12125 skip_to_state_evaluation =
true;
12129 return sax->parse_error(m_lexer.get_position(),
12130 m_lexer.get_token_string(),
12131 parse_error::create(101, m_lexer.get_position(), exception_message(token_type::end_object,
"object"),
nullptr));
12136 token_type get_token()
12138 return last_token = m_lexer.scan();
12141 std::string exception_message(
const token_type expected,
const std::string& context)
12143 std::string error_msg =
"syntax error ";
12145 if (!context.empty())
12147 error_msg +=
concat(
"while parsing ", context,
' ');
12152 if (last_token == token_type::parse_error)
12154 error_msg +=
concat(m_lexer.get_error_message(),
"; last read: '",
12155 m_lexer.get_token_string(),
'\'');
12162 if (expected != token_type::uninitialized)
12174 token_type last_token = token_type::uninitialized;
12178 const bool allow_exceptions =
true;
12212 using difference_type = std::ptrdiff_t;
12213 static constexpr difference_type begin_value = 0;
12214 static constexpr difference_type end_value = begin_value + 1;
12218 difference_type m_it = (std::numeric_limits<std::ptrdiff_t>::min)();
12229 m_it = begin_value;
12241 return m_it == begin_value;
12247 return m_it == end_value;
12252 return lhs.m_it ==
rhs.m_it;
12257 return lhs.m_it <
rhs.m_it;
12262 auto result = *
this;
12269 return lhs.m_it -
rhs.m_it;
12280 auto result = *
this;
12293 auto result = *
this;
12340#include <type_traits>
12381template<
typename BasicJsonType>
12387 friend other_iter_impl;
12388 friend BasicJsonType;
12392 using object_t =
typename BasicJsonType::object_t;
12393 using array_t =
typename BasicJsonType::array_t;
12396 "iter_impl only accepts (const) basic_json");
12398 static_assert(std::is_base_of<std::bidirectional_iterator_tag, std::bidirectional_iterator_tag>::value
12399 && std::is_base_of<std::bidirectional_iterator_tag, typename std::iterator_traits<typename array_t::iterator>::iterator_category>
::value,
12400 "basic_json iterator assumes array and object type iterators satisfy the LegacyBidirectionalIterator named requirement.");
12408 using iterator_category = std::bidirectional_iterator_tag;
12415 using pointer =
typename std::conditional<std::is_const<BasicJsonType>::value,
12416 typename BasicJsonType::const_pointer,
12417 typename BasicJsonType::pointer>
::type;
12420 typename std::conditional<std::is_const<BasicJsonType>::value,
12421 typename BasicJsonType::const_reference,
12422 typename BasicJsonType::reference>
::type;
12439 switch (m_object->m_type)
12443 m_it.object_iterator =
typename object_t::iterator();
12449 m_it.array_iterator =
typename array_t::iterator();
12486 : m_object(other.m_object),
m_it(other.m_it)
12497 if (&other !=
this)
12499 m_object = other.m_object;
12511 : m_object(other.m_object),
m_it(other.m_it)
12522 m_object = other.m_object;
12532 void set_begin() noexcept
12536 switch (m_object->m_type)
12540 m_it.object_iterator = m_object->m_value.object->begin();
12546 m_it.array_iterator = m_object->m_value.array->begin();
12553 m_it.primitive_iterator.set_end();
12566 m_it.primitive_iterator.set_begin();
12580 switch (m_object->m_type)
12584 m_it.object_iterator = m_object->m_value.object->end();
12590 m_it.array_iterator = m_object->m_value.array->end();
12604 m_it.primitive_iterator.set_end();
12619 switch (m_object->m_type)
12623 JSON_ASSERT(
m_it.object_iterator != m_object->m_value.object->end());
12624 return m_it.object_iterator->second;
12630 return *
m_it.array_iterator;
12663 switch (m_object->m_type)
12667 JSON_ASSERT(
m_it.object_iterator != m_object->m_value.object->end());
12668 return &(
m_it.object_iterator->second);
12674 return &*
m_it.array_iterator;
12703 auto result = *
this;
12716 switch (m_object->m_type)
12720 std::advance(
m_it.object_iterator, 1);
12726 std::advance(
m_it.array_iterator, 1);
12740 ++
m_it.primitive_iterator;
12754 auto result = *
this;
12767 switch (m_object->m_type)
12771 std::advance(
m_it.object_iterator, -1);
12777 std::advance(
m_it.array_iterator, -1);
12791 --
m_it.primitive_iterator;
12803 template <
typename IterImpl, detail::enable_if_t < (std::is_same<IterImpl, iter_impl>::value || std::is_same<IterImpl, other_iter_impl>::value), std::
nullptr_t > =
nullptr >
12814 switch (m_object->m_type)
12817 return (
m_it.object_iterator == other.m_it.object_iterator);
12820 return (
m_it.array_iterator == other.m_it.array_iterator);
12831 return (
m_it.primitive_iterator == other.m_it.primitive_iterator);
12839 template <
typename IterImpl, detail::enable_if_t < (std::is_same<IterImpl, iter_impl>::value || std::is_same<IterImpl, other_iter_impl>::value), std::
nullptr_t > =
nullptr >
12859 switch (m_object->m_type)
12865 return (
m_it.array_iterator < other.
m_it.array_iterator);
12876 return (
m_it.primitive_iterator < other.
m_it.primitive_iterator);
12886 return !other.operator < (*this);
12915 switch (m_object->m_type)
12922 std::advance(
m_it.array_iterator, i);
12936 m_it.primitive_iterator += i;
12959 auto result = *
this;
12981 auto result = *
this;
12994 switch (m_object->m_type)
13000 return m_it.array_iterator - other.
m_it.array_iterator;
13011 return m_it.primitive_iterator - other.
m_it.primitive_iterator;
13023 switch (m_object->m_type)
13029 return *std::next(
m_it.array_iterator,
n);
13057 const typename object_t::key_type&
key()
const
13063 return m_it.object_iterator->first;
13080 pointer m_object =
nullptr;
13122template<
typename Base>
13196 auto it = --this->base();
13203 auto it = --this->base();
13204 return it.operator * ();
13215#include <algorithm>
13241template<
typename RefStringType>
13251 template<
typename T>
13270 : reference_tokens(split(s))
13277 return std::accumulate(reference_tokens.begin(), reference_tokens.end(),
13281 return detail::concat(a,
'/', detail::escape(b));
13289 return to_string();
13296 reference_tokens.insert(reference_tokens.end(),
13297 ptr.reference_tokens.begin(),
13298 ptr.reference_tokens.end());
13306 push_back(std::move(
token));
13314 return *
this /= std::to_string(
array_idx);
13362 reference_tokens.pop_back();
13374 return reference_tokens.back();
13381 reference_tokens.push_back(
token);
13388 reference_tokens.push_back(std::move(
token));
13393 bool empty() const noexcept
13395 return reference_tokens.empty();
13409 template<
typename BasicJsonType>
13410 static typename BasicJsonType::size_type array_index(
const string_t& s)
13412 using size_type =
typename BasicJsonType::size_type;
13426 const char* p = s.c_str();
13427 char* p_end =
nullptr;
13429 unsigned long long res = std::strtoull(p, &p_end, 10);
13439 if (
res >=
static_cast<unsigned long long>((std::numeric_limits<size_type>::max)()))
13456 result.reference_tokens = {reference_tokens[0]};
13469 template<
typename BasicJsonType>
13470 BasicJsonType& get_and_create(BasicJsonType& j)
const
13476 for (
const auto& reference_token : reference_tokens)
13478 switch (result->type())
13482 if (reference_token ==
"0")
13485 result = &result->operator[](0);
13490 result = &result->operator[](reference_token);
13498 result = &result->operator[](reference_token);
13505 result = &result->operator[](array_index<BasicJsonType>(reference_token));
13549 template<
typename BasicJsonType>
13550 BasicJsonType& get_unchecked(BasicJsonType* ptr)
const
13552 for (
const auto& reference_token : reference_tokens)
13555 if (ptr->is_null())
13559 std::all_of(reference_token.begin(), reference_token.end(),
13560 [](
const unsigned char x)
13562 return std::isdigit(x);
13566 *ptr = (nums || reference_token ==
"-")
13571 switch (ptr->type())
13576 ptr = &ptr->operator[](reference_token);
13582 if (reference_token ==
"-")
13585 ptr = &ptr->operator[](ptr->m_value.array->size());
13590 ptr = &ptr->operator[](array_index<BasicJsonType>(reference_token));
13617 template<
typename BasicJsonType>
13618 BasicJsonType& get_checked(BasicJsonType* ptr)
const
13620 for (
const auto& reference_token : reference_tokens)
13622 switch (ptr->type())
13627 ptr = &ptr->at(reference_token);
13637 "array index '-' (", std::to_string(ptr->m_value.array->size()),
13638 ") is out of range"), ptr));
13642 ptr = &ptr->at(array_index<BasicJsonType>(reference_token));
13675 template<
typename BasicJsonType>
13676 const BasicJsonType& get_unchecked(
const BasicJsonType* ptr)
const
13678 for (
const auto& reference_token : reference_tokens)
13680 switch (ptr->type())
13685 ptr = &ptr->operator[](reference_token);
13698 ptr = &ptr->operator[](array_index<BasicJsonType>(reference_token));
13724 template<
typename BasicJsonType>
13725 const BasicJsonType& get_checked(
const BasicJsonType* ptr)
const
13727 for (
const auto& reference_token : reference_tokens)
13729 switch (ptr->type())
13734 ptr = &ptr->at(reference_token);
13744 "array index '-' (", std::to_string(ptr->m_value.array->size()),
13745 ") is out of range"), ptr));
13749 ptr = &ptr->at(array_index<BasicJsonType>(reference_token));
13773 template<
typename BasicJsonType>
13774 bool contains(
const BasicJsonType* ptr)
const
13776 for (
const auto& reference_token : reference_tokens)
13778 switch (ptr->type())
13782 if (!ptr->contains(reference_token))
13788 ptr = &ptr->operator[](reference_token);
13799 if (
JSON_HEDLEY_UNLIKELY(reference_token.size() == 1 && !(
"0" <= reference_token && reference_token <=
"9")))
13811 for (std::size_t i = 1; i < reference_token.size(); i++)
13821 const auto idx = array_index<BasicJsonType>(reference_token);
13822 if (idx >= ptr->size())
13828 ptr = &ptr->operator[](idx);
13862 static std::vector<string_t>
split(
const string_t& reference_string)
13864 std::vector<string_t> result;
13867 if (reference_string.empty())
13883 std::size_t slash = reference_string.find_first_of(
'/', 1),
13890 start = (slash == string_t::npos) ? 0 : slash + 1,
13892 slash = reference_string.find_first_of(
'/', start))
13896 auto reference_token = reference_string.substr(start, slash - start);
13899 for (std::size_t pos = reference_token.find_first_of(
'~');
13900 pos != string_t::npos;
13901 pos = reference_token.find_first_of(
'~', pos + 1))
13907 (reference_token[pos + 1] !=
'0' &&
13908 reference_token[pos + 1] !=
'1')))
13915 detail::unescape(reference_token);
13916 result.push_back(reference_token);
13930 template<
typename BasicJsonType>
13931 static void flatten(
const string_t& reference_string,
13932 const BasicJsonType& value,
13933 BasicJsonType& result)
13935 switch (
value.type())
13939 if (
value.m_value.array->empty())
13942 result[reference_string] =
nullptr;
13947 for (std::size_t i = 0; i <
value.m_value.array->size(); ++i)
13949 flatten(
detail::concat(reference_string,
'/', std::to_string(i)),
13950 value.m_value.array->operator[](i), result);
13958 if (
value.m_value.object->empty())
13961 result[reference_string] =
nullptr;
13966 for (
const auto& element : *
value.m_value.object)
13985 result[reference_string] =
value;
14001 template<
typename BasicJsonType>
14002 static BasicJsonType
14003 unflatten(
const BasicJsonType& value)
14010 BasicJsonType result;
14013 for (
const auto& element : *
value.m_value.object)
14024 json_pointer(element.first).get_and_create(result) = element.second;
14034 result.reference_tokens = reference_tokens;
14041 result.reference_tokens = std::move(reference_tokens);
14056 template<
typename RefStringTypeLhs,
typename RefStringTypeRhs>
14072 template<
typename RefStringTypeLhs,
typename RefStringTypeRhs>
14078 std::vector<string_t> reference_tokens;
14082template<
typename RefStringTypeLhs,
typename RefStringTypeRhs>
14086 return lhs.reference_tokens ==
rhs.reference_tokens;
14089template<
typename RefStringTypeLhs,
typename RefStringTypeRhs>
14093 return !(lhs ==
rhs);
14100#include <initializer_list>
14110template<
typename BasicJsonType>
14121 : value_ref(&
value)
14125 : owned_value(
init)
14132 : owned_value(
std::forward<Args>(args)...)
14144 if (value_ref ==
nullptr)
14146 return std::move(owned_value);
14153 return value_ref ? *value_ref : owned_value;
14181#include <algorithm>
14199#include <algorithm>
14233template<typename CharType>
14237template<typename CharType, typename AllocatorType =
std::allocator<CharType>>
14253 v.insert(v.end(), s, s + length);
14257 std::vector<CharType, AllocatorType>& v;
14262template<
typename CharType>
14278 stream.write(s,
static_cast<std::streamsize
>(length));
14282 std::basic_ostream<CharType>& stream;
14287template<
typename CharType,
typename StringType = std::basic_
string<CharType>>
14303 str.append(s, length);
14310template<
typename CharType,
typename StringType = std::basic_
string<CharType>>
14314 template<
typename AllocatorType = std::allocator<CharType>>
14351template<
typename BasicJsonType,
typename CharType>
14354 using string_t =
typename BasicJsonType::string_t;
14355 using binary_t =
typename BasicJsonType::binary_t;
14356 using number_float_t =
typename BasicJsonType::number_float_t;
14379 write_bson_object(*j.m_value.object);
14414 oa->write_character(j.m_value.boolean
14422 if (j.m_value.number_integer >= 0)
14427 if (j.m_value.number_integer <= 0x17)
14429 write_number(
static_cast<std::uint8_t
>(j.m_value.number_integer));
14431 else if (j.m_value.number_integer <= (std::numeric_limits<std::uint8_t>::max)())
14434 write_number(
static_cast<std::uint8_t
>(j.m_value.number_integer));
14436 else if (j.m_value.number_integer <= (std::numeric_limits<std::uint16_t>::max)())
14439 write_number(
static_cast<std::uint16_t
>(j.m_value.number_integer));
14441 else if (j.m_value.number_integer <= (std::numeric_limits<std::uint32_t>::max)())
14444 write_number(
static_cast<std::uint32_t
>(j.m_value.number_integer));
14449 write_number(
static_cast<std::uint64_t
>(j.m_value.number_integer));
14456 const auto positive_number = -1 - j.m_value.number_integer;
14457 if (j.m_value.number_integer >= -24)
14459 write_number(
static_cast<std::uint8_t
>(0x20 + positive_number));
14461 else if (positive_number <= (std::numeric_limits<std::uint8_t>::max)())
14464 write_number(
static_cast<std::uint8_t
>(positive_number));
14466 else if (positive_number <= (std::numeric_limits<std::uint16_t>::max)())
14469 write_number(
static_cast<std::uint16_t
>(positive_number));
14471 else if (positive_number <= (std::numeric_limits<std::uint32_t>::max)())
14474 write_number(
static_cast<std::uint32_t
>(positive_number));
14479 write_number(
static_cast<std::uint64_t
>(positive_number));
14487 if (j.m_value.number_unsigned <= 0x17)
14489 write_number(
static_cast<std::uint8_t
>(j.m_value.number_unsigned));
14491 else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint8_t>::max)())
14494 write_number(
static_cast<std::uint8_t
>(j.m_value.number_unsigned));
14496 else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint16_t>::max)())
14499 write_number(
static_cast<std::uint16_t
>(j.m_value.number_unsigned));
14501 else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint32_t>::max)())
14504 write_number(
static_cast<std::uint32_t
>(j.m_value.number_unsigned));
14509 write_number(
static_cast<std::uint64_t
>(j.m_value.number_unsigned));
14516 if (std::isnan(j.m_value.number_float))
14523 else if (std::isinf(j.m_value.number_float))
14540 const auto N = j.m_value.string->size();
14543 write_number(
static_cast<std::uint8_t
>(0x60 + N));
14545 else if (N <= (std::numeric_limits<std::uint8_t>::max)())
14548 write_number(
static_cast<std::uint8_t
>(N));
14550 else if (N <= (std::numeric_limits<std::uint16_t>::max)())
14553 write_number(
static_cast<std::uint16_t
>(N));
14555 else if (N <= (std::numeric_limits<std::uint32_t>::max)())
14558 write_number(
static_cast<std::uint32_t
>(N));
14561 else if (N <= (std::numeric_limits<std::uint64_t>::max)())
14564 write_number(
static_cast<std::uint64_t
>(N));
14569 oa->write_characters(
14570 reinterpret_cast<const CharType*
>(j.m_value.string->c_str()),
14571 j.m_value.string->size());
14578 const auto N = j.m_value.array->size();
14581 write_number(
static_cast<std::uint8_t
>(0x80 + N));
14583 else if (N <= (std::numeric_limits<std::uint8_t>::max)())
14586 write_number(
static_cast<std::uint8_t
>(N));
14588 else if (N <= (std::numeric_limits<std::uint16_t>::max)())
14591 write_number(
static_cast<std::uint16_t
>(N));
14593 else if (N <= (std::numeric_limits<std::uint32_t>::max)())
14596 write_number(
static_cast<std::uint32_t
>(N));
14599 else if (N <= (std::numeric_limits<std::uint64_t>::max)())
14602 write_number(
static_cast<std::uint64_t
>(N));
14607 for (
const auto& el : *j.m_value.array)
14616 if (j.m_value.binary->has_subtype())
14618 if (j.m_value.binary->subtype() <= (std::numeric_limits<std::uint8_t>::max)())
14620 write_number(
static_cast<std::uint8_t
>(0xd8));
14621 write_number(
static_cast<std::uint8_t
>(j.m_value.binary->subtype()));
14623 else if (j.m_value.binary->subtype() <= (std::numeric_limits<std::uint16_t>::max)())
14625 write_number(
static_cast<std::uint8_t
>(0xd9));
14626 write_number(
static_cast<std::uint16_t
>(j.m_value.binary->subtype()));
14628 else if (j.m_value.binary->subtype() <= (std::numeric_limits<std::uint32_t>::max)())
14630 write_number(
static_cast<std::uint8_t
>(0xda));
14631 write_number(
static_cast<std::uint32_t
>(j.m_value.binary->subtype()));
14633 else if (j.m_value.binary->subtype() <= (std::numeric_limits<std::uint64_t>::max)())
14635 write_number(
static_cast<std::uint8_t
>(0xdb));
14636 write_number(
static_cast<std::uint64_t
>(j.m_value.binary->subtype()));
14641 const auto N = j.m_value.binary->size();
14644 write_number(
static_cast<std::uint8_t
>(0x40 + N));
14646 else if (N <= (std::numeric_limits<std::uint8_t>::max)())
14649 write_number(
static_cast<std::uint8_t
>(N));
14651 else if (N <= (std::numeric_limits<std::uint16_t>::max)())
14654 write_number(
static_cast<std::uint16_t
>(N));
14656 else if (N <= (std::numeric_limits<std::uint32_t>::max)())
14659 write_number(
static_cast<std::uint32_t
>(N));
14662 else if (N <= (std::numeric_limits<std::uint64_t>::max)())
14665 write_number(
static_cast<std::uint64_t
>(N));
14670 oa->write_characters(
14671 reinterpret_cast<const CharType*
>(j.m_value.binary->data()),
14680 const auto N = j.m_value.object->size();
14683 write_number(
static_cast<std::uint8_t
>(0xA0 + N));
14685 else if (N <= (std::numeric_limits<std::uint8_t>::max)())
14688 write_number(
static_cast<std::uint8_t
>(N));
14690 else if (N <= (std::numeric_limits<std::uint16_t>::max)())
14693 write_number(
static_cast<std::uint16_t
>(N));
14695 else if (N <= (std::numeric_limits<std::uint32_t>::max)())
14698 write_number(
static_cast<std::uint32_t
>(N));
14701 else if (N <= (std::numeric_limits<std::uint64_t>::max)())
14704 write_number(
static_cast<std::uint64_t
>(N));
14709 for (
const auto& el : *j.m_value.object)
14738 oa->write_character(j.m_value.boolean
14746 if (j.m_value.number_integer >= 0)
14751 if (j.m_value.number_unsigned < 128)
14754 write_number(
static_cast<std::uint8_t
>(j.m_value.number_integer));
14756 else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint8_t>::max)())
14760 write_number(
static_cast<std::uint8_t
>(j.m_value.number_integer));
14762 else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint16_t>::max)())
14766 write_number(
static_cast<std::uint16_t
>(j.m_value.number_integer));
14768 else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint32_t>::max)())
14772 write_number(
static_cast<std::uint32_t
>(j.m_value.number_integer));
14774 else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint64_t>::max)())
14778 write_number(
static_cast<std::uint64_t
>(j.m_value.number_integer));
14783 if (j.m_value.number_integer >= -32)
14786 write_number(
static_cast<std::int8_t
>(j.m_value.number_integer));
14788 else if (j.m_value.number_integer >= (std::numeric_limits<std::int8_t>::min)() &&
14789 j.m_value.number_integer <= (std::numeric_limits<std::int8_t>::max)())
14793 write_number(
static_cast<std::int8_t
>(j.m_value.number_integer));
14795 else if (j.m_value.number_integer >= (std::numeric_limits<std::int16_t>::min)() &&
14796 j.m_value.number_integer <= (std::numeric_limits<std::int16_t>::max)())
14800 write_number(
static_cast<std::int16_t
>(j.m_value.number_integer));
14802 else if (j.m_value.number_integer >= (std::numeric_limits<std::int32_t>::min)() &&
14803 j.m_value.number_integer <= (std::numeric_limits<std::int32_t>::max)())
14807 write_number(
static_cast<std::int32_t
>(j.m_value.number_integer));
14809 else if (j.m_value.number_integer >= (std::numeric_limits<std::int64_t>::min)() &&
14810 j.m_value.number_integer <= (std::numeric_limits<std::int64_t>::max)())
14814 write_number(
static_cast<std::int64_t
>(j.m_value.number_integer));
14822 if (j.m_value.number_unsigned < 128)
14825 write_number(
static_cast<std::uint8_t
>(j.m_value.number_integer));
14827 else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint8_t>::max)())
14831 write_number(
static_cast<std::uint8_t
>(j.m_value.number_integer));
14833 else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint16_t>::max)())
14837 write_number(
static_cast<std::uint16_t
>(j.m_value.number_integer));
14839 else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint32_t>::max)())
14843 write_number(
static_cast<std::uint32_t
>(j.m_value.number_integer));
14845 else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint64_t>::max)())
14849 write_number(
static_cast<std::uint64_t
>(j.m_value.number_integer));
14863 const auto N = j.m_value.string->size();
14867 write_number(
static_cast<std::uint8_t
>(0xA0 | N));
14869 else if (N <= (std::numeric_limits<std::uint8_t>::max)())
14873 write_number(
static_cast<std::uint8_t
>(N));
14875 else if (N <= (std::numeric_limits<std::uint16_t>::max)())
14879 write_number(
static_cast<std::uint16_t
>(N));
14881 else if (N <= (std::numeric_limits<std::uint32_t>::max)())
14885 write_number(
static_cast<std::uint32_t
>(N));
14889 oa->write_characters(
14890 reinterpret_cast<const CharType*
>(j.m_value.string->c_str()),
14891 j.m_value.string->size());
14898 const auto N = j.m_value.array->size();
14902 write_number(
static_cast<std::uint8_t
>(0x90 | N));
14904 else if (N <= (std::numeric_limits<std::uint16_t>::max)())
14908 write_number(
static_cast<std::uint16_t
>(N));
14910 else if (N <= (std::numeric_limits<std::uint32_t>::max)())
14914 write_number(
static_cast<std::uint32_t
>(N));
14918 for (
const auto& el : *j.m_value.array)
14929 const bool use_ext = j.m_value.binary->has_subtype();
14932 const auto N = j.m_value.binary->size();
14933 if (N <= (std::numeric_limits<std::uint8_t>::max)())
14935 std::uint8_t output_type{};
14942 output_type = 0xD4;
14945 output_type = 0xD5;
14948 output_type = 0xD6;
14951 output_type = 0xD7;
14954 output_type = 0xD8;
14957 output_type = 0xC7;
14965 output_type = 0xC4;
14972 write_number(
static_cast<std::uint8_t
>(N));
14975 else if (N <= (std::numeric_limits<std::uint16_t>::max)())
14977 std::uint8_t output_type = use_ext
14982 write_number(
static_cast<std::uint16_t
>(N));
14984 else if (N <= (std::numeric_limits<std::uint32_t>::max)())
14986 std::uint8_t output_type = use_ext
14991 write_number(
static_cast<std::uint32_t
>(N));
14997 write_number(
static_cast<std::int8_t
>(j.m_value.binary->subtype()));
15001 oa->write_characters(
15002 reinterpret_cast<const CharType*
>(j.m_value.binary->data()),
15011 const auto N = j.m_value.object->size();
15015 write_number(
static_cast<std::uint8_t
>(0x80 | (N & 0xF)));
15017 else if (N <= (std::numeric_limits<std::uint16_t>::max)())
15021 write_number(
static_cast<std::uint16_t
>(N));
15023 else if (N <= (std::numeric_limits<std::uint32_t>::max)())
15027 write_number(
static_cast<std::uint32_t
>(N));
15031 for (
const auto& el : *j.m_value.object)
15053 const bool use_type,
const bool add_prefix =
true,
15054 const bool use_bjdata =
false)
15071 oa->write_character(j.m_value.boolean
15080 write_number_with_ubjson_prefix(j.m_value.number_integer, add_prefix, use_bjdata);
15086 write_number_with_ubjson_prefix(j.m_value.number_unsigned, add_prefix, use_bjdata);
15092 write_number_with_ubjson_prefix(j.m_value.number_float, add_prefix, use_bjdata);
15102 write_number_with_ubjson_prefix(j.m_value.string->size(),
true, use_bjdata);
15103 oa->write_characters(
15104 reinterpret_cast<const CharType*
>(j.m_value.string->c_str()),
15105 j.m_value.string->size());
15116 bool prefix_required =
true;
15117 if (use_type && !j.m_value.array->empty())
15120 const CharType first_prefix = ubjson_prefix(j.front(), use_bjdata);
15121 const bool same_prefix = std::all_of(j.begin() + 1, j.end(),
15122 [
this, first_prefix, use_bjdata](
const BasicJsonType & v)
15124 return ubjson_prefix(v, use_bjdata) == first_prefix;
15127 std::vector<CharType> bjdx = {
'[',
'{',
'S',
'H',
'T',
'F',
'N',
'Z'};
15129 if (same_prefix && !(use_bjdata && std::find(bjdx.begin(), bjdx.end(), first_prefix) != bjdx.end()))
15131 prefix_required =
false;
15133 oa->write_character(first_prefix);
15140 write_number_with_ubjson_prefix(j.m_value.array->size(),
true, use_bjdata);
15143 for (
const auto& el : *j.m_value.array)
15145 write_ubjson(el, use_count, use_type, prefix_required, use_bjdata);
15163 if (use_type && !j.m_value.binary->empty())
15167 oa->write_character(
'U');
15173 write_number_with_ubjson_prefix(j.m_value.binary->size(),
true, use_bjdata);
15178 oa->write_characters(
15179 reinterpret_cast<const CharType*
>(j.m_value.binary->data()),
15180 j.m_value.binary->size());
15184 for (
size_t i = 0; i < j.m_value.binary->size(); ++i)
15187 oa->write_character(j.m_value.binary->data()[i]);
15201 if (use_bjdata && j.m_value.object->size() == 3 && j.m_value.object->find(
"_ArrayType_") != j.m_value.object->end() && j.m_value.object->find(
"_ArraySize_") != j.m_value.object->end() && j.m_value.object->find(
"_ArrayData_") != j.m_value.object->end())
15203 if (!write_bjdata_ndarray(*j.m_value.object, use_count, use_type))
15214 bool prefix_required =
true;
15215 if (use_type && !j.m_value.object->empty())
15218 const CharType first_prefix = ubjson_prefix(j.front(), use_bjdata);
15219 const bool same_prefix = std::all_of(j.begin(), j.end(),
15220 [
this, first_prefix, use_bjdata](
const BasicJsonType & v)
15222 return ubjson_prefix(v, use_bjdata) == first_prefix;
15225 std::vector<CharType> bjdx = {
'[',
'{',
'S',
'H',
'T',
'F',
'N',
'Z'};
15227 if (same_prefix && !(use_bjdata && std::find(bjdx.begin(), bjdx.end(), first_prefix) != bjdx.end()))
15229 prefix_required =
false;
15231 oa->write_character(first_prefix);
15238 write_number_with_ubjson_prefix(j.m_value.object->size(),
true, use_bjdata);
15241 for (
const auto& el : *j.m_value.object)
15243 write_number_with_ubjson_prefix(el.first.size(),
true, use_bjdata);
15244 oa->write_characters(
15245 reinterpret_cast<const CharType*
>(el.first.c_str()),
15247 write_ubjson(el.second, use_count, use_type, prefix_required, use_bjdata);
15273 static std::size_t calc_bson_entry_header_size(
const string_t& name,
const BasicJsonType& j)
15275 const auto it = name.find(
static_cast<typename string_t::value_type
>(0));
15279 static_cast<void>(j);
15282 return 1ul + name.size() + 1u;
15288 void write_bson_entry_header(
const string_t& name,
15289 const std::uint8_t element_type)
15291 oa->write_character(to_char_type(element_type));
15292 oa->write_characters(
15293 reinterpret_cast<const CharType*
>(name.c_str()),
15300 void write_bson_boolean(
const string_t& name,
15303 write_bson_entry_header(name, 0x08);
15304 oa->write_character(value ? to_char_type(0x01) : to_char_type(0x00));
15310 void write_bson_double(
const string_t& name,
15311 const double value)
15313 write_bson_entry_header(name, 0x01);
15314 write_number<double>(value,
true);
15320 static std::size_t calc_bson_string_size(
const string_t& value)
15322 return sizeof(std::int32_t) +
value.size() + 1ul;
15328 void write_bson_string(
const string_t& name,
15329 const string_t& value)
15331 write_bson_entry_header(name, 0x02);
15333 write_number<std::int32_t>(
static_cast<std::int32_t
>(
value.size() + 1ul),
true);
15334 oa->write_characters(
15335 reinterpret_cast<const CharType*
>(
value.c_str()),
15342 void write_bson_null(
const string_t& name)
15344 write_bson_entry_header(name, 0x0A);
15350 static std::size_t calc_bson_integer_size(
const std::int64_t value)
15352 return (std::numeric_limits<std::int32_t>::min)() <= value && value <= (std::numeric_limits<std::int32_t>::max)()
15353 ?
sizeof(std::int32_t)
15354 :
sizeof(std::int64_t);
15360 void write_bson_integer(
const string_t& name,
15361 const std::int64_t value)
15363 if ((std::numeric_limits<std::int32_t>::min)() <= value && value <= (std::numeric_limits<std::int32_t>::max)())
15365 write_bson_entry_header(name, 0x10);
15366 write_number<std::int32_t>(
static_cast<std::int32_t
>(value),
true);
15370 write_bson_entry_header(name, 0x12);
15371 write_number<std::int64_t>(
static_cast<std::int64_t
>(value),
true);
15378 static constexpr std::size_t calc_bson_unsigned_size(
const std::uint64_t value)
noexcept
15380 return (value <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int32_t>::max)()))
15381 ?
sizeof(std::int32_t)
15382 : sizeof(
std::int64_t);
15388 void write_bson_unsigned(
const string_t& name,
15389 const BasicJsonType& j)
15391 if (j.m_value.number_unsigned <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int32_t>::max)()))
15393 write_bson_entry_header(name, 0x10 );
15394 write_number<std::int32_t>(
static_cast<std::int32_t
>(j.m_value.number_unsigned),
true);
15396 else if (j.m_value.number_unsigned <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int64_t>::max)()))
15398 write_bson_entry_header(name, 0x12 );
15399 write_number<std::int64_t>(
static_cast<std::int64_t
>(j.m_value.number_unsigned),
true);
15403 JSON_THROW(out_of_range::create(407,
concat(
"integer number ", std::to_string(j.m_value.number_unsigned),
" cannot be represented by BSON as it does not fit int64"), &j));
15410 void write_bson_object_entry(
const string_t& name,
15411 const typename BasicJsonType::object_t& value)
15413 write_bson_entry_header(name, 0x03);
15414 write_bson_object(value);
15420 static std::size_t calc_bson_array_size(
const typename BasicJsonType::array_t& value)
15422 std::size_t array_index = 0ul;
15424 const std::size_t embedded_document_size = std::accumulate(std::begin(value), std::end(value),
static_cast<std::size_t
>(0), [&array_index](std::size_t result,
const typename BasicJsonType::array_t::value_type & el)
15426 return result + calc_bson_element_size(std::to_string(array_index++), el);
15429 return sizeof(std::int32_t) + embedded_document_size + 1ul;
15435 static std::size_t calc_bson_binary_size(
const typename BasicJsonType::binary_t& value)
15437 return sizeof(std::int32_t) +
value.size() + 1ul;
15443 void write_bson_array(
const string_t& name,
15444 const typename BasicJsonType::array_t& value)
15446 write_bson_entry_header(name, 0x04);
15447 write_number<std::int32_t>(
static_cast<std::int32_t
>(calc_bson_array_size(value)),
true);
15449 std::size_t array_index = 0ul;
15451 for (
const auto& el : value)
15453 write_bson_element(std::to_string(array_index++), el);
15456 oa->write_character(to_char_type(0x00));
15462 void write_bson_binary(
const string_t& name,
15463 const binary_t& value)
15465 write_bson_entry_header(name, 0x05);
15467 write_number<std::int32_t>(
static_cast<std::int32_t
>(
value.size()),
true);
15468 write_number(
value.has_subtype() ?
static_cast<std::uint8_t
>(
value.subtype()) :
static_cast<std::uint8_t
>(0x00));
15470 oa->write_characters(
reinterpret_cast<const CharType*
>(
value.data()),
value.size());
15477 static std::size_t calc_bson_element_size(
const string_t& name,
15478 const BasicJsonType& j)
15480 const auto header_size = calc_bson_entry_header_size(name, j);
15483 case value_t::object:
15484 return header_size + calc_bson_object_size(*j.m_value.object);
15486 case value_t::array:
15487 return header_size + calc_bson_array_size(*j.m_value.array);
15489 case value_t::binary:
15490 return header_size + calc_bson_binary_size(*j.m_value.binary);
15492 case value_t::boolean:
15493 return header_size + 1ul;
15495 case value_t::number_float:
15496 return header_size + 8ul;
15498 case value_t::number_integer:
15499 return header_size + calc_bson_integer_size(j.m_value.number_integer);
15501 case value_t::number_unsigned:
15502 return header_size + calc_bson_unsigned_size(j.m_value.number_unsigned);
15504 case value_t::string:
15505 return header_size + calc_bson_string_size(*j.m_value.string);
15507 case value_t::null:
15508 return header_size + 0ul;
15511 case value_t::discarded:
15525 void write_bson_element(
const string_t& name,
15526 const BasicJsonType& j)
15530 case value_t::object:
15531 return write_bson_object_entry(name, *j.m_value.object);
15533 case value_t::array:
15534 return write_bson_array(name, *j.m_value.array);
15536 case value_t::binary:
15537 return write_bson_binary(name, *j.m_value.binary);
15539 case value_t::boolean:
15540 return write_bson_boolean(name, j.m_value.boolean);
15542 case value_t::number_float:
15543 return write_bson_double(name, j.m_value.number_float);
15545 case value_t::number_integer:
15546 return write_bson_integer(name, j.m_value.number_integer);
15548 case value_t::number_unsigned:
15549 return write_bson_unsigned(name, j);
15551 case value_t::string:
15552 return write_bson_string(name, *j.m_value.string);
15554 case value_t::null:
15555 return write_bson_null(name);
15558 case value_t::discarded:
15572 static std::size_t calc_bson_object_size(
const typename BasicJsonType::object_t& value)
15574 std::size_t document_size = std::accumulate(
value.begin(),
value.end(),
static_cast<std::size_t
>(0),
15575 [](
size_t result,
const typename BasicJsonType::object_t::value_type & el)
15577 return result += calc_bson_element_size(el.first, el.second);
15580 return sizeof(std::int32_t) + document_size + 1ul;
15587 void write_bson_object(
const typename BasicJsonType::object_t& value)
15589 write_number<std::int32_t>(
static_cast<std::int32_t
>(calc_bson_object_size(value)),
true);
15591 for (
const auto& el : value)
15593 write_bson_element(el.first, el.second);
15596 oa->write_character(to_char_type(0x00));
15603 static constexpr CharType get_cbor_float_prefix(
float )
15605 return to_char_type(0xFA);
15608 static constexpr CharType get_cbor_float_prefix(
double )
15610 return to_char_type(0xFB);
15617 static constexpr CharType get_msgpack_float_prefix(
float )
15619 return to_char_type(0xCA);
15622 static constexpr CharType get_msgpack_float_prefix(
double )
15624 return to_char_type(0xCB);
15632 template<
typename NumberType,
typename std::enable_if<
15633 std::is_floating_point<NumberType>::value,
int>
::type = 0>
15634 void write_number_with_ubjson_prefix(
const NumberType
n,
15635 const bool add_prefix,
15636 const bool use_bjdata)
15640 oa->write_character(get_ubjson_float_prefix(
n));
15642 write_number(
n, use_bjdata);
15646 template<
typename NumberType,
typename std::enable_if<
15647 std::is_unsigned<NumberType>::value,
int>
::type = 0>
15648 void write_number_with_ubjson_prefix(
const NumberType
n,
15649 const bool add_prefix,
15650 const bool use_bjdata)
15652 if (
n <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int8_t>::max)()))
15656 oa->write_character(to_char_type(
'i'));
15658 write_number(
static_cast<std::uint8_t
>(
n), use_bjdata);
15660 else if (
n <= (std::numeric_limits<std::uint8_t>::max)())
15664 oa->write_character(to_char_type(
'U'));
15666 write_number(
static_cast<std::uint8_t
>(
n), use_bjdata);
15668 else if (
n <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int16_t>::max)()))
15672 oa->write_character(to_char_type(
'I'));
15674 write_number(
static_cast<std::int16_t
>(
n), use_bjdata);
15676 else if (use_bjdata &&
n <=
static_cast<uint64_t
>((std::numeric_limits<uint16_t>::max)()))
15680 oa->write_character(to_char_type(
'u'));
15682 write_number(
static_cast<std::uint16_t
>(
n), use_bjdata);
15684 else if (
n <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int32_t>::max)()))
15688 oa->write_character(to_char_type(
'l'));
15690 write_number(
static_cast<std::int32_t
>(
n), use_bjdata);
15692 else if (use_bjdata &&
n <=
static_cast<uint64_t
>((std::numeric_limits<uint32_t>::max)()))
15696 oa->write_character(to_char_type(
'm'));
15698 write_number(
static_cast<std::uint32_t
>(
n), use_bjdata);
15700 else if (
n <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int64_t>::max)()))
15704 oa->write_character(to_char_type(
'L'));
15706 write_number(
static_cast<std::int64_t
>(
n), use_bjdata);
15708 else if (use_bjdata &&
n <= (std::numeric_limits<uint64_t>::max)())
15712 oa->write_character(to_char_type(
'M'));
15714 write_number(
static_cast<std::uint64_t
>(
n), use_bjdata);
15720 oa->write_character(to_char_type(
'H'));
15723 const auto number = BasicJsonType(
n).dump();
15724 write_number_with_ubjson_prefix(number.size(),
true, use_bjdata);
15725 for (std::size_t i = 0; i < number.size(); ++i)
15727 oa->write_character(to_char_type(
static_cast<std::uint8_t
>(number[i])));
15733 template <
typename NumberType,
typename std::enable_if <
15734 std::is_signed<NumberType>::value&&
15735 !std::is_floating_point<NumberType>::value,
int >
::type = 0 >
15736 void write_number_with_ubjson_prefix(
const NumberType
n,
15737 const bool add_prefix,
15738 const bool use_bjdata)
15740 if ((std::numeric_limits<std::int8_t>::min)() <=
n &&
n <= (std::numeric_limits<std::int8_t>::max)())
15744 oa->write_character(to_char_type(
'i'));
15746 write_number(
static_cast<std::int8_t
>(
n), use_bjdata);
15748 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)()))
15752 oa->write_character(to_char_type(
'U'));
15754 write_number(
static_cast<std::uint8_t
>(
n), use_bjdata);
15756 else if ((std::numeric_limits<std::int16_t>::min)() <=
n &&
n <= (std::numeric_limits<std::int16_t>::max)())
15760 oa->write_character(to_char_type(
'I'));
15762 write_number(
static_cast<std::int16_t
>(
n), use_bjdata);
15764 else if (use_bjdata && (
static_cast<std::int64_t
>((std::numeric_limits<std::uint16_t>::min)()) <=
n &&
n <=
static_cast<std::int64_t
>((std::numeric_limits<std::uint16_t>::max)())))
15768 oa->write_character(to_char_type(
'u'));
15770 write_number(
static_cast<uint16_t
>(
n), use_bjdata);
15772 else if ((std::numeric_limits<std::int32_t>::min)() <=
n &&
n <= (std::numeric_limits<std::int32_t>::max)())
15776 oa->write_character(to_char_type(
'l'));
15778 write_number(
static_cast<std::int32_t
>(
n), use_bjdata);
15780 else if (use_bjdata && (
static_cast<std::int64_t
>((std::numeric_limits<std::uint32_t>::min)()) <=
n &&
n <=
static_cast<std::int64_t
>((std::numeric_limits<std::uint32_t>::max)())))
15784 oa->write_character(to_char_type(
'm'));
15786 write_number(
static_cast<uint32_t
>(
n), use_bjdata);
15788 else if ((std::numeric_limits<std::int64_t>::min)() <=
n &&
n <= (std::numeric_limits<std::int64_t>::max)())
15792 oa->write_character(to_char_type(
'L'));
15794 write_number(
static_cast<std::int64_t
>(
n), use_bjdata);
15801 oa->write_character(to_char_type(
'H'));
15804 const auto number = BasicJsonType(
n).dump();
15805 write_number_with_ubjson_prefix(number.size(),
true, use_bjdata);
15806 for (std::size_t i = 0; i < number.size(); ++i)
15808 oa->write_character(to_char_type(
static_cast<std::uint8_t
>(number[i])));
15817 CharType ubjson_prefix(
const BasicJsonType& j,
const bool use_bjdata)
const noexcept
15821 case value_t::null:
15824 case value_t::boolean:
15825 return j.m_value.boolean ?
'T' :
'F';
15827 case value_t::number_integer:
15829 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)())
15833 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)())
15837 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)())
15841 if (use_bjdata && ((std::numeric_limits<std::uint16_t>::min)() <= j.m_value.number_integer && j.m_value.number_integer <= (std::numeric_limits<std::uint16_t>::max)()))
15845 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)())
15849 if (use_bjdata && ((std::numeric_limits<std::uint32_t>::min)() <= j.m_value.number_integer && j.m_value.number_integer <= (std::numeric_limits<std::uint32_t>::max)()))
15853 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)())
15861 case value_t::number_unsigned:
15863 if (j.m_value.number_unsigned <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int8_t>::max)()))
15867 if (j.m_value.number_unsigned <=
static_cast<std::uint64_t
>((std::numeric_limits<std::uint8_t>::max)()))
15871 if (j.m_value.number_unsigned <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int16_t>::max)()))
15875 if (use_bjdata && j.m_value.number_unsigned <=
static_cast<std::uint64_t
>((std::numeric_limits<std::uint16_t>::max)()))
15879 if (j.m_value.number_unsigned <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int32_t>::max)()))
15883 if (use_bjdata && j.m_value.number_unsigned <=
static_cast<std::uint64_t
>((std::numeric_limits<std::uint32_t>::max)()))
15887 if (j.m_value.number_unsigned <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int64_t>::max)()))
15891 if (use_bjdata && j.m_value.number_unsigned <= (std::numeric_limits<std::uint64_t>::max)())
15899 case value_t::number_float:
15900 return get_ubjson_float_prefix(j.m_value.number_float);
15902 case value_t::string:
15905 case value_t::array:
15906 case value_t::binary:
15909 case value_t::object:
15912 case value_t::discarded:
15918 static constexpr CharType get_ubjson_float_prefix(
float )
15923 static constexpr CharType get_ubjson_float_prefix(
double )
15931 bool write_bjdata_ndarray(
const typename BasicJsonType::object_t& value,
const bool use_count,
const bool use_type)
15933 std::map<string_t, CharType> bjdtype = {{
"uint8",
'U'}, {
"int8",
'i'}, {
"uint16",
'u'}, {
"int16",
'I'},
15934 {
"uint32",
'm'}, {
"int32",
'l'}, {
"uint64",
'M'}, {
"int64",
'L'}, {
"single",
'd'}, {
"double",
'D'}, {
"char",
'C'}
15938 auto it = bjdtype.find(
static_cast<string_t>(
value.at(key)));
15939 if (it == bjdtype.end())
15943 CharType dtype = it->second;
15945 key =
"_ArraySize_";
15946 std::size_t len = (
value.at(key).empty() ? 0 : 1);
15947 for (
const auto& el :
value.at(key))
15949 len *=
static_cast<std::size_t
>(el.m_value.number_unsigned);
15952 key =
"_ArrayData_";
15953 if (
value.at(key).size() != len)
15958 oa->write_character(
'[');
15959 oa->write_character(
'$');
15960 oa->write_character(dtype);
15961 oa->write_character(
'#');
15963 key =
"_ArraySize_";
15964 write_ubjson(
value.at(key), use_count, use_type,
true,
true);
15966 key =
"_ArrayData_";
15967 if (dtype ==
'U' || dtype ==
'C')
15969 for (
const auto& el :
value.at(key))
15971 write_number(
static_cast<std::uint8_t
>(el.m_value.number_unsigned),
true);
15974 else if (dtype ==
'i')
15976 for (
const auto& el :
value.at(key))
15978 write_number(
static_cast<std::int8_t
>(el.m_value.number_integer),
true);
15981 else if (dtype ==
'u')
15983 for (
const auto& el :
value.at(key))
15985 write_number(
static_cast<std::uint16_t
>(el.m_value.number_unsigned),
true);
15988 else if (dtype ==
'I')
15990 for (
const auto& el :
value.at(key))
15992 write_number(
static_cast<std::int16_t
>(el.m_value.number_integer),
true);
15995 else if (dtype ==
'm')
15997 for (
const auto& el :
value.at(key))
15999 write_number(
static_cast<std::uint32_t
>(el.m_value.number_unsigned),
true);
16002 else if (dtype ==
'l')
16004 for (
const auto& el :
value.at(key))
16006 write_number(
static_cast<std::int32_t
>(el.m_value.number_integer),
true);
16009 else if (dtype ==
'M')
16011 for (
const auto& el :
value.at(key))
16013 write_number(
static_cast<std::uint64_t
>(el.m_value.number_unsigned),
true);
16016 else if (dtype ==
'L')
16018 for (
const auto& el :
value.at(key))
16020 write_number(
static_cast<std::int64_t
>(el.m_value.number_integer),
true);
16023 else if (dtype ==
'd')
16025 for (
const auto& el :
value.at(key))
16027 write_number(
static_cast<float>(el.m_value.number_float),
true);
16030 else if (dtype ==
'D')
16032 for (
const auto& el :
value.at(key))
16034 write_number(
static_cast<double>(el.m_value.number_float),
true);
16057 template<
typename NumberType>
16058 void write_number(
const NumberType
n,
const bool OutputIsLittleEndian =
false)
16061 std::array<CharType,
sizeof(NumberType)> vec{};
16062 std::memcpy(vec.data(), &
n,
sizeof(NumberType));
16065 if (is_little_endian != OutputIsLittleEndian)
16068 std::reverse(vec.begin(), vec.end());
16071 oa->write_characters(vec.data(),
sizeof(NumberType));
16074 void write_compact_float(
const number_float_t
n, detail::input_format_t format)
16077#pragma GCC diagnostic push
16078#pragma GCC diagnostic ignored "-Wfloat-equal"
16080 if (
static_cast<double>(
n) >=
static_cast<double>(std::numeric_limits<float>::lowest()) &&
16081 static_cast<double>(
n) <=
static_cast<double>((std::numeric_limits<float>::max)()) &&
16082 static_cast<double>(
static_cast<float>(
n)) ==
static_cast<double>(
n))
16084 oa->write_character(format == detail::input_format_t::cbor
16085 ? get_cbor_float_prefix(
static_cast<float>(
n))
16086 : get_msgpack_float_prefix(
static_cast<float>(
n)));
16087 write_number(
static_cast<float>(
n));
16091 oa->write_character(format == detail::input_format_t::cbor
16092 ? get_cbor_float_prefix(
n)
16093 : get_msgpack_float_prefix(
n));
16097#pragma GCC diagnostic pop
16106 template <
typename C = CharType,
16107 enable_if_t < std::is_signed<C>::value && std::is_signed<char>::value > * =
nullptr >
16110 return *
reinterpret_cast<char*
>(&x);
16113 template <
typename C = CharType,
16114 enable_if_t < std::is_signed<C>::value && std::is_unsigned<char>::value > * =
nullptr >
16117 static_assert(
sizeof(std::uint8_t) ==
sizeof(CharType),
"size of CharType must be equal to std::uint8_t");
16118 static_assert(std::is_trivial<CharType>::value,
"CharType must be trivial");
16120 std::memcpy(&result, &x,
sizeof(x));
16124 template<
typename C = CharType,
16131 template <
typename InputCharType,
typename C = CharType,
16133 std::is_signed<C>::value &&
16134 std::is_signed<char>::value &&
16135 std::is_same<char, typename std::remove_cv<InputCharType>::type>
::value
16144 const bool is_little_endian = little_endianness();
16157#include <algorithm>
16167#include <type_traits>
16178#include <type_traits>
16210template<
typename Target,
typename Source>
16213 static_assert(
sizeof(Target) ==
sizeof(Source),
"size mismatch");
16216 std::memcpy(&target, &source,
sizeof(Source));
16227 constexpr diyfp(std::uint64_t f_,
int e_) noexcept :
f(f_),
e(e_) {}
16238 return {x.f - y.f, x.e};
16247 static_assert(
kPrecision == 64,
"internal error");
16272 const std::uint64_t u_lo = x.f & 0xFFFFFFFFu;
16273 const std::uint64_t u_hi = x.f >> 32u;
16274 const std::uint64_t v_lo = y.f & 0xFFFFFFFFu;
16275 const std::uint64_t v_hi = y.f >> 32u;
16277 const std::uint64_t p0 = u_lo * v_lo;
16278 const std::uint64_t p1 = u_lo * v_hi;
16279 const std::uint64_t p2 = u_hi * v_lo;
16280 const std::uint64_t p3 = u_hi * v_hi;
16282 const std::uint64_t p0_hi = p0 >> 32u;
16283 const std::uint64_t p1_lo = p1 & 0xFFFFFFFFu;
16284 const std::uint64_t p1_hi = p1 >> 32u;
16285 const std::uint64_t p2_lo = p2 & 0xFFFFFFFFu;
16286 const std::uint64_t p2_hi = p2 >> 32u;
16288 std::uint64_t Q = p0_hi + p1_lo + p2_lo;
16299 Q += std::uint64_t{1} << (64u - 32u - 1u);
16301 const std::uint64_t h = p3 + p2_hi + p1_hi + (Q >> 32u);
16303 return {h, x.e + y.e + 64};
16314 while ((x.f >> 63u) == 0)
16329 const int delta = x.e - target_exponent;
16334 return {x.f << delta, target_exponent};
16351template<
typename FloatType>
16364 static_assert(std::numeric_limits<FloatType>::is_iec559,
16365 "internal error: dtoa_short requires an IEEE-754 floating-point implementation");
16367 constexpr int kPrecision = std::numeric_limits<FloatType>::digits;
16368 constexpr int kBias = std::numeric_limits<FloatType>::max_exponent - 1 + (kPrecision - 1);
16369 constexpr int kMinExp = 1 - kBias;
16370 constexpr std::uint64_t kHiddenBit = std::uint64_t{1} << (kPrecision - 1);
16372 using bits_type =
typename std::conditional<kPrecision == 24, std::uint32_t, std::uint64_t >::type;
16375 const std::uint64_t E = bits >> (kPrecision - 1);
16376 const std::uint64_t F = bits & (kHiddenBit - 1);
16378 const bool is_denormal = E == 0;
16379 const diyfp v = is_denormal
16380 ?
diyfp(F, kMinExp)
16381 :
diyfp(F + kHiddenBit,
static_cast<int>(E) - kBias);
16404 const bool lower_boundary_is_closer = F == 0 && E > 1;
16406 const diyfp m_minus = lower_boundary_is_closer
16407 ?
diyfp(4 * v.
f - 1, v.
e - 2)
16408 :
diyfp(2 * v.
f - 1, v.
e - 1);
16543 constexpr int kCachedPowersMinDecExp = -300;
16544 constexpr int kCachedPowersDecStep = 8;
16546 static constexpr std::array<cached_power, 79> kCachedPowers =
16549 { 0xAB70FE17C79AC6CA, -1060, -300 },
16550 { 0xFF77B1FCBEBCDC4F, -1034, -292 },
16551 { 0xBE5691EF416BD60C, -1007, -284 },
16552 { 0x8DD01FAD907FFC3C, -980, -276 },
16553 { 0xD3515C2831559A83, -954, -268 },
16554 { 0x9D71AC8FADA6C9B5, -927, -260 },
16555 { 0xEA9C227723EE8BCB, -901, -252 },
16556 { 0xAECC49914078536D, -874, -244 },
16557 { 0x823C12795DB6CE57, -847, -236 },
16558 { 0xC21094364DFB5637, -821, -228 },
16559 { 0x9096EA6F3848984F, -794, -220 },
16560 { 0xD77485CB25823AC7, -768, -212 },
16561 { 0xA086CFCD97BF97F4, -741, -204 },
16562 { 0xEF340A98172AACE5, -715, -196 },
16563 { 0xB23867FB2A35B28E, -688, -188 },
16564 { 0x84C8D4DFD2C63F3B, -661, -180 },
16565 { 0xC5DD44271AD3CDBA, -635, -172 },
16566 { 0x936B9FCEBB25C996, -608, -164 },
16567 { 0xDBAC6C247D62A584, -582, -156 },
16568 { 0xA3AB66580D5FDAF6, -555, -148 },
16569 { 0xF3E2F893DEC3F126, -529, -140 },
16570 { 0xB5B5ADA8AAFF80B8, -502, -132 },
16571 { 0x87625F056C7C4A8B, -475, -124 },
16572 { 0xC9BCFF6034C13053, -449, -116 },
16573 { 0x964E858C91BA2655, -422, -108 },
16574 { 0xDFF9772470297EBD, -396, -100 },
16575 { 0xA6DFBD9FB8E5B88F, -369, -92 },
16576 { 0xF8A95FCF88747D94, -343, -84 },
16577 { 0xB94470938FA89BCF, -316, -76 },
16578 { 0x8A08F0F8BF0F156B, -289, -68 },
16579 { 0xCDB02555653131B6, -263, -60 },
16580 { 0x993FE2C6D07B7FAC, -236, -52 },
16581 { 0xE45C10C42A2B3B06, -210, -44 },
16582 { 0xAA242499697392D3, -183, -36 },
16583 { 0xFD87B5F28300CA0E, -157, -28 },
16584 { 0xBCE5086492111AEB, -130, -20 },
16585 { 0x8CBCCC096F5088CC, -103, -12 },
16586 { 0xD1B71758E219652C, -77, -4 },
16587 { 0x9C40000000000000, -50, 4 },
16588 { 0xE8D4A51000000000, -24, 12 },
16589 { 0xAD78EBC5AC620000, 3, 20 },
16590 { 0x813F3978F8940984, 30, 28 },
16591 { 0xC097CE7BC90715B3, 56, 36 },
16592 { 0x8F7E32CE7BEA5C70, 83, 44 },
16593 { 0xD5D238A4ABE98068, 109, 52 },
16594 { 0x9F4F2726179A2245, 136, 60 },
16595 { 0xED63A231D4C4FB27, 162, 68 },
16596 { 0xB0DE65388CC8ADA8, 189, 76 },
16597 { 0x83C7088E1AAB65DB, 216, 84 },
16598 { 0xC45D1DF942711D9A, 242, 92 },
16599 { 0x924D692CA61BE758, 269, 100 },
16600 { 0xDA01EE641A708DEA, 295, 108 },
16601 { 0xA26DA3999AEF774A, 322, 116 },
16602 { 0xF209787BB47D6B85, 348, 124 },
16603 { 0xB454E4A179DD1877, 375, 132 },
16604 { 0x865B86925B9BC5C2, 402, 140 },
16605 { 0xC83553C5C8965D3D, 428, 148 },
16606 { 0x952AB45CFA97A0B3, 455, 156 },
16607 { 0xDE469FBD99A05FE3, 481, 164 },
16608 { 0xA59BC234DB398C25, 508, 172 },
16609 { 0xF6C69A72A3989F5C, 534, 180 },
16610 { 0xB7DCBF5354E9BECE, 561, 188 },
16611 { 0x88FCF317F22241E2, 588, 196 },
16612 { 0xCC20CE9BD35C78A5, 614, 204 },
16613 { 0x98165AF37B2153DF, 641, 212 },
16614 { 0xE2A0B5DC971F303A, 667, 220 },
16615 { 0xA8D9D1535CE3B396, 694, 228 },
16616 { 0xFB9B7CD9A4A7443C, 720, 236 },
16617 { 0xBB764C4CA7A44410, 747, 244 },
16618 { 0x8BAB8EEFB6409C1A, 774, 252 },
16619 { 0xD01FEF10A657842C, 800, 260 },
16620 { 0x9B10A4E5E9913129, 827, 268 },
16621 { 0xE7109BFBA19C0C9D, 853, 276 },
16622 { 0xAC2820D9623BF429, 880, 284 },
16623 { 0x80444B5E7AA7CF85, 907, 292 },
16624 { 0xBF21E44003ACDD2D, 933, 300 },
16625 { 0x8E679C2F5E44FF8F, 960, 308 },
16626 { 0xD433179D9C8CB841, 986, 316 },
16627 { 0x9E19DB92B4E31BA9, 1013, 324 },
16637 const int f =
kAlpha - e - 1;
16638 const int k = (f * 78913) / (1 << 18) +
static_cast<int>(f > 0);
16640 const int index = (-kCachedPowersMinDecExp + k + (kCachedPowersDecStep - 1)) / kCachedPowersDecStep;
16642 JSON_ASSERT(
static_cast<std::size_t
>(index) < kCachedPowers.size());
16644 const cached_power cached = kCachedPowers[
static_cast<std::size_t
>(index)];
16658 if (
n >= 1000000000)
16660 pow10 = 1000000000;
16664 if (
n >= 100000000)
16709inline void grisu2_round(
char* buf,
int len, std::uint64_t dist, std::uint64_t delta,
16710 std::uint64_t rest, std::uint64_t ten_k)
16737 && delta - rest >= ten_k
16738 && (rest + ten_k < dist || dist - rest > rest + ten_k - dist))
16753 static_assert(
kAlpha >= -60,
"internal error");
16754 static_assert(
kGamma <= -32,
"internal error");
16771 std::uint64_t delta =
diyfp::sub(M_plus, M_minus).
f;
16781 const diyfp one(std::uint64_t{1} << -M_plus.
e, M_plus.
e);
16783 auto p1 =
static_cast<std::uint32_t
>(M_plus.
f >> -one.e);
16784 std::uint64_t p2 = M_plus.
f & (one.f - 1);
16792 std::uint32_t pow10{};
16820 const std::uint32_t d = p1 / pow10;
16821 const std::uint32_t r = p1 % pow10;
16827 buffer[length++] =
static_cast<char>(
'0' + d);
16846 const std::uint64_t rest = (std::uint64_t{p1} << -one.e) + p2;
16851 decimal_exponent +=
n;
16862 const std::uint64_t ten_n = std::uint64_t{pow10} << -one.e;
16863 grisu2_round(buffer, length, dist, delta, rest, ten_n);
16924 JSON_ASSERT(p2 <= (std::numeric_limits<std::uint64_t>::max)() / 10);
16926 const std::uint64_t d = p2 >> -one.e;
16927 const std::uint64_t r = p2 & (one.f - 1);
16934 buffer[length++] =
static_cast<char>(
'0' + d);
16959 decimal_exponent -= m;
16967 const std::uint64_t ten_m = one.f;
16991inline
void grisu2(
char* buf,
int& len,
int& decimal_exponent,
17008 const diyfp c_minus_k(cached.
f, cached.
e);
17036 const diyfp M_minus(w_minus.
f + 1, w_minus.
e);
17037 const diyfp M_plus (w_plus.
f - 1, w_plus.
e );
17039 decimal_exponent = -cached.
k;
17049template<
typename FloatType>
17054 "internal error: not enough precision");
17106 auto k =
static_cast<std::uint32_t
>(e);
17112 *buf++ =
static_cast<char>(
'0' + k);
17116 *buf++ =
static_cast<char>(
'0' + k / 10);
17118 *buf++ =
static_cast<char>(
'0' + k);
17122 *buf++ =
static_cast<char>(
'0' + k / 100);
17124 *buf++ =
static_cast<char>(
'0' + k / 10);
17126 *buf++ =
static_cast<char>(
'0' + k);
17144 int min_exp,
int max_exp)
17150 const int n = len + decimal_exponent;
17156 if (k <=
n &&
n <= max_exp)
17161 std::memset(buf + k,
'0',
static_cast<size_t>(
n) -
static_cast<size_t>(k));
17165 return buf + (
static_cast<size_t>(
n) + 2);
17168 if (0 <
n &&
n <= max_exp)
17175 std::memmove(buf + (
static_cast<size_t>(
n) + 1), buf +
n,
static_cast<size_t>(k) -
static_cast<size_t>(
n));
17177 return buf + (
static_cast<size_t>(k) + 1U);
17180 if (min_exp <
n &&
n <= 0)
17185 std::memmove(buf + (2 +
static_cast<size_t>(-
n)), buf,
static_cast<size_t>(k));
17188 std::memset(buf + 2,
'0',
static_cast<size_t>(-
n));
17189 return buf + (2U +
static_cast<size_t>(-
n) +
static_cast<size_t>(k));
17204 std::memmove(buf + 2, buf + 1,
static_cast<size_t>(k) - 1);
17206 buf += 1 +
static_cast<size_t>(k);
17225template<
typename FloatType>
17230 static_cast<void>(last);
17234 if (std::signbit(
value))
17241#pragma GCC diagnostic push
17242#pragma GCC diagnostic ignored "-Wfloat-equal"
17253#pragma GCC diagnostic pop
17256 JSON_ASSERT(last - first >= std::numeric_limits<FloatType>::max_digits10);
17263 int decimal_exponent = 0;
17266 JSON_ASSERT(len <= std::numeric_limits<FloatType>::max_digits10);
17269 constexpr int kMinExp = -4;
17271 constexpr int kMaxExp = std::numeric_limits<FloatType>::digits10;
17274 JSON_ASSERT(last - first >= 2 + (-kMinExp - 1) + std::numeric_limits<FloatType>::max_digits10);
17275 JSON_ASSERT(last - first >= std::numeric_limits<FloatType>::max_digits10 + 6);
17314template<
typename BasicJsonType>
17317 using string_t =
typename BasicJsonType::string_t;
17318 using number_float_t =
typename BasicJsonType::number_float_t;
17319 using number_integer_t =
typename BasicJsonType::number_integer_t;
17320 using number_unsigned_t =
typename BasicJsonType::number_unsigned_t;
17321 using binary_char_t =
typename BasicJsonType::binary_t::value_type;
17322 static constexpr std::uint8_t UTF8_ACCEPT = 0;
17323 static constexpr std::uint8_t UTF8_REJECT = 1;
17334 ,
loc(
std::localeconv())
17372 const bool pretty_print,
17374 const unsigned int indent_step,
17375 const unsigned int current_indent = 0)
17377 switch (val.m_type)
17381 if (val.m_value.object->empty())
17383 o->write_characters(
"{}", 2);
17389 o->write_characters(
"{\n", 2);
17392 const auto new_indent = current_indent + indent_step;
17399 auto i = val.m_value.object->cbegin();
17400 for (std::size_t cnt = 0; cnt < val.m_value.object->size() - 1; ++cnt, ++i)
17403 o->write_character(
'\"');
17405 o->write_characters(
"\": ", 3);
17407 o->write_characters(
",\n", 2);
17412 JSON_ASSERT(std::next(i) == val.m_value.object->cend());
17414 o->write_character(
'\"');
17416 o->write_characters(
"\": ", 3);
17419 o->write_character(
'\n');
17420 o->write_characters(
indent_string.c_str(), current_indent);
17421 o->write_character(
'}');
17425 o->write_character(
'{');
17428 auto i = val.m_value.object->cbegin();
17429 for (std::size_t cnt = 0; cnt < val.m_value.object->size() - 1; ++cnt, ++i)
17431 o->write_character(
'\"');
17433 o->write_characters(
"\":", 2);
17435 o->write_character(
',');
17440 JSON_ASSERT(std::next(i) == val.m_value.object->cend());
17441 o->write_character(
'\"');
17443 o->write_characters(
"\":", 2);
17446 o->write_character(
'}');
17454 if (val.m_value.array->empty())
17456 o->write_characters(
"[]", 2);
17462 o->write_characters(
"[\n", 2);
17465 const auto new_indent = current_indent + indent_step;
17472 for (
auto i = val.m_value.array->cbegin();
17473 i != val.m_value.array->cend() - 1; ++i)
17477 o->write_characters(
",\n", 2);
17483 dump(val.m_value.array->back(),
true,
ensure_ascii, indent_step, new_indent);
17485 o->write_character(
'\n');
17486 o->write_characters(
indent_string.c_str(), current_indent);
17487 o->write_character(
']');
17491 o->write_character(
'[');
17494 for (
auto i = val.m_value.array->cbegin();
17495 i != val.m_value.array->cend() - 1; ++i)
17498 o->write_character(
',');
17503 dump(val.m_value.array->back(),
false,
ensure_ascii, indent_step, current_indent);
17505 o->write_character(
']');
17513 o->write_character(
'\"');
17515 o->write_character(
'\"');
17523 o->write_characters(
"{\n", 2);
17526 const auto new_indent = current_indent + indent_step;
17534 o->write_characters(
"\"bytes\": [", 10);
17536 if (!val.m_value.binary->empty())
17538 for (
auto i = val.m_value.binary->cbegin();
17539 i != val.m_value.binary->cend() - 1; ++i)
17542 o->write_characters(
", ", 2);
17544 dump_integer(val.m_value.binary->back());
17547 o->write_characters(
"],\n", 3);
17550 o->write_characters(
"\"subtype\": ", 11);
17551 if (val.m_value.binary->has_subtype())
17553 dump_integer(val.m_value.binary->subtype());
17557 o->write_characters(
"null", 4);
17559 o->write_character(
'\n');
17560 o->write_characters(
indent_string.c_str(), current_indent);
17561 o->write_character(
'}');
17565 o->write_characters(
"{\"bytes\":[", 10);
17567 if (!val.m_value.binary->empty())
17569 for (
auto i = val.m_value.binary->cbegin();
17570 i != val.m_value.binary->cend() - 1; ++i)
17573 o->write_character(
',');
17575 dump_integer(val.m_value.binary->back());
17578 o->write_characters(
"],\"subtype\":", 12);
17579 if (val.m_value.binary->has_subtype())
17581 dump_integer(val.m_value.binary->subtype());
17582 o->write_character(
'}');
17586 o->write_characters(
"null}", 5);
17594 if (val.m_value.boolean)
17596 o->write_characters(
"true", 4);
17600 o->write_characters(
"false", 5);
17607 dump_integer(val.m_value.number_integer);
17613 dump_integer(val.m_value.number_unsigned);
17619 dump_float(val.m_value.number_float);
17625 o->write_characters(
"<discarded>", 11);
17631 o->write_characters(
"null", 4);
17657 std::uint32_t codepoint{};
17665 for (std::size_t i = 0; i < s.size(); ++i)
17667 const auto byte =
static_cast<std::uint8_t
>(s[i]);
17669 switch (decode(
state, codepoint,
byte))
17728 if ((codepoint <= 0x1F) || (
ensure_ascii && (codepoint >= 0x7F)))
17730 if (codepoint <= 0xFFFF)
17734 static_cast<std::uint16_t
>(codepoint)));
17740 static_cast<void>((std::snprintf)(
string_buffer.data() +
bytes, 13,
"\\u%04x\\u%04x",
17741 static_cast<std::uint16_t
>(0xD7C0u + (codepoint >> 10u)),
17742 static_cast<std::uint16_t
>(0xDC00u + (codepoint & 0x3FFu))));
17830 state = UTF8_ACCEPT;
17886 o->write_characters(
"\\ufffd", 6);
17890 o->write_characters(
"\xEF\xBF\xBD", 3);
17910 inline unsigned int count_digits(number_unsigned_t x)
noexcept
17912 unsigned int n_digits = 1;
17921 return n_digits + 1;
17925 return n_digits + 2;
17929 return n_digits + 3;
17941 static std::string hex_bytes(std::uint8_t
byte)
17943 std::string result =
"FF";
17944 constexpr const char* nibble_to_hex =
"0123456789ABCDEF";
17945 result[0] = nibble_to_hex[
byte / 16];
17946 result[1] = nibble_to_hex[
byte % 16];
17951 template <typename NumberType, enable_if_t<std::is_signed<NumberType>::value,
int> = 0>
17952 bool is_negative_number(NumberType x)
17957 template < typename NumberType, enable_if_t <std::is_unsigned<NumberType>::value,
int > = 0 >
17958 bool is_negative_number(NumberType )
17973 std::is_integral<NumberType>::value ||
17974 std::is_same<NumberType, number_unsigned_t>::value ||
17975 std::is_same<NumberType, number_integer_t>::value ||
17976 std::is_same<NumberType, binary_char_t>::value,
17978 void dump_integer(NumberType x)
17980 static constexpr std::array<std::array<char, 2>, 100> digits_to_99
17983 {{
'0',
'0'}}, {{
'0',
'1'}}, {{
'0',
'2'}}, {{
'0',
'3'}}, {{
'0',
'4'}}, {{
'0',
'5'}}, {{
'0',
'6'}}, {{
'0',
'7'}}, {{
'0',
'8'}}, {{
'0',
'9'}},
17984 {{
'1',
'0'}}, {{
'1',
'1'}}, {{
'1',
'2'}}, {{
'1',
'3'}}, {{
'1',
'4'}}, {{
'1',
'5'}}, {{
'1',
'6'}}, {{
'1',
'7'}}, {{
'1',
'8'}}, {{
'1',
'9'}},
17985 {{
'2',
'0'}}, {{
'2',
'1'}}, {{
'2',
'2'}}, {{
'2',
'3'}}, {{
'2',
'4'}}, {{
'2',
'5'}}, {{
'2',
'6'}}, {{
'2',
'7'}}, {{
'2',
'8'}}, {{
'2',
'9'}},
17986 {{
'3',
'0'}}, {{
'3',
'1'}}, {{
'3',
'2'}}, {{
'3',
'3'}}, {{
'3',
'4'}}, {{
'3',
'5'}}, {{
'3',
'6'}}, {{
'3',
'7'}}, {{
'3',
'8'}}, {{
'3',
'9'}},
17987 {{
'4',
'0'}}, {{
'4',
'1'}}, {{
'4',
'2'}}, {{
'4',
'3'}}, {{
'4',
'4'}}, {{
'4',
'5'}}, {{
'4',
'6'}}, {{
'4',
'7'}}, {{
'4',
'8'}}, {{
'4',
'9'}},
17988 {{
'5',
'0'}}, {{
'5',
'1'}}, {{
'5',
'2'}}, {{
'5',
'3'}}, {{
'5',
'4'}}, {{
'5',
'5'}}, {{
'5',
'6'}}, {{
'5',
'7'}}, {{
'5',
'8'}}, {{
'5',
'9'}},
17989 {{
'6',
'0'}}, {{
'6',
'1'}}, {{
'6',
'2'}}, {{
'6',
'3'}}, {{
'6',
'4'}}, {{
'6',
'5'}}, {{
'6',
'6'}}, {{
'6',
'7'}}, {{
'6',
'8'}}, {{
'6',
'9'}},
17990 {{
'7',
'0'}}, {{
'7',
'1'}}, {{
'7',
'2'}}, {{
'7',
'3'}}, {{
'7',
'4'}}, {{
'7',
'5'}}, {{
'7',
'6'}}, {{
'7',
'7'}}, {{
'7',
'8'}}, {{
'7',
'9'}},
17991 {{
'8',
'0'}}, {{
'8',
'1'}}, {{
'8',
'2'}}, {{
'8',
'3'}}, {{
'8',
'4'}}, {{
'8',
'5'}}, {{
'8',
'6'}}, {{
'8',
'7'}}, {{
'8',
'8'}}, {{
'8',
'9'}},
17992 {{
'9',
'0'}}, {{
'9',
'1'}}, {{
'9',
'2'}}, {{
'9',
'3'}}, {{
'9',
'4'}}, {{
'9',
'5'}}, {{
'9',
'6'}}, {{
'9',
'7'}}, {{
'9',
'8'}}, {{
'9',
'9'}},
17999 o->write_character(
'0');
18004 auto buffer_ptr = number_buffer.begin();
18006 number_unsigned_t abs_value;
18008 unsigned int n_chars{};
18010 if (is_negative_number(x))
18013 abs_value = remove_sign(
static_cast<number_integer_t
>(x));
18016 n_chars = 1 + count_digits(abs_value);
18020 abs_value =
static_cast<number_unsigned_t
>(x);
18021 n_chars = count_digits(abs_value);
18029 buffer_ptr += n_chars;
18033 while (abs_value >= 100)
18035 const auto digits_index =
static_cast<unsigned>((abs_value % 100));
18037 *(--buffer_ptr) = digits_to_99[digits_index][1];
18038 *(--buffer_ptr) = digits_to_99[digits_index][0];
18041 if (abs_value >= 10)
18043 const auto digits_index =
static_cast<unsigned>(abs_value);
18044 *(--buffer_ptr) = digits_to_99[digits_index][1];
18045 *(--buffer_ptr) = digits_to_99[digits_index][0];
18049 *(--buffer_ptr) =
static_cast<char>(
'0' + abs_value);
18052 o->write_characters(number_buffer.data(), n_chars);
18063 void dump_float(number_float_t x)
18066 if (!std::isfinite(x))
18068 o->write_characters(
"null", 4);
18077 static constexpr bool is_ieee_single_or_double
18078 = (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) ||
18079 (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);
18081 dump_float(x, std::integral_constant<bool, is_ieee_single_or_double>());
18084 void dump_float(number_float_t x, std::true_type )
18086 auto*
begin = number_buffer.data();
18089 o->write_characters(
begin,
static_cast<size_t>(
end -
begin));
18092 void dump_float(number_float_t x, std::false_type )
18095 static constexpr auto d = std::numeric_limits<number_float_t>::max_digits10;
18099 std::ptrdiff_t len = (std::snprintf)(number_buffer.data(), number_buffer.size(),
"%.*g", d, x);
18104 JSON_ASSERT(
static_cast<std::size_t
>(len) < number_buffer.size());
18110 const auto end = std::remove(number_buffer.begin(), number_buffer.begin() + len,
thousands_sep);
18111 std::fill(
end, number_buffer.end(),
'\0');
18113 len = (
end - number_buffer.begin());
18120 const auto dec_pos = std::find(number_buffer.begin(), number_buffer.end(),
decimal_point);
18121 if (dec_pos != number_buffer.end())
18127 o->write_characters(number_buffer.data(),
static_cast<std::size_t
>(len));
18130 const bool value_is_int_like =
18131 std::none_of(number_buffer.begin(), number_buffer.begin() + len + 1,
18134 return c ==
'.' || c ==
'e';
18137 if (value_is_int_like)
18139 o->write_characters(
".0", 2);
18164 static std::uint8_t decode(std::uint8_t&
state, std::uint32_t& codep,
const std::uint8_t
byte)
noexcept
18166 static const std::array<std::uint8_t, 400> utf8d =
18169 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,
18170 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,
18171 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,
18172 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,
18173 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,
18174 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,
18175 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,
18176 0xA, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x4, 0x3, 0x3,
18177 0xB, 0x6, 0x6, 0x6, 0x5, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8,
18178 0x0, 0x1, 0x2, 0x3, 0x5, 0x8, 0x7, 0x1, 0x1, 0x1, 0x4, 0x6, 0x1, 0x1, 0x1, 0x1,
18179 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,
18180 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,
18181 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,
18182 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
18187 const std::uint8_t
type = utf8d[
byte];
18189 codep = (
state != UTF8_ACCEPT)
18190 ? (
byte & 0x3fu) | (codep << 6u)
18193 std::size_t index = 256u +
static_cast<size_t>(
state) * 16u +
static_cast<size_t>(
type);
18195 state = utf8d[index];
18204 number_unsigned_t remove_sign(number_unsigned_t x)
18219 inline number_unsigned_t remove_sign(number_integer_t x)
noexcept
18221 JSON_ASSERT(x < 0 && x < (std::numeric_limits<number_integer_t>::max)());
18222 return static_cast<number_unsigned_t
>(-(x + 1)) + 1;
18230 std::array<char, 64> number_buffer{{}};
18260#include <functional>
18261#include <initializer_list>
18264#include <stdexcept>
18265#include <type_traits>
18279template <
class Key,
class T,
class IgnoredLess = std::less<Key>,
18280 class Allocator = std::allocator<std::pair<const Key, T>>>
18281 struct ordered_map : std::vector<std::pair<const Key, T>, Allocator>
18283 using key_type = Key;
18290#ifdef JSON_HAS_CPP_14
18300 template <
class It>
18306 std::pair<iterator, bool>
emplace(
const key_type& key, T&& t)
18308 for (
auto it = this->
begin(); it != this->
end(); ++it)
18310 if (m_compare(it->first, key))
18312 return {it,
false};
18315 Container::emplace_back(key, std::forward<T>(t));
18316 return {std::prev(this->
end()),
true};
18320 detail::is_usable_as_key_type<key_compare, key_type, KeyType>::value,
int> = 0>
18321 std::pair<iterator, bool>
emplace(KeyType && key, T && t)
18323 for (
auto it = this->
begin(); it != this->
end(); ++it)
18325 if (m_compare(it->first, key))
18327 return {it,
false};
18330 Container::emplace_back(std::forward<KeyType>(key), std::forward<T>(t));
18331 return {std::prev(this->
end()),
true};
18336 return emplace(key, T{}).first->second;
18340 detail::is_usable_as_key_type<key_compare, key_type, KeyType>::value,
int> = 0>
18343 return emplace(std::forward<KeyType>(key), T{}).first->second;
18346 const T&
operator[](
const key_type& key)
const
18352 detail::is_usable_as_key_type<key_compare, key_type, KeyType>::value,
int> = 0>
18355 return at(std::forward<KeyType>(key));
18360 for (
auto it = this->
begin(); it != this->
end(); ++it)
18362 if (m_compare(it->first, key))
18368 JSON_THROW(std::out_of_range(
"key not found"));
18372 detail::is_usable_as_key_type<key_compare, key_type, KeyType>::value,
int> = 0>
18375 for (
auto it = this->
begin(); it != this->
end(); ++it)
18377 if (m_compare(it->first, key))
18383 JSON_THROW(std::out_of_range(
"key not found"));
18386 const T&
at(
const key_type& key)
const
18388 for (
auto it = this->
begin(); it != this->
end(); ++it)
18390 if (m_compare(it->first, key))
18396 JSON_THROW(std::out_of_range(
"key not found"));
18400 detail::is_usable_as_key_type<key_compare, key_type, KeyType>::value,
int> = 0>
18401 const T &
at(KeyType && key)
const
18403 for (
auto it = this->
begin(); it != this->
end(); ++it)
18405 if (m_compare(it->first, key))
18411 JSON_THROW(std::out_of_range(
"key not found"));
18416 for (
auto it = this->
begin(); it != this->
end(); ++it)
18418 if (m_compare(it->first, key))
18421 for (
auto next = it; ++next != this->
end(); ++it)
18426 Container::pop_back();
18434 detail::is_usable_as_key_type<key_compare, key_type, KeyType>::value,
int> = 0>
18437 for (
auto it = this->
begin(); it != this->
end(); ++it)
18439 if (m_compare(it->first, key))
18442 for (
auto next = it; ++next != this->
end(); ++it)
18447 Container::pop_back();
18456 return erase(pos, std::next(pos));
18466 const auto elements_affected = std::distance(first, last);
18467 const auto offset = std::distance(Container::begin(), first);
18489 for (
auto it = first; std::next(it, elements_affected) != Container::end(); ++it)
18492 new (&*it)
value_type{std::move(*std::next(it, elements_affected))};
18500 Container::resize(this->size() -
static_cast<size_type>(elements_affected));
18509 return Container::begin() + offset;
18514 for (
auto it = this->
begin(); it != this->
end(); ++it)
18516 if (m_compare(it->first, key))
18525 detail::is_usable_as_key_type<key_compare, key_type, KeyType>::value,
int> = 0>
18528 for (
auto it = this->
begin(); it != this->
end(); ++it)
18530 if (m_compare(it->first, key))
18540 for (
auto it = this->
begin(); it != this->
end(); ++it)
18542 if (m_compare(it->first, key))
18547 return Container::end();
18551 detail::is_usable_as_key_type<key_compare, key_type, KeyType>::value,
int> = 0>
18554 for (
auto it = this->
begin(); it != this->
end(); ++it)
18556 if (m_compare(it->first, key))
18561 return Container::end();
18566 for (
auto it = this->
begin(); it != this->
end(); ++it)
18568 if (m_compare(it->first, key))
18573 return Container::end();
18578 return emplace(value.first, std::move(value.second));
18583 for (
auto it = this->
begin(); it != this->
end(); ++it)
18585 if (m_compare(it->first, value.first))
18587 return {it,
false};
18590 Container::push_back(value);
18591 return {--this->
end(),
true};
18594 template<
typename InputIt>
18595 using require_input_iter =
typename std::enable_if<std::is_convertible<typename std::iterator_traits<InputIt>::iterator_category,
18596 std::input_iterator_tag>::value>
::type;
18598 template<
typename InputIt,
typename = require_input_iter<InputIt>>
18601 for (
auto it = first; it != last; ++it)
18614#if defined(JSON_HAS_CPP_17)
18616 #include <string_view>
18652 friend class ::nlohmann::json_pointer;
18656 template<
typename BasicJsonType,
typename InputType>
18657 friend class ::nlohmann::detail::parser;
18658 friend ::nlohmann::detail::serializer<basic_json>;
18659 template<
typename BasicJsonType>
18660 friend class ::nlohmann::detail::iter_impl;
18661 template<
typename BasicJsonType,
typename CharType>
18662 friend class ::nlohmann::detail::binary_writer;
18663 template<
typename BasicJsonType,
typename InputType,
typename SAX>
18664 friend class ::nlohmann::detail::binary_reader;
18665 template<
typename BasicJsonType>
18666 friend class ::nlohmann::detail::json_sax_dom_parser;
18667 template<
typename BasicJsonType>
18668 friend class ::nlohmann::detail::json_sax_dom_callback_parser;
18669 friend class ::nlohmann::detail::exception;
18674 JSON_PRIVATE_UNLESS_TESTED:
18678 template<
typename InputAdapterType>
18679 static ::nlohmann::detail::parser<basic_json, InputAdapterType>
parser(
18680 InputAdapterType adapter,
18682 const bool allow_exceptions =
true,
18683 const bool ignore_comments =
false
18686 return ::nlohmann::detail::parser<basic_json, InputAdapterType>(std::move(adapter),
18687 std::move(cb), allow_exceptions, ignore_comments);
18692 template<
typename BasicJsonType>
18694 template<
typename BasicJsonType>
18696 template<
typename Iterator>
18700 template<
typename CharType>
18703 template<
typename InputType>
18714 template<
typename T,
typename SFINAE>
18771 using pointer =
typename std::allocator_traits<allocator_type>::pointer;
18773 using const_pointer =
typename std::allocator_traits<allocator_type>::const_pointer;
18801 result[
"copyright"] =
"(C) 2013-2022 Niels Lohmann";
18802 result[
"name"] =
"JSON for Modern C++";
18803 result[
"url"] =
"https://github.com/nlohmann/json";
18804 result[
"version"][
"string"] =
18813 result[
"platform"] =
"win32";
18814#elif defined __linux__
18815 result[
"platform"] =
"linux";
18816#elif defined __APPLE__
18817 result[
"platform"] =
"apple";
18818#elif defined __unix__
18819 result[
"platform"] =
"unix";
18821 result[
"platform"] =
"unknown";
18824#if defined(__ICC) || defined(__INTEL_COMPILER)
18825 result[
"compiler"] = {{
"family",
"icc"}, {
"version", __INTEL_COMPILER}};
18826#elif defined(__clang__)
18827 result[
"compiler"] = {{
"family",
"clang"}, {
"version", __clang_version__}};
18828#elif defined(__GNUC__) || defined(__GNUG__)
18830 std::to_string(__GNUC__),
'.',
18831 std::to_string(__GNUC_MINOR__),
'.',
18832 std::to_string(__GNUC_PATCHLEVEL__))
18835#elif defined(__HP_cc) || defined(__HP_aCC)
18836 result[
"compiler"] =
"hp"
18837#elif defined(__IBMCPP__)
18838 result[
"compiler"] = {{
"family",
"ilecpp"}, {
"version", __IBMCPP__}};
18839#elif defined(_MSC_VER)
18840 result[
"compiler"] = {{
"family",
"msvc"}, {
"version", _MSC_VER}};
18841#elif defined(__PGI)
18842 result[
"compiler"] = {{
"family",
"pgcpp"}, {
"version", __PGI}};
18843#elif defined(__SUNPRO_CC)
18844 result[
"compiler"] = {{
"family",
"sunpro"}, {
"version", __SUNPRO_CC}};
18846 result[
"compiler"] = {{
"family",
"unknown"}, {
"version",
"unknown"}};
18850#if defined(_MSVC_LANG)
18851 result[
"compiler"][
"c++"] = std::to_string(_MSVC_LANG);
18852#elif defined(__cplusplus)
18853 result[
"compiler"][
"c++"] = std::to_string(__cplusplus);
18855 result[
"compiler"][
"c++"] =
"unknown";
18874#if defined(JSON_HAS_CPP_14)
18884 using object_t = ObjectType<StringType,
18887 AllocatorType<std::pair<
const StringType,
18892 using array_t = ArrayType<basic_json, AllocatorType<basic_json>>;
18900 using boolean_t = BooleanType;
18904 using number_integer_t = NumberIntegerType;
18908 using number_unsigned_t = NumberUnsignedType;
18912 using number_float_t = NumberFloatType;
18927 template<
typename T,
typename... Args>
18929 static T* create(Args&& ... args)
18931 AllocatorType<T> alloc;
18932 using AllocatorTraits = std::allocator_traits<AllocatorType<T>>;
18934 auto deleter = [&](T * obj)
18936 AllocatorTraits::deallocate(alloc, obj, 1);
18938 std::unique_ptr<T,
decltype(deleter)> obj(AllocatorTraits::allocate(alloc, 1), deleter);
18939 AllocatorTraits::construct(alloc, obj.get(), std::forward<Args>(args)...);
18941 return obj.release();
18987 number_integer_t number_integer;
18989 number_unsigned_t number_unsigned;
18991 number_float_t number_float;
18994 json_value() =
default;
18996 json_value(boolean_t v) noexcept : boolean(v) {}
18998 json_value(number_integer_t v) noexcept : number_integer(v) {}
19008 case value_t::object:
19010 object = create<object_t>();
19014 case value_t::array:
19016 array = create<array_t>();
19020 case value_t::string:
19022 string = create<string_t>(
"");
19026 case value_t::binary:
19028 binary = create<binary_t>();
19032 case value_t::boolean:
19034 boolean =
static_cast<boolean_t
>(
false);
19038 case value_t::number_integer:
19044 case value_t::number_unsigned:
19050 case value_t::number_float:
19056 case value_t::null:
19062 case value_t::discarded:
19082 json_value(
const object_t& value) :
object(create<object_t>(
value)) {}
19085 json_value(object_t&& value) :
object(create<object_t>(std::move(
value))) {}
19088 json_value(
const array_t& value) :
array(create<array_t>(
value)) {}
19091 json_value(array_t&& value) :
array(create<array_t>(std::move(
value))) {}
19094 json_value(
const typename binary_t::container_type& value) :
binary(create<binary_t>(
value)) {}
19097 json_value(
typename binary_t::container_type&& value) :
binary(create<binary_t>(std::move(
value))) {}
19100 json_value(
const binary_t& value) :
binary(create<binary_t>(
value)) {}
19103 json_value(binary_t&& value) :
binary(create<binary_t>(std::move(
value))) {}
19107 if (t == value_t::array || t == value_t::object)
19110 std::vector<basic_json> stack;
19113 if (t == value_t::array)
19115 stack.reserve(
array->size());
19116 std::move(
array->begin(),
array->end(), std::back_inserter(stack));
19120 stack.reserve(
object->size());
19121 for (
auto&& it : *
object)
19123 stack.push_back(std::move(it.second));
19127 while (!stack.empty())
19130 basic_json current_item(std::move(stack.back()));
19135 if (current_item.is_array())
19137 std::move(current_item.m_value.array->begin(), current_item.m_value.array->end(), std::back_inserter(stack));
19139 current_item.m_value.array->clear();
19141 else if (current_item.is_object())
19143 for (
auto&& it : *current_item.m_value.object)
19145 stack.push_back(std::move(it.second));
19148 current_item.m_value.object->clear();
19158 case value_t::object:
19160 AllocatorType<object_t> alloc;
19161 std::allocator_traits<
decltype(alloc)>::destroy(alloc,
object);
19162 std::allocator_traits<
decltype(alloc)>::deallocate(alloc,
object, 1);
19166 case value_t::array:
19168 AllocatorType<array_t> alloc;
19169 std::allocator_traits<
decltype(alloc)>::destroy(alloc, array);
19170 std::allocator_traits<
decltype(alloc)>::deallocate(alloc, array, 1);
19174 case value_t::string:
19176 AllocatorType<string_t> alloc;
19177 std::allocator_traits<
decltype(alloc)>::destroy(alloc,
string);
19178 std::allocator_traits<
decltype(alloc)>::deallocate(alloc,
string, 1);
19182 case value_t::binary:
19184 AllocatorType<binary_t> alloc;
19185 std::allocator_traits<
decltype(alloc)>::destroy(alloc, binary);
19186 std::allocator_traits<
decltype(alloc)>::deallocate(alloc, binary, 1);
19190 case value_t::null:
19191 case value_t::boolean:
19192 case value_t::number_integer:
19193 case value_t::number_unsigned:
19194 case value_t::number_float:
19195 case value_t::discarded:
19223 void assert_invariant(
bool check_parents =
true) const noexcept
19230#if JSON_DIAGNOSTICS
19236 return j.m_parent ==
this;
19241 static_cast<void>(check_parents);
19246#if JSON_DIAGNOSTICS
19249 case value_t::array:
19251 for (
auto& element : *
m_value.array)
19253 element.m_parent =
this;
19258 case value_t::object:
19260 for (
auto& element : *
m_value.object)
19262 element.second.m_parent =
this;
19267 case value_t::null:
19268 case value_t::string:
19269 case value_t::boolean:
19270 case value_t::number_integer:
19271 case value_t::number_unsigned:
19272 case value_t::number_float:
19273 case value_t::binary:
19274 case value_t::discarded:
19283#if JSON_DIAGNOSTICS
19286 (it + i)->m_parent =
this;
19289 static_cast<void>(count_set_parents);
19294 reference set_parent(
reference j, std::size_t old_capacity =
static_cast<std::size_t
>(-1))
19296#if JSON_DIAGNOSTICS
19297 if (old_capacity !=
static_cast<std::size_t
>(-1))
19311#ifdef JSON_HEDLEY_MSVC_VERSION
19312#pragma warning(push )
19313#pragma warning(disable : 4127)
19320#ifdef JSON_HEDLEY_MSVC_VERSION
19321#pragma warning( pop )
19326 static_cast<void>(j);
19327 static_cast<void>(old_capacity);
19359 assert_invariant();
19364 basic_json(std::nullptr_t =
nullptr) noexcept
19367 assert_invariant();
19372 template <
typename CompatibleType,
19375 !detail::is_basic_json<U>::value && detail::is_compatible_type<basic_json_t, U>::value,
int > = 0 >
19376 basic_json(CompatibleType && val)
noexcept(
noexcept(
19377 JSONSerializer<U>::to_json(std::declval<basic_json_t&>(),
19378 std::forward<CompatibleType>(val))))
19380 JSONSerializer<U>::to_json(*
this, std::forward<CompatibleType>(val));
19382 assert_invariant();
19387 template <
typename BasicJsonType,
19389 detail::is_basic_json<BasicJsonType>::value&& !std::is_same<basic_json, BasicJsonType>::value,
int > = 0 >
19392 using other_boolean_t =
typename BasicJsonType::boolean_t;
19393 using other_number_float_t =
typename BasicJsonType::number_float_t;
19394 using other_number_integer_t =
typename BasicJsonType::number_integer_t;
19395 using other_number_unsigned_t =
typename BasicJsonType::number_unsigned_t;
19396 using other_string_t =
typename BasicJsonType::string_t;
19397 using other_object_t =
typename BasicJsonType::object_t;
19398 using other_array_t =
typename BasicJsonType::array_t;
19399 using other_binary_t =
typename BasicJsonType::binary_t;
19401 switch (val.type())
19403 case value_t::boolean:
19404 JSONSerializer<other_boolean_t>::to_json(*
this, val.template get<other_boolean_t>());
19406 case value_t::number_float:
19407 JSONSerializer<other_number_float_t>::to_json(*
this, val.template get<other_number_float_t>());
19409 case value_t::number_integer:
19410 JSONSerializer<other_number_integer_t>::to_json(*
this, val.template get<other_number_integer_t>());
19412 case value_t::number_unsigned:
19413 JSONSerializer<other_number_unsigned_t>::to_json(*
this, val.template get<other_number_unsigned_t>());
19415 case value_t::string:
19416 JSONSerializer<other_string_t>::to_json(*
this, val.template get_ref<const other_string_t&>());
19418 case value_t::object:
19419 JSONSerializer<other_object_t>::to_json(*
this, val.template get_ref<const other_object_t&>());
19421 case value_t::array:
19422 JSONSerializer<other_array_t>::to_json(*
this, val.template get_ref<const other_array_t&>());
19424 case value_t::binary:
19425 JSONSerializer<other_binary_t>::to_json(*
this, val.template get_ref<const other_binary_t&>());
19427 case value_t::null:
19430 case value_t::discarded:
19431 m_type = value_t::discarded;
19438 assert_invariant();
19444 bool type_deduction =
true,
19445 value_t manual_type = value_t::array)
19449 bool is_an_object = std::all_of(
init.begin(),
init.end(),
19450 [](
const detail::json_ref<basic_json>& element_ref)
19452 return element_ref->is_array() && element_ref->size() == 2 && (*element_ref)[0].is_string();
19456 if (!type_deduction)
19459 if (manual_type == value_t::array)
19461 is_an_object =
false;
19474 m_type = value_t::object;
19477 for (
auto& element_ref :
init)
19479 auto element = element_ref.moved_or_copied();
19481 std::move(*((*element.m_value.array)[0].m_value.string)),
19482 std::move((*element.m_value.array)[1]));
19488 m_type = value_t::array;
19493 assert_invariant();
19499 static basic_json binary(
const typename binary_t::container_type&
init)
19502 res.m_type = value_t::binary;
19510 static basic_json binary(
const typename binary_t::container_type&
init,
typename binary_t::subtype_type subtype)
19513 res.m_type = value_t::binary;
19514 res.m_value = binary_t(
init, subtype);
19521 static basic_json binary(
typename binary_t::container_type&&
init)
19524 res.m_type = value_t::binary;
19525 res.m_value = std::move(
init);
19532 static basic_json binary(
typename binary_t::container_type&&
init,
typename binary_t::subtype_type subtype)
19535 res.m_type = value_t::binary;
19536 res.m_value = binary_t(std::move(
init), subtype);
19561 m_value.array = create<array_t>(cnt, val);
19563 assert_invariant();
19568 template <
class InputIT,
typename std::enable_if <
19569 std::is_same<InputIT, typename basic_json_t::iterator>::value ||
19570 std::is_same<InputIT, typename basic_json_t::const_iterator>::value,
int >
::type = 0 >
19583 m_type = first.m_object->m_type;
19588 case value_t::boolean:
19589 case value_t::number_float:
19590 case value_t::number_integer:
19591 case value_t::number_unsigned:
19592 case value_t::string:
19595 || !last.m_it.primitive_iterator.is_end()))
19602 case value_t::null:
19603 case value_t::object:
19604 case value_t::array:
19605 case value_t::binary:
19606 case value_t::discarded:
19613 case value_t::number_integer:
19615 m_value.number_integer = first.m_object->m_value.number_integer;
19619 case value_t::number_unsigned:
19621 m_value.number_unsigned = first.m_object->m_value.number_unsigned;
19625 case value_t::number_float:
19627 m_value.number_float = first.m_object->m_value.number_float;
19631 case value_t::boolean:
19633 m_value.boolean = first.m_object->m_value.boolean;
19637 case value_t::string:
19639 m_value = *first.m_object->m_value.string;
19643 case value_t::object:
19645 m_value.object = create<object_t>(first.m_it.object_iterator,
19646 last.m_it.object_iterator);
19650 case value_t::array:
19652 m_value.array = create<array_t>(first.m_it.array_iterator,
19653 last.m_it.array_iterator);
19657 case value_t::binary:
19659 m_value = *first.m_object->m_value.binary;
19663 case value_t::null:
19664 case value_t::discarded:
19670 assert_invariant();
19678 template<
typename JsonRef,
19680 std::is_same<typename JsonRef::value_type, basic_json>>::value,
int> = 0 >
19686 : m_type(other.m_type)
19689 other.assert_invariant();
19693 case value_t::object:
19695 m_value = *other.m_value.object;
19699 case value_t::array:
19701 m_value = *other.m_value.array;
19705 case value_t::string:
19707 m_value = *other.m_value.string;
19711 case value_t::boolean:
19713 m_value = other.m_value.boolean;
19717 case value_t::number_integer:
19719 m_value = other.m_value.number_integer;
19723 case value_t::number_unsigned:
19725 m_value = other.m_value.number_unsigned;
19729 case value_t::number_float:
19731 m_value = other.m_value.number_float;
19735 case value_t::binary:
19737 m_value = *other.m_value.binary;
19741 case value_t::null:
19742 case value_t::discarded:
19748 assert_invariant();
19754 : m_type(std::move(other.m_type)),
19755 m_value(std::move(other.m_value))
19758 other.assert_invariant(
false);
19761 other.m_type = value_t::null;
19762 other.m_value = {};
19765 assert_invariant();
19771 std::is_nothrow_move_constructible<value_t>::value&&
19772 std::is_nothrow_move_assignable<value_t>::value&&
19773 std::is_nothrow_move_constructible<json_value>::value&&
19774 std::is_nothrow_move_assignable<json_value>::value
19778 other.assert_invariant();
19781 swap(m_type, other.m_type);
19782 swap(
m_value, other.m_value);
19785 assert_invariant();
19793 assert_invariant(
false);
19810 string_t dump(
const int indent = -1,
19811 const char indent_char =
' ',
19812 const bool ensure_ascii =
false,
19816 serializer s(detail::output_adapter<char, string_t>(
result), indent_char, error_handler);
19820 s.dump(*
this,
true, ensure_ascii,
static_cast<unsigned int>(indent));
19824 s.dump(*
this,
false, ensure_ascii, 0);
19839 constexpr bool is_primitive() const noexcept
19841 return is_null() || is_string() || is_boolean() || is_number() || is_binary();
19846 constexpr bool is_structured() const noexcept
19848 return is_array() || is_object();
19853 constexpr bool is_null() const noexcept
19855 return m_type == value_t::null;
19860 constexpr bool is_boolean() const noexcept
19862 return m_type == value_t::boolean;
19867 constexpr bool is_number() const noexcept
19869 return is_number_integer() || is_number_float();
19874 constexpr bool is_number_integer() const noexcept
19876 return m_type == value_t::number_integer || m_type == value_t::number_unsigned;
19881 constexpr bool is_number_unsigned() const noexcept
19883 return m_type == value_t::number_unsigned;
19888 constexpr bool is_number_float() const noexcept
19890 return m_type == value_t::number_float;
19895 constexpr bool is_object() const noexcept
19897 return m_type == value_t::object;
19902 constexpr bool is_array() const noexcept
19904 return m_type == value_t::array;
19909 constexpr bool is_string() const noexcept
19911 return m_type == value_t::string;
19916 constexpr bool is_binary() const noexcept
19918 return m_type == value_t::binary;
19923 constexpr bool is_discarded() const noexcept
19925 return m_type == value_t::discarded;
19930 constexpr operator value_t() const noexcept
19943 boolean_t get_impl(boolean_t* )
const
19954 object_t* get_impl_ptr(object_t* )
noexcept
19956 return is_object() ?
m_value.object :
nullptr;
19960 constexpr const object_t* get_impl_ptr(
const object_t* )
const noexcept
19962 return is_object() ?
m_value.object :
nullptr;
19966 array_t* get_impl_ptr(array_t* )
noexcept
19968 return is_array() ?
m_value.array :
nullptr;
19972 constexpr const array_t* get_impl_ptr(
const array_t* )
const noexcept
19974 return is_array() ?
m_value.array :
nullptr;
19980 return is_string() ?
m_value.string :
nullptr;
19986 return is_string() ?
m_value.string :
nullptr;
19990 boolean_t* get_impl_ptr(boolean_t* )
noexcept
19992 return is_boolean() ? &
m_value.boolean :
nullptr;
19996 constexpr const boolean_t* get_impl_ptr(
const boolean_t* )
const noexcept
19998 return is_boolean() ? &
m_value.boolean :
nullptr;
20002 number_integer_t* get_impl_ptr(number_integer_t* )
noexcept
20004 return is_number_integer() ? &
m_value.number_integer :
nullptr;
20008 constexpr const number_integer_t* get_impl_ptr(
const number_integer_t* )
const noexcept
20010 return is_number_integer() ? &
m_value.number_integer :
nullptr;
20014 number_unsigned_t* get_impl_ptr(number_unsigned_t* )
noexcept
20016 return is_number_unsigned() ? &
m_value.number_unsigned :
nullptr;
20020 constexpr const number_unsigned_t* get_impl_ptr(
const number_unsigned_t* )
const noexcept
20022 return is_number_unsigned() ? &
m_value.number_unsigned :
nullptr;
20026 number_float_t* get_impl_ptr(number_float_t* )
noexcept
20028 return is_number_float() ? &
m_value.number_float :
nullptr;
20032 constexpr const number_float_t* get_impl_ptr(
const number_float_t* )
const noexcept
20034 return is_number_float() ? &
m_value.number_float :
nullptr;
20038 binary_t* get_impl_ptr(binary_t* )
noexcept
20040 return is_binary() ?
m_value.binary :
nullptr;
20044 constexpr const binary_t* get_impl_ptr(
const binary_t* )
const noexcept
20046 return is_binary() ?
m_value.binary :
nullptr;
20060 template<
typename ReferenceType,
typename ThisType>
20061 static ReferenceType get_ref_impl(ThisType& obj)
20064 auto* ptr = obj.template get_ptr<typename std::add_pointer<ReferenceType>::type>();
20081 template<
typename PointerType,
typename std::enable_if<
20082 std::is_pointer<PointerType>::value,
int>
::type = 0>
20083 auto get_ptr() noexcept -> decltype(std::declval<basic_json_t&>().get_impl_ptr(std::declval<PointerType>()))
20086 return get_impl_ptr(
static_cast<PointerType
>(
nullptr));
20091 template <
typename PointerType,
typename std::enable_if <
20092 std::is_pointer<PointerType>::value&&
20093 std::is_const<typename std::remove_pointer<PointerType>::type>::value,
int >
::type = 0 >
20094 constexpr auto get_ptr() const noexcept -> decltype(std::declval<const basic_json_t&>().get_impl_ptr(std::declval<PointerType>()))
20097 return get_impl_ptr(
static_cast<PointerType
>(
nullptr));
20139 template <
typename ValueType,
20141 detail::is_default_constructible<ValueType>::value&&
20142 detail::has_from_json<basic_json_t, ValueType>::value,
20144 ValueType get_impl(detail::priority_tag<0> )
const noexcept(
noexcept(
20145 JSONSerializer<ValueType>::from_json(std::declval<const basic_json_t&>(), std::declval<ValueType&>())))
20147 auto ret = ValueType();
20148 JSONSerializer<ValueType>::from_json(*
this, ret);
20182 template <
typename ValueType,
20184 detail::has_non_default_from_json<basic_json_t, ValueType>::value,
20186 ValueType get_impl(detail::priority_tag<1> )
const noexcept(
noexcept(
20187 JSONSerializer<ValueType>::from_json(std::declval<const basic_json_t&>())))
20189 return JSONSerializer<ValueType>::from_json(*
this);
20207 template <
typename BasicJsonType,
20209 detail::is_basic_json<BasicJsonType>::value,
20211 BasicJsonType get_impl(detail::priority_tag<2> )
const
20230 template<
typename BasicJsonType,
20232 std::is_same<BasicJsonType, basic_json_t>::value,
20234 basic_json get_impl(detail::priority_tag<3> )
const
20243 template<
typename PointerType,
20245 std::is_pointer<PointerType>::value,
20247 constexpr auto get_impl(detail::priority_tag<4> )
const noexcept
20248 ->
decltype(std::declval<const basic_json_t&>().template get_ptr<PointerType>())
20251 return get_ptr<PointerType>();
20278 template <
typename ValueTypeCV,
typename ValueType = detail::uncvref_t<ValueTypeCV>>
20279#if defined(JSON_HAS_CPP_14)
20282 auto get() const noexcept(
20283 noexcept(std::declval<const basic_json_t&>().template get_impl<ValueType>(detail::priority_tag<4> {})))
20284 ->
decltype(std::declval<const basic_json_t&>().template get_impl<ValueType>(detail::priority_tag<4> {}))
20289 static_assert(!std::is_reference<ValueTypeCV>::value,
20290 "get() cannot be used with reference types, you might want to use get_ref()");
20291 return get_impl<ValueType>(detail::priority_tag<4> {});
20321 template<
typename PointerType,
typename std::enable_if<
20322 std::is_pointer<PointerType>::value,
int>
::type = 0>
20323 auto get() noexcept -> decltype(std::declval<basic_json_t&>().template get_ptr<PointerType>())
20326 return get_ptr<PointerType>();
20331 template <
typename ValueType,
20333 !detail::is_basic_json<ValueType>::value&&
20334 detail::has_from_json<basic_json_t, ValueType>::value,
20336 ValueType & get_to(ValueType& v)
const noexcept(
noexcept(
20337 JSONSerializer<ValueType>::from_json(std::declval<const basic_json_t&>(), v)))
20339 JSONSerializer<ValueType>::from_json(*
this, v);
20345 template<
typename ValueType,
20347 detail::is_basic_json<ValueType>::value,
20349 ValueType & get_to(ValueType& v)
const
20356 typename T, std::size_t N,
20357 typename Array = T (&)[N],
20359 detail::has_from_json<basic_json_t, Array>::value,
int > = 0 >
20360 Array get_to(T (&v)[N])
const
20361 noexcept(
noexcept(JSONSerializer<Array>::from_json(
20362 std::declval<const basic_json_t&>(), v)))
20364 JSONSerializer<Array>::from_json(*
this, v);
20370 template<
typename ReferenceType,
typename std::enable_if<
20371 std::is_reference<ReferenceType>::value,
int>
::type = 0>
20372 ReferenceType get_ref()
20375 return get_ref_impl<ReferenceType>(*
this);
20380 template <
typename ReferenceType,
typename std::enable_if <
20381 std::is_reference<ReferenceType>::value&&
20382 std::is_const<typename std::remove_reference<ReferenceType>::type>::value,
int >
::type = 0 >
20383 ReferenceType get_ref()
const
20386 return get_ref_impl<ReferenceType>(*
this);
20418 template <
typename ValueType,
typename std::enable_if <
20419 detail::conjunction <
20420 detail::negation<std::is_pointer<ValueType>>,
20421 detail::negation<std::is_same<ValueType, std::nullptr_t>>,
20422 detail::negation<std::is_same<ValueType, detail::json_ref<basic_json>>>,
20423 detail::negation<std::is_same<ValueType, typename string_t::value_type>>,
20424 detail::negation<detail::is_basic_json<ValueType>>,
20425 detail::negation<std::is_same<ValueType, std::initializer_list<typename string_t::value_type>>>,
20426#if defined(JSON_HAS_CPP_17) && (defined(__GNUC__) || (defined(_MSC_VER) && _MSC_VER >= 1910 && _MSC_VER <= 1914))
20427 detail::negation<std::is_same<ValueType, std::string_view>>,
20429#if defined(JSON_HAS_CPP_17)
20430 detail::negation<std::is_same<ValueType, std::any>>,
20432 detail::is_detected_lazy<detail::get_template_function, const basic_json_t&, ValueType>
20433 >::value,
int >
::type = 0 >
20437 return get<ValueType>();
20442 binary_t& get_binary()
20449 return *get_ptr<binary_t*>();
20454 const binary_t& get_binary()
const
20461 return *get_ptr<const binary_t*>();
20484 return set_parent(
m_value.array->at(idx));
20507 return m_value.array->at(idx);
20523 reference at(
const typename object_t::key_type& key)
20531 auto it =
m_value.object->find(key);
20532 if (it ==
m_value.object->end())
20536 return set_parent(it->second);
20542 detail::is_usable_as_basic_json_key_type<basic_json_t, KeyType>::value,
int> = 0>
20551 auto it =
m_value.object->find(std::forward<KeyType>(key));
20552 if (it ==
m_value.object->end())
20556 return set_parent(it->second);
20569 auto it =
m_value.object->find(key);
20570 if (it ==
m_value.object->end())
20580 detail::is_usable_as_basic_json_key_type<basic_json_t, KeyType>::value,
int> = 0>
20589 auto it =
m_value.object->find(std::forward<KeyType>(key));
20590 if (it ==
m_value.object->end())
20604 m_type = value_t::array;
20605 m_value.array = create<array_t>();
20606 assert_invariant();
20613 if (idx >=
m_value.array->size())
20615#if JSON_DIAGNOSTICS
20617 const auto old_size =
m_value.array->size();
20618 const auto old_capacity =
m_value.array->capacity();
20620 m_value.array->resize(idx + 1);
20622#if JSON_DIAGNOSTICS
20634 assert_invariant();
20637 return m_value.array->operator[](idx);
20650 return m_value.array->operator[](idx);
20663 m_type = value_t::object;
20664 m_value.object = create<object_t>();
20665 assert_invariant();
20671 auto result =
m_value.object->emplace(std::move(key),
nullptr);
20672 return set_parent(
result.first->second);
20685 auto it =
m_value.object->find(key);
20695 template<
typename T>
20698 return operator[](
typename object_t::key_type(key));
20701 template<
typename T>
20704 return operator[](
typename object_t::key_type(key));
20710 detail::is_usable_as_basic_json_key_type<basic_json_t, KeyType>::value,
int > = 0 >
20716 m_type = value_t::object;
20717 m_value.object = create<object_t>();
20718 assert_invariant();
20724 auto result =
m_value.object->emplace(std::forward<KeyType>(key),
nullptr);
20725 return set_parent(
result.first->second);
20734 detail::is_usable_as_basic_json_key_type<basic_json_t, KeyType>::value,
int > = 0 >
20740 auto it =
m_value.object->find(std::forward<KeyType>(key));
20752 std::is_same<KeyType, typename object_t::key_type>::value
20754 && !std::is_same<value_t, ValueType>::value,
int > = 0 >
20755 typename std::decay<ValueType>::type
value(
const KeyType& key, ValueType && default_value)
const
20761 const auto it =
find(key);
20764 return it->template get<typename std::decay<ValueType>::type>();
20767 return std::forward<ValueType>(default_value);
20776 string_t value(
const typename object_t::key_type& key,
const char* default_value)
const
20786 && !std::is_same<value_t, ValueType>::value,
int > = 0 >
20787 typename std::decay<ValueType>::type
value(
const char* key, ValueType && default_value)
const
20789 return value(
typename object_t::key_type(key), std::forward<ValueType>(default_value));
20792 string_t value(
const char* key,
const char* default_value)
const
20794 return value(
typename object_t::key_type(key),
string_t(default_value));
20802 && !std::is_same<value_t, ValueType>::value
20803 && detail::is_usable_as_basic_json_key_type<basic_json_t, KeyType>::value,
int > = 0 >
20804 typename std::decay<ValueType>::type
value(KeyType && key, ValueType && default_value)
const
20810 const auto it =
find(std::forward<KeyType>(key));
20813 return it->template get<typename std::decay<ValueType>::type>();
20816 return std::forward<ValueType>(default_value);
20826 !detail::is_json_pointer<KeyType>::value,
int > = 0 >
20827 string_t value(KeyType && key,
const char* default_value)
const
20829 return value(std::forward<KeyType>(key),
string_t(default_value));
20844 return ptr.get_checked(
this).template get<ValueType>();
20848 return default_value;
20858 ValueType
value(const ::nlohmann::json_pointer<BasicJsonType>& ptr,
const ValueType& default_value)
const
20860 return value(ptr.convert(), default_value);
20872 template<
typename BasicJsonType>
20875 string_t value(const typename ::nlohmann::
json_pointer<BasicJsonType>& ptr, const
char* default_value)
const
20877 return value(ptr.convert(), default_value);
20915 std::is_same<IteratorType, typename basic_json_t::iterator>::value ||
20916 std::is_same<IteratorType, typename basic_json_t::const_iterator>::value,
int > = 0 >
20917 IteratorType
erase(IteratorType pos)
20929 case value_t::boolean:
20930 case value_t::number_float:
20931 case value_t::number_integer:
20932 case value_t::number_unsigned:
20933 case value_t::string:
20934 case value_t::binary:
20943 AllocatorType<string_t> alloc;
20944 std::allocator_traits<
decltype(alloc)>::destroy(alloc,
m_value.string);
20945 std::allocator_traits<
decltype(alloc)>::deallocate(alloc,
m_value.string, 1);
20948 else if (is_binary())
20950 AllocatorType<binary_t> alloc;
20951 std::allocator_traits<
decltype(alloc)>::destroy(alloc,
m_value.binary);
20952 std::allocator_traits<
decltype(alloc)>::deallocate(alloc,
m_value.binary, 1);
20956 m_type = value_t::null;
20957 assert_invariant();
20961 case value_t::object:
20963 result.m_it.object_iterator =
m_value.object->erase(pos.m_it.object_iterator);
20967 case value_t::array:
20969 result.m_it.array_iterator =
m_value.array->erase(pos.m_it.array_iterator);
20973 case value_t::null:
20974 case value_t::discarded:
20985 std::is_same<IteratorType, typename basic_json_t::iterator>::value ||
20986 std::is_same<IteratorType, typename basic_json_t::const_iterator>::value,
int > = 0 >
20987 IteratorType
erase(IteratorType first, IteratorType last)
20999 case value_t::boolean:
21000 case value_t::number_float:
21001 case value_t::number_integer:
21002 case value_t::number_unsigned:
21003 case value_t::string:
21004 case value_t::binary:
21007 || !last.m_it.primitive_iterator.is_end()))
21014 AllocatorType<string_t> alloc;
21015 std::allocator_traits<
decltype(alloc)>::destroy(alloc,
m_value.string);
21016 std::allocator_traits<
decltype(alloc)>::deallocate(alloc,
m_value.string, 1);
21019 else if (is_binary())
21021 AllocatorType<binary_t> alloc;
21022 std::allocator_traits<
decltype(alloc)>::destroy(alloc,
m_value.binary);
21023 std::allocator_traits<
decltype(alloc)>::deallocate(alloc,
m_value.binary, 1);
21027 m_type = value_t::null;
21028 assert_invariant();
21032 case value_t::object:
21034 result.m_it.object_iterator =
m_value.object->erase(first.m_it.object_iterator,
21035 last.m_it.object_iterator);
21039 case value_t::array:
21041 result.m_it.array_iterator =
m_value.array->erase(first.m_it.array_iterator,
21042 last.m_it.array_iterator);
21046 case value_t::null:
21047 case value_t::discarded:
21057 detail::has_erase_with_key_type<basic_json_t, KeyType>::value,
int > = 0 >
21058 size_type erase_internal(KeyType && key)
21066 return m_value.object->erase(std::forward<KeyType>(key));
21070 !detail::has_erase_with_key_type<basic_json_t, KeyType>::value,
int > = 0 >
21071 size_type erase_internal(KeyType && key)
21079 const auto it =
m_value.object->find(std::forward<KeyType>(key));
21080 if (it !=
m_value.object->end())
21096 return erase_internal(key);
21102 detail::is_usable_as_basic_json_key_type<basic_json_t, KeyType>::value,
int> = 0>
21105 return erase_internal(std::forward<KeyType>(key));
21169 detail::is_usable_as_basic_json_key_type<basic_json_t, KeyType>::value,
int> = 0>
21176 result.m_it.object_iterator =
m_value.object->find(std::forward<KeyType>(key));
21185 detail::is_usable_as_basic_json_key_type<basic_json_t, KeyType>::value,
int> = 0>
21192 result.m_it.object_iterator =
m_value.object->find(std::forward<KeyType>(key));
21203 return is_object() ?
m_value.object->count(key) : 0;
21209 detail::is_usable_as_basic_json_key_type<basic_json_t, KeyType>::value,
int> = 0>
21213 return is_object() ?
m_value.object->count(std::forward<KeyType>(key)) : 0;
21218 bool contains(
const typename object_t::key_type& key)
const
21220 return is_object() &&
m_value.object->find(key) !=
m_value.object->end();
21226 detail::is_usable_as_basic_json_key_type<basic_json_t, KeyType>::value,
int> = 0>
21227 bool contains(KeyType && key)
const
21229 return is_object() &&
m_value.object->find(std::forward<KeyType>(key)) !=
m_value.object->end();
21236 return ptr.contains(
this);
21239 template<
typename BasicJsonType>
21241 bool contains(
const typename ::nlohmann::json_pointer<BasicJsonType> ptr)
const
21243 return ptr.contains(
this);
21357 return ref.items();
21368 return ref.items();
21373 iteration_proxy<iterator> items() noexcept
21375 return iteration_proxy<iterator>(*
this);
21380 iteration_proxy<const_iterator> items() const noexcept
21382 return iteration_proxy<const_iterator>(*
this);
21397 bool empty() const noexcept
21401 case value_t::null:
21407 case value_t::array:
21410 return m_value.array->empty();
21413 case value_t::object:
21416 return m_value.object->empty();
21419 case value_t::string:
21420 case value_t::boolean:
21421 case value_t::number_integer:
21422 case value_t::number_unsigned:
21423 case value_t::number_float:
21424 case value_t::binary:
21425 case value_t::discarded:
21440 case value_t::null:
21446 case value_t::array:
21449 return m_value.array->size();
21452 case value_t::object:
21455 return m_value.object->size();
21458 case value_t::string:
21459 case value_t::boolean:
21460 case value_t::number_integer:
21461 case value_t::number_unsigned:
21462 case value_t::number_float:
21463 case value_t::binary:
21464 case value_t::discarded:
21479 case value_t::array:
21482 return m_value.array->max_size();
21485 case value_t::object:
21488 return m_value.object->max_size();
21491 case value_t::null:
21492 case value_t::string:
21493 case value_t::boolean:
21494 case value_t::number_integer:
21495 case value_t::number_unsigned:
21496 case value_t::number_float:
21497 case value_t::binary:
21498 case value_t::discarded:
21519 void clear() noexcept
21523 case value_t::number_integer:
21529 case value_t::number_unsigned:
21535 case value_t::number_float:
21541 case value_t::boolean:
21547 case value_t::string:
21553 case value_t::binary:
21559 case value_t::array:
21565 case value_t::object:
21571 case value_t::null:
21572 case value_t::discarded:
21591 m_type = value_t::array;
21593 assert_invariant();
21597 const auto old_capacity =
m_value.array->capacity();
21598 m_value.array->push_back(std::move(val));
21599 set_parent(
m_value.array->back(), old_capacity);
21607 push_back(std::move(val));
21624 m_type = value_t::array;
21626 assert_invariant();
21630 const auto old_capacity =
m_value.array->capacity();
21631 m_value.array->push_back(val);
21632 set_parent(
m_value.array->back(), old_capacity);
21645 void push_back(
const typename object_t::value_type& val)
21656 m_type = value_t::object;
21658 assert_invariant();
21663 set_parent(
res.first->second);
21668 reference operator+=(
const typename object_t::value_type& val)
21678 if (is_object() &&
init.size() == 2 && (*
init.begin())->is_string())
21681 push_back(
typename object_t::value_type(
21682 std::move(
key.get_ref<
string_t&>()), (
init.begin() + 1)->moved_or_copied()));
21700 template<
class... Args>
21701 reference emplace_back(Args&& ... args)
21712 m_type = value_t::array;
21714 assert_invariant();
21718 const auto old_capacity =
m_value.array->capacity();
21719 m_value.array->emplace_back(std::forward<Args>(args)...);
21720 return set_parent(
m_value.array->back(), old_capacity);
21725 template<
class... Args>
21726 std::pair<iterator, bool>
emplace(Args&& ... args)
21737 m_type = value_t::object;
21739 assert_invariant();
21743 auto res =
m_value.object->emplace(std::forward<Args>(args)...);
21744 set_parent(
res.first->second);
21748 it.m_it.object_iterator =
res.first;
21751 return {it,
res.second};
21757 template<
typename... Args>
21763 auto insert_pos = std::distance(
m_value.array->begin(), pos.m_it.array_iterator);
21764 m_value.array->insert(pos.m_it.array_iterator, std::forward<Args>(args)...);
21765 result.m_it.array_iterator =
m_value.array->begin() + insert_pos;
21789 return insert_iterator(pos, val);
21799 return insert(pos, val);
21816 return insert_iterator(pos, cnt, val);
21850 return insert_iterator(pos, first.m_it.array_iterator, last.m_it.array_iterator);
21870 return insert_iterator(pos, ilist.begin(), ilist.end());
21895 m_value.object->insert(first.m_it.object_iterator, last.m_it.object_iterator);
21902 update(j.begin(), j.end(), merge_objects);
21912 m_type = value_t::object;
21913 m_value.object = create<object_t>();
21914 assert_invariant();
21934 for (
auto it = first; it != last; ++it)
21936 if (merge_objects && it.value().is_object())
21938 auto it2 =
m_value.object->find(it.key());
21939 if (it2 !=
m_value.object->end())
21941 it2->second.update(it.value(),
true);
21945 m_value.object->operator[](it.key()) = it.value();
21946#if JSON_DIAGNOSTICS
21947 m_value.object->operator[](it.key()).m_parent =
this;
21955 std::is_nothrow_move_constructible<value_t>::value&&
21956 std::is_nothrow_move_assignable<value_t>::value&&
21957 std::is_nothrow_move_constructible<json_value>::value&&
21958 std::is_nothrow_move_assignable<json_value>::value
21961 std::swap(m_type, other.m_type);
21962 std::swap(
m_value, other.m_value);
21965 other.set_parents();
21966 assert_invariant();
21972 std::is_nothrow_move_constructible<value_t>::value&&
21973 std::is_nothrow_move_assignable<value_t>::value&&
21974 std::is_nothrow_move_constructible<json_value>::value&&
21975 std::is_nothrow_move_assignable<json_value>::value
21983 void swap(array_t& other)
21988 std::swap(*(
m_value.array), other);
21998 void swap(object_t& other)
22003 std::swap(*(
m_value.object), other);
22018 std::swap(*(
m_value.string), other);
22028 void swap(binary_t& other)
22033 std::swap(*(
m_value.binary), other);
22043 void swap(
typename binary_t::container_type& other)
22048 std::swap(*(
m_value.binary), other);
22067#define JSON_IMPLEMENT_OPERATOR(op, null_result, unordered_result, default_result) \
22068 const auto lhs_type = lhs.type(); \
22069 const auto rhs_type = rhs.type(); \
22071 if (lhs_type == rhs_type) \
22073 switch (lhs_type) \
22075 case value_t::array: \
22076 return (*lhs.m_value.array) op (*rhs.m_value.array); \
22078 case value_t::object: \
22079 return (*lhs.m_value.object) op (*rhs.m_value.object); \
22081 case value_t::null: \
22082 return (null_result); \
22084 case value_t::string: \
22085 return (*lhs.m_value.string) op (*rhs.m_value.string); \
22087 case value_t::boolean: \
22088 return (lhs.m_value.boolean) op (rhs.m_value.boolean); \
22090 case value_t::number_integer: \
22091 return (lhs.m_value.number_integer) op (rhs.m_value.number_integer); \
22093 case value_t::number_unsigned: \
22094 return (lhs.m_value.number_unsigned) op (rhs.m_value.number_unsigned); \
22096 case value_t::number_float: \
22097 return (lhs.m_value.number_float) op (rhs.m_value.number_float); \
22099 case value_t::binary: \
22100 return (*lhs.m_value.binary) op (*rhs.m_value.binary); \
22102 case value_t::discarded: \
22104 return (unordered_result); \
22107 else if (lhs_type == value_t::number_integer && rhs_type == value_t::number_float) \
22109 return static_cast<number_float_t>(lhs.m_value.number_integer) op rhs.m_value.number_float; \
22111 else if (lhs_type == value_t::number_float && rhs_type == value_t::number_integer) \
22113 return lhs.m_value.number_float op static_cast<number_float_t>(rhs.m_value.number_integer); \
22115 else if (lhs_type == value_t::number_unsigned && rhs_type == value_t::number_float) \
22117 return static_cast<number_float_t>(lhs.m_value.number_unsigned) op rhs.m_value.number_float; \
22119 else if (lhs_type == value_t::number_float && rhs_type == value_t::number_unsigned) \
22121 return lhs.m_value.number_float op static_cast<number_float_t>(rhs.m_value.number_unsigned); \
22123 else if (lhs_type == value_t::number_unsigned && rhs_type == value_t::number_integer) \
22125 return static_cast<number_integer_t>(lhs.m_value.number_unsigned) op rhs.m_value.number_integer; \
22127 else if (lhs_type == value_t::number_integer && rhs_type == value_t::number_unsigned) \
22129 return lhs.m_value.number_integer op static_cast<number_integer_t>(rhs.m_value.number_unsigned); \
22131 else if(compares_unordered(lhs, rhs))\
22133 return (unordered_result);\
22136 return (default_result);
22138 JSON_PRIVATE_UNLESS_TESTED:
22146 if ((lhs.is_number_float() && std::isnan(lhs.m_value.number_float) &&
rhs.is_number())
22147 || (
rhs.is_number_float() && std::isnan(
rhs.m_value.number_float) && lhs.is_number()))
22151#if JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON
22152 return (lhs.is_discarded() ||
rhs.is_discarded()) && !inverse;
22154 static_cast<void>(inverse);
22155 return lhs.is_discarded() ||
rhs.is_discarded();
22162 return compares_unordered(*
this,
rhs, inverse);
22166#if JSON_HAS_THREE_WAY_COMPARISON
22172#pragma GCC diagnostic push
22173#pragma GCC diagnostic ignored "-Wfloat-equal"
22178#pragma GCC diagnostic pop
22184 template<
typename ScalarType>
22185 requires std::is_scalar_v<ScalarType>
22186 bool operator==(ScalarType
rhs)
const noexcept
22195 if (compares_unordered(
rhs,
true))
22199 return !operator==(
rhs);
22210 std::partial_ordering::equivalent,
22211 std::partial_ordering::unordered,
22212 lhs_type <=> rhs_type)
22217 template<
typename ScalarType>
22218 requires std::is_scalar_v<ScalarType>
22219 std::partial_ordering operator<=>(ScalarType
rhs)
const noexcept
22224#if JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON
22233 if (compares_unordered(
rhs,
true))
22237 return !(
rhs < *
this);
22242 template<
typename ScalarType>
22243 requires std::is_scalar_v<ScalarType>
22244 bool operator<=(ScalarType
rhs)
const noexcept
22254 if (compares_unordered(
rhs,
true))
22258 return !(*
this <
rhs);
22263 template<
typename ScalarType>
22264 requires std::is_scalar_v<ScalarType>
22265 bool operator>=(ScalarType
rhs)
const noexcept
22276#pragma GCC diagnostic push
22277#pragma GCC diagnostic ignored "-Wfloat-equal"
22281#pragma GCC diagnostic pop
22287 template<
typename ScalarType,
typename std::enable_if<
22288 std::is_scalar<ScalarType>::value,
int>
::type = 0>
22296 template<
typename ScalarType,
typename std::enable_if<
22297 std::is_scalar<ScalarType>::value,
int>
::type = 0>
22307 if (compares_unordered(lhs,
rhs,
true))
22311 return !(lhs ==
rhs);
22316 template<
typename ScalarType,
typename std::enable_if<
22317 std::is_scalar<ScalarType>::value,
int>
::type = 0>
22325 template<
typename ScalarType,
typename std::enable_if<
22326 std::is_scalar<ScalarType>::value,
int>
::type = 0>
22344 template<
typename ScalarType,
typename std::enable_if<
22345 std::is_scalar<ScalarType>::value,
int>
::type = 0>
22353 template<
typename ScalarType,
typename std::enable_if<
22354 std::is_scalar<ScalarType>::value,
int>
::type = 0>
22364 if (compares_unordered(lhs,
rhs,
true))
22368 return !(
rhs < lhs);
22373 template<
typename ScalarType,
typename std::enable_if<
22374 std::is_scalar<ScalarType>::value,
int>
::type = 0>
22382 template<
typename ScalarType,
typename std::enable_if<
22383 std::is_scalar<ScalarType>::value,
int>
::type = 0>
22394 if (compares_unordered(lhs,
rhs))
22398 return !(lhs <=
rhs);
22403 template<
typename ScalarType,
typename std::enable_if<
22404 std::is_scalar<ScalarType>::value,
int>
::type = 0>
22412 template<
typename ScalarType,
typename std::enable_if<
22413 std::is_scalar<ScalarType>::value,
int>
::type = 0>
22423 if (compares_unordered(lhs,
rhs,
true))
22427 return !(lhs <
rhs);
22432 template<
typename ScalarType,
typename std::enable_if<
22433 std::is_scalar<ScalarType>::value,
int>
::type = 0>
22441 template<
typename ScalarType,
typename std::enable_if<
22442 std::is_scalar<ScalarType>::value,
int>
::type = 0>
22449#undef JSON_IMPLEMENT_OPERATOR
22465 const bool pretty_print = o.width() > 0;
22466 const auto indentation = pretty_print ? o.width() : 0;
22472 serializer s(detail::output_adapter<char>(o), o.fill());
22473 s.dump(j, pretty_print,
false,
static_cast<unsigned int>(indentation));
22484 friend std::ostream& operator>>(
const basic_json& j, std::ostream& o)
22501 template<
typename InputType>
22504 const parser_callback_t cb =
nullptr,
22505 const bool allow_exceptions =
true,
22506 const bool ignore_comments =
false)
22515 template<
typename IteratorType>
22519 const parser_callback_t cb =
nullptr,
22520 const bool allow_exceptions =
true,
22521 const bool ignore_comments =
false)
22530 static basic_json parse(detail::span_input_adapter&& i,
22531 const parser_callback_t cb =
nullptr,
22532 const bool allow_exceptions =
true,
22533 const bool ignore_comments =
false)
22536 parser(i.get(), cb, allow_exceptions, ignore_comments).parse(
true,
result);
22542 template<
typename InputType>
22543 static bool accept(InputType&& i,
22544 const bool ignore_comments =
false)
22551 template<
typename IteratorType>
22552 static bool accept(IteratorType first, IteratorType last,
22553 const bool ignore_comments =
false)
22560 static bool accept(detail::span_input_adapter&& i,
22561 const bool ignore_comments =
false)
22563 return parser(i.get(),
nullptr,
false, ignore_comments).accept(
true);
22568 template <
typename InputType,
typename SAX>
22570 static
bool sax_parse(InputType&& i, SAX* sax,
22572 const
bool strict = true,
22573 const
bool ignore_comments = false)
22576 return format == input_format_t::json
22577 ?
parser(std::move(ia),
nullptr,
true, ignore_comments).sax_parse(sax, strict)
22578 : detail::binary_reader<basic_json, decltype(ia), SAX>(std::move(ia), format).sax_parse(format, sax, strict);
22583 template<
class IteratorType,
class SAX>
22585 static
bool sax_parse(IteratorType first, IteratorType last, SAX* sax,
22587 const
bool strict = true,
22588 const
bool ignore_comments = false)
22591 return format == input_format_t::json
22592 ?
parser(std::move(ia),
nullptr,
true, ignore_comments).sax_parse(sax, strict)
22593 : detail::binary_reader<basic_json, decltype(ia), SAX>(std::move(ia), format).sax_parse(format, sax, strict);
22601 template <
typename SAX>
22604 static
bool sax_parse(detail::span_input_adapter&& i, SAX* sax,
22606 const
bool strict = true,
22607 const
bool ignore_comments = false)
22610 return format == input_format_t::json
22612 ?
parser(std::move(ia),
nullptr,
true, ignore_comments).sax_parse(sax, strict)
22614 : detail::binary_reader<basic_json, decltype(ia), SAX>(std::move(ia), format).sax_parse(format, sax, strict);
22626 return operator>>(i, j);
22631 friend std::istream& operator>>(std::istream& i,
basic_json& j)
22646 const char* type_name() const noexcept
22650 case value_t::null:
22652 case value_t::object:
22654 case value_t::array:
22656 case value_t::string:
22658 case value_t::boolean:
22660 case value_t::binary:
22662 case value_t::discarded:
22663 return "discarded";
22664 case value_t::number_integer:
22665 case value_t::number_unsigned:
22666 case value_t::number_float:
22673 JSON_PRIVATE_UNLESS_TESTED:
22679 value_t m_type = value_t::null;
22684#if JSON_DIAGNOSTICS
22699 static std::vector<std::uint8_t> to_cbor(
const basic_json& j)
22701 std::vector<std::uint8_t> result;
22702 to_cbor(j, result);
22708 static void to_cbor(
const basic_json& j, detail::output_adapter<std::uint8_t> o)
22715 static void to_cbor(
const basic_json& j, detail::output_adapter<char> o)
22722 static std::vector<std::uint8_t> to_msgpack(
const basic_json& j)
22724 std::vector<std::uint8_t>
result;
22731 static void to_msgpack(
const basic_json& j, detail::output_adapter<std::uint8_t> o)
22738 static void to_msgpack(
const basic_json& j, detail::output_adapter<char> o)
22745 static std::vector<std::uint8_t> to_ubjson(
const basic_json& j,
22746 const bool use_size =
false,
22747 const bool use_type =
false)
22749 std::vector<std::uint8_t>
result;
22750 to_ubjson(j,
result, use_size, use_type);
22756 static void to_ubjson(
const basic_json& j, detail::output_adapter<std::uint8_t> o,
22757 const bool use_size =
false,
const bool use_type =
false)
22764 static void to_ubjson(
const basic_json& j, detail::output_adapter<char> o,
22765 const bool use_size =
false,
const bool use_type =
false)
22772 static std::vector<std::uint8_t> to_bjdata(
const basic_json& j,
22773 const bool use_size =
false,
22774 const bool use_type =
false)
22776 std::vector<std::uint8_t>
result;
22777 to_bjdata(j,
result, use_size, use_type);
22783 static void to_bjdata(
const basic_json& j, detail::output_adapter<std::uint8_t> o,
22784 const bool use_size =
false,
const bool use_type =
false)
22791 static void to_bjdata(
const basic_json& j, detail::output_adapter<char> o,
22792 const bool use_size =
false,
const bool use_type =
false)
22799 static std::vector<std::uint8_t> to_bson(
const basic_json& j)
22801 std::vector<std::uint8_t>
result;
22808 static void to_bson(
const basic_json& j, detail::output_adapter<std::uint8_t> o)
22815 static void to_bson(
const basic_json& j, detail::output_adapter<char> o)
22822 template<
typename InputType>
22825 const bool strict =
true,
22826 const bool allow_exceptions =
true,
22830 detail::json_sax_dom_parser<basic_json> sdp(
result, allow_exceptions);
22838 template<
typename IteratorType>
22840 static basic_json from_cbor(IteratorType first, IteratorType last,
22841 const bool strict =
true,
22842 const bool allow_exceptions =
true,
22846 detail::json_sax_dom_parser<basic_json> sdp(
result, allow_exceptions);
22852 template<
typename T>
22855 static basic_json from_cbor(
const T* ptr, std::size_t len,
22856 const bool strict =
true,
22857 const bool allow_exceptions =
true,
22860 return from_cbor(ptr, ptr + len, strict, allow_exceptions, tag_handler);
22866 static basic_json from_cbor(detail::span_input_adapter&& i,
22867 const bool strict =
true,
22868 const bool allow_exceptions =
true,
22872 detail::json_sax_dom_parser<basic_json> sdp(
result, allow_exceptions);
22881 template<
typename InputType>
22883 static basic_json from_msgpack(InputType&& i,
22884 const bool strict =
true,
22885 const bool allow_exceptions =
true)
22888 detail::json_sax_dom_parser<basic_json> sdp(
result, allow_exceptions);
22896 template<
typename IteratorType>
22898 static basic_json from_msgpack(IteratorType first, IteratorType last,
22899 const bool strict =
true,
22900 const bool allow_exceptions =
true)
22903 detail::json_sax_dom_parser<basic_json> sdp(
result, allow_exceptions);
22909 template<
typename T>
22912 static basic_json from_msgpack(
const T* ptr, std::size_t len,
22913 const bool strict =
true,
22914 const bool allow_exceptions =
true)
22916 return from_msgpack(ptr, ptr + len, strict, allow_exceptions);
22921 static basic_json from_msgpack(detail::span_input_adapter&& i,
22922 const bool strict =
true,
22923 const bool allow_exceptions =
true)
22926 detail::json_sax_dom_parser<basic_json> sdp(
result, allow_exceptions);
22935 template<
typename InputType>
22937 static basic_json from_ubjson(InputType&& i,
22938 const bool strict =
true,
22939 const bool allow_exceptions =
true)
22942 detail::json_sax_dom_parser<basic_json> sdp(
result, allow_exceptions);
22950 template<
typename IteratorType>
22952 static basic_json from_ubjson(IteratorType first, IteratorType last,
22953 const bool strict =
true,
22954 const bool allow_exceptions =
true)
22957 detail::json_sax_dom_parser<basic_json> sdp(
result, allow_exceptions);
22963 template<
typename T>
22966 static basic_json from_ubjson(
const T* ptr, std::size_t len,
22967 const bool strict =
true,
22968 const bool allow_exceptions =
true)
22970 return from_ubjson(ptr, ptr + len, strict, allow_exceptions);
22975 static basic_json from_ubjson(detail::span_input_adapter&& i,
22976 const bool strict =
true,
22977 const bool allow_exceptions =
true)
22980 detail::json_sax_dom_parser<basic_json> sdp(
result, allow_exceptions);
22990 template<
typename InputType>
22992 static basic_json from_bjdata(InputType&& i,
22993 const bool strict =
true,
22994 const bool allow_exceptions =
true)
22997 detail::json_sax_dom_parser<basic_json> sdp(
result, allow_exceptions);
23005 template<
typename IteratorType>
23007 static basic_json from_bjdata(IteratorType first, IteratorType last,
23008 const bool strict =
true,
23009 const bool allow_exceptions =
true)
23012 detail::json_sax_dom_parser<basic_json> sdp(
result, allow_exceptions);
23020 template<
typename InputType>
23023 const bool strict =
true,
23024 const bool allow_exceptions =
true)
23027 detail::json_sax_dom_parser<basic_json> sdp(
result, allow_exceptions);
23035 template<
typename IteratorType>
23037 static basic_json from_bson(IteratorType first, IteratorType last,
23038 const bool strict =
true,
23039 const bool allow_exceptions =
true)
23042 detail::json_sax_dom_parser<basic_json> sdp(
result, allow_exceptions);
23048 template<
typename T>
23051 static basic_json from_bson(
const T* ptr, std::size_t len,
23052 const bool strict =
true,
23053 const bool allow_exceptions =
true)
23055 return from_bson(ptr, ptr + len, strict, allow_exceptions);
23060 static basic_json from_bson(detail::span_input_adapter&& i,
23061 const bool strict =
true,
23062 const bool allow_exceptions =
true)
23065 detail::json_sax_dom_parser<basic_json> sdp(
result, allow_exceptions);
23084 return ptr.get_unchecked(
this);
23087 template<typename BasicJsonType, detail::enable_if_t<detail::is_basic_json<BasicJsonType>::value,
int> = 0>
23091 return ptr.get_unchecked(
this);
23098 return ptr.get_unchecked(
this);
23101 template<typename BasicJsonType, detail::enable_if_t<detail::is_basic_json<BasicJsonType>::value,
int> = 0>
23105 return ptr.get_unchecked(
this);
23112 return ptr.get_checked(
this);
23115 template<
typename BasicJsonType>
23117 reference at(const ::nlohmann::json_pointer<BasicJsonType>& ptr)
23119 return ptr.get_checked(
this);
23126 return ptr.get_checked(
this);
23129 template<
typename BasicJsonType>
23133 return ptr.get_checked(
this);
23141 json_pointer::flatten(
"", *
this,
result);
23149 return json_pointer::unflatten(*
this);
23169 enum class patch_operations {add, remove,
replace, move, copy, test, invalid};
23171 const auto get_op = [](
const std::string & op)
23175 return patch_operations::add;
23177 if (op ==
"remove")
23179 return patch_operations::remove;
23181 if (op ==
"replace")
23183 return patch_operations::replace;
23187 return patch_operations::move;
23191 return patch_operations::copy;
23195 return patch_operations::test;
23198 return patch_operations::invalid;
23213 if (top_pointer != ptr)
23219 const auto last_path = ptr.back();
23225 case value_t::null:
23226 case value_t::object:
23229 parent[last_path] = val;
23233 case value_t::array:
23235 if (last_path ==
"-")
23242 const auto idx = json_pointer::template array_index<basic_json_t>(last_path);
23256 case value_t::string:
23257 case value_t::boolean:
23258 case value_t::number_integer:
23259 case value_t::number_unsigned:
23260 case value_t::number_float:
23261 case value_t::binary:
23262 case value_t::discarded:
23272 const auto last_path = ptr.back();
23280 auto it =
parent.find(last_path);
23290 else if (
parent.is_array())
23293 parent.erase(json_pointer::template array_index<basic_json_t>(last_path));
23300 JSON_THROW(parse_error::create(104, 0,
"JSON patch must be an array of objects", &json_patch));
23304 for (
const auto& val : json_patch)
23307 const auto get_value = [&val](
const std::string & op,
23308 const std::string & member,
23312 auto it = val.m_value.object->find(member);
23315 const auto error_msg = (op ==
"op") ?
"operation" : detail::
concat(
"operation '", op,
'\'');
23321 JSON_THROW(parse_error::create(105, 0, detail::concat(error_msg,
" must have member '", member,
"'"), &val));
23328 JSON_THROW(parse_error::create(105, 0, detail::concat(error_msg,
" must have string member '", member,
"'"), &val));
23338 JSON_THROW(parse_error::create(104, 0,
"JSON patch must be an array of objects", &val));
23342 const auto op = get_value(
"op",
"op",
true).template get<std::string>();
23343 const auto path = get_value(op,
"path",
true).template get<std::string>();
23346 switch (get_op(op))
23348 case patch_operations::add:
23350 operation_add(ptr, get_value(
"add",
"value",
false));
23354 case patch_operations::remove:
23356 operation_remove(ptr);
23360 case patch_operations::replace:
23363 result.at(ptr) = get_value(
"replace",
"value",
false);
23367 case patch_operations::move:
23369 const auto from_path = get_value(
"move",
"from",
true).template get<std::string>();
23379 operation_remove(from_ptr);
23380 operation_add(ptr, v);
23384 case patch_operations::copy:
23386 const auto from_path = get_value(
"copy",
"from",
true).template get<std::string>();
23395 operation_add(ptr, v);
23399 case patch_operations::test:
23401 bool success =
false;
23406 success = (
result.at(ptr) == get_value(
"test",
"value",
false));
23422 case patch_operations::invalid:
23439 const std::string& path =
"")
23445 if (source == target)
23450 if (source.type() != target.type())
23455 {
"op",
"replace"}, {
"path", path}, {
"value", target}
23460 switch (source.type())
23462 case value_t::array:
23466 while (i < source.size() && i < target.size())
23469 auto temp_diff = diff(source[i], target[i],
detail::concat(path,
'/', std::to_string(i)));
23470 result.insert(
result.end(), temp_diff.begin(), temp_diff.end());
23479 while (i < source.size())
23486 {
"path", detail::concat(path,
'/', std::to_string(i))}
23492 while (i < target.size())
23498 {
"value", target[i]}
23506 case value_t::object:
23509 for (
auto it = source.cbegin(); it != source.cend(); ++it)
23514 if (target.find(it.key()) != target.end())
23517 auto temp_diff = diff(it.value(), target[it.key()], path_key);
23518 result.insert(
result.end(), temp_diff.begin(), temp_diff.end());
23523 result.push_back(
object(
23525 {
"op",
"remove"}, {
"path", path_key}
23531 for (
auto it = target.cbegin(); it != target.cend(); ++it)
23533 if (source.find(it.key()) == source.end())
23539 {
"op",
"add"}, {
"path", path_key},
23540 {
"value", it.value()}
23548 case value_t::null:
23549 case value_t::string:
23550 case value_t::boolean:
23551 case value_t::number_integer:
23552 case value_t::number_unsigned:
23553 case value_t::number_float:
23554 case value_t::binary:
23555 case value_t::discarded:
23561 {
"op",
"replace"}, {
"path", path}, {
"value", target}
23581 void merge_patch(
const basic_json& apply_patch)
23583 if (apply_patch.is_object())
23589 for (
auto it = apply_patch.begin(); it != apply_patch.end(); ++it)
23591 if (it.value().is_null())
23597 operator[](it.key()).merge_patch(it.value());
23603 *
this = apply_patch;
23632 std::size_t operator()(
const nlohmann::NLOHMANN_BASIC_JSON_TPL& j)
const
23649#if JSON_HAS_THREE_WAY_COMPARISON
23650 return std::is_lt(lhs <=> rhs);
23652 return ::nlohmann::detail::operator<(lhs, rhs);
23658#ifndef JSON_HAS_CPP_20
23663inline void swap(nlohmann::NLOHMANN_BASIC_JSON_TPL& j1, nlohmann::NLOHMANN_BASIC_JSON_TPL& j2)
noexcept(
23664 is_nothrow_move_constructible<nlohmann::NLOHMANN_BASIC_JSON_TPL>::value&&
23665 is_nothrow_move_assignable<nlohmann::NLOHMANN_BASIC_JSON_TPL>::value)
23679 return nlohmann::json::parse(s, s +
n);
23685inline
nlohmann::
json::json_pointer operator
""_json_pointer(const
char* s,
std::
size_t n)
23694#if defined(__clang__)
23695 #pragma clang diagnostic pop
23700#undef JSON_INTERNAL_CATCH
23702#undef JSON_PRIVATE_UNLESS_TESTED
23703#undef NLOHMANN_BASIC_JSON_TPL_DECLARATION
23704#undef NLOHMANN_BASIC_JSON_TPL
23705#undef JSON_EXPLICIT
23706#undef NLOHMANN_CAN_CALL_STD_FUNC_IMPL
23707#undef JSON_INLINE_VARIABLE
23708#undef JSON_NO_UNIQUE_ADDRESS
23709#undef JSON_DISABLE_ENUM_SERIALIZATION
23711#ifndef JSON_TEST_KEEP_MACROS
23714 #undef JSON_HAS_CPP_11
23715 #undef JSON_HAS_CPP_14
23716 #undef JSON_HAS_CPP_17
23717 #undef JSON_HAS_CPP_20
23718 #undef JSON_HAS_FILESYSTEM
23719 #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM
23720 #undef JSON_HAS_THREE_WAY_COMPARISON
23721 #undef JSON_HAS_RANGES
23722 #undef JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON
23728#undef JSON_HEDLEY_ALWAYS_INLINE
23729#undef JSON_HEDLEY_ARM_VERSION
23730#undef JSON_HEDLEY_ARM_VERSION_CHECK
23731#undef JSON_HEDLEY_ARRAY_PARAM
23732#undef JSON_HEDLEY_ASSUME
23733#undef JSON_HEDLEY_BEGIN_C_DECLS
23734#undef JSON_HEDLEY_CLANG_HAS_ATTRIBUTE
23735#undef JSON_HEDLEY_CLANG_HAS_BUILTIN
23736#undef JSON_HEDLEY_CLANG_HAS_CPP_ATTRIBUTE
23737#undef JSON_HEDLEY_CLANG_HAS_DECLSPEC_DECLSPEC_ATTRIBUTE
23738#undef JSON_HEDLEY_CLANG_HAS_EXTENSION
23739#undef JSON_HEDLEY_CLANG_HAS_FEATURE
23740#undef JSON_HEDLEY_CLANG_HAS_WARNING
23741#undef JSON_HEDLEY_COMPCERT_VERSION
23742#undef JSON_HEDLEY_COMPCERT_VERSION_CHECK
23743#undef JSON_HEDLEY_CONCAT
23744#undef JSON_HEDLEY_CONCAT3
23745#undef JSON_HEDLEY_CONCAT3_EX
23746#undef JSON_HEDLEY_CONCAT_EX
23747#undef JSON_HEDLEY_CONST
23748#undef JSON_HEDLEY_CONSTEXPR
23749#undef JSON_HEDLEY_CONST_CAST
23750#undef JSON_HEDLEY_CPP_CAST
23751#undef JSON_HEDLEY_CRAY_VERSION
23752#undef JSON_HEDLEY_CRAY_VERSION_CHECK
23753#undef JSON_HEDLEY_C_DECL
23754#undef JSON_HEDLEY_DEPRECATED
23755#undef JSON_HEDLEY_DEPRECATED_FOR
23756#undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL
23757#undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_
23758#undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED
23759#undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES
23760#undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS
23761#undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION
23762#undef JSON_HEDLEY_DIAGNOSTIC_POP
23763#undef JSON_HEDLEY_DIAGNOSTIC_PUSH
23764#undef JSON_HEDLEY_DMC_VERSION
23765#undef JSON_HEDLEY_DMC_VERSION_CHECK
23766#undef JSON_HEDLEY_EMPTY_BASES
23767#undef JSON_HEDLEY_EMSCRIPTEN_VERSION
23768#undef JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK
23769#undef JSON_HEDLEY_END_C_DECLS
23770#undef JSON_HEDLEY_FLAGS
23771#undef JSON_HEDLEY_FLAGS_CAST
23772#undef JSON_HEDLEY_GCC_HAS_ATTRIBUTE
23773#undef JSON_HEDLEY_GCC_HAS_BUILTIN
23774#undef JSON_HEDLEY_GCC_HAS_CPP_ATTRIBUTE
23775#undef JSON_HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE
23776#undef JSON_HEDLEY_GCC_HAS_EXTENSION
23777#undef JSON_HEDLEY_GCC_HAS_FEATURE
23778#undef JSON_HEDLEY_GCC_HAS_WARNING
23779#undef JSON_HEDLEY_GCC_NOT_CLANG_VERSION_CHECK
23780#undef JSON_HEDLEY_GCC_VERSION
23781#undef JSON_HEDLEY_GCC_VERSION_CHECK
23782#undef JSON_HEDLEY_GNUC_HAS_ATTRIBUTE
23783#undef JSON_HEDLEY_GNUC_HAS_BUILTIN
23784#undef JSON_HEDLEY_GNUC_HAS_CPP_ATTRIBUTE
23785#undef JSON_HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE
23786#undef JSON_HEDLEY_GNUC_HAS_EXTENSION
23787#undef JSON_HEDLEY_GNUC_HAS_FEATURE
23788#undef JSON_HEDLEY_GNUC_HAS_WARNING
23789#undef JSON_HEDLEY_GNUC_VERSION
23790#undef JSON_HEDLEY_GNUC_VERSION_CHECK
23791#undef JSON_HEDLEY_HAS_ATTRIBUTE
23792#undef JSON_HEDLEY_HAS_BUILTIN
23793#undef JSON_HEDLEY_HAS_CPP_ATTRIBUTE
23794#undef JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS
23795#undef JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE
23796#undef JSON_HEDLEY_HAS_EXTENSION
23797#undef JSON_HEDLEY_HAS_FEATURE
23798#undef JSON_HEDLEY_HAS_WARNING
23799#undef JSON_HEDLEY_IAR_VERSION
23800#undef JSON_HEDLEY_IAR_VERSION_CHECK
23801#undef JSON_HEDLEY_IBM_VERSION
23802#undef JSON_HEDLEY_IBM_VERSION_CHECK
23803#undef JSON_HEDLEY_IMPORT
23804#undef JSON_HEDLEY_INLINE
23805#undef JSON_HEDLEY_INTEL_CL_VERSION
23806#undef JSON_HEDLEY_INTEL_CL_VERSION_CHECK
23807#undef JSON_HEDLEY_INTEL_VERSION
23808#undef JSON_HEDLEY_INTEL_VERSION_CHECK
23809#undef JSON_HEDLEY_IS_CONSTANT
23810#undef JSON_HEDLEY_IS_CONSTEXPR_
23811#undef JSON_HEDLEY_LIKELY
23812#undef JSON_HEDLEY_MALLOC
23813#undef JSON_HEDLEY_MCST_LCC_VERSION
23814#undef JSON_HEDLEY_MCST_LCC_VERSION_CHECK
23815#undef JSON_HEDLEY_MESSAGE
23816#undef JSON_HEDLEY_MSVC_VERSION
23817#undef JSON_HEDLEY_MSVC_VERSION_CHECK
23818#undef JSON_HEDLEY_NEVER_INLINE
23819#undef JSON_HEDLEY_NON_NULL
23820#undef JSON_HEDLEY_NO_ESCAPE
23821#undef JSON_HEDLEY_NO_RETURN
23822#undef JSON_HEDLEY_NO_THROW
23823#undef JSON_HEDLEY_NULL
23824#undef JSON_HEDLEY_PELLES_VERSION
23825#undef JSON_HEDLEY_PELLES_VERSION_CHECK
23826#undef JSON_HEDLEY_PGI_VERSION
23827#undef JSON_HEDLEY_PGI_VERSION_CHECK
23828#undef JSON_HEDLEY_PREDICT
23829#undef JSON_HEDLEY_PRINTF_FORMAT
23830#undef JSON_HEDLEY_PRIVATE
23831#undef JSON_HEDLEY_PUBLIC
23832#undef JSON_HEDLEY_PURE
23833#undef JSON_HEDLEY_REINTERPRET_CAST
23834#undef JSON_HEDLEY_REQUIRE
23835#undef JSON_HEDLEY_REQUIRE_CONSTEXPR
23836#undef JSON_HEDLEY_REQUIRE_MSG
23837#undef JSON_HEDLEY_RESTRICT
23838#undef JSON_HEDLEY_RETURNS_NON_NULL
23839#undef JSON_HEDLEY_SENTINEL
23840#undef JSON_HEDLEY_STATIC_ASSERT
23841#undef JSON_HEDLEY_STATIC_CAST
23842#undef JSON_HEDLEY_STRINGIFY
23843#undef JSON_HEDLEY_STRINGIFY_EX
23844#undef JSON_HEDLEY_SUNPRO_VERSION
23845#undef JSON_HEDLEY_SUNPRO_VERSION_CHECK
23846#undef JSON_HEDLEY_TINYC_VERSION
23847#undef JSON_HEDLEY_TINYC_VERSION_CHECK
23848#undef JSON_HEDLEY_TI_ARMCL_VERSION
23849#undef JSON_HEDLEY_TI_ARMCL_VERSION_CHECK
23850#undef JSON_HEDLEY_TI_CL2000_VERSION
23851#undef JSON_HEDLEY_TI_CL2000_VERSION_CHECK
23852#undef JSON_HEDLEY_TI_CL430_VERSION
23853#undef JSON_HEDLEY_TI_CL430_VERSION_CHECK
23854#undef JSON_HEDLEY_TI_CL6X_VERSION
23855#undef JSON_HEDLEY_TI_CL6X_VERSION_CHECK
23856#undef JSON_HEDLEY_TI_CL7X_VERSION
23857#undef JSON_HEDLEY_TI_CL7X_VERSION_CHECK
23858#undef JSON_HEDLEY_TI_CLPRU_VERSION
23859#undef JSON_HEDLEY_TI_CLPRU_VERSION_CHECK
23860#undef JSON_HEDLEY_TI_VERSION
23861#undef JSON_HEDLEY_TI_VERSION_CHECK
23862#undef JSON_HEDLEY_UNAVAILABLE
23863#undef JSON_HEDLEY_UNLIKELY
23864#undef JSON_HEDLEY_UNPREDICTABLE
23865#undef JSON_HEDLEY_UNREACHABLE
23866#undef JSON_HEDLEY_UNREACHABLE_RETURN
23867#undef JSON_HEDLEY_VERSION
23868#undef JSON_HEDLEY_VERSION_DECODE_MAJOR
23869#undef JSON_HEDLEY_VERSION_DECODE_MINOR
23870#undef JSON_HEDLEY_VERSION_DECODE_REVISION
23871#undef JSON_HEDLEY_VERSION_ENCODE
23872#undef JSON_HEDLEY_WARNING
23873#undef JSON_HEDLEY_WARN_UNUSED_RESULT
23874#undef JSON_HEDLEY_WARN_UNUSED_RESULT_MSG
23875#undef JSON_HEDLEY_FALL_THROUGH
a class to store JSON values
*brief a type for an array *sa AllocatorType< basic_json >
::nlohmann::json_pointer< std::string > json_pointer
json_sax< basic_json > json_sax_t
detail::error_handler_t error_handler_t
detail::input_format_t input_format_t
detail::out_of_range out_of_range
std::ptrdiff_t difference_type
{ *the type of elements in a basic_json container using value_type=basic_json value_type & reference
typename std::allocator_traits< allocator_type >::const_pointer const_pointer
typename std::allocator_traits< allocator_type >::pointer pointer
std::initializer_list< detail::json_ref< basic_json > > initializer_list_t
detail::cbor_tag_handler_t cbor_tag_handler_t
json_reverse_iterator< typename basic_json::iterator > reverse_iterator
{ using exception=detail::exception detail::parse_error parse_error
friend class ::nlohmann::detail::binary_writer
detail::invalid_iterator invalid_iterator
***name constructors and destructors *Constructors of class ref basic_json copy move constructor copy static functions creating and the destructor **the value of the current element json_value m_value
detail::other_error other_error
friend class ::nlohmann::detail::iter_impl
friend class ::nlohmann::detail::binary_reader
iter_impl< basic_json > iterator
json_reverse_iterator< typename basic_json::const_iterator > const_reverse_iterator
const value_type & const_reference
friend class ::nlohmann::detail::exception
friend class ::nlohmann::detail::parser
detail::type_error type_error
std::allocator< basic_json > allocator_type
adl_serializer< T, SFINAE > json_serializer
***name JSON value data types *The data types to store a JSON value These types are derived from *the template arguments passed to class ref basic_json **brief a type for an object *sa basic_json
iter_impl< const basic_json > const_iterator
***name JSON value data types *The data types to store a JSON value These types are derived from *the template arguments passed to class ref basic_json **brief a type for an object *sa default_object_comparator_t
an internal type for a backed binary type
byte_container_with_subtype(const container_type &b, subtype_type subtype_) noexcept(noexcept(container_type(b)))
BinaryType container_type
byte_container_with_subtype(const container_type &b) noexcept(noexcept(container_type(b)))
byte_container_with_subtype(container_type &&b) noexcept(noexcept(container_type(std::move(b))))
bool operator!=(const byte_container_with_subtype &rhs) const
void clear_subtype() noexcept
clears the binary subtype
byte_container_with_subtype() noexcept(noexcept(container_type()))
byte_container_with_subtype(container_type &&b, subtype_type subtype_) noexcept(noexcept(container_type(std::move(b))))
constexpr bool has_subtype() const noexcept
return whether the value has a subtype
void set_subtype(subtype_type subtype_) noexcept
sets the binary subtype
constexpr subtype_type subtype() const noexcept
return the binary subtype
std::uint64_t subtype_type
bool operator==(const byte_container_with_subtype &rhs) const
deserialization of CBOR, MessagePack, and UBJSON values
binary_reader & operator=(const binary_reader &)=delete
binary_reader(InputAdapterType &&adapter, const input_format_t format=input_format_t::json) noexcept
create a binary reader
binary_reader & operator=(binary_reader &&)=default
binary_reader(const binary_reader &)=delete
bool sax_parse(const input_format_t format, json_sax_t *sax_, const bool strict=true, const cbor_tag_handler_t tag_handler=cbor_tag_handler_t::error)
binary_reader(binary_reader &&)=default
serialization to CBOR and MessagePack values
void write_ubjson(const BasicJsonType &j, const bool use_count, const bool use_type, const bool add_prefix=true, const bool use_bjdata=false)
static constexpr CharType to_char_type(InputCharType x) noexcept
binary_writer(output_adapter_t< CharType > adapter)
create a binary writer
static CharType to_char_type(std::uint8_t x) noexcept
void write_bson(const BasicJsonType &j)
void write_cbor(const BasicJsonType &j)
static constexpr CharType to_char_type(std::uint8_t x) noexcept
void write_msgpack(const BasicJsonType &j)
general exception of the basic_json class
const int id
the id of the exception
static std::string diagnostics(std::nullptr_t)
static std::string diagnostics(const BasicJsonType *leaf_element)
static std::string name(const std::string &ename, int id_)
const char * what() const noexcept override
returns the explanatory string
exception(int id_, const char *what_arg)
exception indicating errors with iterators
static invalid_iterator create(int id_, const std::string &what_arg, BasicJsonContext context)
a template for a bidirectional iterator for the basic_json class This class implements a both iterato...
bool operator<(const iter_impl &other) const
comparison: smaller
iter_impl operator-(difference_type i) const
subtract from iterator
bool operator!=(const IterImpl &other) const
comparison: not equal
void set_end() noexcept
set the iterator past the last value
*the actual iterator of the associated instance internal_iterator< typename std::remove_const< BasicJsonType >::type > m_it
typename BasicJsonType::difference_type difference_type
iter_impl & operator--()
pre-decrement (–it)
difference_type operator-(const iter_impl &other) const
return difference
iter_impl & operator=(const iter_impl< const BasicJsonType > &other) noexcept
converting assignment
reference operator*() const
return a reference to the value pointed to by the iterator
iter_impl(iter_impl &&) noexcept=default
bool operator>=(const iter_impl &other) const
comparison: greater than or equal
iter_impl & operator=(const iter_impl< typename std::remove_const< BasicJsonType >::type > &other) noexcept
converting assignment
pointer operator->() const
dereference the iterator
iter_impl(const iter_impl< const BasicJsonType > &other) noexcept
const copy constructor
iter_impl(const iter_impl< typename std::remove_const< BasicJsonType >::type > &other) noexcept
converting constructor
iter_impl operator+(difference_type i) const
add to iterator
friend iter_impl operator+(difference_type i, const iter_impl &it)
addition of distance and iterator
const object_t::key_type & key() const
return the key of an object iterator
bool operator==(const IterImpl &other) const
comparison: equal
bool operator>(const iter_impl &other) const
comparison: greater than
typename BasicJsonType::value_type value_type
reference value() const
return the value of an iterator
iter_impl & operator++()
pre-increment (++it)
reference operator[](difference_type n) const
access to successor
bool operator<=(const iter_impl &other) const
comparison: less than or equal
iter_impl operator++(int) &
post-increment (it++)
iter_impl operator--(int) &
post-decrement (it–)
iter_impl & operator+=(difference_type i)
add to iterator
iter_impl & operator-=(difference_type i)
subtract from iterator
std::input_iterator_tag iterator_category
typename std::remove_cv< typename std::remove_reference< decltype(std::declval< IteratorType >().key()) >::type >::type string_type
iteration_proxy_value(iteration_proxy_value const &)=default
iteration_proxy_value & operator=(iteration_proxy_value const &)=default
iteration_proxy_value value_type
bool operator!=(const iteration_proxy_value &o) const
inequality operator (needed for range-based for)
iteration_proxy_value(IteratorType it, std::size_t array_index_=0) noexcept(std::is_nothrow_move_constructible< IteratorType >::value &&std::is_nothrow_default_constructible< string_type >::value)
iteration_proxy_value operator++(int) &
iteration_proxy_value()=default
IteratorType::reference value() const
return value of the iterator
iteration_proxy_value & operator++()
increment operator (needed for range-based for)
std::ptrdiff_t difference_type
const string_type & key() const
return key of the iterator
bool operator==(const iteration_proxy_value &o) const
equality operator (needed for InputIterator)
iteration_proxy_value(iteration_proxy_value &&) noexcept(std::is_nothrow_move_constructible< IteratorType >::value &&std::is_nothrow_move_constructible< string_type >::value)=default
proxy class for the items() function
iteration_proxy_value< Iterator > begin() const noexcept
iteration_proxy(iteration_proxy &&) noexcept=default
iteration_proxy_value< IteratorType > end() const noexcept
return iterator end (needed for range-based for)
iteration_proxy()=default
iteration_proxy & operator=(iteration_proxy const &)=default
iteration_proxy(iteration_proxy const &)=default
iteration_proxy(typename IteratorType::reference cont) noexcept
construct iteration proxy from a container
json_ref(json_ref &&) noexcept=default
value_type const & operator*() const
json_ref(Args &&... args)
json_ref(const value_type &value)
value_type const * operator->() const
json_ref(std::initializer_list< json_ref > init)
json_ref(value_type &&value)
value_type moved_or_copied() const
a template for a reverse iterator class
*access to successor reference operator[](difference_type n) const
*return the value of an iterator reference value() const
typename Base::reference reference
std::reverse_iterator< Base > base_iterator
*create reverse iterator from base class explicit json_reverse_iterator(const base_iterator &it) noexcept
std::ptrdiff_t difference_type
*return difference difference_type operator-(const json_reverse_iterator &other) const
*subtract from iterator json_reverse_iterator operator-(difference_type i) const
*add to iterator json_reverse_iterator & operator+=(difference_type i)
*create reverse iterator from iterator json_reverse_iterator(const typename base_iterator::iterator_type &it) noexcept
*return the key of an object iterator auto key() const -> decltype(std::declval< Base >().key())
*add to iterator json_reverse_iterator operator+(difference_type i) const
bool start_object(std::size_t=static_cast< std::size_t >(-1))
typename BasicJsonType::string_t string_t
typename BasicJsonType::number_integer_t number_integer_t
typename BasicJsonType::number_float_t number_float_t
typename BasicJsonType::binary_t binary_t
bool start_array(std::size_t=static_cast< std::size_t >(-1))
bool parse_error(std::size_t, const std::string &, const detail::exception &)
bool number_integer(number_integer_t)
bool number_unsigned(number_unsigned_t)
typename BasicJsonType::number_unsigned_t number_unsigned_t
bool number_float(number_float_t, const string_t &)
typename BasicJsonType::string_t string_t
json_sax_dom_callback_parser & operator=(const json_sax_dom_callback_parser &)=delete
bool start_object(std::size_t len)
constexpr bool is_errored() const
typename BasicJsonType::number_unsigned_t number_unsigned_t
typename BasicJsonType::number_integer_t number_integer_t
typename BasicJsonType::parser_callback_t parser_callback_t
bool start_array(std::size_t len)
~json_sax_dom_callback_parser()=default
json_sax_dom_callback_parser(const json_sax_dom_callback_parser &)=delete
typename BasicJsonType::binary_t binary_t
bool binary(binary_t &val)
bool number_integer(number_integer_t val)
typename BasicJsonType::number_float_t number_float_t
typename BasicJsonType::parse_event_t parse_event_t
bool number_unsigned(number_unsigned_t val)
json_sax_dom_callback_parser & operator=(json_sax_dom_callback_parser &&)=default
bool string(string_t &val)
bool number_float(number_float_t val, const string_t &)
json_sax_dom_callback_parser(json_sax_dom_callback_parser &&)=default
bool parse_error(std::size_t, const std::string &, const Exception &ex)
json_sax_dom_callback_parser(BasicJsonType &r, const parser_callback_t cb, const bool allow_exceptions_=true)
SAX implementation to create a JSON value from SAX events.
bool start_array(std::size_t len)
json_sax_dom_parser(const json_sax_dom_parser &)=delete
typename BasicJsonType::binary_t binary_t
json_sax_dom_parser & operator=(json_sax_dom_parser &&)=default
bool number_unsigned(number_unsigned_t val)
typename BasicJsonType::number_integer_t number_integer_t
~json_sax_dom_parser()=default
bool parse_error(std::size_t, const std::string &, const Exception &ex)
bool string(string_t &val)
typename BasicJsonType::number_unsigned_t number_unsigned_t
bool start_object(std::size_t len)
bool binary(binary_t &val)
constexpr bool is_errored() const
json_sax_dom_parser(json_sax_dom_parser &&)=default
typename BasicJsonType::number_float_t number_float_t
json_sax_dom_parser & operator=(const json_sax_dom_parser &)=delete
bool number_float(number_float_t val, const string_t &)
json_sax_dom_parser(BasicJsonType &r, const bool allow_exceptions_=true)
typename BasicJsonType::string_t string_t
bool number_integer(number_integer_t val)
JSON_HEDLEY_RETURNS_NON_NULL static JSON_HEDLEY_CONST const char * token_type_name(const token_type t) noexcept
return name of values of type token_type (only used for errors)
token_type
token types for the parser
@ value_float
an floating point number – use get_number_float() for actual value
@ begin_array
the character for array begin [
@ value_string
a string – use get_string() for actual value
@ end_array
the character for array end ]
@ uninitialized
indicating the scanner is uninitialized
@ parse_error
indicating a parse error
@ value_integer
a signed integer – use get_number_integer() for actual value
@ value_separator
the value separator ,
@ end_object
the character for object end }
@ literal_true
the true literal
@ begin_object
the character for object begin {
@ value_unsigned
an unsigned integer – use get_number_unsigned() for actual value
@ literal_null
the null literal
@ end_of_input
indicating the end of the input buffer
@ name_separator
the name separator :
@ literal_or_value
a literal or the begin of a value (only for diagnostics)
@ literal_false
the false literal
string_t & get_string()
return current string value (implicitly resets the token; useful only once)
lexer & operator=(lexer &&)=default
bool skip_bom()
skip the UTF-8 byte order mark
lexer(InputAdapterType &&adapter, bool ignore_comments_=false) noexcept
constexpr position_t get_position() const noexcept
return position of last read token
constexpr number_integer_t get_number_integer() const noexcept
return integer value
typename lexer_base< BasicJsonType >::token_type token_type
lexer & operator=(lexer &)=delete
lexer(const lexer &)=delete
constexpr number_unsigned_t get_number_unsigned() const noexcept
return unsigned integer value
constexpr number_float_t get_number_float() const noexcept
return floating-point value
std::string get_token_string() const
JSON_HEDLEY_RETURNS_NON_NULL constexpr const char * get_error_message() const noexcept
return syntax error message
exception indicating other library errors
static other_error create(int id_, const std::string &what_arg, BasicJsonContext context)
exception indicating access out of the defined range
static out_of_range create(int id_, const std::string &what_arg, BasicJsonContext context)
output_adapter(std::basic_ostream< CharType > &s)
output_adapter(std::vector< CharType, AllocatorType > &vec)
output_adapter(StringType &s)
void write_character(CharType c) override
void write_characters(const CharType *s, std::size_t length) override
output_stream_adapter(std::basic_ostream< CharType > &s) noexcept
void write_character(CharType c) override
void write_characters(const CharType *s, std::size_t length) override
output_string_adapter(StringType &s) noexcept
void write_characters(const CharType *s, std::size_t length) override
output_vector_adapter(std::vector< CharType, AllocatorType > &vec) noexcept
void write_character(CharType c) override
exception indicating a parse error
static parse_error create(int id_, const position_t &pos, const std::string &what_arg, BasicJsonContext context)
create a parse error exception
static parse_error create(int id_, std::size_t byte_, const std::string &what_arg, BasicJsonContext context)
const std::size_t byte
byte index of the parse error
bool sax_parse(SAX *sax, const bool strict=true)
bool accept(const bool strict=true)
public accept interface
void parse(const bool strict, BasicJsonType &result)
public parser interface
*a parser reading from an input adapter parser(InputAdapterType &&adapter, const parser_callback_t< BasicJsonType > cb=nullptr, const bool allow_exceptions_=true, const bool skip_comments=false)
primitive_iterator_t operator+(difference_type n) noexcept
primitive_iterator_t & operator++() noexcept
*return whether the iterator can be dereferenced constexpr bool is_begin() const noexcept
primitive_iterator_t & operator-=(difference_type n) noexcept
*set iterator to a defined beginning void set_begin() noexcept
friend constexpr bool operator<(primitive_iterator_t lhs, primitive_iterator_t rhs) noexcept
primitive_iterator_t operator++(int) &noexcept
*set iterator to a defined past the end void set_end() noexcept
friend constexpr bool operator==(primitive_iterator_t lhs, primitive_iterator_t rhs) noexcept
friend constexpr difference_type operator-(primitive_iterator_t lhs, primitive_iterator_t rhs) noexcept
primitive_iterator_t & operator--() noexcept
constexpr difference_type get_value() const noexcept
primitive_iterator_t operator--(int) &noexcept
*return whether the iterator is at end constexpr bool is_end() const noexcept
primitive_iterator_t & operator+=(difference_type n) noexcept
*the indentation string string_t indent_string
*error_handler how to react on decoding errors const error_handler_t error_handler
*the locale s thousand separator character const char thousands_sep
serializer(serializer &&)=delete
serializer & operator=(serializer &&)=delete
*string buffer std::array< char, 512 > string_buffer
serializer & operator=(const serializer &)=delete
std::size_t undumped_chars
void dump(const BasicJsonType &val, const bool pretty_print, const bool ensure_ascii, const unsigned int indent_step, const unsigned int current_indent=0)
internal implementation of the serialization function
std::size_t bytes_after_last_accept
*a *(hopefully) large enough character buffer std the locale const std::lconv * loc
JSON_PRIVATE_UNLESS_TESTED const bool ensure_ascii
serializer(output_adapter_t< char > s, const char ichar, error_handler_t error_handler_=error_handler_t::strict)
*the indentation character const char indent_char
*the locale s decimal point character const char decimal_point
serializer(const serializer &)=delete
exception indicating executing a member function with a wrong type
static type_error create(int id_, const std::string &what_arg, BasicJsonContext context)
JSON Pointer defines a string syntax for identifying a specific value within a JSON document.
decltype( get< N >(std::declval< ::nlohmann::detail::iteration_proxy_value< IteratorType > >())) type
#define NLOHMANN_BASIC_JSON_TPL_DECLARATION
#define JSON_HEDLEY_CONST
#define JSON_HEDLEY_DIAGNOSTIC_PUSH
#define JSON_INLINE_VARIABLE
#define JSON_HEDLEY_WARN_UNUSED_RESULT
#define JSON_PRIVATE_UNLESS_TESTED
#define NLOHMANN_JSON_VERSION_PATCH
*brief user defined string literal for JSON values *sa std::size_t n
#define JSON_HEDLEY_LIKELY(expr)
#define JSON_HEDLEY_NON_NULL(...)
#define JSON_INTERNAL_CATCH(exception)
#define JSON_HEDLEY_RETURNS_NON_NULL
#define JSON_CATCH(exception)
#define JSON_THROW(exception)
#define JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON
#define NLOHMANN_JSON_VERSION_MAJOR
#define NLOHMANN_BASIC_JSON_TPL
#define JSON_HEDLEY_UNLIKELY(expr)
#define JSON_NO_UNIQUE_ADDRESS
#define NLOHMANN_JSON_VERSION_MINOR
#define NLOHMANN_CAN_CALL_STD_FUNC_IMPL(std_name)
#define JSON_HEDLEY_DIAGNOSTIC_POP
#define JSON_HEDLEY_DEPRECATED_FOR(since, replacement)
#define JSON_IMPLEMENT_OPERATOR(op, null_result, unordered_result, default_result)
std::vector< std::string > split(const std::string &input, const std::string ®ex)
std::variant< std::monostate, bool, std::int64_t, std::uint64_t, double, std::string > Value
std::ostream & operator<<(std::ostream &os, const Error &obj)
std::string to_string(Error error)
implements the Grisu2 algorithm for binary to decimal floating-point conversion.
void grisu2(char *buf, int &len, int &decimal_exponent, diyfp m_minus, diyfp v, diyfp m_plus)
JSON_HEDLEY_RETURNS_NON_NULL char * format_buffer(char *buf, int len, int decimal_exponent, int min_exp, int max_exp)
prettify v = buf * 10^decimal_exponent
Target reinterpret_bits(const Source source)
boundaries compute_boundaries(FloatType value)
int find_largest_pow10(const std::uint32_t n, std::uint32_t &pow10)
void grisu2_round(char *buf, int len, std::uint64_t dist, std::uint64_t delta, std::uint64_t rest, std::uint64_t ten_k)
JSON_HEDLEY_RETURNS_NON_NULL char * append_exponent(char *buf, int e)
appends a decimal representation of e to buf
void grisu2_digit_gen(char *buffer, int &length, int &decimal_exponent, diyfp M_minus, diyfp w, diyfp M_plus)
cached_power get_cached_power_for_binary_exponent(int e)
detail namespace with internal helper functions
is_specialization_of<::nlohmann::json_pointer, uncvref_t< T > > is_json_pointer
typename detector< nonesuch, void, Op, Args... >::value_t is_detected
is_detected< string_can_append_op, StringType, Arg > detect_string_can_append_op
bool operator<(const value_t lhs, const value_t rhs) noexcept
comparison operator for JSON types
std::is_same< Expected, detected_t< Op, Args... > > is_detected_exact
conjunction< std::is_signed< Types >... > all_signed
decltype(std::declval< T & >().binary(std::declval< Binary & >())) binary_function_t
decltype(std::declval< T & >().number_float( std::declval< Float >(), std::declval< const String & >())) number_float_function_t
void to_json(BasicJsonType &j, T b) noexcept
make_integer_sequence< size_t, N > make_index_sequence
value_t
the JSON type enumeration
@ number_integer
number value (signed integer)
@ discarded
discarded by the parser callback function
@ binary
binary array (ordered collection of bytes)
@ object
object (unordered set of name/value pairs)
@ number_float
number value (floating-point)
@ number_unsigned
number value (unsigned integer)
@ array
array (ordered collection of values)
void from_json(const BasicJsonType &j, typename std::nullptr_t &n)
decltype(std::declval< StringType & >().append(std::declval< Arg && >())) string_can_append
typename actual_object_comparator< BasicJsonType >::type actual_object_comparator_t
decltype(std::declval< StringType & >().append(std::declval< const Arg & >().begin(), std::declval< const Arg & >().end())) string_can_append_iter
value_type_t< iterator_traits< iterator_t< T > > > range_value_t
constexpr T static_const< T >::value
void int_to_string(string_type &target, std::size_t value)
decltype(std::declval< T & >().number_integer(std::declval< Integer >())) number_integer_function_t
void from_json_array_impl(const BasicJsonType &j, typename BasicJsonType::array_t &arr, priority_tag< 3 >)
decltype(std::declval< T & >().string(std::declval< String & >())) string_function_t
typename T::is_transparent detect_is_transparent
JSON_HEDLEY_RETURNS_NON_NULL char * to_chars(char *first, const char *last, FloatType value)
generates a decimal representation of the floating-point number value in [first, last).
typename T::iterator_category iterator_category_t
typename T::difference_type difference_type_t
void to_json_tuple_impl(BasicJsonType &j, const Tuple &t, index_sequence< Idx... >)
decltype(std::declval< StringType & >().append(std::declval< const Arg & >().data(), std::declval< const Arg & >().size())) string_can_append_data
std::integral_constant< bool,(std::is_signed< OfType >::value &&(sizeof(T)< sizeof(OfType)))||(same_sign< OfType, T >::value &&sizeof(OfType)==sizeof(T)) > never_out_of_range
cbor_tag_handler_t
how to treat CBOR tags
@ store
store tags as binary type
@ error
throw a parse_error exception in case of a tag
@ strict
throw a type_error exception in case of invalid UTF-8
@ ignore
ignore invalid UTF-8 sequences
@ replace
replace invalid UTF-8 sequences with U+FFFD
typename T::value_type value_type_t
typename std::remove_cv< typename std::remove_reference< T >::type >::type uncvref_t
iterator_input_adapter_factory< IteratorType >::adapter_type input_adapter(IteratorType first, IteratorType last)
typename make_void< Ts... >::type void_t
make_index_sequence< sizeof...(Ts)> index_sequence_for
decltype(std::declval< T & >().key(std::declval< String & >())) key_function_t
std::size_t combine(std::size_t seed, std::size_t h) noexcept
decltype(T::from_json(std::declval< Args >()...)) from_json_function
std::size_t hash(const BasicJsonType &j)
hash a JSON value
conjunction< std::is_unsigned< Types >... > all_unsigned
StringType escape(StringType s)
string escaping as described in RFC 6901 (Sect. 4)
conjunction< std::is_integral< Types >... > all_integral
typename T::pointer pointer_t
is_detected< string_can_append, StringType, Arg > detect_string_can_append
typename T::mapped_type mapped_type_t
typename T::key_compare detect_key_compare
constexpr bool value_in_range_of(T val)
std::pair< A1, A2 > from_json_tuple_impl(BasicJsonType &&j, identity_tag< std::pair< A1, A2 > >, priority_tag< 0 >)
decltype(input_adapter(std::declval< const char * >(), std::declval< const char * >())) contiguous_bytes_input_adapter
void concat_into(OutStringType &)
void get_arithmetic_value(const BasicJsonType &j, ArithmeticType &val)
typename T::reference reference_t
void replace_substring(StringType &s, const StringType &f, const StringType &t)
replace all occurrences of a substring by another string
typename utility_internal::Gen< T, N >::type make_integer_sequence
OutStringType concat(Args &&... args)
decltype(std::declval< T >().template get< U >()) get_template_function
decltype(T::to_json(std::declval< Args >()...)) to_json_function
decltype(std::declval< T & >().start_array(std::declval< std::size_t >())) start_array_function_t
input_format_t
the supported input formats
decltype(std::declval< T & >().number_unsigned(std::declval< Unsigned >())) number_unsigned_function_t
decltype(std::declval< T & >().start_object(std::declval< std::size_t >())) start_object_function_t
typename std::conditional< is_comparable< Comparator, ObjectKeyType, KeyTypeCVRef >::value &&!(ExcludeObjectKeyType &&std::is_same< KeyType, ObjectKeyType >::value) &&(!RequireTransparentComparator||is_detected< detect_is_transparent, Comparator >::value) &&!is_json_pointer< KeyType >::value, std::true_type, std::false_type >::type is_usable_as_key_type
typename std::conditional< is_detected< detect_erase_with_key_type, typename BasicJsonType::object_t, KeyType >::value, std::true_type, std::false_type >::type has_erase_with_key_type
std::tuple< Args... > from_json_tuple_impl_base(BasicJsonType &&j, index_sequence< Idx... >)
typename detector< nonesuch, void, Op, Args... >::type detected_t
std::array< T, sizeof...(Idx)> from_json_inplace_array_impl(BasicJsonType &&j, identity_tag< std::array< T, sizeof...(Idx)> >, index_sequence< Idx... >)
integer_sequence< size_t, Ints... > index_sequence
typename std::conditional< is_usable_as_key_type< typename BasicJsonType::object_comparator_t, typename BasicJsonType::object_t::key_type, KeyTypeCVRef, RequireTransparentComparator, ExcludeObjectKeyType >::value &&!is_json_iterator_of< BasicJsonType, KeyType >::value, std::true_type, std::false_type >::type is_usable_as_basic_json_key_type
decltype(std::declval< ObjectType & >().erase(std::declval< KeyType >())) detect_erase_with_key_type
decltype(std::declval< T & >().end_object()) end_object_function_t
std::is_convertible< detected_t< Op, Args... >, To > is_detected_convertible
auto get(const nlohmann::detail::iteration_proxy_value< IteratorType > &i) -> decltype(i.key())
typename std::enable_if< B, T >::type enable_if_t
decltype(std::declval< T & >().end_array()) end_array_function_t
decltype(std::declval< T & >().null()) null_function_t
std::function< bool(int, parse_event_t, BasicJsonType &)> parser_callback_t
std::size_t concat_length()
typename T::key_type key_type_t
std::integral_constant< bool, all_signed< Types... >::value||all_unsigned< Types... >::value > same_sign
is_detected< string_can_append_data, StringType, Arg > detect_string_can_append_data
is_detected< string_can_append_iter, StringType, Arg > detect_string_can_append_iter
std::shared_ptr< output_adapter_protocol< CharType > > output_adapter_t
decltype(std::declval< StringType & >()+=std::declval< Arg && >()) string_can_append_op
typename detected_or< Default, Op, Args... >::type detected_or_t
enable_if_t< is_range< R >::value, result_of_begin< decltype(std::declval< R & >())> > iterator_t
detector< Default, void, Op, Args... > detected_or
T conditional_static_cast(U value)
decltype(std::declval< T & >().boolean(std::declval< bool >())) boolean_function_t
decltype(std::declval< T & >().parse_error( std::declval< std::size_t >(), std::declval< const std::string & >(), std::declval< const Exception & >())) parse_error_function_t
namespace for Niels Lohmann
size_type erase(const key_type &key)
typename Container::size_type size_type
basic_json< nlohmann::ordered_map > ordered_json
specialization that maintains the insertion order of object keys
*brief create JSON pointer *sa reference_tokens const string_t & a
typename string_t_helper< RefStringType >::type string_t
*brief remove last reference token *sa JSON pointer has no parent
*brief create JSON pointer *sa reference_tokens end()
std::vector< std::pair< const Key, T >, Allocator > Container
typename Container::value_type value_type
typename Container::iterator iterator
std::equal_to< Key > key_compare
friend class json_pointer
*brief append another JSON pointer at the end of this JSON pointer *sa ptr reference_tokens begin()
T & at(const key_type &key)
*brief create a new JSON pointer by appending the right JSON pointer at the end of the left JSON pointer *sa const json_pointer & rhs
basic_json<> json
default specialization
iterator find(const key_type &key)
typename Container::const_iterator const_iterator
std::pair< iterator, bool > emplace(const key_type &key, T &&t)
return reference_tokens back()
*brief create a new JSON pointer by appending the unescaped token at the end of the JSON pointer *sa string_t token
*brief remove last reference token *sa JSON pointer has no nullptr
*brief create JSON pointer *sa reference_tokens const string_t const string_t & b
*brief create a new JSON pointer by appending the array index token at the end of the JSON pointer *sa std::size_t array_idx
typename std::enable_if< std::is_convertible< typename std::iterator_traits< InputIt >::iterator_category, std::input_iterator_tag >::value >::type require_input_iter
size_type count(const key_type &key) const
std::pair< iterator, bool > insert(value_type &&value)
T & operator[](const key_type &key)
*brief exchanges the values of two JSON objects *sa nlohmann::NLOHMANN_BASIC_JSON_TPL &j2 noexcept(is_nothrow_move_constructible< nlohmann::NLOHMANN_BASIC_JSON_TPL >::value &&is_nothrow_move_assignable< nlohmann::NLOHMANN_BASIC_JSON_TPL >::value)
default JSONSerializer template argument
static auto from_json(BasicJsonType &&j, TargetType &val) noexcept(noexcept(::nlohmann::from_json(std::forward< BasicJsonType >(j), val))) -> decltype(::nlohmann::from_json(std::forward< BasicJsonType >(j), val), void())
convert a JSON value to any value type
static auto from_json(BasicJsonType &&j) noexcept(noexcept(::nlohmann::from_json(std::forward< BasicJsonType >(j), detail::identity_tag< TargetType > {}))) -> decltype(::nlohmann::from_json(std::forward< BasicJsonType >(j), detail::identity_tag< TargetType > {}))
convert a JSON value to any value type
static auto to_json(BasicJsonType &j, TargetType &&val) noexcept(noexcept(::nlohmann::to_json(j, std::forward< TargetType >(val)))) -> decltype(::nlohmann::to_json(j, std::forward< TargetType >(val)), void())
convert any value type to a JSON value
typename BasicJsonType::default_object_comparator_t object_comparator_t
typename std::conditional< has_key_compare< object_t >::value, typename object_t::key_compare, object_comparator_t >::type type
typename BasicJsonType::object_t object_t
static constexpr int kPrecision
static diyfp normalize(diyfp x) noexcept
normalize x such that the significand is >= 2^(q-1)
static diyfp normalize_to(const diyfp &x, const int target_exponent) noexcept
normalize x such that the result has the exponent E
static diyfp mul(const diyfp &x, const diyfp &y) noexcept
returns x * y
constexpr diyfp(std::uint64_t f_, int e_) noexcept
static diyfp sub(const diyfp &x, const diyfp &y) noexcept
returns x - y
static void construct(BasicJsonType &j, const CompatibleArrayType &arr)
static void construct(BasicJsonType &j, const std::valarray< T > &arr)
static void construct(BasicJsonType &j, const std::vector< bool > &arr)
static void construct(BasicJsonType &j, typename BasicJsonType::array_t &&arr)
static void construct(BasicJsonType &j, const typename BasicJsonType::array_t &arr)
static void construct(BasicJsonType &j, const typename BasicJsonType::binary_t &b)
static void construct(BasicJsonType &j, typename BasicJsonType::binary_t &&b)
static void construct(BasicJsonType &j, typename BasicJsonType::boolean_t b) noexcept
static void construct(BasicJsonType &j, typename BasicJsonType::number_float_t val) noexcept
static void construct(BasicJsonType &j, typename BasicJsonType::number_integer_t val) noexcept
static void construct(BasicJsonType &j, typename BasicJsonType::number_unsigned_t val) noexcept
static void construct(BasicJsonType &j, typename BasicJsonType::object_t &&obj)
static void construct(BasicJsonType &j, const typename BasicJsonType::object_t &obj)
static void construct(BasicJsonType &j, const CompatibleObjectType &obj)
static void construct(BasicJsonType &j, typename BasicJsonType::string_t &&s)
static void construct(BasicJsonType &j, const CompatibleStringType &str)
static void construct(BasicJsonType &j, const typename BasicJsonType::string_t &s)
auto operator()(const BasicJsonType &j, T &&val) const noexcept(noexcept(from_json(j, std::forward< T >(val)))) -> decltype(from_json(j, std::forward< T >(val)))
static constexpr bool value
typename BasicJsonType::template json_serializer< T, void > serializer
typename BasicJsonType::template json_serializer< T, void > serializer
static constexpr bool value
static constexpr bool value
typename BasicJsonType::template json_serializer< T, void > serializer
static constexpr std::size_t size() noexcept
*iterator for JSON objects BasicJsonType::object_t::iterator object_iterator
*iterator for JSON arrays BasicJsonType::array_t::iterator array_iterator
*generic iterator for all other types primitive_iterator_t primitive_iterator
static constexpr bool value
std::numeric_limits< CompatibleNumberIntegerType > CompatibleLimits
static constexpr auto value
std::numeric_limits< RealIntegerType > RealLimits
static constexpr bool value
typename BasicJsonType::object_t object_t
static constexpr auto value
static constexpr bool value
nlohmann::detail::is_constructible_array_type_impl< BasicJsonType, ConstructibleArrayType, enable_if_t< !std::is_same< ConstructibleArrayType, typename BasicJsonType::value_type >::value &&!is_compatible_string_type< BasicJsonType, ConstructibleArrayType >::value &&is_default_constructible< ConstructibleArrayType >::value &&(std::is_move_assignable< ConstructibleArrayType >::value||std::is_copy_assignable< ConstructibleArrayType >::value)&&is_detected< iterator_t, ConstructibleArrayType >::value &&is_iterator_traits< iterator_traits< detected_t< iterator_t, ConstructibleArrayType > > >::value &&is_detected< range_value_t, ConstructibleArrayType >::value &&!std::is_same< ConstructibleArrayType, detected_t< range_value_t, ConstructibleArrayType > >::value &&is_complete_type< detected_t< range_value_t, ConstructibleArrayType > >::value > >::value_type range_value_t< ConstructibleArrayType > value_type
nlohmann::detail::is_constructible_array_type_impl< BasicJsonType, ConstructibleArrayType, enable_if_t< !std::is_same< ConstructibleArrayType, typename BasicJsonType::value_type >::value &&!is_compatible_string_type< BasicJsonType, ConstructibleArrayType >::value &&is_default_constructible< ConstructibleArrayType >::value &&(std::is_move_assignable< ConstructibleArrayType >::value||std::is_copy_assignable< ConstructibleArrayType >::value)&&is_detected< iterator_t, ConstructibleArrayType >::value &&is_iterator_traits< iterator_traits< detected_t< iterator_t, ConstructibleArrayType > > >::value &&is_detected< range_value_t, ConstructibleArrayType >::value &&!std::is_same< ConstructibleArrayType, detected_t< range_value_t, ConstructibleArrayType > >::value &&is_complete_type< detected_t< range_value_t, ConstructibleArrayType > >::value > >::value static constexpr bool value
static constexpr bool value
typename BasicJsonType::object_t object_t
static constexpr auto value
ConstructibleStringType laundered_type
static constexpr bool value
typename std::iterator_traits< T >::value_type value_type
static constexpr auto value
static one test(decltype(&C::capacity))
static constexpr bool value
static constexpr bool value
std::random_access_iterator_tag iterator_category
ptrdiff_t difference_type
typename It::difference_type difference_type
typename It::reference reference
typename It::iterator_category iterator_category
typename It::pointer pointer
typename It::value_type value_type
nonesuch(nonesuch const &)=delete
void operator=(nonesuch &&)=delete
nonesuch(nonesuch const &&)=delete
void operator=(nonesuch const &)=delete
virtual void write_characters(const CharType *s, std::size_t length)=0
virtual void write_character(CharType c)=0
output_adapter_protocol(output_adapter_protocol &&) noexcept=default
virtual ~output_adapter_protocol()=default
output_adapter_protocol(const output_adapter_protocol &)=default
output_adapter_protocol()=default
struct to capture the start position of the current token
std::size_t lines_read
the number of lines read
std::size_t chars_read_current_line
the number of characters read in the current line
std::size_t chars_read_total
the total number of characters read
auto operator()(BasicJsonType &j, T &&val) const noexcept(noexcept(to_json(j, std::forward< T >(val)))) -> decltype(to_json(j, std::forward< T >(val)), void())
integer_sequence< T, Ints...,(Ints+SeqSize)..., 2 *SeqSize > type
integer_sequence< T, Ints...,(Ints+SeqSize)... > type
integer_sequence< T > type
typename Extend< typename Gen< T, N/2 >::type, N/2, N % 2 >::type type
static constexpr bool test(T val)
static constexpr bool test(T)
static constexpr bool test(T val)
static constexpr bool test(T val)
static constexpr bool test(T val)
static constexpr bool test(T val)
virtual bool start_object(std::size_t elements)=0
the beginning of an object was read
virtual bool string(string_t &val)=0
a string value was read
virtual bool null()=0
a null value was read
typename BasicJsonType::number_integer_t number_integer_t
typename BasicJsonType::binary_t binary_t
virtual bool end_array()=0
the end of an array was read
virtual bool key(string_t &val)=0
an object key was read
typename BasicJsonType::number_unsigned_t number_unsigned_t
virtual bool binary(binary_t &val)=0
a binary value was read
typename BasicJsonType::number_float_t number_float_t
virtual bool start_array(std::size_t elements)=0
the beginning of an array was read
virtual bool parse_error(std::size_t position, const std::string &last_token, const detail::exception &ex)=0
a parse error occurred
json_sax(json_sax &&) noexcept=default
virtual bool boolean(bool val)=0
a boolean value was read
json_sax(const json_sax &)=default
virtual bool end_object()=0
the end of an object was read
virtual bool number_unsigned(number_unsigned_t val)=0
an unsigned integer number was read
typename BasicJsonType::string_t string_t
virtual bool number_float(number_float_t val, const string_t &s)=0
a floating-point number was read
virtual bool number_integer(number_integer_t val)=0
an integer number was read
a minimal map-like container that preserves insertion order
bool operator()(::nlohmann::detail::value_t lhs, ::nlohmann::detail::value_t rhs) const noexcept
compare two value_t enum values