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>
71 #include <type_traits>
79 #include <forward_list>
84 #include <type_traits>
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
560 #if defined(__POCC__)
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>
2192 template<
class Default,
2194 template<
class...>
class Op,
2202 template<
class Default,
template<
class...>
class Op,
class... Args>
2209 template<
template<
class...>
class Op,
class... Args>
2212 template<
template<
class...>
class Op,
class... Args>
2215 template<
template<
class...>
class Op,
class... Args>
2218 template<
class Default,
template<
class...>
class Op,
class... Args>
2221 template<
class Default,
template<
class...>
class Op,
class... Args>
2224 template<
class Expected,
template<
class...>
class Op,
class... Args>
2227 template<
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
2267 #ifdef __has_include
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);
2817 template<
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()))
2836 template<
typename StringType>
2851 template<
typename StringType>
2852 static void unescape(StringType& s)
2881 constexpr
operator size_t()
const
2896 #include <type_traits>
2907 template<
typename T>
2910 #ifdef JSON_HAS_CPP_14
2921 template<
bool B,
typename T =
void>
2948 template <
typename T, T... Ints>
2952 static constexpr std::size_t
size() noexcept
2954 return sizeof...(Ints);
2963 template <
size_t... Ints>
2966 namespace utility_internal
2969 template <
typename Seq,
size_t SeqSize,
size_t Rem>
2973 template <
typename T, T... Ints,
size_t SeqSize>
2979 template <
typename T, T... Ints,
size_t SeqSize>
2987 template <
typename T,
size_t N>
2994 template <
typename T>
3009 template <
typename T, T N>
3025 template <
typename... Ts>
3037 template<
typename T>
3043 #ifndef JSON_HAS_CPP_17
3045 template<
typename T>
3057 #include <type_traits>
3078 template<
typename It,
typename =
void>
3081 template<
typename It>
3085 typename It::reference, typename It::iterator_category >>
3096 template<
typename T,
typename =
void>
3101 template<
typename T>
3107 template<
typename T>
3146 #ifndef INCLUDE_NLOHMANN_JSON_FWD_HPP_
3147 #define INCLUDE_NLOHMANN_JSON_FWD_HPP_
3169 template<
typename T =
void,
typename SFINAE =
void>
3170 struct adl_serializer;
3174 template<
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>>
3189 template<
typename BasicJsonType>
3200 template<
class Key,
class T,
class IgnoredLess,
class Allocator>
3245 template<
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 >
3262 template<
typename T>
3269 template<
typename T>
3272 template<
typename T>
3275 template<
typename T>
3278 template<
typename T>
3281 template<
typename T>
3284 template<
typename T>
3287 template<
typename T>
3290 template<
typename T,
typename... Args>
3293 template<
typename T,
typename... Args>
3296 template<
typename T,
typename U>
3300 template<
typename BasicJsonType,
typename T,
typename =
void>
3307 template <
typename BasicJsonType,
typename T>
3313 template<
typename BasicJsonType,
typename T>
3316 using serializer =
typename BasicJsonType::template json_serializer<T, void>;
3320 const BasicJsonType&, T&>::value;
3325 template<
typename BasicJsonType,
typename T,
typename =
void>
3328 template<
typename BasicJsonType,
typename T>
3331 using serializer =
typename BasicJsonType::template json_serializer<T, void>;
3335 const BasicJsonType&>::value;
3340 template<
typename BasicJsonType,
typename T,
typename =
void>
3343 template<
typename BasicJsonType,
typename T>
3346 using serializer =
typename BasicJsonType::template json_serializer<T, void>;
3353 template<
typename T>
3356 template<
typename T>
3357 struct has_key_compare : std::integral_constant<bool, is_detected<detect_key_compare, T>::value> {};
3360 template<
typename BasicJsonType>
3365 using type =
typename std::conditional < has_key_compare<object_t>::value,
3369 template<
typename BasicJsonType>
3379 template<
class B,
class... Bn>
3381 : std::conditional<static_cast<bool>(B::value), conjunction<Bn...>, B>
::type {};
3384 template<
class B>
struct negation : std::integral_constant < bool, !B::value > { };
3389 template <
typename T>
3392 template <
typename T1,
typename T2>
3394 :
conjunction<is_default_constructible<T1>, is_default_constructible<T2>> {};
3396 template <
typename T1,
typename T2>
3398 :
conjunction<is_default_constructible<T1>, is_default_constructible<T2>> {};
3400 template <
typename... Ts>
3402 :
conjunction<is_default_constructible<Ts>...> {};
3404 template <
typename... Ts>
3406 :
conjunction<is_default_constructible<Ts>...> {};
3409 template <
typename T,
typename... Args>
3412 template <
typename T1,
typename T2>
3415 template <
typename T1,
typename T2>
3418 template <
typename... Ts>
3421 template <
typename... Ts>
3425 template<
typename T,
typename =
void>
3428 template<
typename T>
3443 template<
typename T>
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;
3462 template<
typename R>
3465 template<
typename T>
3472 template<
typename T,
typename =
void>
3475 template<
typename T>
3478 template<
typename BasicJsonType,
typename CompatibleObjectType,
3482 template<
typename BasicJsonType,
typename CompatibleObjectType>
3484 BasicJsonType, CompatibleObjectType,
3486 is_detected<key_type_t, CompatibleObjectType>::value >>
3493 typename CompatibleObjectType::key_type>::value &&
3495 typename CompatibleObjectType::mapped_type>::value;
3498 template<
typename BasicJsonType,
typename CompatibleObjectType>
3502 template<
typename BasicJsonType,
typename ConstructibleObjectType,
3506 template<
typename BasicJsonType,
typename ConstructibleObjectType>
3508 BasicJsonType, ConstructibleObjectType,
3510 is_detected<key_type_t, ConstructibleObjectType>::value >>
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);
3530 template<
typename BasicJsonType,
typename ConstructibleObjectType>
3533 ConstructibleObjectType> {};
3535 template<
typename BasicJsonType,
typename CompatibleStringType>
3542 template<
typename BasicJsonType,
typename ConstructibleStringType>
3546 #ifdef __INTEL_COMPILER
3547 using laundered_type = decltype(std::declval<ConstructibleStringType>());
3554 typename BasicJsonType::string_t>
::value;
3557 template<
typename BasicJsonType,
typename CompatibleArrayType,
typename =
void>
3560 template<
typename BasicJsonType,
typename CompatibleArrayType>
3562 BasicJsonType, CompatibleArrayType,
3565 is_iterator_traits<iterator_traits<detected_t<iterator_t, CompatibleArrayType>>>::value&&
3568 !std::is_same<CompatibleArrayType, detected_t<range_value_t, CompatibleArrayType>>::value >>
3575 template<
typename BasicJsonType,
typename CompatibleArrayType>
3579 template<
typename BasicJsonType,
typename ConstructibleArrayType,
typename =
void>
3582 template<
typename BasicJsonType,
typename ConstructibleArrayType>
3584 BasicJsonType, ConstructibleArrayType,
3586 typename BasicJsonType::value_type>::value >>
3587 : std::true_type {};
3589 template<
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)&&
3598 is_detected<iterator_t, ConstructibleArrayType>::value&&
3599 is_iterator_traits<iterator_traits<detected_t<iterator_t, ConstructibleArrayType>>>::value&&
3600 is_detected<range_value_t, 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 ||
3619 template<
typename BasicJsonType,
typename ConstructibleArrayType>
3623 template<
typename RealIntegerType,
typename CompatibleNumberIntegerType,
3627 template<
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;
3645 template<
typename RealIntegerType,
typename CompatibleNumberIntegerType>
3648 CompatibleNumberIntegerType> {};
3650 template<
typename BasicJsonType,
typename CompatibleType,
typename =
void>
3653 template<
typename BasicJsonType,
typename CompatibleType>
3655 BasicJsonType, CompatibleType,
3662 template<
typename BasicJsonType,
typename CompatibleType>
3666 template<
typename T1,
typename T2>
3669 template<
typename T1,
typename... Args>
3672 template<
typename BasicJsonType,
typename T>
3675 template<
typename BasicJsonType>
3678 template<
typename BasicJsonType>
3683 template<
template <
typename...>
class Primary,
typename T>
3686 template<
template <
typename...>
class Primary,
typename... Args>
3689 template<
typename T>
3693 template<
typename Compare,
typename A,
typename B,
typename =
void>
3696 template<
typename Compare,
typename A,
typename B>
3698 decltype(
std::declval<Compare>()(std::declval<A>(), std::declval<B>())),
3699 decltype(std::declval<Compare>()(std::declval<B>(), std::declval<A>()))
3700 >> : std::true_type {};
3702 template<
typename T>
3707 template<
typename Comparator,
typename ObjectKeyType,
typename KeyTypeCVRef,
bool RequireTransparentComparator =
true,
3711 && !(ExcludeObjectKeyType && std::is_same<KeyType,
3712 ObjectKeyType>::value)
3713 && (!RequireTransparentComparator
3725 template<
typename BasicJsonType,
typename KeyTypeCVRef,
bool RequireTransparentComparator =
true,
3729 typename BasicJsonType::object_t::key_type, KeyTypeCVRef,
3730 RequireTransparentComparator, ExcludeObjectKeyType>::value
3735 template<
typename ObjectType,
typename KeyType>
3739 template<
typename BasicJsonType,
typename KeyType>
3743 typename BasicJsonType::object_t, KeyType >::value,
3749 template <
typename T>
3759 template <
typename C>
static one test( decltype(&C::capacity) ) ;
3762 enum {
value =
sizeof(test<T>(
nullptr)) ==
sizeof(
char) };
3766 template < typename T, typename U, enable_if_t < !std::is_same<T, U>::value,
int > = 0 >
3769 return static_cast<T
>(
value);
3772 template<typename T, typename U, enable_if_t<std::is_same<T, U>::value,
int> = 0>
3778 template<
typename... Types>
3781 template<
typename... Types>
3784 template<
typename... Types>
3788 template<
typename... Types>
3792 template<
typename OfType,
typename T>
3794 (std::is_signed<OfType>::value && (
sizeof(T) <
sizeof(OfType)))
3797 template<
typename OfType,
typename T,
3798 bool OfTypeSigned = std::is_signed<OfType>::value,
3799 bool TSigned = std::is_signed<T>::value>
3802 template<
typename OfType,
typename T>
3812 template<
typename OfType,
typename T>
3822 template<
typename OfType,
typename T>
3833 template<
typename OfType,
typename T>
3844 template<
typename OfType,
typename T,
3845 bool NeverOutOfRange = never_out_of_range<OfType, T>::value,
3849 template<
typename OfType,
typename T>
3858 template<
typename OfType,
typename T>
3867 template<
typename OfType,
typename T>
3898 template<
typename... Args>
3899 inline std::size_t
concat_length(
const char* cstr, Args&& ... rest);
3901 template<
typename StringType,
typename... Args>
3902 inline std::size_t
concat_length(
const StringType& str, Args&& ... rest);
3904 template<
typename... Args>
3910 template<
typename... Args>
3914 return ::strlen(cstr) +
concat_length(std::forward<Args>(rest)...);
3917 template<
typename StringType,
typename... Args>
3920 return str.size() +
concat_length(std::forward<Args>(rest)...);
3923 template<
typename OutStringType>
3927 template<
typename StringType,
typename Arg>
3930 template<
typename StringType,
typename Arg>
3933 template<
typename StringType,
typename Arg>
3936 template<
typename StringType,
typename Arg>
3939 template<
typename StringType,
typename Arg>
3940 using string_can_append_iter = decltype(std::declval<StringType&>().append(std::declval<const Arg&>().begin(), std::declval<const Arg&>().end()));
3942 template<
typename StringType,
typename Arg>
3945 template<
typename StringType,
typename Arg>
3946 using string_can_append_data = decltype(std::declval<StringType&>().append(std::declval<const Arg&>().data(), std::declval<const Arg&>().size()));
3948 template<
typename StringType,
typename Arg>
3951 template <
typename OutStringType,
typename Arg,
typename... Args,
3954 inline void concat_into(OutStringType& out, Arg && arg, Args && ... rest);
3956 template <
typename OutStringType,
typename Arg,
typename... Args,
3960 inline void concat_into(OutStringType& out,
const Arg& arg, Args && ... rest);
3962 template <
typename OutStringType,
typename Arg,
typename... Args,
3967 inline void concat_into(OutStringType& out,
const Arg& arg, Args && ... rest);
3969 template<
typename OutStringType,
typename Arg,
typename... Args,
3971 inline void concat_into(OutStringType& out, Arg && arg, Args && ... rest)
3973 out.append(std::forward<Arg>(arg));
3977 template <
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 > >
3980 inline void concat_into(OutStringType& out, Arg&& arg, Args&& ... rest)
3982 out += std::forward<Arg>(arg);
3986 template <
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 > >
3990 inline void concat_into(OutStringType& out,
const Arg& arg, Args&& ... rest)
3992 out.append(arg.begin(), arg.end());
3996 template <
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 > >
4001 inline void concat_into(OutStringType& out,
const Arg& arg, Args&& ... rest)
4003 out.append(arg.data(), arg.size());
4007 template<
typename OutStringType = std::string,
typename... Args>
4008 inline OutStringType
concat(Args && ... 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_)
4057 template<
typename BasicJsonType>
4060 #if JSON_DIAGNOSTICS
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)
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>
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)
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>
4189 return {id_, w.c_str()};
4203 template<typename BasicJsonContext, enable_if_t<is_basic_json_context<BasicJsonContext>::value,
int> = 0>
4207 return {id_, w.c_str()};
4220 template<typename BasicJsonContext, enable_if_t<is_basic_json_context<BasicJsonContext>::value,
int> = 0>
4224 return {id_, w.c_str()};
4237 template<typename BasicJsonContext, enable_if_t<is_basic_json_context<BasicJsonContext>::value,
int> = 0>
4241 return {id_, w.c_str()};
4275 #if JSON_HAS_EXPERIMENTAL_FILESYSTEM
4276 #include <experimental/filesystem>
4279 namespace std_fs = std::experimental::filesystem;
4281 #elif JSON_HAS_FILESYSTEM
4282 #include <filesystem>
4285 namespace std_fs = std::filesystem;
4293 template<
typename BasicJsonType>
4294 inline void from_json(
const BasicJsonType& j,
typename std::nullptr_t& n)
4304 template <
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*>());
4340 template<
typename BasicJsonType>
4341 inline void from_json(
const BasicJsonType& j,
typename BasicJsonType::boolean_t& b)
4347 b = *j.template get_ptr<const typename BasicJsonType::boolean_t*>();
4350 template<
typename BasicJsonType>
4351 inline 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 >
4366 inline void from_json(
const BasicJsonType& j, StringType& s)
4373 s = *j.template get_ptr<const typename BasicJsonType::string_t*>();
4376 template<
typename BasicJsonType>
4377 inline void from_json(
const BasicJsonType& j,
typename BasicJsonType::number_float_t& val)
4382 template<
typename BasicJsonType>
4383 inline void from_json(
const BasicJsonType& j,
typename BasicJsonType::number_unsigned_t& val)
4388 template<
typename BasicJsonType>
4389 inline void from_json(
const BasicJsonType& j,
typename BasicJsonType::number_integer_t& val)
4394 #if !JSON_DISABLE_ENUM_SERIALIZATION
4395 template<
typename BasicJsonType,
typename EnumType,
4396 enable_if_t<std::is_enum<EnumType>::value,
int> = 0>
4401 e =
static_cast<EnumType
>(val);
4406 template<
typename BasicJsonType,
typename T,
typename Allocator,
4407 enable_if_t<is_getable<BasicJsonType, T>::value,
int> = 0>
4408 inline 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>();
4423 template<
typename BasicJsonType,
typename T,
4424 enable_if_t<is_getable<BasicJsonType, T>::value,
int> = 0>
4425 inline 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>();
4439 template<
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>();
4449 template<
typename BasicJsonType>
4452 arr = *j.template get_ptr<const typename BasicJsonType::array_t*>();
4455 template<
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>();
4466 template<
typename BasicJsonType,
typename ConstructibleArrayType,
4468 std::is_assignable<ConstructibleArrayType&, ConstructibleArrayType>::value,
4472 arr.reserve(std::declval<typename ConstructibleArrayType::size_type>()),
4473 j.template get<typename ConstructibleArrayType::value_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)
4485 return i.template get<typename ConstructibleArrayType::value_type>();
4487 arr = std::move(ret);
4490 template<
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)
4506 return i.template get<typename ConstructibleArrayType::value_type>();
4508 arr = std::move(ret);
4511 template <
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,
4519 auto from_json(
const BasicJsonType& j, ConstructibleArrayType& arr)
4521 j.template get<typename ConstructibleArrayType::value_type>(),
4532 template <
typename BasicJsonType,
typename T, std::size_t... Idx >
4536 return { { std::forward<BasicJsonType>(j).at(Idx).template get<T>()... } };
4539 template <
typename BasicJsonType,
typename T, std::
size_t N >
4551 template<
typename BasicJsonType>
4552 inline void from_json(
const BasicJsonType& j,
typename BasicJsonType::binary_t& bin)
4559 bin = *j.template get_ptr<const typename BasicJsonType::binary_t*>();
4562 template<
typename BasicJsonType,
typename ConstructibleObjectType,
4563 enable_if_t<is_constructible_object_type<BasicJsonType, ConstructibleObjectType>::value,
int> = 0>
4564 inline 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);
4588 template <
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,
4596 inline 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*>());
4632 template<
typename BasicJsonType,
typename... Args, std::size_t... Idx>
4635 return std::make_tuple(std::forward<BasicJsonType>(j).at(Idx).
template get<Args>()...);
4638 template <
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>()};
4645 template<
typename BasicJsonType,
typename A1,
typename A2>
4651 template<
typename BasicJsonType,
typename... Args>
4657 template<
typename BasicJsonType,
typename... Args>
4663 template<
typename BasicJsonType,
typename TupleRelated>
4672 return from_json_tuple_impl(std::forward<BasicJsonType>(j), std::forward<TupleRelated>(t), priority_tag<3> {});
4675 template <
typename BasicJsonType,
typename Key,
typename Value,
typename Compare,
typename Allocator,
4677 typename BasicJsonType::string_t, Key >::value >>
4678 inline void from_json(
const BasicJsonType& j, std::map<Key, Value, Compare, Allocator>& m)
4685 for (
const auto& p : j)
4691 m.emplace(p.at(0).template get<Key>(), p.at(1).template get<Value>());
4695 template <
typename BasicJsonType,
typename Key,
typename Value,
typename Hash,
typename KeyEqual,
typename Allocator,
4697 typename BasicJsonType::string_t, Key >::value >>
4698 inline void from_json(
const BasicJsonType& j, std::unordered_map<Key, Value, Hash, KeyEqual, Allocator>& m)
4705 for (
const auto& p : j)
4711 m.emplace(p.at(0).template get<Key>(), p.at(1).template get<Value>());
4715 #if JSON_HAS_FILESYSTEM || JSON_HAS_EXPERIMENTAL_FILESYSTEM
4716 template<
typename BasicJsonType>
4717 inline 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
4756 #include <algorithm>
4760 #include <type_traits>
4789 template<
typename string_type>
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) {}
4952 template<std::
size_t N,
typename IteratorType, enable_if_t<N == 0,
int> = 0>
4960 template<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"
4979 template<
typename IteratorType>
4981 :
public std::integral_constant<std::size_t, 2> {};
4983 template<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>
5012 namespace std_fs = std::experimental::filesystem;
5014 #elif JSON_HAS_FILESYSTEM
5015 #include <filesystem>
5018 namespace 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,
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,
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,
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();
5258 template<
typename BasicJsonType,
typename T,
5259 enable_if_t<std::is_same<T, typename BasicJsonType::boolean_t>::value,
int> = 0>
5260 inline void to_json(BasicJsonType& j, T b) noexcept
5265 template<
typename BasicJsonType,
5266 enable_if_t<std::is_convertible<const std::vector<bool>::reference&,
typename BasicJsonType::boolean_t>::value,
int> = 0>
5267 inline void to_json(BasicJsonType& j,
const std::vector<bool>::reference& b) noexcept
5272 template<
typename BasicJsonType,
typename CompatibleString,
5273 enable_if_t<std::is_constructible<typename BasicJsonType::string_t, CompatibleString>::value,
int> = 0>
5274 inline void to_json(BasicJsonType& j,
const CompatibleString& s)
5279 template<
typename BasicJsonType>
5280 inline void to_json(BasicJsonType& j,
typename BasicJsonType::string_t&& s)
5285 template<
typename BasicJsonType,
typename FloatType,
5286 enable_if_t<std::is_floating_point<FloatType>::value,
int> = 0>
5287 inline void to_json(BasicJsonType& j, FloatType val) noexcept
5292 template<
typename BasicJsonType,
typename CompatibleNumberUnsignedType,
5293 enable_if_t<is_compatible_integer_type<typename BasicJsonType::number_unsigned_t, CompatibleNumberUnsignedType>::value,
int> = 0>
5294 inline void to_json(BasicJsonType& j, CompatibleNumberUnsignedType val) noexcept
5299 template<
typename BasicJsonType,
typename CompatibleNumberIntegerType,
5300 enable_if_t<is_compatible_integer_type<typename BasicJsonType::number_integer_t, CompatibleNumberIntegerType>::value,
int> = 0>
5301 inline void to_json(BasicJsonType& j, CompatibleNumberIntegerType val) noexcept
5306 #if !JSON_DISABLE_ENUM_SERIALIZATION
5307 template<
typename BasicJsonType,
typename EnumType,
5308 enable_if_t<std::is_enum<EnumType>::value,
int> = 0>
5309 inline void to_json(BasicJsonType& j, EnumType e) noexcept
5316 template<
typename BasicJsonType>
5317 inline void to_json(BasicJsonType& j,
const std::vector<bool>& e)
5322 template <
typename BasicJsonType,
typename CompatibleArrayType,
5323 enable_if_t < is_compatible_array_type<BasicJsonType,
5324 CompatibleArrayType>::value&&
5325 !is_compatible_object_type<BasicJsonType, CompatibleArrayType>::value&&
5327 !std::is_same<typename BasicJsonType::binary_t, CompatibleArrayType>::value&&
5328 !is_basic_json<CompatibleArrayType>::value,
5330 inline void to_json(BasicJsonType& j,
const CompatibleArrayType& arr)
5335 template<
typename BasicJsonType>
5336 inline void to_json(BasicJsonType& j,
const typename BasicJsonType::binary_t& bin)
5341 template<
typename BasicJsonType,
typename T,
5342 enable_if_t<std::is_convertible<T, BasicJsonType>::value,
int> = 0>
5343 inline void to_json(BasicJsonType& j,
const std::valarray<T>& arr)
5348 template<
typename BasicJsonType>
5349 inline void to_json(BasicJsonType& j,
typename BasicJsonType::array_t&& arr)
5354 template <
typename BasicJsonType,
typename CompatibleObjectType,
5355 enable_if_t < is_compatible_object_type<BasicJsonType, CompatibleObjectType>::value&& !is_basic_json<CompatibleObjectType>::value,
int > = 0 >
5356 inline void to_json(BasicJsonType& j,
const CompatibleObjectType& obj)
5361 template<
typename BasicJsonType>
5362 inline 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,
5370 const T(&)[N]>::value,
5372 inline void to_json(BasicJsonType& j,
const T(&arr)[N])
5377 template < typename BasicJsonType, typename T1, typename T2, enable_if_t < std::is_constructible<BasicJsonType, T1>::value&& std::is_constructible<BasicJsonType, T2>::value,
int > = 0 >
5378 inline void to_json(BasicJsonType& j,
const std::pair<T1, T2>& p)
5380 j = { p.first, p.second };
5384 template<
typename BasicJsonType,
typename T,
5385 enable_if_t<std::is_same<T, iteration_proxy_value<typename BasicJsonType::iterator>>::value,
int> = 0>
5388 j = { {b.key(), b.value()} };
5391 template<
typename BasicJsonType,
typename Tuple, std::size_t... Idx>
5394 j = { std::get<Idx>(t)... };
5397 template<typename BasicJsonType, typename T, enable_if_t<is_constructible_tuple<BasicJsonType, T>::value,
int > = 0>
5398 inline void to_json(BasicJsonType& j,
const T& t)
5403 #if JSON_HAS_FILESYSTEM || JSON_HAS_EXPERIMENTAL_FILESYSTEM
5404 template<
typename BasicJsonType>
5405 inline 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
5445 template<
typename ValueType,
typename>
5450 template<
typename BasicJsonType,
typename TargetType = ValueType>
5451 static auto from_json(BasicJsonType && j, TargetType& val) noexcept(
5460 template<
typename BasicJsonType,
typename TargetType = ValueType>
5470 template<
typename BasicJsonType,
typename TargetType = ValueType>
5471 static auto to_json(BasicJsonType& j, TargetType && val) noexcept(
5492 template<
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>
5600 inline std::size_t
combine(std::size_t seed, std::size_t h) noexcept
5602 seed ^= h + 0x9e3779b9 + (seed << 6U) + (seed >> 2U);
5617 template<
typename BasicJsonType>
5618 std::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:
5670 const auto h = std::hash<number_integer_t> {}(j.template get<number_integer_t>());
5674 case BasicJsonType::value_t::number_unsigned:
5676 const auto h = std::hash<number_unsigned_t> {}(j.template get<number_unsigned_t>());
5680 case BasicJsonType::value_t::number_float:
5682 const auto h = std::hash<number_float_t> {}(j.template get<number_float_t>());
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));
5711 #include <algorithm>
5737 #include <type_traits>
5785 return std::fgetc(m_file);
5814 is->clear(is->rdstate() & std::ios::eofbit);
5819 : is(&i), sb(i.rdbuf())
5828 : is(rhs.is), sb(rhs.sb)
5839 auto res = sb->sbumpc();
5843 is->clear(is->rdstate() | std::ios::eofbit);
5850 std::istream* is =
nullptr;
5851 std::streambuf* sb =
nullptr;
5857 template<
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;
5893 template<
typename BaseInputAdapter,
size_t T>
5896 template<
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;
5954 template<
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;
6017 template<
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;
6062 template<
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));
6075 template<
typename T>
6085 template<
typename IteratorType>
6089 using char_type =
typename std::iterator_traits<iterator_type>::value_type;
6100 template<
typename IteratorType>
6104 return factory_type::create(first, last);
6111 namespace container_input_adapter_factory_impl
6117 template<
typename ContainerType,
typename Enable =
void>
6120 template<
typename ContainerType>
6122 void_t<decltype(begin(
std::declval<ContainerType>()), end(std::declval<ContainerType>()))>>
6134 template<
typename ContainerType>
6161 template <
typename CharT,
6162 typename std::enable_if <
6163 std::is_pointer<CharT>::value&&
6164 !std::is_array<CharT>::value&&
6170 auto length = std::strlen(
reinterpret_cast<const char*
>(b));
6171 const auto* ptr =
reinterpret_cast<const char*
>(b);
6175 template<
typename T, std::
size_t N>
6187 template <
typename CharT,
6188 typename std::enable_if <
6189 std::is_pointer<CharT>::value&&
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);
6240 template<
typename BasicJsonType>
6253 virtual bool null() = 0;
6344 const std::string& last_token,
6371 template<
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;
6554 template<
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()))
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())
6717 keep = callback(
static_cast<int>(ref_stack.size()) - 1, parse_event_t::array_end, *ref_stack.back());
6720 ref_stack.back()->set_parents();
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;
6861 template<
typename BasicJsonType>
6948 #include <initializer_list>
6968 template<
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";
7045 template<
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;
8036 scan_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;
8063 scan_number_decimal2:
8079 goto scan_number_decimal2;
8086 goto scan_number_exponent;
8090 goto scan_number_done;
8093 scan_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 {};
8552 string_t token_buffer {};
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 =
'.';
8586 template<
typename T>
8589 template<
typename T>
8591 decltype(std::declval<T&>().
boolean(std::declval<bool>()));
8593 template<
typename T,
typename Integer>
8595 decltype(std::declval<T&>().
number_integer(std::declval<Integer>()));
8597 template<
typename T,
typename Un
signed>
8599 decltype(std::declval<T&>().
number_unsigned(std::declval<Unsigned>()));
8601 template<
typename T,
typename Float,
typename String>
8603 std::declval<Float>(), std::declval<const String&>()));
8605 template<
typename T,
typename String>
8607 decltype(std::declval<T&>().
string(std::declval<String&>()));
8609 template<
typename T,
typename Binary>
8611 decltype(std::declval<T&>().
binary(std::declval<Binary&>()));
8613 template<
typename T>
8615 decltype(std::declval<T&>().start_object(std::declval<std::size_t>()));
8617 template<
typename T,
typename String>
8619 decltype(std::declval<T&>().
key(std::declval<String&>()));
8621 template<
typename T>
8624 template<
typename T>
8626 decltype(std::declval<T&>().start_array(std::declval<std::size_t>()));
8628 template<
typename T>
8631 template<
typename T,
typename Exception>
8633 std::declval<std::size_t>(), std::declval<const std::string&>(),
8634 std::declval<const Exception&>()));
8636 template<
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;
8667 template<
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)");
8690 number_integer_t>::
value,
8691 "Missing/invalid function: bool number_integer(number_integer_t)");
8694 number_unsigned_t>::
value,
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&)");
8750 static inline bool little_endianness(
int num = 1) noexcept
8752 return *
reinterpret_cast<char*
>(&num) == 1;
8763 template<
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();
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();
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),
"");
8984 return get_number<std::int32_t, true>(
input_format_t::bson, len) && get_bson_string(len, value) && sax->string(value);
8989 return parse_bson_internal();
8994 return parse_bson_array();
9001 return get_number<std::int32_t, true>(
input_format_t::bson, len) && get_bson_binary(len, value) && sax->binary(value);
9006 return sax->boolean(get() != 0);
9016 std::int32_t
value{};
9017 return get_number<std::int32_t, true>(
input_format_t::bson, value) && sax->number_integer(value);
9022 std::int64_t
value{};
9023 return get_number<std::int64_t, true>(
input_format_t::bson, value) && sax->number_integer(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(
9325 conditional_static_cast<std::size_t>(
static_cast<unsigned int>(current) & 0x1Fu), tag_handler);
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{};
9342 return get_number(
input_format_t::cbor, len) && get_cbor_array(conditional_static_cast<std::size_t>(len), tag_handler);
9347 std::uint64_t len{};
9348 return get_number(
input_format_t::cbor, len) && get_cbor_array(conditional_static_cast<std::size_t>(len), tag_handler);
9352 return get_cbor_array(
static_cast<std::size_t
>(-1), tag_handler);
9379 return get_cbor_object(conditional_static_cast<std::size_t>(
static_cast<unsigned int>(current) & 0x1Fu), 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{};
9396 return get_number(
input_format_t::cbor, len) && get_cbor_object(conditional_static_cast<std::size_t>(len), tag_handler);
9401 std::uint64_t len{};
9402 return get_number(
input_format_t::cbor, len) && get_cbor_object(conditional_static_cast<std::size_t>(len), tag_handler);
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{};
9482 b.set_subtype(detail::conditional_static_cast<typename binary_t::subtype_type>(subtype));
9487 std::uint16_t subtype{};
9489 b.set_subtype(detail::conditional_static_cast<typename binary_t::subtype_type>(subtype));
9494 std::uint32_t subtype{};
9496 b.set_subtype(detail::conditional_static_cast<typename binary_t::subtype_type>(subtype));
9501 std::uint64_t subtype{};
9503 b.set_subtype(detail::conditional_static_cast<typename binary_t::subtype_type>(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));
10049 return get_msgpack_object(conditional_static_cast<std::size_t>(
static_cast<unsigned int>(current) & 0x0Fu));
10068 return get_msgpack_array(conditional_static_cast<std::size_t>(
static_cast<unsigned int>(current) & 0x0Fu));
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{};
10205 return get_number(
input_format_t::msgpack, len) && get_msgpack_array(conditional_static_cast<std::size_t>(len));
10210 std::uint16_t len{};
10216 std::uint32_t len{};
10217 return get_number(
input_format_t::msgpack, len) && get_msgpack_object(conditional_static_cast<std::size_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));
10786 if (!value_in_range_of<std::size_t>(number))
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{};
10821 result = conditional_static_cast<std::size_t>(number);
10831 std::uint64_t number{};
10836 if (!value_in_range_of<std::size_t>(number))
10839 exception_message(input_format,
"integer value overflow",
"size"),
nullptr));
10841 result = detail::conditional_static_cast<std::size_t>(number);
10853 return sax->parse_error(chars_read, get_token_string(),
parse_error::create(113, chars_read, exception_message(input_format,
"ndarray dimentional 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_";
10877 if (
JSON_HEDLEY_UNLIKELY(!sax->start_object(3) || !sax->key(key) || !sax->start_array(dim.size())))
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>
11725 template<
typename BasicJsonType>
11727 std::function<bool(
int ,
parse_event_t , BasicJsonType& )>;
11734 template<
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_)
11768 void parse(
const bool strict, BasicJsonType& result)
11773 sax_parse_internal(&sdp);
11776 if (
strict && (get_token() != token_type::end_of_input))
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))
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))
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)
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:
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:
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:
12037 skip_to_state_evaluation =
false;
12041 if (states.empty())
12050 if (get_token() == token_type::value_separator)
12071 skip_to_state_evaluation =
true;
12083 if (get_token() == token_type::value_separator)
12125 skip_to_state_evaluation =
true;
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)
12162 if (expected != token_type::uninitialized)
12172 const parser_callback_t<BasicJsonType> callback =
nullptr;
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;
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;
12339 #include <iterator>
12340 #include <type_traits>
12362 template<
typename IteratorType>
class iteration_proxy;
12363 template<
typename IteratorType>
class iteration_proxy_value;
12381 template<
typename BasicJsonType>
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.");
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)
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)
12580 switch (m_object->m_type)
12619 switch (m_object->m_type)
12663 switch (m_object->m_type)
12703 auto result = *
this;
12716 switch (m_object->m_type)
12754 auto result = *
this;
12767 switch (m_object->m_type)
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)
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)
12886 return !other.operator < (*this);
12915 switch (m_object->m_type)
12959 auto result = *
this;
12981 auto result = *
this;
12994 switch (m_object->m_type)
13023 switch (m_object->m_type)
13057 const typename object_t::key_type&
key()
const
13093 #include <iterator>
13122 template<
typename Base>
13196 auto it = --this->base();
13203 auto it = --this->base();
13204 return it.operator * ();
13215 #include <algorithm>
13241 template<
typename RefStringType>
13251 template<
typename T>
13252 struct string_t_helper
13260 using type = StringType;
13265 using string_t =
typename string_t_helper<RefStringType>::type;
13270 : reference_tokens(split(s))
13277 return std::accumulate(reference_tokens.begin(), reference_tokens.end(),
13281 return detail::concat(a,
'/', detail::escape(b));
13296 reference_tokens.insert(reference_tokens.end(),
13297 ptr.reference_tokens.begin(),
13298 ptr.reference_tokens.end());
13362 reference_tokens.pop_back();
13374 return reference_tokens.back();
13381 reference_tokens.push_back(token);
13388 reference_tokens.push_back(std::move(token));
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);
13444 return static_cast<size_type
>(res);
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)
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;
14031 json_pointer<string_t> convert() const&
14033 json_pointer<string_t> result;
14034 result.reference_tokens = reference_tokens;
14038 json_pointer<string_t> convert()&&
14040 json_pointer<string_t> result;
14041 result.reference_tokens = std::move(reference_tokens);
14056 template<
typename RefStringTypeLhs,
typename RefStringTypeRhs>
14058 friend bool operator==(json_pointer<RefStringTypeLhs>
const& lhs,
14059 json_pointer<RefStringTypeRhs>
const& rhs) noexcept;
14072 template<
typename RefStringTypeLhs,
typename RefStringTypeRhs>
14074 friend bool operator!=(json_pointer<RefStringTypeLhs>
const& lhs,
14075 json_pointer<RefStringTypeRhs>
const& rhs) noexcept;
14078 std::vector<string_t> reference_tokens;
14082 template<
typename RefStringTypeLhs,
typename RefStringTypeRhs>
14086 return lhs.reference_tokens == rhs.reference_tokens;
14089 template<
typename RefStringTypeLhs,
typename RefStringTypeRhs>
14093 return !(lhs == rhs);
14100 #include <initializer_list>
14110 template<
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>
14201 #include <iterator>
14233 template<typename CharType>
14237 template<typename CharType, typename AllocatorType =
std::allocator<CharType>>
14251 void write_characters(const CharType* s,
std::
size_t length)
override
14253 v.insert(v.end(), s, s + length);
14257 std::vector<CharType, AllocatorType>& v;
14262 template<
typename CharType>
14276 void write_characters(const CharType* s,
std::
size_t length)
override
14278 stream.write(s,
static_cast<std::streamsize
>(length));
14282 std::basic_ostream<CharType>& stream;
14287 template<
typename CharType,
typename StringType = std::basic_
string<CharType>>
14301 void write_characters(const CharType* s,
std::
size_t length)
override
14303 str.append(s, length);
14310 template<
typename CharType,
typename StringType = std::basic_
string<CharType>>
14314 template<
typename AllocatorType = std::allocator<CharType>>
14351 template<
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;
14377 case value_t::object:
14379 write_bson_object(*j.m_value.object);
14383 case value_t::null:
14384 case value_t::array:
14385 case value_t::string:
14386 case value_t::boolean:
14387 case value_t::number_integer:
14388 case value_t::number_unsigned:
14389 case value_t::number_float:
14390 case value_t::binary:
14391 case value_t::discarded:
14394 JSON_THROW(type_error::create(317,
concat(
"to serialize to BSON, top-level type must be object, but is ", j.type_name()), &j));
14406 case value_t::null:
14408 oa->write_character(to_char_type(0xF6));
14412 case value_t::boolean:
14414 oa->write_character(j.m_value.boolean
14415 ? to_char_type(0xF5)
14416 : to_char_type(0xF4));
14420 case value_t::number_integer:
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));
14433 oa->write_character(to_char_type(0x18));
14434 write_number(
static_cast<std::uint8_t
>(j.m_value.number_integer));
14438 oa->write_character(to_char_type(0x19));
14439 write_number(
static_cast<std::uint16_t
>(j.m_value.number_integer));
14443 oa->write_character(to_char_type(0x1A));
14444 write_number(
static_cast<std::uint32_t
>(j.m_value.number_integer));
14448 oa->write_character(to_char_type(0x1B));
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));
14463 oa->write_character(to_char_type(0x38));
14464 write_number(
static_cast<std::uint8_t
>(positive_number));
14468 oa->write_character(to_char_type(0x39));
14469 write_number(
static_cast<std::uint16_t
>(positive_number));
14473 oa->write_character(to_char_type(0x3A));
14474 write_number(
static_cast<std::uint32_t
>(positive_number));
14478 oa->write_character(to_char_type(0x3B));
14479 write_number(
static_cast<std::uint64_t
>(positive_number));
14485 case value_t::number_unsigned:
14487 if (j.m_value.number_unsigned <= 0x17)
14489 write_number(
static_cast<std::uint8_t
>(j.m_value.number_unsigned));
14493 oa->write_character(to_char_type(0x18));
14494 write_number(
static_cast<std::uint8_t
>(j.m_value.number_unsigned));
14498 oa->write_character(to_char_type(0x19));
14499 write_number(
static_cast<std::uint16_t
>(j.m_value.number_unsigned));
14503 oa->write_character(to_char_type(0x1A));
14504 write_number(
static_cast<std::uint32_t
>(j.m_value.number_unsigned));
14508 oa->write_character(to_char_type(0x1B));
14509 write_number(
static_cast<std::uint64_t
>(j.m_value.number_unsigned));
14514 case value_t::number_float:
14516 if (std::isnan(j.m_value.number_float))
14519 oa->write_character(to_char_type(0xF9));
14520 oa->write_character(to_char_type(0x7E));
14521 oa->write_character(to_char_type(0x00));
14523 else if (std::isinf(j.m_value.number_float))
14526 oa->write_character(to_char_type(0xf9));
14527 oa->write_character(j.m_value.number_float > 0 ? to_char_type(0x7C) : to_char_type(0xFC));
14528 oa->write_character(to_char_type(0x00));
14532 write_compact_float(j.m_value.number_float, detail::input_format_t::cbor);
14537 case value_t::string:
14540 const auto N = j.m_value.string->size();
14543 write_number(
static_cast<std::uint8_t
>(0x60 + N));
14547 oa->write_character(to_char_type(0x78));
14548 write_number(
static_cast<std::uint8_t
>(N));
14552 oa->write_character(to_char_type(0x79));
14553 write_number(
static_cast<std::uint16_t
>(N));
14557 oa->write_character(to_char_type(0x7A));
14558 write_number(
static_cast<std::uint32_t
>(N));
14563 oa->write_character(to_char_type(0x7B));
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());
14575 case value_t::array:
14578 const auto N = j.m_value.array->size();
14581 write_number(
static_cast<std::uint8_t
>(0x80 + N));
14585 oa->write_character(to_char_type(0x98));
14586 write_number(
static_cast<std::uint8_t
>(N));
14590 oa->write_character(to_char_type(0x99));
14591 write_number(
static_cast<std::uint16_t
>(N));
14595 oa->write_character(to_char_type(0x9A));
14596 write_number(
static_cast<std::uint32_t
>(N));
14601 oa->write_character(to_char_type(0x9B));
14602 write_number(
static_cast<std::uint64_t
>(N));
14607 for (
const auto& el : *j.m_value.array)
14614 case value_t::binary:
14616 if (j.m_value.binary->has_subtype())
14620 write_number(
static_cast<std::uint8_t
>(0xd8));
14621 write_number(
static_cast<std::uint8_t
>(j.m_value.binary->subtype()));
14625 write_number(
static_cast<std::uint8_t
>(0xd9));
14626 write_number(
static_cast<std::uint16_t
>(j.m_value.binary->subtype()));
14630 write_number(
static_cast<std::uint8_t
>(0xda));
14631 write_number(
static_cast<std::uint32_t
>(j.m_value.binary->subtype()));
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));
14648 oa->write_character(to_char_type(0x58));
14649 write_number(
static_cast<std::uint8_t
>(N));
14653 oa->write_character(to_char_type(0x59));
14654 write_number(
static_cast<std::uint16_t
>(N));
14658 oa->write_character(to_char_type(0x5A));
14659 write_number(
static_cast<std::uint32_t
>(N));
14664 oa->write_character(to_char_type(0x5B));
14665 write_number(
static_cast<std::uint64_t
>(N));
14670 oa->write_characters(
14671 reinterpret_cast<const CharType*
>(j.m_value.binary->data()),
14677 case value_t::object:
14680 const auto N = j.m_value.object->size();
14683 write_number(
static_cast<std::uint8_t
>(0xA0 + N));
14687 oa->write_character(to_char_type(0xB8));
14688 write_number(
static_cast<std::uint8_t
>(N));
14692 oa->write_character(to_char_type(0xB9));
14693 write_number(
static_cast<std::uint16_t
>(N));
14697 oa->write_character(to_char_type(0xBA));
14698 write_number(
static_cast<std::uint32_t
>(N));
14703 oa->write_character(to_char_type(0xBB));
14704 write_number(
static_cast<std::uint64_t
>(N));
14709 for (
const auto& el : *j.m_value.object)
14711 write_cbor(el.first);
14712 write_cbor(el.second);
14717 case value_t::discarded:
14730 case value_t::null:
14732 oa->write_character(to_char_type(0xC0));
14736 case value_t::boolean:
14738 oa->write_character(j.m_value.boolean
14739 ? to_char_type(0xC3)
14740 : to_char_type(0xC2));
14744 case value_t::number_integer:
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));
14759 oa->write_character(to_char_type(0xCC));
14760 write_number(
static_cast<std::uint8_t
>(j.m_value.number_integer));
14765 oa->write_character(to_char_type(0xCD));
14766 write_number(
static_cast<std::uint16_t
>(j.m_value.number_integer));
14771 oa->write_character(to_char_type(0xCE));
14772 write_number(
static_cast<std::uint32_t
>(j.m_value.number_integer));
14777 oa->write_character(to_char_type(0xCF));
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));
14792 oa->write_character(to_char_type(0xD0));
14793 write_number(
static_cast<std::int8_t
>(j.m_value.number_integer));
14799 oa->write_character(to_char_type(0xD1));
14800 write_number(
static_cast<std::int16_t
>(j.m_value.number_integer));
14806 oa->write_character(to_char_type(0xD2));
14807 write_number(
static_cast<std::int32_t
>(j.m_value.number_integer));
14813 oa->write_character(to_char_type(0xD3));
14814 write_number(
static_cast<std::int64_t
>(j.m_value.number_integer));
14820 case value_t::number_unsigned:
14822 if (j.m_value.number_unsigned < 128)
14825 write_number(
static_cast<std::uint8_t
>(j.m_value.number_integer));
14830 oa->write_character(to_char_type(0xCC));
14831 write_number(
static_cast<std::uint8_t
>(j.m_value.number_integer));
14836 oa->write_character(to_char_type(0xCD));
14837 write_number(
static_cast<std::uint16_t
>(j.m_value.number_integer));
14842 oa->write_character(to_char_type(0xCE));
14843 write_number(
static_cast<std::uint32_t
>(j.m_value.number_integer));
14848 oa->write_character(to_char_type(0xCF));
14849 write_number(
static_cast<std::uint64_t
>(j.m_value.number_integer));
14854 case value_t::number_float:
14856 write_compact_float(j.m_value.number_float, detail::input_format_t::msgpack);
14860 case value_t::string:
14863 const auto N = j.m_value.string->size();
14867 write_number(
static_cast<std::uint8_t
>(0xA0 | N));
14872 oa->write_character(to_char_type(0xD9));
14873 write_number(
static_cast<std::uint8_t
>(N));
14878 oa->write_character(to_char_type(0xDA));
14879 write_number(
static_cast<std::uint16_t
>(N));
14884 oa->write_character(to_char_type(0xDB));
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());
14895 case value_t::array:
14898 const auto N = j.m_value.array->size();
14902 write_number(
static_cast<std::uint8_t
>(0x90 | N));
14907 oa->write_character(to_char_type(0xDC));
14908 write_number(
static_cast<std::uint16_t
>(N));
14913 oa->write_character(to_char_type(0xDD));
14914 write_number(
static_cast<std::uint32_t
>(N));
14918 for (
const auto& el : *j.m_value.array)
14925 case value_t::binary:
14929 const bool use_ext = j.m_value.binary->has_subtype();
14932 const auto N = j.m_value.binary->size();
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;
14969 oa->write_character(to_char_type(output_type));
14972 write_number(
static_cast<std::uint8_t
>(N));
14977 std::uint8_t output_type = use_ext
14981 oa->write_character(to_char_type(output_type));
14982 write_number(
static_cast<std::uint16_t
>(N));
14986 std::uint8_t output_type = use_ext
14990 oa->write_character(to_char_type(output_type));
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()),
15008 case value_t::object:
15011 const auto N = j.m_value.object->size();
15015 write_number(
static_cast<std::uint8_t
>(0x80 | (N & 0xF)));
15020 oa->write_character(to_char_type(0xDE));
15021 write_number(
static_cast<std::uint16_t
>(N));
15026 oa->write_character(to_char_type(0xDF));
15027 write_number(
static_cast<std::uint32_t
>(N));
15031 for (
const auto& el : *j.m_value.object)
15033 write_msgpack(el.first);
15034 write_msgpack(el.second);
15039 case value_t::discarded:
15053 const bool use_type,
const bool add_prefix =
true,
15054 const bool use_bjdata =
false)
15058 case value_t::null:
15062 oa->write_character(to_char_type(
'Z'));
15067 case value_t::boolean:
15071 oa->write_character(j.m_value.boolean
15072 ? to_char_type(
'T')
15073 : to_char_type(
'F'));
15078 case value_t::number_integer:
15080 write_number_with_ubjson_prefix(j.m_value.number_integer, add_prefix, use_bjdata);
15084 case value_t::number_unsigned:
15086 write_number_with_ubjson_prefix(j.m_value.number_unsigned, add_prefix, use_bjdata);
15090 case value_t::number_float:
15092 write_number_with_ubjson_prefix(j.m_value.number_float, add_prefix, use_bjdata);
15096 case value_t::string:
15100 oa->write_character(to_char_type(
'S'));
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());
15109 case value_t::array:
15113 oa->write_character(to_char_type(
'['));
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;
15132 oa->write_character(to_char_type(
'$'));
15133 oa->write_character(first_prefix);
15139 oa->write_character(to_char_type(
'#'));
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);
15150 oa->write_character(to_char_type(
']'));
15156 case value_t::binary:
15160 oa->write_character(to_char_type(
'['));
15163 if (use_type && !j.m_value.binary->empty())
15166 oa->write_character(to_char_type(
'$'));
15167 oa->write_character(
'U');
15172 oa->write_character(to_char_type(
'#'));
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)
15186 oa->write_character(to_char_type(
'U'));
15187 oa->write_character(j.m_value.binary->data()[i]);
15193 oa->write_character(to_char_type(
']'));
15199 case value_t::object:
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))
15211 oa->write_character(to_char_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;
15230 oa->write_character(to_char_type(
'$'));
15231 oa->write_character(first_prefix);
15237 oa->write_character(to_char_type(
'#'));
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);
15252 oa->write_character(to_char_type(
'}'));
15258 case value_t::discarded:
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)
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)
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
15381 ?
sizeof(std::int32_t)
15382 :
sizeof(std::int64_t);
15388 void write_bson_unsigned(
const string_t& name,
15389 const BasicJsonType& j)
15393 write_bson_entry_header(name, 0x10 );
15394 write_number<std::int32_t>(
static_cast<std::int32_t
>(j.m_value.number_unsigned),
true);
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)
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)
15656 oa->write_character(to_char_type(
'i'));
15658 write_number(
static_cast<std::uint8_t
>(n), use_bjdata);
15664 oa->write_character(to_char_type(
'U'));
15666 write_number(
static_cast<std::uint8_t
>(n), use_bjdata);
15672 oa->write_character(to_char_type(
'I'));
15674 write_number(
static_cast<std::int16_t
>(n), use_bjdata);
15680 oa->write_character(to_char_type(
'u'));
15682 write_number(
static_cast<std::uint16_t
>(n), use_bjdata);
15688 oa->write_character(to_char_type(
'l'));
15690 write_number(
static_cast<std::int32_t
>(n), use_bjdata);
15696 oa->write_character(to_char_type(
'm'));
15698 write_number(
static_cast<std::uint32_t
>(n), use_bjdata);
15704 oa->write_character(to_char_type(
'L'));
15706 write_number(
static_cast<std::int64_t
>(n), use_bjdata);
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)
15744 oa->write_character(to_char_type(
'i'));
15746 write_number(
static_cast<std::int8_t
>(n), use_bjdata);
15752 oa->write_character(to_char_type(
'U'));
15754 write_number(
static_cast<std::uint8_t
>(n), use_bjdata);
15760 oa->write_character(to_char_type(
'I'));
15762 write_number(
static_cast<std::int16_t
>(n), use_bjdata);
15768 oa->write_character(to_char_type(
'u'));
15770 write_number(
static_cast<uint16_t
>(n), use_bjdata);
15776 oa->write_character(to_char_type(
'l'));
15778 write_number(
static_cast<std::int32_t
>(n), use_bjdata);
15784 oa->write_character(to_char_type(
'm'));
15786 write_number(
static_cast<uint32_t
>(n), use_bjdata);
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:
15861 case value_t::number_unsigned:
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'}
15937 string_t
key =
"_ArrayType_";
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));
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()) &&
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,
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 &&
16144 const bool is_little_endian = little_endianness();
16157 #include <algorithm>
16167 #include <type_traits>
16178 #include <type_traits>
16207 namespace dtoa_impl
16210 template<
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};
16351 template<
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);
16374 const auto bits =
static_cast<std::uint64_t
>(reinterpret_bits<bits_type>(
value));
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)
16709 inline 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;
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;
16991 inline
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;
17049 template<
typename FloatType>
17051 void
grisu2(
char* buf,
int& len,
int& decimal_exponent, FloatType value)
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);
17225 template<
typename FloatType>
17228 char*
to_chars(
char* first, const
char* last, FloatType value)
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);
17314 template<
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');
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);
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 )
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;
18127 o->write_characters(
number_buffer.data(),
static_cast<std::size_t
>(len));
18130 const bool value_is_int_like =
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
18222 return static_cast<number_unsigned_t
>(-(x + 1)) + 1;
18227 output_adapter_t<char> o =
nullptr;
18260 #include <functional>
18261 #include <initializer_list>
18262 #include <iterator>
18264 #include <stdexcept>
18265 #include <type_traits>
18279 template <
class Key,
class T,
class IgnoredLess = std::less<Key>,
18280 class Allocator = std::allocator<std::pair<const Key, T>>>
18285 using Container = std::vector<std::pair<const Key, T>, Allocator>;
18290 #ifdef JSON_HAS_CPP_14
18300 template <
class It>
18303 ordered_map(std::initializer_list<value_type> init,
const Allocator& alloc = Allocator() )
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};
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;
18343 return emplace(std::forward<KeyType>(key), T{}).first->second;
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"));
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"));
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"));
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();
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))
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();
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;
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__)
18829 result[
"compiler"] = {{
"family",
"gcc"}, {
"version",
detail::concat(
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)
18852 #elif defined(__cplusplus)
18855 result[
"compiler"][
"c++"] =
"unknown";
18874 #if defined(JSON_HAS_CPP_14)
18887 AllocatorType<std::pair<
const StringType,
18892 using array_t = ArrayType<basic_json, AllocatorType<basic_json>>;
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();
18994 json_value() =
default;
18996 json_value(
boolean_t v) noexcept : boolean(v) {}
19010 object = create<object_t>();
19016 array = create<array_t>();
19022 string = create<string_t>(
"");
19028 binary = create<binary_t>();
19034 boolean =
static_cast<boolean_t>(
false);
19110 std::vector<basic_json> stack;
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();
19160 AllocatorType<object_t> alloc;
19161 std::allocator_traits<decltype(alloc)>::destroy(alloc,
object);
19162 std::allocator_traits<decltype(alloc)>::deallocate(alloc,
object, 1);
19168 AllocatorType<array_t> alloc;
19169 std::allocator_traits<decltype(alloc)>::destroy(alloc, array);
19170 std::allocator_traits<decltype(alloc)>::deallocate(alloc, array, 1);
19176 AllocatorType<string_t> alloc;
19177 std::allocator_traits<decltype(alloc)>::destroy(alloc,
string);
19178 std::allocator_traits<decltype(alloc)>::deallocate(alloc,
string, 1);
19184 AllocatorType<binary_t> alloc;
19185 std::allocator_traits<decltype(alloc)>::destroy(alloc, binary);
19186 std::allocator_traits<decltype(alloc)>::deallocate(alloc, binary, 1);
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
19251 for (
auto& element : *
m_value.array)
19253 element.m_parent =
this;
19260 for (
auto& element : *
m_value.object)
19262 element.second.m_parent =
this;
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();
19367 assert_invariant();
19372 template <
typename CompatibleType,
19378 std::forward<CompatibleType>(val))))
19382 assert_invariant();
19387 template <
typename BasicJsonType,
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())
19438 assert_invariant();
19444 bool type_deduction =
true,
19449 bool is_an_object = std::all_of(init.begin(), init.end(),
19452 return element_ref->is_array() && element_ref->size() == 2 && (*element_ref)[0].is_string();
19456 if (!type_deduction)
19461 is_an_object =
false;
19477 for (
auto& element_ref : init)
19481 std::move(*((*element.m_value.array)[0].m_value.string)),
19482 std::move((*element.m_value.array)[1]));
19489 m_value.array = create<array_t>(init.begin(), init.end());
19493 assert_invariant();
19503 res.m_value = init;
19514 res.m_value =
binary_t(init, subtype);
19525 res.m_value = std::move(init);
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;
19595 || !last.m_it.primitive_iterator.is_end()))
19615 m_value.number_integer = first.m_object->m_value.number_integer;
19621 m_value.number_unsigned = first.m_object->m_value.number_unsigned;
19627 m_value.number_float = first.m_object->m_value.number_float;
19633 m_value.boolean = first.m_object->m_value.boolean;
19639 m_value = *first.m_object->m_value.string;
19645 m_value.object = create<object_t>(first.m_it.object_iterator,
19646 last.m_it.object_iterator);
19652 m_value.array = create<array_t>(first.m_it.array_iterator,
19653 last.m_it.array_iterator);
19659 m_value = *first.m_object->m_value.binary;
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();
19748 assert_invariant();
19754 : m_type(std::move(other.m_type)),
19755 m_value(std::move(other.m_value))
19758 other.assert_invariant(
false);
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);
19785 assert_invariant();
19793 assert_invariant(
false);
19811 const char indent_char =
' ',
19812 const bool ensure_ascii =
false,
19820 s.dump(*
this,
true, ensure_ascii,
static_cast<unsigned int>(indent));
19824 s.dump(*
this,
false, ensure_ascii, 0);
19972 constexpr
const array_t* get_impl_ptr(
const array_t* )
const noexcept
20060 template<
typename ReferenceType,
typename ThisType>
20061 static ReferenceType get_ref_impl(ThisType& obj)
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&&
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,
20147 auto ret = ValueType();
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(
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)
20283 noexcept(
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,
20336 ValueType &
get_to(ValueType& v)
const noexcept(noexcept(
20345 template<
typename ValueType,
20356 typename T, std::size_t N,
20357 typename Array = T (&)[N],
20362 std::declval<const basic_json_t&>(), v)))
20370 template<
typename ReferenceType,
typename std::enable_if<
20371 std::is_reference<ReferenceType>::value,
int>
::type = 0>
20375 return get_ref_impl<ReferenceType>(*
this);
20380 template <
typename ReferenceType,
typename std::enable_if <
20381 std::is_reference<ReferenceType>::value&&
20386 return get_ref_impl<ReferenceType>(*
this);
20418 template <
typename ValueType,
typename std::enable_if <
20426 #if defined(JSON_HAS_CPP_17) && (defined(__GNUC__) || (defined(_MSC_VER) && _MSC_VER >= 1910 && _MSC_VER <= 1914))
20429 #if defined(JSON_HAS_CPP_17)
20437 return get<ValueType>();
20449 return *get_ptr<binary_t*>();
20461 return *get_ptr<const binary_t*>();
20484 return set_parent(
m_value.array->at(idx));
20507 return m_value.array->at(idx);
20531 auto it =
m_value.object->find(key);
20532 if (it ==
m_value.object->end())
20536 return set_parent(it->second);
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())
20589 auto it =
m_value.object->find(std::forward<KeyType>(key));
20590 if (it ==
m_value.object->end())
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);
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));
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);
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 >
20761 const auto it =
find(key);
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 >
20789 return value(
typename object_t::key_type(key), std::forward<ValueType>(default_value));
20794 return value(
typename object_t::key_type(key),
string_t(default_value));
20802 && !std::is_same<value_t, ValueType>::value
20810 const auto it =
find(std::forward<KeyType>(key));
20816 return std::forward<ValueType>(default_value);
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>
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 >
20925 IteratorType result = end();
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);
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);
20957 assert_invariant();
20963 result.m_it.object_iterator =
m_value.object->erase(pos.m_it.object_iterator);
20969 result.m_it.array_iterator =
m_value.array->erase(pos.m_it.array_iterator);
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)
20995 IteratorType result = end();
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);
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);
21028 assert_invariant();
21034 result.m_it.object_iterator =
m_value.object->erase(first.m_it.object_iterator,
21035 last.m_it.object_iterator);
21041 result.m_it.array_iterator =
m_value.array->erase(first.m_it.array_iterator,
21042 last.m_it.array_iterator);
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);
21105 return erase_internal(std::forward<KeyType>(key));
21142 auto result = end();
21146 result.m_it.object_iterator =
m_value.object->find(key);
21156 auto result = cend();
21160 result.m_it.object_iterator =
m_value.object->find(key);
21172 auto result = end();
21176 result.m_it.object_iterator =
m_value.object->find(std::forward<KeyType>(key));
21188 auto result = cend();
21192 result.m_it.object_iterator =
m_value.object->find(std::forward<KeyType>(key));
21213 return is_object() ?
m_value.object->count(std::forward<KeyType>(key)) : 0;
21218 bool contains(
const typename object_t::key_type& key)
const
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);
21261 result.set_begin();
21277 result.set_begin();
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
21410 return m_value.array->empty();
21416 return m_value.object->empty();
21449 return m_value.array->size();
21455 return m_value.object->size();
21482 return m_value.array->max_size();
21488 return m_value.object->max_size();
21519 void clear() noexcept
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);
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);
21658 assert_invariant();
21662 auto res =
m_value.object->insert(val);
21663 set_parent(res.first->second);
21678 if (
is_object() && init.size() == 2 && (*init.begin())->is_string())
21680 basic_json&& key = init.begin()->moved_or_copied();
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>
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>
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>
21799 return insert(pos, val);
21902 update(j.begin(), j.end(), merge_objects);
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
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
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);
22151 #if JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON
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>
22195 if (compares_unordered(
rhs,
true))
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));
22501 template<
typename InputType>
22505 const bool allow_exceptions =
true,
22506 const bool ignore_comments =
false)
22509 parser(
detail::input_adapter(std::forward<InputType>(i)), cb, allow_exceptions, ignore_comments).parse(
true, result);
22515 template<
typename IteratorType>
22520 const bool allow_exceptions =
true,
22521 const bool ignore_comments =
false)
22524 parser(
detail::input_adapter(std::move(first), std::move(last)), cb, allow_exceptions, ignore_comments).parse(
true, result);
22530 static basic_json parse(detail::span_input_adapter&& i,
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)
22546 return parser(
detail::input_adapter(std::forward<InputType>(i)),
nullptr,
false, ignore_comments).accept(
true);
22551 template<
typename IteratorType>
22552 static bool accept(IteratorType first, IteratorType last,
22553 const bool ignore_comments =
false)
22555 return parser(
detail::input_adapter(std::move(first), std::move(last)),
nullptr,
false, ignore_comments).accept(
true);
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>
22572 const
bool strict = true,
22573 const
bool ignore_comments = false)
22577 ? parser(std::move(ia),
nullptr,
true, ignore_comments).sax_parse(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)
22592 ? parser(std::move(ia),
nullptr,
true, ignore_comments).sax_parse(sax, strict)
22601 template <
typename SAX>
22606 const
bool strict = true,
22607 const
bool ignore_comments = false)
22612 ? parser(std::move(ia),
nullptr,
true, ignore_comments).sax_parse(sax, strict)
22663 return "discarded";
22684 #if JSON_DIAGNOSTICS
22701 std::vector<std::uint8_t> result;
22724 std::vector<std::uint8_t> result;
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);
22757 const bool use_size =
false,
const bool use_type =
false)
22765 const bool use_size =
false,
const bool use_type =
false)
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);
22784 const bool use_size =
false,
const bool use_type =
false)
22792 const bool use_size =
false,
const bool use_type =
false)
22801 std::vector<std::uint8_t> result;
22822 template<
typename InputType>
22825 const bool strict =
true,
22826 const bool allow_exceptions =
true,
22838 template<
typename IteratorType>
22841 const bool strict =
true,
22842 const bool allow_exceptions =
true,
22852 template<
typename T>
22856 const
bool strict = true,
22857 const
bool allow_exceptions = true,
22860 return from_cbor(ptr, ptr + len, strict, allow_exceptions, tag_handler);
22867 const
bool strict = true,
22868 const
bool allow_exceptions = true,
22881 template<
typename InputType>
22884 const bool strict =
true,
22885 const bool allow_exceptions =
true)
22896 template<
typename IteratorType>
22899 const bool strict =
true,
22900 const bool allow_exceptions =
true)
22909 template<
typename T>
22913 const
bool strict = true,
22914 const
bool allow_exceptions = true)
22916 return from_msgpack(ptr, ptr + len, strict, allow_exceptions);
22922 const
bool strict = true,
22923 const
bool allow_exceptions = true)
22935 template<
typename InputType>
22938 const bool strict =
true,
22939 const bool allow_exceptions =
true)
22950 template<
typename IteratorType>
22953 const bool strict =
true,
22954 const bool allow_exceptions =
true)
22963 template<
typename T>
22967 const
bool strict = true,
22968 const
bool allow_exceptions = true)
22970 return from_ubjson(ptr, ptr + len, strict, allow_exceptions);
22976 const
bool strict = true,
22977 const
bool allow_exceptions = true)
22990 template<
typename InputType>
22993 const bool strict =
true,
22994 const bool allow_exceptions =
true)
23005 template<
typename IteratorType>
23008 const bool strict =
true,
23009 const bool allow_exceptions =
true)
23020 template<
typename InputType>
23023 const bool strict =
true,
23024 const bool allow_exceptions =
true)
23035 template<
typename IteratorType>
23038 const bool strict =
true,
23039 const bool allow_exceptions =
true)
23048 template<
typename T>
23052 const
bool strict = true,
23053 const
bool allow_exceptions = true)
23055 return from_bson(ptr, ptr + len, strict, allow_exceptions);
23061 const
bool strict = true,
23062 const
bool allow_exceptions = true)
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)
23215 result.at(top_pointer);
23219 const auto last_path = ptr.back();
23223 switch (parent.m_type)
23229 parent[last_path] = val;
23235 if (last_path ==
"-")
23238 parent.push_back(val);
23242 const auto idx = json_pointer::template array_index<basic_json_t>(last_path);
23250 parent.insert(parent.begin() +
static_cast<difference_type>(idx), val);
23269 const auto operation_remove = [
this, &result](
json_pointer & ptr)
23272 const auto last_path = ptr.back();
23277 if (parent.is_object())
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));
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,
'\'');
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())
23466 while (i < source.size() && i < target.size())
23470 result.insert(result.end(), temp_diff.begin(), temp_diff.end());
23479 while (i < source.size())
23483 result.insert(result.begin() + end_index,
object(
23492 while (i < target.size())
23498 {
"value", target[i]}
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()}
23561 {
"op",
"replace"}, {
"path", path}, {
"value", target}
23589 for (
auto it = apply_patch.begin(); it != apply_patch.end(); ++it)
23591 if (it.value().is_null())
23603 *
this = apply_patch;
23649 #if JSON_HAS_THREE_WAY_COMPARISON
23650 return std::is_lt(lhs <=> rhs);
23658 #ifndef JSON_HAS_CPP_20
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);
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
void insert(const_iterator first, const_iterator last)
inserts range of elements into object
detail::parser_callback_t< basic_json > parser_callback_t
per-element parser callback type
const_reference operator[](const json_pointer &ptr) const
access specified element via JSON Pointer
reference operator[](const json_pointer &ptr)
access specified element via JSON Pointer
constexpr bool is_number_float() const noexcept
return whether value is a floating-point number
const_reference operator[](T *key) const
NumberIntegerType number_integer_t
a type for a number (integer)
void update(const_reference j, bool merge_objects=false)
updates a JSON object from another object, overwriting existing keys
::nlohmann::json_pointer< StringType > json_pointer
JSON Pointer, see nlohmann::json_pointer.
ReferenceType get_ref()
get a reference value (implicit)
reference emplace_back(Args &&... args)
add an object to an array
basic_json(const value_t v)
create an empty value with a given type
basic_json & operator=(basic_json other) noexcept(std::is_nothrow_move_constructible< value_t >::value &&std::is_nothrow_move_assignable< value_t >::value &&std::is_nothrow_move_constructible< json_value >::value &&std::is_nothrow_move_assignable< json_value >::value)
copy assignment
iterator find(KeyType &&key)
find an element in a JSON object
value_type & reference
the type of an element reference
void erase(const size_type idx)
remove element from a JSON array given an index
detail::out_of_range out_of_range
const_reference at(const typename object_t::key_type &key) const
access specified object element with bounds checking
reference at(const typename object_t::key_type &key)
access specified object element with bounds checking
basic_json(InputIT first, InputIT last)
construct a JSON container given an iterator range
basic_json(const JsonRef &ref)
static std::vector< std::uint8_t > to_ubjson(const basic_json &j, const bool use_size=false, const bool use_type=false)
create a UBJSON serialization of a given JSON value
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json array(initializer_list_t init={})
explicitly create an array from an initializer list
reference back()
access the last element
static void to_bjdata(const basic_json &j, detail::output_adapter< char > o, const bool use_size=false, const bool use_type=false)
create a BJData serialization of a given JSON value
StringType string_t
a type for a string
void push_back(const basic_json &val)
add an object to an array
reference at(KeyType &&key)
access specified object element with bounds checking
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json meta()
returns version information on the library
ValueType value(const json_pointer &ptr, const ValueType &default_value) const
access specified object element via JSON Pointer with default value
ObjectType< StringType, basic_json, default_object_comparator_t, AllocatorType< std::pair< const StringType, basic_json > >> object_t
a type for an object
std::size_t size_type
a type to represent container sizes
std::ptrdiff_t difference_type
a type to represent differences between iterators
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json binary(const typename binary_t::container_type &init)
explicitly create a binary array (without subtype)
reference operator+=(basic_json &&val)
add an object to an array
basic_json(const BasicJsonType &val)
create a JSON value from an existing one
typename std::allocator_traits< allocator_type >::const_pointer const_pointer
the type of an element const pointer
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json from_bson(IteratorType first, IteratorType last, const bool strict=true, const bool allow_exceptions=true)
create a JSON value from an input in BSON format
size_type count(const typename object_t::key_type &key) const
returns the number of occurrences of a key in a JSON object
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json from_bjdata(InputType &&i, const bool strict=true, const bool allow_exceptions=true)
create a JSON value from an input in BJData format
typename std::allocator_traits< allocator_type >::pointer pointer
the type of an element pointer
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json from_cbor(InputType &&i, const bool strict=true, const bool allow_exceptions=true, const cbor_tag_handler_t tag_handler=cbor_tag_handler_t::error)
create a JSON value from an input in CBOR format
BooleanType boolean_t
a type for a boolean
void push_back(initializer_list_t init)
add an object to an object
JSON_HEDLEY_RETURNS_NON_NULL const char * type_name() const noexcept
return the type as string
string_t dump(const int indent=-1, const char indent_char=' ', const bool ensure_ascii=false, const error_handler_t error_handler=error_handler_t::strict) const
serialization
reference operator[](typename object_t::key_type key)
access specified object element
IteratorType erase(IteratorType pos)
remove element given an iterator
const_iterator find(const typename object_t::key_type &key) const
find an element in a JSON object
static void to_bson(const basic_json &j, detail::output_adapter< std::uint8_t > o)
create a BSON serialization of a given JSON value
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json from_bson(InputType &&i, const bool strict=true, const bool allow_exceptions=true)
create a JSON value from an input in BSON format
constexpr bool is_structured() const noexcept
return whether type is structured
void update(const_iterator first, const_iterator last, bool merge_objects=false)
updates a JSON object from another object, overwriting existing keys
JSON_PRIVATE_UNLESS_TESTED const_reference bool static SAX bool sax_parse(InputType &&i, SAX *sax, input_format_t format=input_format_t::json, const bool strict=true, const bool ignore_comments=false)
reference at(size_type idx)
access specified array element with bounds checking
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json binary(typename binary_t::container_type &&init, typename binary_t::subtype_type subtype)
explicitly create a binary array (with subtype)
constexpr bool is_primitive() const noexcept
return whether type is primitive
constexpr bool is_number_unsigned() const noexcept
return whether value is an unsigned integer number
static void to_cbor(const basic_json &j, detail::output_adapter< char > o)
create a CBOR serialization of a given JSON value
void swap(object_t &other)
exchanges the values
constexpr bool is_object() const noexcept
return whether value is an object
bool contains(KeyType &&key) const
check the existence of an element in a JSON object
reference operator[](KeyType &&key)
access specified object element
const_reference front() const
access the first element
static std::vector< std::uint8_t > to_bson(const basic_json &j)
create a BSON serialization of a given JSON value
constexpr value_t type() const noexcept
return the type of the JSON value (explicit)
NumberFloatType number_float_t
a type for a number (floating-point)
json_reverse_iterator< typename basic_json::iterator > reverse_iterator
a reverse iterator for a basic_json container
basic_json(const basic_json &other)
copy constructor
~basic_json() noexcept
destructor
friend std::istream & operator<<(basic_json &j, std::istream &i)
deserialize from stream
const_iterator find(KeyType &&key) const
find an element in a JSON object
basic_json(basic_json &&other) noexcept
move constructor
bool contains(const typename object_t::key_type &key) const
check the existence of an element in a JSON object
static void to_ubjson(const basic_json &j, detail::output_adapter< char > o, const bool use_size=false, const bool use_type=false)
create a UBJSON serialization of a given JSON value
static std::vector< std::uint8_t > to_bjdata(const basic_json &j, const bool use_size=false, const bool use_type=false)
create a BJData serialization of a given JSON value
iterator insert(const_iterator pos, size_type cnt, const basic_json &val)
inserts copies of element into array
json_value m_value
the value of the current element
void swap(typename binary_t::container_type &other)
exchanges the values
void swap(array_t &other)
exchanges the values
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json binary(const typename binary_t::container_type &init, typename binary_t::subtype_type subtype)
explicitly create a binary array (with subtype)
static std::vector< std::uint8_t > to_cbor(const basic_json &j)
create a CBOR serialization of a given JSON value
std::less< StringType > default_object_comparator_t
default object key comparator type The actual object key comparator type (object_comparator_t) may be...
ReferenceType get_ref() const
get a reference value (implicit)
const_reference at(KeyType &&key) const
access specified object element with bounds checking
std::decay< ValueType >::type value(const KeyType &key, ValueType &&default_value) const
access specified object element with default value
iterator insert(const_iterator pos, const_iterator first, const_iterator last)
inserts range of elements into array
auto get() noexcept -> decltype(std::declval< basic_json_t & >().template get_ptr< PointerType >())
get a pointer value (explicit)
const_reference at(const json_pointer &ptr) const
access specified element via JSON Pointer
void merge_patch(const basic_json &apply_patch)
applies a JSON Merge Patch
auto get_ptr() noexcept -> decltype(std::declval< basic_json_t & >().get_impl_ptr(std::declval< PointerType >()))
get a pointer value (implicit)
iterator insert(const_iterator pos, initializer_list_t ilist)
inserts elements from initializer list into array
ArrayType< basic_json, AllocatorType< basic_json > > array_t
a type for an array
Array get_to(T(&v)[N]) const noexcept(noexcept(JSONSerializer< Array >::from_json(std::declval< const basic_json_t & >(), v)))
const_reference operator[](KeyType &&key) const
access specified object element
IteratorType erase(IteratorType first, IteratorType last)
remove elements given an iterator range
constexpr bool is_boolean() const noexcept
return whether value is a boolean
void swap(reference other) noexcept(std::is_nothrow_move_constructible< value_t >::value &&std::is_nothrow_move_assignable< value_t >::value &&std::is_nothrow_move_constructible< json_value >::value &&std::is_nothrow_move_assignable< json_value >::value)
exchanges the values
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json from_msgpack(IteratorType first, IteratorType last, const bool strict=true, const bool allow_exceptions=true)
create a JSON value from an input in MessagePack format
constexpr bool is_binary() const noexcept
return whether value is a binary array
JSON_HEDLEY_DEPRECATED_FOR(3.11.0, basic_json::json_pointer or nlohmann::json_pointer< basic_json::string_t >) const _reference operator[](const
access specified element via JSON Pointer
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json object(initializer_list_t init={})
explicitly create an object from an initializer list
iterator insert(const_iterator pos, basic_json &&val)
inserts element into array
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json from_ubjson(IteratorType first, IteratorType last, const bool strict=true, const bool allow_exceptions=true)
create a JSON value from an input in UBJSON format
reference operator[](size_type idx)
access specified array element
static void to_bson(const basic_json &j, detail::output_adapter< char > o)
create a BSON serialization of a given JSON value
string_t value(KeyType &&key, const char *default_value) const
access specified object element with default value
ValueType & get_to(ValueType &v) const noexcept(noexcept(JSONSerializer< ValueType >::from_json(std::declval< const basic_json_t & >(), v)))
get a value (explicit)
void swap(binary_t &other)
exchanges the values
iter_impl< basic_json > iterator
an iterator for a basic_json container
json_reverse_iterator< typename basic_json::const_iterator > const_reverse_iterator
a const reverse iterator for a basic_json container
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json from_ubjson(InputType &&i, const bool strict=true, const bool allow_exceptions=true)
create a JSON value from an input in UBJSON format
static void to_ubjson(const basic_json &j, detail::output_adapter< std::uint8_t > o, const bool use_size=false, const bool use_type=false)
create a UBJSON serialization of a given JSON value
binary_t & get_binary()
get a binary value
string_t value(const char *key, const char *default_value) const
size_type count(KeyType &&key) const
returns the number of occurrences of a key in a JSON object
void swap(string_t &other)
exchanges the values
const_reference back() const
access the last element
friend std::istream & operator>>(std::istream &i, basic_json &j)
deserialize from stream
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json binary(typename binary_t::container_type &&init)
explicitly create a binary array
constexpr bool is_string() const noexcept
return whether value is a string
constexpr bool is_array() const noexcept
return whether value is an array
iterator insert_iterator(const_iterator pos, Args &&... args)
JSON_HEDLEY_DEPRECATED_FOR(3.11.0, basic_json::json_pointer or nlohmann::json_pointer< basic_json::string_t >) ValueType value(const
access specified object element via JSON Pointer with default value
const value_type & const_reference
the type of an element const reference
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json from_cbor(IteratorType first, IteratorType last, const bool strict=true, const bool allow_exceptions=true, const cbor_tag_handler_t tag_handler=cbor_tag_handler_t::error)
create a JSON value from an input in CBOR format
const binary_t & get_binary() const
get a binary value
reference operator[](T *key)
constexpr bool is_number() const noexcept
return whether value is a number
std::pair< iterator, bool > emplace(Args &&... args)
add an object to an object if key does not exist
reference operator+=(initializer_list_t init)
add an object to an object
constexpr bool is_number_integer() const noexcept
return whether value is an integer number
std::initializer_list< detail::json_ref< basic_json > > initializer_list_t
helper type for initializer lists of basic_json values
static void to_cbor(const basic_json &j, detail::output_adapter< std::uint8_t > o)
create a CBOR serialization of a given JSON value
ValueType & get_to(ValueType &v) const
size_type erase(KeyType &&key)
remove element from a JSON object given a key
static void to_msgpack(const basic_json &j, detail::output_adapter< char > o)
create a MessagePack serialization of a given JSON value
const_reference operator[](const typename object_t::key_type &key) const
access specified object element
std::decay< ValueType >::type value(const char *key, ValueType &&default_value) const
detail::actual_object_comparator_t< basic_json > object_comparator_t
object key comparator type
basic_json(std::nullptr_t=nullptr) noexcept
create a null object
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json from_bjdata(IteratorType first, IteratorType last, const bool strict=true, const bool allow_exceptions=true)
create a JSON value from an input in BJData format
JSON_HEDLEY_DEPRECATED_FOR(3.11.0, basic_json::json_pointer or nlohmann::json_pointer< basic_json::string_t >) reference operator[](const
const_reference operator[](size_type idx) const
access specified array element
AllocatorType< basic_json > allocator_type
the allocator type
nlohmann::byte_container_with_subtype< BinaryType > binary_t
a type for a packed binary type
JSONSerializer< T, SFINAE > json_serializer
void push_back(const typename object_t::value_type &val)
add an object to an object
JSON_HEDLEY_DEPRECATED_FOR(3.11.0, basic_json::json_pointer or nlohmann::json_pointer< basic_json::string_t >) reference at(const
JSON_PRIVATE_UNLESS_TESTED const_reference rhs
bool contains(const json_pointer &ptr) const
check the existence of an element in a JSON object given a JSON pointer
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json from_msgpack(InputType &&i, const bool strict=true, const bool allow_exceptions=true)
create a JSON value from an input in MessagePack format
string_t value(const typename object_t::key_type &key, const char *default_value) const
access specified object element with default value
std::decay< ValueType >::type value(KeyType &&key, ValueType &&default_value) const
access specified object element with default value
basic_json(CompatibleType &&val) noexcept(noexcept(//NOLINT(bugprone-forwarding-reference-overload, bugprone-exception-escape) JSONSerializer< U >::to_json(std::declval< basic_json_t & >(), std::forward< CompatibleType >(val))))
create a JSON value from compatible types
NumberUnsignedType number_unsigned_t
a type for a number (unsigned)
iterator find(const typename object_t::key_type &key)
find an element in a JSON object
reference operator+=(const typename object_t::value_type &val)
add an object to an object
static std::vector< std::uint8_t > to_msgpack(const basic_json &j)
create a MessagePack serialization of a given JSON value
basic_json(initializer_list_t init, bool type_deduction=true, value_t manual_type=value_t::array)
create a container (array or object) from an initializer list
const_reference at(size_type idx) const
access specified array element with bounds checking
iterator insert(const_iterator pos, const basic_json &val)
inserts element into array
iter_impl< const basic_json > const_iterator
a const iterator for a basic_json container
constexpr bool is_discarded() const noexcept
return whether value is discarded
constexpr bool is_null() const noexcept
return whether value is null
friend void swap(reference left, reference right) noexcept(std::is_nothrow_move_constructible< value_t >::value &&std::is_nothrow_move_assignable< value_t >::value &&std::is_nothrow_move_constructible< json_value >::value &&std::is_nothrow_move_assignable< json_value >::value)
exchanges the values
static void to_bjdata(const basic_json &j, detail::output_adapter< std::uint8_t > o, const bool use_size=false, const bool use_type=false)
create a BJData serialization of a given JSON value
JSON_PRIVATE_UNLESS_TESTED const_reference bool inverse
auto get() const noexcept(noexcept(std::declval< const basic_json_t & >().template get_impl< ValueType >(detail::priority_tag< 4 > {}))) -> decltype(std::declval< const basic_json_t & >().template get_impl< ValueType >(detail::priority_tag< 4 > {}))
get a (pointer) value (explicit)
static void to_msgpack(const basic_json &j, detail::output_adapter< std::uint8_t > o)
create a MessagePack serialization of a given JSON value
reference operator+=(const basic_json &val)
add an object to an array
size_type erase(const typename object_t::key_type &key)
remove element from a JSON object given a key
basic_json(size_type cnt, const basic_json &val)
construct an array with count copies of given value
static allocator_type get_allocator()
returns the allocator associated with the container
constexpr auto get_ptr() const noexcept -> decltype(std::declval< const basic_json_t & >().get_impl_ptr(std::declval< PointerType >()))
get a pointer value (implicit)
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(InputAdapterType &&adapter, const input_format_t format=input_format_t::json) noexcept
create a binary reader
binary_reader & operator=(const binary_reader &)=delete
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
binary_reader & operator=(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 char * what() const noexcept override
returns the explanatory string
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_)
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
const object_t::key_type & key() const
return the key of an object iterator
bool operator!=(const IterImpl &other) const
comparison: not equal
void set_end() noexcept
set the iterator past the last value
typename BasicJsonType::difference_type difference_type
a type to represent differences between iterators
iter_impl & operator+=(difference_type i)
add to iterator
difference_type operator-(const iter_impl &other) const
return difference
typename std::conditional< std::is_const< BasicJsonType >::value, typename BasicJsonType::const_reference, typename BasicJsonType::reference >::type reference
defines a reference to the type iterated over (value_type)
reference operator*() const
return a reference to the value pointed to by the iterator
iter_impl(iter_impl &&) noexcept=default
bool operator>=(const iter_impl &other) const
comparison: greater than or equal
typename std::conditional< std::is_const< BasicJsonType >::value, typename BasicJsonType::const_pointer, typename BasicJsonType::pointer >::type pointer
defines a pointer to the type iterated over (value_type)
pointer operator->() const
dereference the iterator
iter_impl & operator=(const iter_impl< typename std::remove_const< BasicJsonType >::type > &other) noexcept
converting assignment
iter_impl(const iter_impl< const BasicJsonType > &other) noexcept
const copy constructor
iter_impl & operator--()
pre-decrement (–it)
iter_impl(const iter_impl< typename std::remove_const< BasicJsonType >::type > &other) noexcept
converting constructor
internal_iterator< typename std::remove_const< BasicJsonType >::type > m_it
the actual iterator of the associated instance
iter_impl operator+(difference_type i) const
add to iterator
friend iter_impl operator+(difference_type i, const iter_impl &it)
addition of distance and iterator
iter_impl & operator=(const iter_impl< const BasicJsonType > &other) noexcept
converting assignment
bool operator==(const IterImpl &other) const
comparison: equal
bool operator>(const iter_impl &other) const
comparison: greater than
typename BasicJsonType::value_type value_type
the type of the values when the iterator is dereferenced
reference value() const
return the value of an iterator
iter_impl & operator-=(difference_type i)
subtract from 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++)
std::bidirectional_iterator_tag iterator_category
iter_impl operator--(int) &
post-decrement (it–)
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
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
std::ptrdiff_t difference_type
iteration_proxy_value & operator++()
increment operator (needed for range-based for)
iteration_proxy_value & operator=(iteration_proxy_value const &)=default
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(iteration_proxy &&) noexcept=default
iteration_proxy()=default
iteration_proxy_value< IteratorType > end() const noexcept
return iterator end (needed for range-based for)
iteration_proxy_value< IteratorType > begin() const noexcept
return iterator begin (needed for range-based for)
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
json_ref(Args &&... args)
json_ref(const value_type &value)
value_type const & operator*() const
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
json_reverse_iterator(const typename base_iterator::iterator_type &it) noexcept
create reverse iterator from iterator
json_reverse_iterator & operator--()
pre-decrement (–it)
json_reverse_iterator & operator++()
pre-increment (++it)
typename Base::reference reference
the reference type for the pointed-to element
json_reverse_iterator & operator+=(difference_type i)
add to iterator
json_reverse_iterator operator-(difference_type i) const
subtract from iterator
std::reverse_iterator< Base > base_iterator
shortcut to the reverse iterator adapter
json_reverse_iterator(const base_iterator &it) noexcept
create reverse iterator from base class
reference operator[](difference_type n) const
access to successor
json_reverse_iterator operator--(int) &
post-decrement (it–)
std::ptrdiff_t difference_type
difference_type operator-(const json_reverse_iterator &other) const
return difference
json_reverse_iterator operator+(difference_type i) const
add to iterator
json_reverse_iterator operator++(int) &
post-increment (it++)
auto key() const -> decltype(std::declval< Base >().key())
return the key of an object iterator
reference value() const
return the value of an iterator
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
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
json_sax_dom_callback_parser & operator=(const json_sax_dom_callback_parser &)=delete
json_sax_dom_callback_parser & operator=(json_sax_dom_callback_parser &&)=default
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)
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
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
json_sax_dom_parser & operator=(const json_sax_dom_parser &)=delete
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
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_sax_dom_parser & operator=(json_sax_dom_parser &&)=default
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
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)
lexer & operator=(lexer &&)=default
string_t & get_string()
return current string value (implicitly resets the token; useful only once)
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
constexpr JSON_HEDLEY_RETURNS_NON_NULL const char * get_error_message() const noexcept
return syntax error message
typename lexer_base< BasicJsonType >::token_type token_type
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
lexer & operator=(lexer &)=delete
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)
output adapter for output streams
void write_character(CharType c) override
output_stream_adapter(std::basic_ostream< CharType > &s) noexcept
output adapter for basic_string
void write_character(CharType c) override
output_string_adapter(StringType &s) noexcept
output adapter for byte vectors
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)
parser(InputAdapterType &&adapter, const parser_callback_t< BasicJsonType > cb=nullptr, const bool allow_exceptions_=true, const bool skip_comments=false)
a parser reading from an input adapter
bool accept(const bool strict=true)
public accept interface
void parse(const bool strict, BasicJsonType &result)
public parser interface
primitive_iterator_t operator+(difference_type n) noexcept
primitive_iterator_t & operator-=(difference_type n) noexcept
constexpr bool is_end() const noexcept
return whether the iterator is at end
constexpr friend bool operator<(primitive_iterator_t lhs, primitive_iterator_t rhs) noexcept
constexpr friend difference_type operator-(primitive_iterator_t lhs, primitive_iterator_t rhs) noexcept
constexpr bool is_begin() const noexcept
return whether the iterator can be dereferenced
primitive_iterator_t operator++(int) &noexcept
void set_begin() noexcept
set iterator to a defined beginning
primitive_iterator_t & operator--() noexcept
primitive_iterator_t & operator++() noexcept
void set_end() noexcept
set iterator to a defined past the end
constexpr difference_type get_value() const noexcept
primitive_iterator_t & operator+=(difference_type n) noexcept
primitive_iterator_t operator--(int) &noexcept
constexpr friend bool operator==(primitive_iterator_t lhs, primitive_iterator_t rhs) noexcept
const error_handler_t error_handler
error_handler how to react on decoding errors
const std::lconv * loc
the locale
std::array< char, 64 > number_buffer
a (hopefully) large enough character buffer
serializer(serializer &&)=delete
const char decimal_point
the locale's decimal point character
serializer & operator=(const serializer &)=delete
const char thousands_sep
the locale's thousand separator character
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
const char indent_char
the indentation character
std::size_t bytes_after_last_accept
std::array< char, 512 > string_buffer
string buffer
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)
serializer & operator=(serializer &&)=delete
serializer(const serializer &)=delete
string_t indent_string
the indentation string
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.
friend json_pointer operator/(const json_pointer &lhs, string_t token)
create a new JSON pointer by appending the unescaped token at the end of the JSON pointer
json_pointer & operator/=(const json_pointer &ptr)
append another JSON pointer at the end of this JSON pointer
void pop_back()
remove last reference token
json_pointer & operator/=(std::size_t array_idx)
append an array index at the end of this JSON pointer
friend json_pointer operator/(const json_pointer &lhs, std::size_t array_idx)
create a new JSON pointer by appending the array-index-token at the end of the JSON pointer
json_pointer parent_pointer() const
returns the parent of this JSON pointer
bool empty() const noexcept
return whether pointer points to the root document
const string_t & back() const
return last reference token
void push_back(const string_t &token)
append an unescaped token at the end of the reference pointer
typename string_t_helper< RefStringType >::type string_t
friend json_pointer operator/(const json_pointer &lhs, const json_pointer &rhs)
create a new JSON pointer by appending the right JSON pointer at the end of the left JSON pointer
friend class json_pointer
string_t to_string() const
return a string representation of the JSON pointer
friend bool operator==(json_pointer< RefStringTypeLhs > const &lhs, json_pointer< RefStringTypeRhs > const &rhs) noexcept
compares two JSON pointers for equality
friend bool operator!=(json_pointer< RefStringTypeLhs > const &lhs, json_pointer< RefStringTypeRhs > const &rhs) noexcept
compares two JSON pointers for inequality
json_pointer(const string_t &s="")
create JSON pointer
void push_back(string_t &&token)
append an unescaped token at the end of the reference pointer
json_pointer & operator/=(string_t token)
append an unescaped reference token at the end of this JSON pointer
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
#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 JSON_HEDLEY_DIAGNOSTIC_POP
#define JSON_IMPLEMENT_OPERATOR(op, null_result, unordered_result, default_result)
std::vector< uint8_t > buffer
Target
The Target enum Specifies the target device of the command.
void grisu2(char *buf, int &len, int &decimal_exponent, diyfp m_minus, diyfp v, diyfp m_plus)
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)
void grisu2_digit_gen(char *buffer, int &length, int &decimal_exponent, diyfp M_minus, diyfp w, 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
JSON_HEDLEY_RETURNS_NON_NULL char * append_exponent(char *buf, int e)
appends a decimal representation of e to buf
cached_power get_cached_power_for_binary_exponent(int e)
detail namespace with internal helper functions
std::integral_constant< bool, all_signed< Types... >::value||all_unsigned< Types... >::value > same_sign
typename std::enable_if< B, T >::type enable_if_t
typename T::reference reference_t
decltype(std::declval< StringType & >().append(std::declval< const Arg & >().data(), std::declval< const Arg & >().size())) string_can_append_data
bool operator<(const value_t lhs, const value_t rhs) noexcept
comparison operator for JSON types
typename actual_object_comparator< BasicJsonType >::type actual_object_comparator_t
typename T::key_compare detect_key_compare
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
decltype(T::from_json(std::declval< Args >()...)) from_json_function
is_detected< string_can_append_iter, StringType, Arg > detect_string_can_append_iter
void to_json(BasicJsonType &j, T b) noexcept
value_type_t< iterator_traits< iterator_t< T > >> range_value_t
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)
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
make_index_sequence< sizeof...(Ts)> index_sequence_for
decltype(std::declval< T & >().parse_error(std::declval< std::size_t >(), std::declval< const std::string & >(), std::declval< const Exception & >())) parse_error_function_t
typename T::pointer pointer_t
decltype(std::declval< T & >().string(std::declval< String & >())) string_function_t
is_detected< string_can_append, StringType, Arg > detect_string_can_append
std::function< bool(int, parse_event_t, BasicJsonType &)> parser_callback_t
typename T::difference_type difference_type_t
typename detector< nonesuch, void, Op, Args... >::type detected_t
void int_to_string(string_type &target, std::size_t value)
void from_json_array_impl(const BasicJsonType &j, typename BasicJsonType::array_t &arr, priority_tag< 3 >)
integer_sequence< size_t, Ints... > index_sequence
decltype(std::declval< T & >().key(std::declval< String & >())) key_function_t
decltype(std::declval< T & >().boolean(std::declval< bool >())) boolean_function_t
decltype(std::declval< T & >().binary(std::declval< Binary & >())) binary_function_t
decltype(std::declval< T & >().number_integer(std::declval< Integer >())) number_integer_function_t
void to_json_tuple_impl(BasicJsonType &j, const Tuple &t, index_sequence< Idx... >)
enable_if_t< is_range< R >::value, result_of_begin< decltype(std::declval< R & >())> > iterator_t
std::is_convertible< detected_t< Op, Args... >, To > is_detected_convertible
typename std::remove_cv< typename std::remove_reference< T >::type >::type uncvref_t
decltype(std::declval< StringType & >().append(std::declval< Arg && >())) string_can_append
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
@ value
the parser finished reading a JSON value
@ key
the parser read a key of a value in an object
@ array_end
the parser read ] and finished processing a JSON array
@ array_start
the parser read [ and started to process a JSON array
@ object_start
the parser read { and started to process a JSON object
@ object_end
the parser read } and finished processing a JSON object
error_handler_t
how to treat decoding errors
@ strict
throw a type_error exception in case of invalid UTF-8
@ ignore
ignore invalid UTF-8 sequences
@ replace
replace invalid UTF-8 sequences with U+FFFD
decltype(std::declval< T & >().start_object(std::declval< std::size_t >())) start_object_function_t
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
typename T::key_type key_type_t
std::size_t combine(std::size_t seed, std::size_t h) noexcept
std::size_t hash(const BasicJsonType &j)
hash a JSON value
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).
StringType escape(StringType s)
string escaping as described in RFC 6901 (Sect. 4)
typename utility_internal::Gen< T, N >::type make_integer_sequence
decltype(std::declval< T & >().number_unsigned(std::declval< Unsigned >())) number_unsigned_function_t
std::is_same< Expected, detected_t< Op, Args... > > is_detected_exact
typename 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 detected_or< Default, Op, Args... >::type detected_or_t
decltype(std::declval< T & >().start_array(std::declval< std::size_t >())) start_array_function_t
constexpr bool value_in_range_of(T val)
void concat_into(OutStringType &)
void get_arithmetic_value(const BasicJsonType &j, ArithmeticType &val)
void replace_substring(StringType &s, const StringType &f, const StringType &t)
replace all occurrences of a substring by another string
std::array< T, sizeof...(Idx)> from_json_inplace_array_impl(BasicJsonType &&j, identity_tag< std::array< T, sizeof...(Idx)>>, index_sequence< Idx... >)
typename detector< nonesuch, void, Op, Args... >::value_t is_detected
is_detected< string_can_append_data, StringType, Arg > detect_string_can_append_data
typename make_void< Ts... >::type void_t
OutStringType concat(Args &&... args)
make_integer_sequence< size_t, N > make_index_sequence
std::shared_ptr< output_adapter_protocol< CharType > > output_adapter_t
a type to simplify interfaces
typename T::mapped_type mapped_type_t
input_format_t
the supported input formats
void to_json(BasicJsonType &j, const T &b)
std::tuple< Args... > from_json_tuple_impl_base(BasicJsonType &&j, index_sequence< Idx... >)
decltype(std::declval< T >().template get< U >()) get_template_function
decltype(std::declval< ObjectType & >().erase(std::declval< KeyType >())) detect_erase_with_key_type
decltype(std::declval< StringType & >().append(std::declval< const Arg & >().begin(), std::declval< const Arg & >().end())) string_can_append_iter
decltype(input_adapter(std::declval< const char * >(), std::declval< const char * >())) contiguous_bytes_input_adapter
typename T::is_transparent detect_is_transparent
decltype(std::declval< T & >().null()) null_function_t
auto get(const nlohmann::detail::iteration_proxy_value< IteratorType > &i) -> decltype(i.key())
iterator_input_adapter_factory< IteratorType >::adapter_type input_adapter(IteratorType first, IteratorType last)
typename T::iterator_category iterator_category_t
decltype(std::declval< T & >().number_float(std::declval< Float >(), std::declval< const String & >())) number_float_function_t
std::size_t concat_length()
is_detected< string_can_append_op, StringType, Arg > detect_string_can_append_op
decltype(std::declval< StringType & >()+=std::declval< Arg && >()) string_can_append_op
decltype(std::declval< T & >().end_array()) end_array_function_t
void from_json(const BasicJsonType &j, std::unordered_map< Key, Value, Hash, KeyEqual, Allocator > &m)
std::pair< A1, A2 > from_json_tuple_impl(BasicJsonType &&j, identity_tag< std::pair< A1, A2 >>, priority_tag< 0 >)
decltype(std::declval< T & >().end_object()) end_object_function_t
T conditional_static_cast(U value)
decltype(T::to_json(std::declval< Args >()...)) to_json_function
typename T::value_type value_type_t
namespace for Niels Lohmann
basic_json<> json
default specialization
NLOHMANN_BASIC_JSON_TPL_DECLARATION std::string to_string(const NLOHMANN_BASIC_JSON_TPL &j)
user-defined to_string function for JSON values
NLOHMANN_CAN_CALL_STD_FUNC_IMPL(begin)
bool operator!=(json_pointer< RefStringTypeLhs > const &lhs, json_pointer< RefStringTypeRhs > const &rhs) noexcept
bool operator==(json_pointer< RefStringTypeLhs > const &lhs, json_pointer< RefStringTypeRhs > const &rhs) noexcept
NLOHMANN_BASIC_JSON_TPL_DECLARATION void swap(nlohmann::NLOHMANN_BASIC_JSON_TPL &j1, nlohmann::NLOHMANN_BASIC_JSON_TPL &j2) noexcept(//NOLINT(readability-inconsistent-declaration-parameter-name) is_nothrow_move_constructible< nlohmann::NLOHMANN_BASIC_JSON_TPL >::value &&//NOLINT(misc-redundant-expression) is_nothrow_move_assignable< nlohmann::NLOHMANN_BASIC_JSON_TPL >::value)
exchanges the values of two JSON objects
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)))
typename BasicJsonType::template json_serializer< T, void > serializer
typename BasicJsonType::template json_serializer< T, void > serializer
typename BasicJsonType::template json_serializer< T, void > serializer
static constexpr std::size_t size() noexcept
primitive_iterator_t primitive_iterator
generic iterator for all other types
BasicJsonType::array_t::iterator array_iterator
iterator for JSON arrays
BasicJsonType::object_t::iterator object_iterator
iterator for JSON objects
std::numeric_limits< CompatibleNumberIntegerType > CompatibleLimits
std::numeric_limits< RealIntegerType > RealLimits
typename BasicJsonType::object_t object_t
static constexpr auto 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
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 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
abstract output adapter interface
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())
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
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
std::pair< iterator, bool > insert(const value_type &value)
std::vector< std::pair< const Key, T >, Allocator > Container
const_iterator find(const key_type &key) const
iterator erase(iterator pos)
void insert(InputIt first, InputIt last)
size_type count(const key_type &key) const
std::pair< iterator, bool > emplace(const key_type &key, T &&t)
std::pair< iterator, bool > insert(value_type &&value)
iterator erase(iterator first, iterator last)
iterator find(KeyType &&key)
typename Container::const_iterator const_iterator
typename std::enable_if< std::is_convertible< typename std::iterator_traits< InputIt >::iterator_category, std::input_iterator_tag >::value >::type require_input_iter
const T & at(const key_type &key) const
T & at(const key_type &key)
ordered_map(It first, It last, const Allocator &alloc=Allocator())
std::equal_to< Key > key_compare
const T & operator[](KeyType &&key) const
ordered_map(const Allocator &alloc) noexcept(noexcept(Container(alloc)))
typename Container::size_type size_type
size_type erase(const key_type &key)
typename Container::value_type value_type
iterator find(const key_type &key)
const T & operator[](const key_type &key) const
T & operator[](KeyType &&key)
T & operator[](const key_type &key)
ordered_map(std::initializer_list< value_type > init, const Allocator &alloc=Allocator())
ordered_map() noexcept(noexcept(Container()))
size_type count(KeyType &&key) const
const T & at(KeyType &&key) const
std::pair< iterator, bool > emplace(KeyType &&key, T &&t)
typename Container::iterator iterator
size_type erase(KeyType &&key)
std::size_t operator()(const nlohmann::NLOHMANN_BASIC_JSON_TPL &j) const
bool operator()(::nlohmann::detail::value_t lhs, ::nlohmann::detail::value_t rhs) const noexcept
compare two value_t enum values